您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xsID函数代码示例

51自学网 2021-06-03 11:51:03
  C++
这篇教程C++ xsID函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xsID函数的典型用法代码示例。如果您正苦于以下问题:C++ xsID函数的具体用法?C++ xsID怎么用?C++ xsID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xsID函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xs_mod_init

voidxs_mod_init(xsMachine *the){	mod_t *mod;	UInt32 options = xsToInteger(xsArgc) > 0 && xsTypeOf(xsArg(0)) == xsIntegerType ? xsToInteger(xsArg(0)): 0;	FskErr ferr;	if ((ferr = FskMemPtrNew(sizeof(mod_t), (FskMemPtr *)&mod)) != kFskErrNone)		cryptThrowFSK(ferr);	if ((ferr = FskMemPtrNew(sizeof(bn_mod_t), (FskMemPtr *)&mod->mod_data)) != kFskErrNone) {		FskMemPtrDispose(mod);		cryptThrowFSK(ferr);	}	mod->_mod_code = &modFuncs;	xsResult = xsGet(xsThis, xsID("z"));	/* must exist */	if (!xsIsInstanceOf(xsResult, xsGet(xsGet(xsGlobal, xsID("Arith")), xsID("z"))) || (mod->z = xsGetHostData(xsResult)) == NULL)		cryptThrow("kCryptTypeError");	xsResult = xsGet(xsThis, xsID("m"));	/* must exist */	if (!xsIsInstanceOf(xsResult, mod->z->z_protoInteger) || (mod->m = xsGetHostData(xsResult)) == NULL)		nanError();	bn_mod_init(mod->mod_data, mod->z->z_data, mod->m->cint_data, options);	xsSetHostData(xsThis, mod);}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:28,


示例2: xs_gpio_init

void xs_gpio_init(xsMachine* the){    FskErr err;    FskGPIO gpio;    SInt32 pin = 0;	GPIOdirection dir;    char *pinName = NULL;    xsVars(1);    if ((gpio = xsGetHostData(xsThis)))        xsThrowDiagnosticIfFskErr(kFskErrOperationFailed, "Digital pin %d already initialized.", (int)gpio->pinNum);    dir = stringToDirection(the, xsToString(xsGet(xsThis, xsID("_direction"))), gpio);    xsVar(0) = xsGet(xsThis, xsID("_pin"));    if (xsStringType == xsTypeOf(xsVar(0)))        pinName = xsToString(xsVar(0));    else        pin = xsToInteger(xsVar(0));    err = FskGPIONew(&gpio, pin, pinName, dir);    xsThrowDiagnosticIfFskErr(err, "Digital pin %d initialization failed with error %s.", pin, FskInstrumentationGetErrorString(err));    xsSetHostData(xsThis, gpio);}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:26,


示例3: KprMessageScriptTargetTransform

void KprMessageScriptTargetTransform(void* it, KprMessage message, xsMachine* machine){	KprMessageScriptTarget self = it;	if (message->error) return;	xsBeginHostSandboxCode(machine, NULL);	{		xsVars(2);		{			xsTry {				void* data;				UInt32 size; 				KprMessageGetResponseBody(message, &data, &size);				if (data && size) {					xsIndex id = xsID(self->name);					if (xsHas(xsGlobal, id)) {						xsVar(0) = xsGet(xsGlobal, id);						xsVar(1) = xsNewInstanceOf(xsChunkPrototype);						xsSetHostData(xsVar(1), data);						xsSetHostDestructor(xsVar(1) , NULL);						xsSet(xsVar(1), xsID("length"), xsInteger(size));						xsResult = xsCall1(xsVar(0), xsID("parse"), xsVar(1));							self->result = xsMarshall(xsResult);					}				}			}			xsCatch {			}		}	}	xsEndHostSandboxCode();}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:31,


示例4: KPR_canvasRenderingContext2D_cloneImageData

// image datavoid KPR_canvasRenderingContext2D_cloneImageData(xsMachine *the){	FskCanvas2dContext ctx = xsGetHostData(xsThis);	FskCanvas2dImageData data = xsGetHostData(xsArg(0));	data = FskCanvas2dCloneImageData(ctx, data);	xsResult = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID("KPR")), xsID("imageData")));	xsSetHostData(xsResult, data);}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:9,


示例5: xs_console_load

voidxs_console_load(xsMachine *the){	xsVars(1);	xsSetInteger(xsVar(0), CONSOLE_LOG_FILE);	xsSet(xsThis, xsID("LOGFILE"), xsVar(0));	xsSetInteger(xsVar(0), CONSOLE_XSBUG);	xsSet(xsThis, xsID("XSBUG"), xsVar(0));}
开发者ID:basuke,项目名称:kinomajs,代码行数:9,


示例6: KPR_canvasRenderingContext2D_createImageData

// pixel manipulationvoid KPR_canvasRenderingContext2D_createImageData(xsMachine *the){	FskCanvas2dContext ctx = xsGetHostData(xsThis);	xsNumberValue sw = xsToNumber(xsArg(0));	xsNumberValue sh = xsToNumber(xsArg(1));	FskCanvas2dImageData data = FskCanvas2dCreateImageData(ctx, sw, sh);	xsResult = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID("KPR")), xsID("imageData")));	xsSetHostData(xsResult, data);}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:10,


示例7: FskSSLNew

FskErrFskSSLNew(void **fsslp, const char *host, int port, Boolean blocking, long flags, int priority){	FskSSL *fssl;	FskErr err;	if ((err = FskMemPtrNewClear(sizeof(FskSSL), (FskMemPtr*)(void*)&fssl)) != kFskErrNone)		return err;	if ((err = newSSLVM(&fssl->vm)) != kFskErrNone) {		FskMemPtrDispose(fssl);		return err;	}	xsBeginHost(fssl->vm->the);	xsTry {		const char *prStr;		xsVars(2);		/* construct the options */		xsVar(0) = xsNewInstanceOf(xsObjectPrototype);		if (blocking)			xsSet(xsVar(0), xsID("blocking"), xsTrue);		if (flags & kConnectFlagsSynchronous)			xsSet(xsVar(0), xsID("synchronous"), xsTrue);		switch (priority) {		default:		case kFskNetSocketLowestPriority: prStr = "lowest"; break;		case kFskNetSocketLowPriority: prStr = "low"; break;		case kFskNetSocketMediumPriority: prStr = "medium"; break;		case kFskNetSocketHighPriority: prStr = "high"; break;		case kFskNetSocketHighestPriority: prStr = "highest"; break;		}		(void)xsSet(xsVar(0), xsID("priority"), xsString((xsStringValue)prStr));		(void)xsSet(xsVar(0), xsID("raw"), xsTrue);		xsVar(1) = xsNew3(xsGet(xsGlobal, xsID("Stream")), xsID("Socket"), xsString((xsStringValue)host), xsInteger(port), xsVar(0));		fssl->socket = xsVar(1); xsRemember(fssl->socket);		xsVar(1) = xsNew0(xsGet(xsGlobal, xsID("FskSSL")), xsID("Session"));		fssl->ssl = xsVar(1); xsRemember(fssl->ssl);	} xsCatch {		if (xsHas(xsException, xsID("code")))			err = xsToInteger(xsGet(xsException, xsID("code")));		if (err == kFskErrNone)			err = kFskErrOperationFailed;	}	xsEndHost(fssl->vm->the);	if (err == kFskErrNone) {		if (fsslp != NULL)			*fsslp = fssl;	}	else {		disposeSSLVM(fssl->vm);		FskMemPtrDispose(fssl);	}	return err;}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:55,


示例8: xs_i2c_readBlock

void xs_i2c_readBlock(xsMachine *the){	FskErr err;	xsI2C i2c = xsGetHostData(xsThis);	int argc = xsToInteger(xsArgc), i;	int format = 2;    SInt32 dataSize = xsToInteger(xsArg(0)), readCount;	UInt8 data[32];	xsThrowIfNULL(i2c);    DBG_I2C("xs_i2c_readBlock/n");	if ((dataSize > 32) || (dataSize <= 0))		xsThrowDiagnosticIfFskErr(kFskErrInvalidParameter, "I2C readBlock invalid size %d. %s", (int)dataSize, i2c->diagnosticID);	FskPinI2CSetAddress(i2c->pin, i2c->address);	err = FskPinI2CReadBytes(i2c->pin, dataSize, &readCount, data);    if (err) {        xsTraceDiagnostic("I2C readBlock failed with error %s %s.", FskInstrumentationGetErrorString(err), i2c->diagnosticID);        goto bail;    }    if (argc > 1) {        int t = xsTypeOf(xsArg(1));        if ((xsNumberType == t) || (t == xsIntegerType))            format = xsToInteger(xsArg(1));        else {            char *formatString = xsToString(xsArg(1));            if (0 == FskStrCompare(formatString, "Buffer"))                format = 2;            else if (0 == FskStrCompare(formatString, "Chunk"))                format = 0;            else if (0 == FskStrCompare(formatString, "Array"))                format = 1;        }    }        if (2 == format) {        xsResult = xsArrayBuffer(data, readCount);    }    else if (0 == format) {        xsResult = xsNew1(xsGlobal, xsID("Chunk"), xsInteger(readCount));        FskMemMove(xsGetHostData(xsResult), data, readCount);    }    else if (1 == format) {        xsResult = xsNew1(xsGlobal, xsID("Array"), xsInteger(readCount));        for (i = 0; i < readCount; i++)            xsSet(xsResult, i, xsInteger(data[i]));    }    bail:    if (err)		xsError(err);}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:55,


示例9: xs_z_init

voidxs_z_init(xsMachine *the){	z_t *z;	char *err;	if ((err = kcl_z_init(the, &z)) != NULL)		cryptThrow(err);	z->z_protoInteger = xsGet(xsGet(xsGlobal, xsID("Arith")), xsID("integer"));	xsSetHostData(xsThis, z);}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:11,


示例10: KPR_canvas_getContext

void KPR_canvas_getContext(xsMachine *the){	KprCanvas self = xsGetHostData(xsThis);	if (self->cnv) {		FskCanvas2dContext ctx = FskCanvasGet2dContext(self->cnv);		xsResult = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID("KPR")), xsID("canvasRenderingContext2D")));		xsSetHostData(xsResult, ctx);		xsSet(xsResult, xsID("canvas"), xsThis);		KprContentInvalidate((KprContent)self);	}}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:11,


示例11: KPR_host_clearAllBreakpoints

void KPR_host_clearAllBreakpoints(xsMachine* the){#ifdef mxDebug	KprHost self = xsGetHostData(xsThis);	KprApplication application = (KprApplication)self->first;	xsBeginHost(application->the);	{		(void)xsCall0(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("clearAllBreakpoints"));	}	xsEndHost(application->the);#endif}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:12,


示例12: KPR_host_get_profiling

void KPR_host_get_profiling(xsMachine* the){	KprHost self = xsGetHostData(xsThis);	KprApplication application = (KprApplication)self->first;	Boolean result = false;	xsBeginHost(application->the);	{		result = xsTest(xsCall0(xsGet(xsGlobal, xsID("xs")), xsID("isProfiling")));	}	xsEndHost(application->the);	xsResult = xsBoolean(result);}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:12,


示例13: KPR_canvasRenderingContext2D_measureText

void KPR_canvasRenderingContext2D_measureText(xsMachine *the){	FskCanvas2dContext ctx = xsGetHostData(xsThis);	xsStringValue text = xsToString(xsArg(0));	UInt16* buffer;	if (kFskErrNone == FskTextUTF8ToUnicode16NE((unsigned char*)text, FskStrLen(text), &buffer, NULL)) {		xsNumberValue width = FskCanvas2dMeasureText(ctx, buffer);		FskMemPtrDispose(buffer);		xsResult = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID("KPR")), xsID("textMetrics")));		xsSet(xsResult, xsID("width"), xsNumber(width));	}}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:12,


示例14: KPR_system_alert

void KPR_system_alert(xsMachine* the){	int argc = xsToInteger(xsArgc);	MSGBOXPARAMSW params;	xsStringValue string;	xsIntegerValue result;	xsVars(1);	params.cbSize = sizeof(params);	params.hwndOwner = NULL;	params.hInstance = FskMainGetHInstance();	params.lpszText = NULL;	params.lpszCaption = xsStringToWideString("Kinoma Code");	params.dwStyle = MB_ICONSTOP;	params.dwContextHelpId = 0;	params.lpfnMsgBoxCallback = NULL;	params.dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);	if ((argc > 0) && xsTest(xsArg(0))) {		if (xsFindString(xsArg(0), xsID_type, &string)) {			if (!FskStrCompare(string, "about"))				params.dwStyle = MB_ICONINFORMATION;			else if (!FskStrCompare(string, "stop"))				params.dwStyle = MB_ICONSTOP;			else if (!FskStrCompare(string, "note"))				params.dwStyle = MB_ICONEXCLAMATION;		}		if (xsFindResult(xsArg(0), xsID_prompt)) {			xsVar(0) = xsResult;		}		if (xsFindResult(xsArg(0), xsID_info)) {			xsVar(0) = xsCall1(xsVar(0), xsID("concat"), xsString("/n/n"));			xsVar(0) = xsCall1(xsVar(0), xsID("concat"), xsResult);		}		params.lpszText = xsStringToWideString(xsToString(xsVar(0)));		if (xsFindResult(xsArg(0), xsID_buttons)) {			if (xsIsInstanceOf(xsResult, xsArrayPrototype)) {				xsIntegerValue c = xsToInteger(xsGet(xsResult, xsID_length));				if (c == 3)					params.dwStyle |= MB_YESNOCANCEL;				else if (c == 2)					params.dwStyle |= MB_OKCANCEL;				else					params.dwStyle |= MB_OK;			}		}	}	result = MessageBoxIndirectW(&params);	if (params.lpszText)		CoTaskMemFree((LPVOID *)params.lpszText);	if (params.lpszCaption)		CoTaskMemFree((LPVOID *)params.lpszCaption);	if ((argc > 1) && xsTest(xsArg(1)))		(void)xsCallFunction1(xsArg(1), xsNull, ((result == IDYES) || (result == IDOK)) ? xsTrue : (result == IDNO) ? xsFalse : xsUndefined);}
开发者ID:basuke,项目名称:kinomajs,代码行数:53,


示例15: xs_z_div2

voidxs_z_div2(xsMachine *the){	z_t *z = xsGetHostData(xsThis);	xsVars(2);	z_call3(the, z, kcl_z_div, &xsVar(1));	xsVar(0) = xsResult;	xsResult = xsNewInstanceOf(xsObjectPrototype);	xsSet(xsResult, xsID("q"), xsVar(0));	xsSet(xsResult, xsID("r"), xsVar(1));}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:12,


示例16: xs_system_get_timezone

voidxs_system_get_timezone(xsMachine *the){	struct timezone tz;	xsVars(1);	mc_gettimeofday(NULL, &tz);	xsResult = xsNewInstanceOf(xsObjectPrototype);	xsSetInteger(xsVar(0), tz.tz_minuteswest);	xsSet(xsResult, xsID("timedifference"), xsVar(0));	xsSetInteger(xsVar(0), tz.tz_dsttime);	xsSet(xsResult, xsID("dst"), xsVar(0));}
开发者ID:basuke,项目名称:kinomajs,代码行数:13,


示例17: KPR_host_set_debugging

void KPR_host_set_debugging(xsMachine* the){#ifdef mxDebug	KprHost self = xsGetHostData(xsThis);	KprApplication application = (KprApplication)self->first;	Boolean flag = xsToBoolean(xsArg(0));	xsBeginHost(application->the);	{		(void)xsCall1(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("setConnected"), xsBoolean(flag));	}	xsEndHost(application->the);#endif}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:13,


示例18: usb_callback

static voidusb_callback(xsMachine *the, void *closure){	char *buf = closure;	xsBeginHost(the);	xsVars(2);	xsGet(xsVar(0), xsGlobal, xsID("require"));	xsSetString(xsVar(1), "CLI");	xsCall(xsResult, xsVar(0), xsID("weak"), &xsVar(1), NULL);	xsSetString(xsVar(1), buf);	xsCall_noResult(xsResult, xsID("evaluate"), &xsVar(1), NULL);	xsEndHost(the);}
开发者ID:cugfeng,项目名称:kinomajs,代码行数:14,


示例19: KPR_host_set_profiling

void KPR_host_set_profiling(xsMachine* the){	KprHost self = xsGetHostData(xsThis);	KprApplication application = (KprApplication)self->first;	Boolean flag = xsToBoolean(xsArg(0));	xsBeginHost(application->the);	{		if (flag)			(void)xsCall0(xsGet(xsGlobal, xsID("xs")), xsID("startProfiling"));		else			(void)xsCall0(xsGet(xsGlobal, xsID("xs")), xsID("stopProfiling"));	}	xsEndHost(application->the);}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:14,


示例20: KPR_canvasLinearGradient_setStyle

void KPR_canvasLinearGradient_setStyle(xsMachine *the){	FskCanvas2dContext ctx = xsGetHostData(xsArg(0));	xsNumberValue x0 = xsToNumber(xsGet(xsThis, xsID("x0")));	xsNumberValue y0 = xsToNumber(xsGet(xsThis, xsID("y0")));	xsNumberValue x1 = xsToNumber(xsGet(xsThis, xsID("x1")));	xsNumberValue y1 = xsToNumber(xsGet(xsThis, xsID("y1")));	UInt32 c, i;	FskCanvas2dGradientStop stops[kCanvas2DMaxGradientStops];	xsVars(2);	xsVar(0) = xsGet(xsThis, xsID("stops"));	c = xsToInteger(xsGet(xsVar(0), xsID("length")));	if (c > kCanvas2DMaxGradientStops) c = kCanvas2DMaxGradientStops;	for (i = 0; i < c; i++) {		xsVar(1) = xsGetAt(xsVar(0), xsInteger(i));		stops[i].offset = xsToNumber(xsGet(xsVar(1), xsID("offset")));		xsVar(1) = xsGet(xsVar(1), xsID("color"));		if (!KprParseColor(the, xsToString(xsVar(1)), &(stops[i].color)))			return;	}	if (xsTest(xsArg(1)))		FskCanvas2dSetStrokeStyleLinearGradient(ctx, x0, y0, x1, y1, c, stops);	else		FskCanvas2dSetFillStyleLinearGradient(ctx, x0, y0, x1, y1, c, stops);}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:25,


示例21: KPR_host_setBreakpoint

void KPR_host_setBreakpoint(xsMachine* the){#ifdef mxDebug	KprHost self = xsGetHostData(xsThis);	KprApplication application = (KprApplication)self->first;	xsStringValue file = xsToString(xsArg(0));	xsStringValue line = xsToString(xsArg(1));	xsBeginHost(application->the);	{		(void)xsCall2(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("setBreakpoint"), xsString(file), xsString(line));	}	xsEndHost(application->the);#endif}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:14,


示例22: KPR_host_get_debugging

void KPR_host_get_debugging(xsMachine* the){#ifdef mxDebug	KprHost self = xsGetHostData(xsThis);	KprApplication application = (KprApplication)self->first;	Boolean result = false;	xsBeginHost(application->the);	{		result = xsTest(xsCall0(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("getConnected")));	}	xsEndHost(application->the);	xsResult = xsBoolean(result);#endif}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:14,


示例23: fxFindModuleLoadAsDirectory

xsBooleanValue fxFindModuleLoadAsDirectory(xsMachine* the, xsStringValue base, xsStringValue name, xsIndex* id){	char node[1024];	UInt32 nodeSize;	xsStringValue slash;	FskErr err;	FskFileMapping map = NULL;	xsBooleanValue result = 0;	xsStringValue path = NULL;	unsigned char* data;	FskInt64 size;	xsSlot slot;		nodeSize = sizeof(node);	FskStrNCopy(node, base, nodeSize);	slash = FskStrRChr(node, '/');	if (slash)		*slash = 0;	FskStrNCat(node, "/", nodeSize);	FskStrNCat(node, name, nodeSize);	if (FskStrTail(node, "/") != 0)		FskStrNCat(node, "/", nodeSize);	FskStrNCat(node, "package.json", nodeSize);	err = KprURLToPath(node, &path);	if (err == kFskErrNone) {		err = FskFileMap(path, &data, &size, 0, &map);		if (err == kFskErrNone) {			xsTry {				slot = xsNewInstanceOf(xsChunkPrototype);				xsSetHostData(slot, data);				xsSetHostDestructor(slot, NULL);				xsSet(slot, xsID("length"), xsInteger(size));				slot = xsCall1(xsGet(xsGlobal, xsID("JSON")), xsID("parse"), slot);			}			xsCatch {				slot = xsUndefined;			}			if (xsTest(slot)) {				slot = xsGet(slot, xsID("main"));				if (xsTest(slot)) {					FskStrNCopy(node, name, nodeSize);					if (FskStrTail(node, "/") != 0)						FskStrNCat(node, "/", nodeSize);					FskStrNCat(node, xsToString(slot), nodeSize);					if (fxFindModuleLoadAsFile(the, base, node, id))						result = 1;				}			}		}
开发者ID:basuke,项目名称:kinomajs,代码行数:49,


示例24: xs_i2c_init

void xs_i2c_init(xsMachine *the){    xsI2C i2c = NULL;    FskErr err;    int address;    int sdaPin = 0, clkPin = 0, sdaDev = 0, clkDev = 0;	FskPinI2C pin = NULL;    if (xsGetHostData(xsThis))        xsThrowDiagnosticIfFskErr(kFskErrBadState, "I2C pin already initialized (SDA pin %d).", i2c->sdaPin);    address = xsToInteger(xsGet(xsThis, xsID("address")));    xsResult = xsGet(xsThis, xsID("bus"));    if (xsUndefinedType == xsTypeOf(xsResult)) {        sdaPin = xsToInteger(xsGet(xsThis, xsID("sda")));        clkPin = xsToInteger(xsGet(xsThis, xsID("clock")));		err = FskPinI2CNew(&pin, sdaPin, clkPin, kFskPinI2CNoBus);    }    else {        sdaDev = xsToInteger(xsResult);		err = FskPinI2CNew(&pin, 0, 0, sdaDev);	}    xsThrowDiagnosticIfFskErr(err, "I2C open failed %s (SDA pin %d, CLK pin %d).", FskInstrumentationGetErrorString(err), sdaPin, clkPin);    err = FskMemPtrNewClear(sizeof(xsI2CRecord), &i2c);    if (err) {        FskPinI2CDispose(pin);        xsError(err);    }        xsSetHostData(xsThis, i2c);	i2c->pin = pin;    i2c->sdaPin = sdaPin;    i2c->clkPin = clkPin;    i2c->sdaDev = sdaDev;    i2c->clkDev = clkDev;    i2c->address = (UInt8)address;    i2c->bus = sdaDev;#if SUPPORT_XS_DEBUG    if (0 != sdaPin)        snprintf(i2c->diagnosticID, sizeof(i2c->diagnosticID), "(Address 0x%x, SDA pin %d, CLK pin %d)", address, sdaPin, clkPin);    else        snprintf(i2c->diagnosticID, sizeof(i2c->diagnosticID), "(Address 0x%x, Bus %d)", address, sdaDev);#endif}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:49,


示例25: main

int main(int argc, char* argv[]) {	xsAllocation anAllocation = {		2048 * 1024, /* initialChunkSize */		512 * 1024, /* incrementalChunkSize */		1000 * 1000, /* initialHeapCount */			50 * 1000, /* incrementalHeapCount */		1024, /* stackCount */		8192, /* symbolCount */		1993 /* symbolModulo */	};	xsMachine* aMachine;	int argi;	int result = 1;	for (argi = 0; argi < argc; argi++){		result = strncmp(argv[argi], "--help", strlen("--help"));		if(!result) {			printHelp();			exit(0);		}	}		result = 1;	gxProperties = calloc(mxPropertyModulo, sizeof(xsSlot));	if (gxProperties) {		aMachine = xsNewMachine(&anAllocation, &kprconfigGrammar, NULL);		if (aMachine) {			xsBeginHost(aMachine);			{				xsTry {					xsResult = xsNewInstanceOf(xsArrayPrototype);					for (argi = 0; argi < argc; argi++)						xsSet(xsResult, argi, xsString(argv[argi]));					(void)xsCall1(xsGlobal, xsID("main"), xsResult);					result = 0;				}				xsCatch {					char* aMessage = xsToString(xsGet(xsException, xsID("message")));					fprintf(stderr, "### %s/n", aMessage);				}			}			xsEndHost(aMachine);			xsDeleteMachine(aMachine);		}		else			fprintf(stderr, "### Cannot allocate machine!/n");	}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:49,


示例26: KPR_Message_patch

void KPR_Message_patch(xsMachine* the){	xsResult = xsGet(xsGlobal, xsID("Message"));	xsNewHostProperty(xsResult, xsID("BUFFER"), xsString("BUFFER"), xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);	xsNewHostProperty(xsResult, xsID("CHUNK"), xsString("CHUNK"), xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);	xsNewHostProperty(xsResult, xsID("DOM"), xsString("DOM"), xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);	xsNewHostProperty(xsResult, xsID("JSON"), xsString("JSON"), xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);	xsNewHostProperty(xsResult, xsID("TEXT"), xsString("TEXT"), xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);	xsNewHostProperty(xsResult, xsID("URI"), xsNewHostFunction(KPR_Message_URI, 1), xsDefault, xsDontScript);	xsNewHostProperty(xsResult, xsID("cancelReferrer"), xsNewHostFunction(KPR_Message_cancelReferrer, 1), xsDefault, xsDontScript);	xsNewHostProperty(xsResult, xsID("notify"), xsNewHostFunction(KPR_Message_notify, 1), xsDefault, xsDontScript);}
开发者ID:basuke,项目名称:kinomajs,代码行数:12,


示例27: KprPinsInvoke

void KprPinsInvoke(KprService service, KprMessage message){	FskErr err = kFskErrNone;	KprPins self = gPins;	if (KprMessageContinue(message)) {		KprPinsListener listener = NULL;		KprPinsListenerFind(&listener, self, message);		if (listener) listener->useCount++;		if (!FskStrCompareWithLength(message->parts.path, "close", message->parts.pathLength)) {			if (listener) {				xsBeginHostSandboxCode(listener->the, NULL);				{                    {						xsTry {							(void)xsCall0(xsAccess(listener->pins), xsID("close"));						}						xsCatch {							err = exceptionToFskErr(the);						}					}                    while (listener->pollers)                        KprPinsPollerDispose(listener->pollers);				}				xsEndHostSandboxCode();				KprPinsListenerDispose(listener, self);				listener = NULL;			}			else {				err = kFskErrNotFound;			}		}		else if (!FskStrCompareWithLength(message->parts.path, "configure", message->parts.pathLength)) {
开发者ID:basuke,项目名称:kinomajs,代码行数:33,


示例28: KprDebugMachineLoadView

void KprDebugMachineLoadView(KprDebugMachine self, int theView, char* thePath, int theLine){	FskErr err = kFskErrNone;	KprDebug debug = self->debug;	xsMachine* the = debug->the;//	FskFileInfo info;//	FskFileMapping map = NULL;//	FskDebugStr("%s: %d - %s:%d", __FUNCTION__, theView, thePath, theLine);	if (xsTypeOf(debug->behavior) == xsUndefinedType) goto bail;	xsVar(0) = xsAccess(debug->behavior);		if (xsFindResult(xsVar(0), xsID("onMachineFileChanged"))) {		(void)xsCallFunction5(xsResult, xsVar(0), xsString(self->address), xsInteger(theView), xsNull, thePath ? xsString(thePath) : xsNull, xsInteger(theLine));	}//	if (kFskErrNone == FskFileGetFileInfo(thePath, &info) && (kFskDirectoryItemIsFile == info.filetype)) {//		unsigned char *data;//		FskInt64 size;//		BAIL_IF_ERR(err = FskFileMap(thePath, &data, &size, 0, &map));//		xsVar(0) = xsAccess(debug->behavior);//		//		if (xsFindResult(xsVar(0), xsID("onMachineFileChanged"))) {//			(void)xsCallFunction5(xsResult, xsVar(0), xsString(self->address), xsInteger(theView), xsNull, xsString(thePath), xsInteger(theLine));//		}//	}bail://	FskFileDisposeMap(map);	xsThrowIfFskErr(err);}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:28,


示例29: xs_system_set_timezone

voidxs_system_set_timezone(xsMachine *the){	struct timezone tz;	xsVars(1);	xsGet(xsVar(0), xsArg(0), xsID("timedifference"));	tz.tz_minuteswest = xsToInteger(xsVar(0));	xsGet(xsVar(0), xsArg(0), xsID("dst"));	tz.tz_dsttime = xsToInteger(xsVar(0));	mc_settimeofday(NULL, &tz);	if (xsHas(xsArg(0), xsID("timezone"))) {		xsGet(xsVar(0), xsArg(0), xsID("timezone"));		mc_env_set_default("TIME_ZONE", xsToString(xsVar(0)));	}}
开发者ID:basuke,项目名称:kinomajs,代码行数:16,


示例30: KPR_canvasRenderingContext2D_setLineDash

// dashesvoid KPR_canvasRenderingContext2D_setLineDash(xsMachine *the){	FskCanvas2dContext	ctx		= xsGetHostData(xsThis);	UInt32				len		= xsToInteger(xsGet(xsArg(0), xsID("length")));	/* Array of even length */	double				dash[kCanvas2DMaxDashCycles*2];	UInt32				i;	if (len) {		if (len > sizeof(dash) / sizeof(dash[0])) {								/* If too large, truncate */			kprTraceDiagnostic(the, "dash length %u > %u is too long", (unsigned)len, sizeof(dash) / sizeof(dash[0]));			len = sizeof(dash) / sizeof(dash[0]);		}		i = (len & 1) ? (len * 2) : len;										/* If odd, double the length to make it even */		for (i = 0; i < len; ++i)			dash[i] = xsToNumber(xsGetAt(xsArg(0), xsInteger(i)));				/* Copy from xs Array to C array to interface to FskCanvas2dSetLineDash() */		if (len & 1) {															/* If odd, ... */			for (i = 0; i < len; ++i)				dash[i + len] = dash[i];										/* ... replicate. Now it is even. */		}		else {			len /= 2;															/* Len here is the number of cycles */		}	}	(void)FskCanvas2dSetLineDash(ctx, len, dash);								/* Set the context line dash state */	return;}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:27,



注:本文中的xsID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xsString函数代码示例
C++ xsGet函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。