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


C++ xsString函数代码示例

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


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

示例1: KprDebugMachineEchoItem

void KprDebugMachineEchoItem(KprDebugMachine self, int theView, char* path, int line, char* name, char* value)
{
	KprDebug debug = self->debug;
	xsMachine* the = debug->the;

	if (xsTypeOf(debug->behavior) == xsUndefinedType) goto bail;
	{
		xsTry {
			xsVar(0) = xsAccess(debug->behavior);
			xsVar(1) = xsGet(xsVar(0), xsID(self->address));
			xsVar(2) = xsNewInstanceOf(xsObjectPrototype);
			if (path)
				xsNewHostProperty(xsVar(2), xsID("path"), xsString(path), xsDefault, xsDontScript);
			if (line >= 0)
				xsNewHostProperty(xsVar(2), xsID("line"), xsInteger(line), xsDefault, xsDontScript);
			if (name)
				xsNewHostProperty(xsVar(2), xsID("name"), xsString(name), xsDefault, xsDontScript);
			if (value)
				xsNewHostProperty(xsVar(2), xsID("value"), xsString(value), xsDefault, xsDontScript);
			if (xsFindResult(xsVar(1), xsID_push)) {
				(void)xsCallFunction1(xsResult, xsVar(1), xsVar(2));
			}
		}
		xsCatch {
		}
	}
bail:
	return;
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:29,代码来源:kprDebug.c

示例2: kpr2jsSplitPath

void kpr2jsSplitPath(xsMachine* the)
{
    char *aPath;
    char *aSeparator = NULL;
    char *aDot = NULL;
    int aLength;
    char aDirectory[1024];
    char aName[1024];
    char anExtension[1024];

    aPath = xsToString(xsArg(0));
    aSeparator = strrchr(aPath, mxSeparator);
    if (aSeparator == NULL)
        aSeparator = aPath;
    else
        aSeparator++;
    aDot = strrchr(aSeparator, '.');
    if (aDot == NULL)
        aDot = aSeparator + strlen(aSeparator);
    aLength = aSeparator - aPath;
    strncpy(aDirectory, aPath, aLength);
    aDirectory[aLength - 1] = 0;
    aLength = aDot - aSeparator;
    strncpy(aName, aSeparator, aLength);
    aName[aLength] = 0;
    strcpy(anExtension, aDot);
    xsResult = xsNewInstanceOf(xsArrayPrototype);
    xsSet(xsResult, 0, xsString(aDirectory));
    xsSet(xsResult, 1, xsString(aName));
    xsSet(xsResult, 2, xsString(anExtension));
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:31,代码来源:kpr2js.c

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

示例4: KPR_Message_patch

void KPR_Message_patch(xsMachine* the)
{
	xsResult = xsGet(xsGlobal, xsID("Message"));
	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:giapdangle,项目名称:kinomajs,代码行数:11,代码来源:kprMessage.c

示例5: KprApplicationNew

FskErr KprApplicationNew(KprApplication* it, char* url, char* id, Boolean breakOnStart, Boolean breakOnExceptions)
{
	KprCoordinatesRecord coordinates = { kprLeftRight, kprTopBottom, 0, 0, 0, 0, 0, 0 };
	xsAllocation allocation = {
		2 * 1024 * 1024,
		1024 * 1024,
		64 * 1024,
		8 * 1024,
		2048,
		16000,
		1993
	};
	FskErr err = kFskErrNone;
	KprApplication self;
	
	bailIfError(FskMemPtrNewClear(sizeof(KprApplicationRecord), it));
	self = *it;
	FskInstrumentedItemNew(self, NULL, &KprApplicationInstrumentation);
	self->dispatch = &KprApplicationDispatchRecord;
	self->flags = kprContainer | kprClip | kprVisible;
	KprContentInitialize((KprContent)self, &coordinates, NULL, NULL);
	bailIfError(KprURLMerge(gShell->url, url, &self->url));	
	if (id) {
		self->id = FskStrDoCopy(id);	
		bailIfNULL(self->id);
	}
	self->the = xsAliasMachine(&allocation, gShell->root, self->url, self);
	if (!self->the) 
		BAIL(kFskErrMemFull);
	FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentCreateMachine, self);
	xsBeginHost(self->the);
	xsResult = xsNewHostFunction(KPR_include, 1);
	xsSet(xsResult, xsID("uri"), xsString(self->url));
	xsNewHostProperty(xsGlobal, xsID("include"), xsResult, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);
	xsResult = xsNewHostFunction(KPR_require, 1);
	xsSet(xsResult, xsID("uri"), xsString(self->url));
	xsNewHostProperty(xsGlobal, xsID("require"), xsResult, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);
	xsResult = xsNewInstanceOf(xsGet(xsGet(xsGlobal, xsID("KPR")), xsID("application")));
	self->slot = xsResult;
	xsSetHostData(xsResult, self);
	(void)xsCall1(xsGet(xsGlobal, xsID("Object")), xsID("seal"), xsResult);
	xsNewHostProperty(xsGlobal, xsID("application"), xsResult, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);
	xsNewHostProperty(xsGlobal, xsID("shell"), xsNull, xsDontDelete | xsDontSet, xsDontScript | xsDontDelete | xsDontSet);
	if (breakOnStart)
		xsDebugger();
    if (breakOnExceptions)
		(void)xsCall1(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("setBreakOnException"), xsBoolean(breakOnExceptions));
	(void)xsCall1(xsGlobal, xsID("include"), xsString(self->url));
	xsEndHost(self->the);
	KprContentChainPrepend(&gShell->applicationChain, self, 0, NULL);
bail:
	return err;
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:53,代码来源:kprApplication.c

示例6: Zeroconf_browser_callback

void Zeroconf_browser_callback(KprZeroconfBrowser self, char* function, KprZeroconfServiceInfo service)
{
	xsBeginHostSandboxCode(self->the, self->code);
	if (xsTypeOf(self->behavior) == xsUndefinedType) goto bail;
	xsVars(3);
	{
		xsTry {
			xsVar(0) = xsAccess(self->behavior);
			xsVar(1) = xsNewInstanceOf(xsObjectPrototype);
			xsSet(xsVar(1), xsID("name"), xsString(service->name));
			xsSet(xsVar(1), xsID("type"), xsString(service->type));
			if (service->host)
				xsSet(xsVar(1), xsID("host"), xsString(service->host));
			if (service->ip) {
				xsSet(xsVar(1), xsID("ip"), xsString(service->ip));
				xsSet(xsVar(1), xsID("port"), xsInteger(service->port));
			}
			if (service->txt) {
				char* txt = service->txt;
				UInt32 position = 0, size = FskStrLen(txt);
				UInt32 length = 0;
				xsVar(2) = xsNewInstanceOf(xsObjectPrototype);
				xsSet(xsVar(1), xsID("txt"), xsVar(2));
				length = txt[position++] & 0xFF;
				while ((position + length) <= size) {
					char end;
					char* equal;
					if (!length) break;
					end = txt[position + length];
					txt[position + length] = 0;
					equal = FskStrChr(txt + position, '=');
					if (equal) {
						*equal = 0;
						xsSet(xsVar(2), xsID(txt + position), xsString(equal + 1));
						*equal = '=';
					}
					txt[position + length] = end;
					position += length;
					length = txt[position++] & 0xFF;
				}
			}
			if (xsFindResult(xsVar(0), xsID(function))) {
				(void)xsCallFunction1(xsResult, xsVar(0), xsVar(1));
			}
		}
		xsCatch {
		}
	}
bail:
	xsEndHostSandboxCode();
}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:51,代码来源:kprZeroconf.c

示例7: xs_gpio_get_direction

void xs_gpio_get_direction(xsMachine* the)
{
    FskGPIO gpio = xsGetHostData(xsThis);
    if (gpio) {
        GPIOdirection direction;
        FskGPIOPlatformGetDirection(gpio, &direction);
        if (in == direction)
            xsResult = xsString("in");      //@@ input - to match constructor
        else if (out == direction)
            xsResult = xsString("out");     //@@ output - to match constructor
        else
            xsResult = xsString("undefined");
    }
}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:14,代码来源:gpio.c

示例8: kpr2jsGetPlatform

void kpr2jsGetPlatform(xsMachine* the)
{
#if mxWindows
    xsResult = xsString("Windows");
#elif mxMacOSX
    xsResult = xsString("MacOSX");
#elif mxLinux
    xsResult = xsString("Linux");
#elif mxSolaris
    xsResult = xsString("Solaris");
#else
#pragma error("need a platform")
#endif
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:14,代码来源:kpr2js.c

示例9: xsToolReadString

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

	aPath = xsToString(xsArg(0));
#if mxWindows
	{
		char* aSlash;
		aSlash = aPath;
		while (*aSlash) {
			if (*aSlash == '/')
				*aSlash = '\\';
			aSlash++;
		}
	}
#endif
	aFile = fopen(aPath, "rb");
	if (aFile) {
		fseek(aFile, 0, SEEK_END);
		aSize = ftell(aFile);
		fseek(aFile, 0, SEEK_SET);
		aBuffer = malloc(aSize + 1);
		if (aBuffer) {
			aSize = fread(aBuffer, 1, aSize, aFile);
			aBuffer[aSize] = 0;
			xsResult = xsString(aBuffer);
			free(aBuffer);
		}
		fclose(aFile);
	}
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:34,代码来源:xsTool.c

示例10: xsToolGetEnvironmentValue

void xsToolGetEnvironmentValue(xsMachine* the)
{
	char* aName = xsToString(xsArg(0));
	char* aValue = getenv(aName);
	if (aValue)
		xsResult = xsString(aValue);
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:7,代码来源:xsTool.c

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

示例12: KPR_host_get_id

void KPR_host_get_id(xsMachine* the)
{
	KprContainer self = xsGetHostData(xsThis);
	KprApplication application = (KprApplication)self->first;
	if (application->id)
		xsResult = xsString(application->id);
}
开发者ID:giapdangle,项目名称:kinomajs,代码行数:7,代码来源:kprApplication.c

示例13: KPR_Message_URI

void KPR_Message_URI(xsMachine* the)
{
	char* url = NULL;
	xsThrowIfFskErr(KprMessageURL(xsGetContext(the), xsToString(xsArg(0)), &url));
	xsResult = xsString(url);
	FskMemPtrDispose(url);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:7,代码来源:kprMessage.c

示例14: KPR_message_get_method

void KPR_message_get_method(xsMachine *the)
{
	KprMessage self = xsGetHostData(xsThis);
	xsStringValue method = KprMessageGetMethod(self);
	if (method)
		xsResult = xsString(method);
}
开发者ID:basuke,项目名称:kinomajs,代码行数:7,代码来源:kprMessage.c

示例15: KprDebugMachineDataReader

void KprDebugMachineDataReader(FskThreadDataHandler handler UNUSED, FskThreadDataSource source UNUSED, void *refCon)
{
	FskErr err = kFskErrNone;
	KprDebugMachine self = refCon;
	KprDebug debug = self->debug;
	int size;

	err = FskNetSocketRecvTCP(self->socket, self->buffer, XS_BUFFER_COUNT, &size);
	if (size > 0) {
		xsBeginHostSandboxCode(debug->the, debug->code);
		xsVars(4);
		KprDebugMachineParse(self, self->buffer, size);
		if (self->done) {
			self->state = XS_HEADER_STATE;
			self->dataIndex = 0;
			
			if (self->broken) {
				xsCall0(xsGet(xsGlobal, xsID_KPR), xsID_gotoFront);
			}
			else {
				xsCall1(debug->slot, xsID_go, xsString(self->address));
				KprDebugMachineCallback(self, "gone");
			}
		}
		xsEndHostSandboxCode();
	}
	if (err) {
		KprDebugMachineDispose(self);
	}
}
开发者ID:dadongdong,项目名称:kinomajs,代码行数:30,代码来源:kprDebug.c


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