当前位置: 首页>>代码示例>>C++>>正文


C++ xsGet函数代码示例

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


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

示例1: FskSSLRead

FskErr
FskSSLRead(void *a, void *buf, int *bufLen)
{
	FskSSL *fssl = a;
	FskErr err = kFskErrNone;
	int len = *bufLen, nread;

	if (fssl->skt == NULL)
		return kFskErrOperationFailed;

	xsBeginHost(fssl->vm->the);
	xsTry {
		xsCall1_noResult(fssl->socket, xsID("attachData"), xsHostData(fssl->skt));
		xsResult = xsCall2(fssl->ssl, xsID("read"), fssl->socket, xsInteger(len));
		if (xsTest(xsResult)) {
			nread = xsToInteger(xsGet(xsResult, xsID("length")));
			if (nread > len)
				nread = len;
			FskMemCopy(buf, xsGetHostData(xsResult), nread);
			xsCall0_noResult(xsResult, xsID("free"));
			*bufLen = nread;
			err = nread == 0 ? kFskErrNoData: kFskErrNone;
		}
		else
			err = kFskErrConnectionClosed;
	} xsCatch {
		if (xsHas(xsException, xsID("code")))
			err = xsToInteger(xsGet(xsException, xsID("code")));
		if (err == kFskErrNone)
			err = kFskErrOperationFailed;
	}
	xsEndHost(fssl->vm->the);
	return err;
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:34,代码来源:FskSSL.c

示例2: xs_ed_init

void
xs_ed_init(xsMachine *the)
{
	ed_t *ed;
	mod_t *mod;	/* mod_t* */
	void *d;	/* kcl_int_t* */
	kcl_err_t err;

	if ((ed = crypt_malloc(sizeof(ed_t))) == NULL)
		kcl_throw_error(the, KCL_ERR_NOMEM);
	if ((err = kcl_ed_alloc(&ed->ctx)) != KCL_ERR_NONE) {
		crypt_free(ed);
		kcl_throw_error(the, err);
	}
	xsResult = xsGet(xsThis, xsID("mod"));
	mod = xsGetHostData(xsResult);
	xsResult = xsGet(xsThis, xsID("d"));
	d = xsGetHostData(xsResult);
	kcl_ed_init(ed->ctx, mod->ctx, d);

	ed->id_x = xsID("x");
	ed->id_y = xsID("y");
	ed->proto_int = xsGet(xsThis, xsID("_proto_int"));
	ed->proto_ecp = xsGet(xsThis, xsID("_proto_ecp"));
	xsSetHostData(xsThis, ed);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:26,代码来源:arith_ed.c

示例3: 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,代码来源:gpio.c

示例4: KPR_message_setRequestCertificate

void KPR_message_setRequestCertificate(xsMachine* the)
{
	KprMessage self = xsGetHostData(xsThis);
	FskSocketCertificateRecord* certs = NULL;
	FskSocketCertificateRecord certsRecord = {
		NULL, 0,
		NULL,
		NULL,
		NULL, 0,
	};
	if (xsIsInstanceOf(xsArg(0), xsObjectPrototype)) {
		certs = &certsRecord;
		if (xsHas(xsArg(0), xsID("certificates"))) {
			certs->certificates = (void*)xsToString(xsGet(xsArg(0), xsID("certificates")));
			certs->certificatesSize = FskStrLen(certs->certificates);
		}
		if (xsHas(xsArg(0), xsID("policies"))) {
			certs->policies = xsToString(xsGet(xsArg(0), xsID("policies")));
		}
		if (xsHas(xsArg(0), xsID("key"))) {
			certs->key = (void*)xsToString(xsGet(xsArg(0), xsID("key")));
			certs->keySize = FskStrLen(certs->key);
		}
	}
	else { // compatibility
		certs = &certsRecord;
		if (xsTest(xsArg(0))) {
			certs->certificates = xsGetHostData(xsArg(0));
			certs->certificatesSize = xsToInteger(xsGet(xsArg(0), xsID_length));
		}
		if (xsTest(xsArg(1)))
			certs->policies = xsToString(xsArg(1));
	}
	xsThrowIfFskErr(KprMessageSetRequestCertificate(self, certs));
}
开发者ID:basuke,项目名称:kinomajs,代码行数:35,代码来源:kprMessage.c

示例5: 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);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:28,代码来源:arith_kcl.c

示例6: KPR_canvasPattern_setStyle

void KPR_canvasPattern_setStyle(xsMachine *the)
{
	FskCanvas2dContext ctx = xsGetHostData(xsArg(0));
	UInt32 repetition = kFskCanvas2dPatternRepeat;
	FskConstBitmap bitmap = NULL;
	Boolean owned = false;
	xsVars(1);
	xsVar(0) = xsGet(xsThis, xsID("repetition"));
	if (xsTest(xsVar(0))) {
		xsStringValue it = xsToString(xsVar(0));
		if (!FskStrCompare(it, "no-repeat")) repetition = kFskCanvas2dPatternRepeatNone;
		else if (!FskStrCompare(it, "repeat-x")) repetition = kFskCanvas2dPatternRepeatX;
		else if (!FskStrCompare(it, "repeat-y")) repetition = kFskCanvas2dPatternRepeatY;
		else if (!FskStrCompare(it, "repeat")) repetition = kFskCanvas2dPatternRepeat;
		else xsError(kFskErrInvalidParameter);
	}
	xsVar(0) = xsGet(xsThis, xsID("image"));
	if (xsIsInstanceOf(xsVar(0), xsGet(xsGet(xsGlobal, xsID_KPR), xsID_texture))) {
		KprTexture texture = xsGetHostData(xsVar(0));
		bitmap = KprTextureGetBitmap(texture, NULL, &owned);
	}
	else {
		KprContent content = xsGetHostData(xsVar(0));
		bitmap = (*content->dispatch->getBitmap)(content, NULL, &owned);
	}
	if (!bitmap)
		xsError(kFskErrInvalidParameter);
	if (xsTest(xsArg(1)))
		FskCanvas2dSetStrokeStylePattern(ctx, repetition, bitmap);
	else
		FskCanvas2dSetFillStylePattern(ctx, repetition, bitmap);
	if (!owned)
		FskBitmapDispose((FskBitmap)bitmap);
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:34,代码来源:kprCanvas.c

示例7: KprPromiseTargetComplete

static void KprPromiseTargetComplete(KprMessage message, void* it)
{
	KprPromiseTarget self = it;
	xsBeginHost(self->the);
	xsVars(3);
	xsVar(0) = xsAccess(self->resolve);
	xsVar(1) = xsAccess(self->reject);
	if (message->error) {
		xsVar(2) = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID_KPR), xsID_message));
		xsSetHostData(xsVar(2), message);
		FskInstrumentedItemSendMessageDebug(message, kprInstrumentedMessageConstruct, message);
		message->usage++; // host
		(void)xsCallFunction1(xsVar(1), xsUndefined, xsVar(2));
	}
	else {
		if (message->stream)
			KprMessageScriptTargetGet(message, the, &xsVar(2));
		else {
			xsVar(2) = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID_KPR), xsID_message));
			xsSetHostData(xsVar(2), message);
			FskInstrumentedItemSendMessageDebug(message, kprInstrumentedMessageConstruct, message);
			message->usage++; // host
		}
		(void)xsCallFunction1(xsVar(0), xsUndefined, xsVar(2));
	}
	xsEndHost(self->the);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:27,代码来源:kprMessage.c

示例8: KPR_canvasRadialGradient_setStyle

void KPR_canvasRadialGradient_setStyle(xsMachine *the)
{
	FskCanvas2dContext ctx = xsGetHostData(xsArg(0));
	xsNumberValue x0 = xsToNumber(xsGet(xsThis, xsID("x0")));
	xsNumberValue y0 = xsToNumber(xsGet(xsThis, xsID("y0")));
	xsNumberValue r0 = xsToNumber(xsGet(xsThis, xsID("r0")));
	xsNumberValue x1 = xsToNumber(xsGet(xsThis, xsID("x1")));
	xsNumberValue y1 = xsToNumber(xsGet(xsThis, xsID("y1")));
	xsNumberValue r1 = xsToNumber(xsGet(xsThis, xsID("r1")));
	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)))
		FskCanvas2dSetStrokeStyleRadialGradient(ctx, x0, y0, r0, x1, y1, r1, c, stops);
	else
		FskCanvas2dSetFillStyleRadialGradient(ctx, x0, y0, r0, x1, y1, r1, c, stops);
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:27,代码来源:kprCanvas.c

示例9: Library_cacheQuery

void Library_cacheQuery(xsMachine* the)
{
    KprLibraryServer self = gLibraryServer;
    UInt32 index;
    KprLibraryQuery query;
    FskMutexAcquire(self->queryMutex);
    index = self->queryIndex % kQueryCount;
    query = self->queries[index];
    if (query) {
        KprLibraryQueryDispose(query);
        self->queries[index] = NULL;
    }
    KprLibraryQueryNew(&query);
    FskInstrumentedItemSetOwner(query, self);
    xsEnterSandbox();
    query->index = self->queryIndex;
    query->info = FskStrDoCopy(xsToString(xsGet(xsArg(0), xsID("info"))));
    query->kind = xsToInteger(xsGet(xsArg(0), xsID("kind")));
    query->mime = FskStrDoCopy(xsToString(xsGet(xsArg(0), xsID("mime"))));
    query->url = FskStrDoCopy(xsToString(xsGet(xsArg(0), xsID("url"))));
    xsResult = xsGet(xsArg(0), xsID("authorization"));
    if (xsTest(xsResult))
        query->authorization = FskStrDoCopy(xsToString(xsResult));
    xsLeaveSandbox();
    self->queries[index] = query;
    xsResult = xsInteger(self->queryIndex);
    self->queryIndex++;
    FskMutexRelease(self->queryMutex);
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:29,代码来源:kprLibraryServer.c

示例10: 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);
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:9,代码来源:kprCanvas.c

示例11: scanStopTag

void scanStopTag(void *data, const char *name)
{
	Scanner* self = data;
	xsMachine* the = self->the;
	scanText(data);
	xsArrayCacheEnd(xsVar(CHILDREN));
	xsResult = xsGet(xsResult, xsID_parent);
	xsVar(CHILDREN) = xsGet(xsResult, xsID_children);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:9,代码来源:xsInfoset.c

示例12: 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);
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:10,代码来源:kprCanvas.c

示例13: KPR_canvasRenderingContext2D_drawImage

// drawing images
void KPR_canvasRenderingContext2D_drawImage(xsMachine *the)
{
	FskCanvas2dContext ctx = xsGetHostData(xsThis);
	xsIntegerValue c = xsToInteger(xsArgc);
	FskConstCanvas cnv = NULL;
	FskBitmap bitmap = NULL;
	Boolean owned = false;
	xsVars(1);
	if (xsIsInstanceOf(xsArg(0), xsGet(xsGet(xsGlobal, xsID_KPR), xsID_texture))) {
		KprTexture texture = xsGetHostData(xsArg(0));
		bitmap = KprTextureGetBitmap(texture, NULL, &owned);
	}
	else {
		KprContent content = xsGetHostData(xsArg(0));
		if (content->dispatch == &KprCanvasDispatchRecord)
			cnv = ((KprCanvas)content)->cnv;
		else
			bitmap = (*content->dispatch->getBitmap)(content, NULL, &owned);
	}
	if (!cnv && !bitmap)
		xsError(kFskErrInvalidParameter);
	if (c > 8) {
		xsNumberValue sx = xsToNumber(xsArg(1));
		xsNumberValue sy = xsToNumber(xsArg(2));
		xsNumberValue sw = xsToNumber(xsArg(3));
		xsNumberValue sh = xsToNumber(xsArg(4));
		xsNumberValue dx = xsToNumber(xsArg(5));
		xsNumberValue dy = xsToNumber(xsArg(6));
		xsNumberValue dw = xsToNumber(xsArg(7));
		xsNumberValue dh = xsToNumber(xsArg(8));
		if (cnv)
			FskCanvas2dDrawSubScaledCanvas2d(ctx, cnv, sx, sy, sw, sh, dx, dy, dw, dh);
		else
			FskCanvas2dDrawSubScaledBitmap(ctx, bitmap, sx, sy, sw, sh, dx, dy, dw, dh);
	}
	else if (c > 4) {
		xsNumberValue dx = xsToNumber(xsArg(1));
		xsNumberValue dy = xsToNumber(xsArg(2));
		xsNumberValue dw = xsToNumber(xsArg(3));
		xsNumberValue dh = xsToNumber(xsArg(4));
		if (cnv)
			FskCanvas2dDrawScaledCanvas2d(ctx, cnv, dx, dy, dw, dh);
		else
			FskCanvas2dDrawScaledBitmap(ctx, bitmap, dx, dy, dw, dh);
	}
	else {
		xsNumberValue dx = xsToNumber(xsArg(1));
		xsNumberValue dy = xsToNumber(xsArg(2));
		if (cnv)
			FskCanvas2dDrawCanvas2d(ctx, cnv, dx, dy);
		else
			FskCanvas2dDrawBitmap(ctx, bitmap, dx, dy);
	}
	if (!owned)
		FskBitmapDispose(bitmap);
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:57,代码来源:kprCanvas.c

示例14: 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;
}
开发者ID:afrog33k,项目名称:kinomajs,代码行数:55,代码来源:FskSSL.c

示例15: 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);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:11,代码来源:arith_kcl.c


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