本文整理汇总了C++中xsID函数的典型用法代码示例。如果您正苦于以下问题:C++ xsID函数的具体用法?C++ xsID怎么用?C++ xsID使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xsID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xs_mod_init
void
xs_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);
}
示例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);
}
示例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();
}
示例4: KPR_canvasRenderingContext2D_cloneImageData
// image data
void 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);
}
示例5: xs_console_load
void
xs_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));
}
示例6: KPR_canvasRenderingContext2D_createImageData
// pixel manipulation
void 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);
}
示例7: FskSSLNew
FskErr
FskSSLNew(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;
}
示例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);
}
示例9: xs_z_init
void
xs_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);
}
示例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);
}
}
示例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
}
示例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);
}
示例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));
}
}
示例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(¶ms);
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);
}
示例15: xs_z_div2
void
xs_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));
}