void KPR_host_debugger(xsMachine* the) { KprHost self = xsGetHostData(xsThis); KprApplication application = (KprApplication)self->first; xsBeginHostSandboxCode(application->the, NULL); { xsDebugger(); } xsEndHostSandboxCode(); }
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; }
void kpr2jsReportError(xsMachine* the) { char* aPath; long aLine; int aCount; xsDebugger(); if (xsTypeOf(xsArg(0)) == xsStringType) { aPath = xsToString(xsArg(0)); aLine = xsToInteger(xsArg(1)); #if mxWindows fprintf(stderr, "%s(%ld): error: ", aPath, aLine); #else fprintf(stderr, "%s:%ld: error: ", aPath, aLine); #endif } fprintf(stderr, "%s!\n", xsToString(xsArg(2))); aCount = xsToInteger(xsGet(xsThis, xsID("errorCount"))); xsSet(xsThis, xsID("errorCount"), xsInteger(aCount + 1)); }
void xs_dbg_debugger(xsMachine *the) { xsDebugger(); }
// focus management void KPR_canvasRenderingContext2D_drawFocusRing(xsMachine *the) { xsDebugger(); }
void xscBuildSymbolsCode(txMachine* the, xsSymbolsData* theData, txByte* theCode) { txID aCount; for (;;) { // if (((XS_LABEL <= *((txU1*)theCode)) && (*((txU1*)theCode) < XS_COUNT))) // fprintf(stderr, "%s\n", gxCodeNames[*((txU1*)theCode)]); // else // fprintf(stderr, "%d\n", *((txU1*)theCode)); switch (*((txU1*)theCode++)) { case XS_LABEL: return; case XS_BEGIN: xscBuildSymbolsID(the, theData, theCode); theCode += 3; aCount = *theCode++; while (aCount) { xscBuildSymbolsID(the, theData, theCode); theCode += 2; aCount--; } aCount = *theCode++; while (aCount) { xscBuildSymbolsID(the, theData, theCode); theCode += 2; aCount--; } break; case PSEUDO_INCREMENT: case PSEUDO_DECREMENT: case XS_DELETE_AT: case XS_GET_AT: case PSEUDO_BRANCH_ELSE0: case PSEUDO_BRANCH_ELSE1: case PSEUDO_LESS: case PSEUDO_LESS_EQUAL: case PSEUDO_DOUBLE_GET_NEGATIVE: case PSEUDO_DOUBLE_GET_AT: case XS_GET_NEGATIVE_ID: case XS_INTEGER_8: case XS_SET_AT: case XS_SET_NEGATIVE_ID: theCode++; break; case XS_CATCH: case XS_DELETE: case XS_DELETE_MEMBER: case XS_FILE: case XS_GET: case XS_GET_FOR_NEW: case XS_GET_MEMBER: case XS_GET_MEMBER_FOR_CALL: case XS_SET: case XS_SET_MEMBER: xscBuildSymbolsID(the, theData, theCode); theCode += 2; break; case XS_PUT_MEMBER: case PSEUDO_PUT_MEMBER: xscBuildSymbolsID(the, theData, theCode); theCode += 4; break; case XS_PUT_MEMBER_AT: theCode += 3; break; case XS_BRANCH: case XS_BRANCH_ELSE: case XS_BRANCH_IF: case XS_BRANCH_ELSE_BOOL: case XS_BRANCH_IF_BOOL: case XS_FUNCTION: case XS_INTEGER_16: case XS_LINE: case XS_ROUTE: case XS_STATUS: theCode += 2; break; case XS_BRANCH2: case XS_BRANCH_ELSE2: case XS_BRANCH_IF2: case XS_BRANCH_ELSE_BOOL2: case XS_BRANCH_IF_BOOL2: case XS_FUNCTION2: case XS_INTEGER_32: case XS_ROUTE2: theCode += 4; break; case XS_NUMBER: theCode += 8; break; case XS_STRING_POINTER: case XS_STRING_CONCAT: case XS_STRING_CONCATBY: case XS_STRING: { txID len; #if mxStringLength mxDecode2(theCode,len); #else len = c_strlen((const char *)theCode) + 1; #endif theCode += len; }break; case XS_ADD: case XS_ALIAS: case XS_BIT_AND: case XS_BIT_NOT: case XS_BIT_OR: case XS_BIT_XOR: case XS_BREAK: case XS_CALL: case XS_DELETE_MEMBER_AT: case XS_DEBUGGER: case XS_DECREMENT: case XS_DIVIDE: case XS_DUB: case XS_END: case XS_ENUM: case XS_EQUAL: case XS_FALSE: case XS_FLAG_INSTANCE: case XS_GET_MEMBER_AT: case XS_GLOBAL: case XS_IN: case XS_INCREMENT: case XS_INSTANCEOF: case XS_INSTANCIATE: case XS_JUMP: case XS_LEFT_SHIFT: case XS_LESS: case XS_LESS_EQUAL: case XS_MINUS: case XS_MODULO: case XS_MORE: case XS_MORE_EQUAL: case XS_MULTIPLY: case XS_NEW: case XS_NOT: case XS_NOT_EQUAL: case XS_NULL: case XS_PARAMETERS: case XS_PLUS: case XS_POP: case PSEUDO_DUB: case XS_RESULT: case XS_RETURN: case XS_SCOPE: case XS_SET_MEMBER_AT: case XS_SIGNED_RIGHT_SHIFT: case XS_STRICT_EQUAL: case XS_STRICT_NOT_EQUAL: case XS_SUBTRACT: case XS_SWAP: case XS_THIS: case PSEUDO_SET_MEMBER: case PSEUDO_GET_MEMBER: case XS_THROW: case XS_TRUE: case XS_TYPEOF: case XS_UNCATCH: case XS_UNDEFINED: case XS_UNSCOPE: case XS_UNSIGNED_RIGHT_SHIFT: case XS_VOID: break; case XS_ATTRIBUTE_PATTERN: case XS_DATA_PATTERN: case XS_PI_PATTERN: case XS_EMBED_PATTERN: case XS_JUMP_PATTERN: case XS_REFER_PATTERN: case XS_REPEAT_PATTERN: aCount = *theCode++; while (aCount > 0) { xscBuildSymbolsID(the, theData, theCode); theCode += 2; xscBuildSymbolsID(the, theData, theCode); theCode += 2; aCount--; } break; default: xsDebugger(); break; } } }