void fxParse(xsMachine* the, void* theStream, xsGetter theGetter, xsStringValue thePath, xsIntegerValue theLine, xsFlag theFlag) { xsStreamGetter streamGetter; xsSlot* stack = the->stack; xsIntegerValue c = xsToInteger(stack[0]); stack[c] = xsGet(xsGet(xsGlobal, xsID("xs")), xsID("infoset")); stack[c - 1] = xsNewHostObject(NULL); streamGetter.stream = theStream; streamGetter.getter = theGetter; xsSetHostData(stack[c - 1], &streamGetter); if (thePath && theLine) stack[c - 2] = xsCall3(stack[c], xsID("scan"), stack[c - 1], xsString(thePath), xsInteger(theLine)); else if (thePath) stack[c - 2] = xsCall2(stack[c], xsID("scan"), stack[c - 1], xsString(thePath)); else stack[c - 2] = xsCall1(stack[c], xsID("scan"), stack[c - 1]); stack[c] = xsCall2(stack[c], xsID("parse"), stack[c - 2], xsInteger(theFlag)); the->stack = stack + c; }
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)); } }
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)); }