本文整理汇总了C++中xsArg函数的典型用法代码示例。如果您正苦于以下问题:C++ xsArg函数的具体用法?C++ xsArg怎么用?C++ xsArg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xsArg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KPR_path2D_bezierCurveTo
void KPR_path2D_bezierCurveTo(xsMachine *the)
{
FskCanvas2dPath path = xsGetHostData(xsThis);
xsNumberValue cp1x = xsToNumber(xsArg(0));
xsNumberValue cp1y = xsToNumber(xsArg(1));
xsNumberValue cp2x = xsToNumber(xsArg(2));
xsNumberValue cp2y = xsToNumber(xsArg(3));
xsNumberValue x = xsToNumber(xsArg(4));
xsNumberValue y = xsToNumber(xsArg(5));
FskCanvas2dPathBezierCurveTo(NULL, path, cp1x, cp1y, cp2x, cp2y, x, y);
}
示例2: KPR_Message
void KPR_Message(xsMachine* the)
{
xsStringValue url = NULL;
KprMessage self = NULL;
xsTry {
xsThrowIfFskErr(KprMessageURL(xsGetContext(the), xsToString(xsArg(0)), &url));
xsThrowIfFskErr(KprMessageNew(&self, url));
xsSetHostData(xsThis, self);
FskInstrumentedItemSendMessageDebug(self, kprInstrumentedMessageConstruct, self);
self->usage++; // host
FskMemPtrDispose(url);
}
xsCatch {
FskMemPtrDispose(url);
xsThrow(xsException);
}
}
示例3: xs_tftpd_connect
void
xs_tftpd_connect(xsMachine *the)
{
int s;
void *instance;
xsVars(1);
xsGet(xsVar(0), xsArg(0), xsID("nativeSocket"));
s = xsToInteger(xsVar(0));
instance = tftpd_connect(s, the, &xsThis);
if (instance == NULL) {
xsSetBoolean(xsResult, 0);
return;
}
xsSetHostData(xsThis, instance);
xsSetBoolean(xsResult, 1);
}
示例4: kprGrammar_countLines
void kprGrammar_countLines(xsMachine* the)
{
char* aString;
char c;
int i = 0;
aString = xsToString(xsArg(0));
while ((c = *aString)) {
if (c <= 0x20) {
if (c == 0x0A)
i++;
}
else
break;
aString++;
}
xsResult = xsInteger(i);
}
示例5: kpr2jsLoad
void kpr2jsLoad(xsMachine* the)
{
char* aPath;
FILE* aFile = NULL;
xsTry {
aPath = xsToString(xsArg(0));
aFile = fopen(aPath, "r");
xsElseError(aFile);
xsResult = xsParse(aFile, (xsGetter)fgetc, aPath, 1, xsSourceFlag | xsDebugFlag);
fclose(aFile);
}
xsCatch {
if (aFile)
fclose(aFile);
xsThrow(xsException);
}
}
示例6: xs_env_next
void
xs_env_next(xsMachine *the)
{
char *p = xsGetHostData(xsThis);
char *pattern = xsToInteger(xsArgc) > 0 ? xsToString(xsArg(0)) : NULL;
while (*p != '\0') {
char *name = p;
p += strlen(p) + 1;
p += strlen(p) + 1;
if (pattern == NULL || *pattern == '\0' || strncmp(name, pattern, strlen(pattern)) == 0) {
xsSetString(xsResult, name);
xsSetHostData(xsThis, p);
return;
}
}
xsSetNull(xsResult);
}
示例7: xs_i2c_readByteDataSMB
void xs_i2c_readByteDataSMB(xsMachine *the)
{
xsI2C i2c = xsGetHostData(xsThis);
FskErr err;
UInt8 command = (UInt8)xsToInteger(xsArg(0));
UInt8 byte;
DBG_I2C("xs_i2c_readByteDataSMB Reading byte from %u\n", reg);
xsThrowIfNULL(i2c);
FskPinI2CSetAddress(i2c->pin, i2c->address);
err = FskPinI2CReadDataByte(i2c->pin, command, &byte);
xsThrowDiagnosticIfFskErr(err, "I2C readByteDataSMB register %d failed %s.", (int)command, i2c->diagnosticID);
xsResult = xsInteger(byte);
}
示例8: KPR_system_set_backGesture
void KPR_system_set_backGesture(xsMachine *the)
{
FskErr err = kFskErrNone;
char* path = NULL;
char* pathName = NULL;
FskFile file = NULL;
char* data = xsToString(xsArg(0));
xsIntegerValue size = FskStrLen(data);
#if MINITV
pathName = TOUCHD_CONF;
// system("/etc/init.d/touchd.sh stop");
#else
bailIfError(FskDirectoryGetSpecialPath(kFskDirectorySpecialTypeApplicationPreference, true, NULL, &path));
pathName = FskStrDoCat(path, "touchd.conf");
bailIfNULL(pathName);
#endif
err = FskFileOpen(pathName, kFskFilePermissionReadWrite, &file);
if (kFskErrFileNotFound == err) {
bailIfError(FskFileCreate(pathName));
err = FskFileOpen(pathName, kFskFilePermissionReadWrite, &file);
}
else {
FskInt64 zero = 0;
err = FskFileSetSize(file, &zero);
}
bailIfError(err);
bailIfError(FskFileWrite(file, size, data, NULL));
bail:
FskFileClose(file);
#if MINITV
int pipe = open(TOUCH_PIPE, O_WRONLY | O_NONBLOCK);
if (pipe >= 0) {
char data = 1;
write(pipe, &data, 1);
close(pipe);
}
// system("/etc/init.d/touchd.sh start");
#endif
if (path) {
FskMemPtrDispose(path);
FskMemPtrDispose(pathName);
}
xsThrowIfFskErr(err);
}
示例9: xs_parse
void xs_parse(xsMachine* the)
{
xsIntegerValue c = xsToInteger(xsArgc);
xsVars(2);
if (c < 1)
xsSyntaxError("no buffer");
xsVar(0) = xsGet(xsGet(xsGlobal, xsID_xs), xsID_infoset);
if (c > 3)
xsVar(1) = xsCall3(xsVar(0), xsID_scan, xsArg(0), xsArg(2), xsArg(3));
else if (c > 2)
xsVar(1) = xsCall2(xsVar(0), xsID_scan, xsArg(0), xsArg(2));
else if (c > 1)
xsVar(1) = xsCall1(xsVar(0), xsID_scan, xsArg(0));
else
xsVar(1) = xsCall1(xsVar(0), xsID_scan, xsArg(0));
if (c > 1)
xsResult = xsCall2(xsVar(0), xsID_parse, xsVar(1), xsArg(1));
else
xsResult = xsCall1(xsVar(0), xsID_parse, xsVar(1));
}
示例10: KPR_canvasRenderingContext2D_isPointInPath
void KPR_canvasRenderingContext2D_isPointInPath(xsMachine *the)
{
FskCanvas2dContext ctx = xsGetHostData(xsThis);
FskCanvas2dPath path = NULL;
SInt32 fillRule = kFskCanvas2dFillRuleNonZero;
int numArgs = xsToInteger(xsArgc);
xsNumberValue x, y;
if (xsIsInstanceOf(xsArg(0), xsGet(xsGet(xsGlobal, xsID_KPR), xsID("path2D")))) { /* ctx.isPointInPath(path, x, y) */
path = xsGetHostData(xsArg(0));
x = xsToNumber(xsArg(1));
y = xsToNumber(xsArg(2));
if (numArgs > 3) fillRule = GetFillRule(xsToString(xsArg(3))); /* ctx.isPointInPath(path, x, y, fillRule) */
} else { /* ctx.isPointInPath(x, y) */
x = xsToNumber(xsArg(0));
y = xsToNumber(xsArg(1));
if (numArgs > 2) fillRule = GetFillRule(xsToString(xsArg(2))); /* ctx.isPointInPath(x, y, fillRule) */
}
xsResult = xsBoolean(FskCanvas2dIsPointInPathFill(ctx, path, x, y, fillRule));
}
示例11: xs_i2c_readWordDataSMB
void xs_i2c_readWordDataSMB(xsMachine *the)
{
xsI2C i2c = xsGetHostData(xsThis);
UInt8 command = (UInt8)xsToInteger(xsArg(0));
FskErr err;
UInt16 val;
DBG_I2C("xs_i2c_readWordDataSMB Call SMB to register %d\n", command);
xsThrowIfNULL(i2c);
FskPinI2CSetAddress(i2c->pin, i2c->address);
err = FskPinI2CReadDataWord(i2c->pin, command, &val);
//@@ if (! (i2c->address == 0x36) ) xsTraceDiagnostic("I2C readWordDataSMB register %d failed %s.", (int)reg, i2c->diagnosticID);
xsThrowDiagnosticIfFskErr(err, "I2C readWordDataSMB register %d failed %s.", (int)command, i2c->diagnosticID);
xsResult = xsInteger(val);
}
示例12: xs_i2c_writeBlock
void xs_i2c_writeBlock(xsMachine* the)
{
FskErr err;
xsI2C i2c = xsGetHostData(xsThis);
int argc = xsToInteger(xsArgc), i;
UInt8 buffer[32], *bufPtr = buffer;
xsThrowIfNULL(i2c);
DBG_I2C("xs_i2c_writeBlock\n");
for (i = 0; i < argc; i++)
bufPtr = writeOne(the, i2c, &xsArg(i), bufPtr, buffer + sizeof(buffer));
FskPinI2CSetAddress(i2c->pin, i2c->address);
err = FskPinI2CWriteBytes(i2c->pin, bufPtr - buffer, buffer);
xsThrowDiagnosticIfFskErr(err, "I2C FskI2CWriteBlock failed with error %s %s.", FskInstrumentationGetErrorString(err), i2c->diagnosticID);
}
示例13: xsToolIsKPR
void xsToolIsKPR(xsMachine* the)
{
char* aPath;
FILE* aFile = NULL;
size_t aSize = 1024;
char aBuffer[1024];
aPath = xsToString(xsArg(0));
aFile = fopen(aPath, "r");
xsElseError(aFile);
aSize = fread(aBuffer, 1, aSize, aFile);
if (aSize) {
aBuffer[aSize - 1] = 0;
xsResult = (strstr(aBuffer, "xmlns=\"http://www.kinoma.com/kpr/1\"") && !strstr(aBuffer, "<application") && !strstr(aBuffer, "<device")) ? xsTrue : xsFalse;
}
else
xsResult = xsFalse;
fclose(aFile);
}
示例14: KPR_system_setClipboardText
void KPR_system_setClipboardText(xsMachine* the)
{
HWND window = (HWND)FskWindowGetNativeWindow(gShell->window);
xsStringValue string, src, buffer, dst;
char c;
xsIntegerValue length;
HGLOBAL data;
if (OpenClipboard(window)) {
EmptyClipboard();
if (xsToInteger(xsArgc) > 0) {
string = xsToString(xsArg(0));
src = string;
length = 0;
while ((c = *src++)) {
length++;
if (c == 10)
length++;
}
length++;
if (FskMemPtrNew(length, &buffer) == kFskErrNone) {
src = string;
dst = buffer;
while ((c = *src++)) {
if (c == 10)
*dst++ = 13;
*dst++ = c;
}
*dst = 0;
length = MultiByteToWideChar(CP_UTF8, 0, buffer, -1, NULL, 0);
data = GlobalAlloc(GMEM_MOVEABLE, 2 * length);
if (data) {
MultiByteToWideChar(CP_UTF8, 0, buffer, -1, (LPWSTR)GlobalLock(data), length);
GlobalUnlock(data);
SetClipboardData(CF_UNICODETEXT, data);
}
FskMemPtrDispose(buffer);
}
}
CloseClipboard();
}
}
示例15: xsToolInsertProperty
void xsToolInsertProperty(xsMachine* the)
{
xsStringValue aString;
xsIntegerValue aSum;
aString = xsToString(xsArg(0));
aSum = 0;
while(*aString != 0) {
aSum = (aSum << 1) + *aString++;
}
aSum &= 0x7FFFFFFF;
xsResult = gxProperties[aSum % mxPropertyModulo];
if (xsTypeOf(xsResult) == xsReferenceType)
(void)xsCall3(xsResult, xsID("insertProperty"), xsArg(0), xsArg(1), xsArg(2));
else {
gxProperties[aSum % mxPropertyModulo] = xsArg(1);
xsSet(xsArg(1), xsID("qualifiedName"), xsArg(0));
}
}