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


C++ xsToString函数代码示例

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


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

示例1: xs_stream_encrypt

void
xs_stream_encrypt(xsMachine *the)
{
	crypt_stream_t *stream = xsGetHostData(xsThis);
	int ac = xsToInteger(xsArgc);
	size_t len;
	void *indata, *outdata;

	if (xsTypeOf(xsArg(0)) == xsStringType)
		len = c_strlen(xsToString(xsArg(0)));
	else
		len = xsGetArrayBufferLength(xsArg(0));
	if (ac > 2 && xsTypeOf(xsArg(2)) != xsUndefinedType) {
		size_t n = xsToInteger(xsArg(2));
		if (n < len)
			len = n;
	}
	if (ac > 1 && xsTest(xsArg(1))) {
		if (xsGetArrayBufferLength(xsArg(1)) < (xsIntegerValue)len)
			crypt_throw_error(the, "too small buffer");
		xsResult = xsArg(1);
	}
	else
		xsResult = xsArrayBuffer(NULL, len);
	if (xsTypeOf(xsArg(0)) == xsStringType)
		indata = xsToString(xsArg(0));
	else
		indata = xsToArrayBuffer(xsArg(0));
	outdata = xsToArrayBuffer(xsResult);
	(*stream->process)(stream->ctx, indata, outdata, len);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:31,代码来源:crypt_stream.c

示例2: xs_stream_encrypt

void
xs_stream_encrypt(xsMachine *the)
{
	crypt_stream_t *stream = xsGetHostData(xsThis);
	int ac = xsToInteger(xsArgc);
	size_t len;
	void *indata, *outdata;

	if (xsTypeOf(xsArg(0)) == xsStringType)
		len = strlen(xsToString(xsArg(0)));
	else
		len = xsGetArrayBufferLength(xsArg(0));
	if (ac > 2 && xsTypeOf(xsArg(2)) != xsUndefinedType) {
		size_t n = xsToInteger(xsArg(2));
		if (n < len)
			len = n;
	}
	xsResult = ac > 1 && xsTest(xsArg(1)) ? xsArg(1) : xsArrayBuffer(NULL, len);
	if (xsTypeOf(xsArg(0)) == xsStringType)
		indata = xsToString(xsArg(0));
	else
		indata = xsToArrayBuffer(xsArg(0));
	outdata = xsToArrayBuffer(xsResult);
	(*stream->process)(stream->ctx, indata, outdata, len);
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:25,代码来源:crypt_stream.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: KPR_debug_file

void KPR_debug_file(xsMachine *the)
{
	KprDebug self = xsGetHostData(xsThis);
	KprDebugMachine machine = NULL;
	int command = mxNoCommand;
	char* path = NULL;
	char* value = NULL;
	xsIntegerValue line = -1;
	xsIntegerValue c = xsToInteger(xsArgc);
	xsVars(4);
	if ((c >= 2) && (xsTypeOf(xsArg(0)) == xsStringType) && (xsTypeOf(xsArg(1)) == xsIntegerType)) {
		char* address = xsToString(xsArg(0));
		command = xsToInteger(xsArg(1));
		machine = KprDebugFindMachine(self, address);
	}
	if ((c >= 4) && (xsTypeOf(xsArg(2)) == xsStringType) && (xsTypeOf(xsArg(3)) == xsIntegerType)) {
		path = FskStrDoCopy(xsToString(xsArg(2)));
		line = xsToInteger(xsArg(3));
	}
	if ((c >= 5) && (xsTypeOf(xsArg(4)) == xsStringType)) {
		value = FskStrDoCopy(xsToString(xsArg(4)));
	}
	if (machine && ((command == mxFramesView) || (command == mxFilesView) || (command == mxLogView) || (command == mxBreakpointsView))) {
		xsEnterSandbox();
		KprDebugMachineDispatchCommand(machine, command, path, value, line);
		xsLeaveSandbox();
	}
	else
		xsThrowIfFskErr(kFskErrInvalidParameter);
	FskMemPtrDispose(value);
	FskMemPtrDispose(path);
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:32,代码来源:kprDebug.c

示例6: xsToolWriteString

void xsToolWriteString(xsMachine* the)
{
	char* aPath;
	FILE* aFile;
	char *aBuffer;
	size_t aSize;

	aPath = xsToString(xsArg(0));
#if mxWindows
	{
		char* aSlash;
		aSlash = aPath;
		while (*aSlash) {
			if (*aSlash == '/')
				*aSlash = '\\';
			aSlash++;
		}
	}
#endif
	aFile = fopen(aPath, "wb");
	if (aFile) {
		aBuffer = xsToString(xsArg(1));
		aSize = strlen(aBuffer);
		fwrite(aBuffer, 1, aSize, aFile);
		fclose(aFile);
	}
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:27,代码来源:xsTool.c

示例7: KPR_message_setResponseHeader

void KPR_message_setResponseHeader(xsMachine* the)
{
	KprMessage self = kprGetHostData(xsThis, this, message);
	xsStringValue name = xsToString(xsArg(0));
	xsStringValue value = xsToString(xsArg(1));
	(void)KprMessageSetResponseHeader(self, name, value);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:7,代码来源:kprMessage.c

示例8: 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

示例9: KPR_mqttclient_publish

void KPR_mqttclient_publish(xsMachine* the)
{
	KPR_MQTTClientRecord *self = xsGetHostData(xsThis);
	FskErr err = kFskErrNone;
	char *topic;
	void *payload = NULL;
	UInt32 payloadLength = 0;
	UInt8 qos;
	Boolean retain;
	UInt16 token;

	if (xsToInteger(xsArgc) != 4) xsThrowIfFskErr(kFskErrParameterError);

	topic = xsToString(xsArg(0));

	if (xsTest(xsArg(1))) {
		if (isArrayBuffer(xsArg(1))) {
			payload = xsToArrayBuffer(xsArg(1));
			payloadLength = xsGetArrayBufferLength(xsArg(1));
		} else {
			payload = xsToString(xsArg(1));
			payloadLength = FskStrLen(payload);
		}
	}

	qos = xsToInteger(xsArg(2));
	retain = xsToBoolean(xsArg(3));

	bailIfError(KprMQTTClientPublish(self->client, topic, payload, payloadLength, qos, retain, &token));
	xsResult = xsInteger(token);

bail:
	xsThrowIfFskErr(err);
}
开发者ID:Kazu-zamasu,项目名称:kinomajs,代码行数:34,代码来源:kprMQTT.c

示例10: xs_env_set

void
xs_env_set(xsMachine *the)
{
	mc_env_t *env;
	char *val, *name;
	int pos;
	int argc = xsToInteger(xsArgc);

	if (argc < 1)
		return;
	env = xsGetHostData(xsThis);
	if (1 == argc || xsTypeOf(xsArg(1)) == xsUndefinedType) {
		int result;

		name = xsToString(xsArg(0));
		result = mc_env_unset(env, name);
		xsSetBoolean(xsResult, result == 0);
	}
	else {
		if ((val = mc_strdup(xsToString(xsArg(1)))) == NULL)
			return;
		pos = argc > 2 && xsTypeOf(xsArg(2)) != xsUndefinedType ? xsToInteger(xsArg(2)) : -1;
		name = xsToString(xsArg(0));
		mc_env_set(env, name, val, pos);
		mc_free(val);
	}
}
开发者ID:basuke,项目名称:kinomajs,代码行数:27,代码来源:xm_env.c

示例11: xs_dbg_login

void
xs_dbg_login(xsMachine *the)
{
	char *host = xsToString(xsArg(0));
	char *name = NULL;
	if (xsToInteger(xsArgc) > 1 && xsTest(xsArg(1)))
		name = xsToString(xsArg(1));
	xsSetBoolean(xsResult, xsStartDebug(the, host, name));
}
开发者ID:basuke,项目名称:kinomajs,代码行数:9,代码来源:xm_debug.c

示例12: KPR_mergeURI

void KPR_mergeURI(xsMachine *the)
{
	xsStringValue base = xsToString(xsArg(0));
	xsStringValue url = xsToString(xsArg(1));
	xsStringValue target;
	xsThrowIfFskErr(KprURLMerge(base, url, &target));
	xsResult = xsString(target);
	FskMemPtrDispose(target);
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:9,代码来源:kprURL.c

示例13: xsToolResolvePath

void xsToolResolvePath(xsMachine* the)
{
#if mxWindows
	char* srcPath;
	char* aSlash;
	char aPath[1024];
	DWORD attributes;
	int aResult = 0;

	srcPath = xsToString(xsArg(0));
	aSlash = srcPath;
	while (*aSlash) {
		if (*aSlash == '/')
			*aSlash = '\\';
		aSlash++;
	}	
	if (_fullpath(aPath, srcPath, 1024) != NULL) {
		attributes = GetFileAttributes(aPath);
		if (attributes != 0xFFFFFFFF) {
			if (xsToInteger(xsArgc) == 1)
				aResult = 1;
			else if (xsToBoolean(xsArg(1)))
				aResult = (attributes & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; 
			else
				aResult = (attributes & FILE_ATTRIBUTE_DIRECTORY) ? 0 : 1; 
		}
	}
#else
	char* srcPath;
	char aPath[PATH_MAX];
	struct stat a_stat;
	int aResult = 0;
	
	srcPath = xsToString(xsArg(0));
	if (realpath(srcPath, aPath) != NULL) {
		if (stat(aPath, &a_stat) == 0) {
			if (xsToInteger(xsArgc) == 1)
				aResult = 1;
			else if (xsToBoolean(xsArg(1)))
				aResult = S_ISDIR(a_stat.st_mode) ? 1 : 0;
			else
				aResult = S_ISREG(a_stat.st_mode) ? 1 : 0;
		}
	}
#endif
	if (aResult) {
		if (xsToBoolean(xsArg(1))) {
			aResult = strlen(aPath) - 1;
			if (aPath[aResult] == mxSeparator)
				aPath[aResult] = 0;
		}
		xsResult = xsString(aPath);
	}
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:54,代码来源:xsTool.c

示例14: xsToolOpenFile

void xsToolOpenFile(xsMachine* the)
{
	FILE* aFile;
	int argc = xsToInteger(xsArgc);
	char *path = xsToString(xsArg(0));
	if (argc > 1)
		aFile = fopen(path, xsToString(xsArg(1)));
	else
		aFile = fopen(path, "w");
	xsElseError(aFile);
	xsSetHostData(xsThis, aFile);
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:12,代码来源:xsTool.c

示例15: kpr2jsCompareName

void kpr2jsCompareName(xsMachine* the)
{
    char *aName1 = NULL;
    char *aName2 = NULL;

    aName1 = xsToString(xsArg(0));
    aName2 = xsToString(xsArg(1));
#if mxWindows
    xsResult = xsInteger(_stricmp(aName1, aName2));
#else
    xsResult = xsInteger(strcasecmp(aName1, aName2));
#endif
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:13,代码来源:kpr2js.c


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