Пример #1
0
void KPR_host_get_profiling(xsMachine* the)
{
	KprHost self = xsGetHostData(xsThis);
	KprApplication application = (KprApplication)self->first;
	Boolean result = false;
	xsBeginHost(application->the);
	{
		result = xsTest(xsCall0(xsGet(xsGlobal, xsID("xs")), xsID("isProfiling")));
	}
	xsEndHost(application->the);
	xsResult = xsBoolean(result);
}
Пример #2
0
void KPR_host_get_debugging(xsMachine* the)
{
#ifdef mxDebug
	KprHost self = xsGetHostData(xsThis);
	KprApplication application = (KprApplication)self->first;
	Boolean result = false;
	xsBeginHost(application->the);
	{
		result = xsTest(xsCall0(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("getConnected")));
	}
	xsEndHost(application->the);
	xsResult = xsBoolean(result);
#endif
}
Пример #3
0
void KPR_canvasRenderingContext2D_isPointInPathStroke(xsMachine *the)
{
	FskCanvas2dContext	ctx			= xsGetHostData(xsThis);
	FskCanvas2dPath		path		= NULL;
	xsNumberValue		x, y;

	if (xsIsInstanceOf(xsArg(0), xsGet(xsGet(xsGlobal, xsID_KPR), xsID("path2D")))) {	/* ctx.isPointInPathStroke(path, x, y) */
		path = xsGetHostData(xsArg(0));
		x = xsToNumber(xsArg(1));
		y = xsToNumber(xsArg(2));
	} else {																			/* ctx.isPointInPathStroke(x, y) */
		x = xsToNumber(xsArg(0));
		y = xsToNumber(xsArg(1));
	}
	xsResult = xsBoolean(FskCanvas2dIsPointInPathStroke(ctx, path, x, y));
}
Пример #4
0
static void KPR_canvasRenderingContext2D_setStyle(xsMachine *the, xsBooleanValue stroke)
{
	if (xsTypeOf(xsArg(0)) == xsStringType) {
		xsStringValue s = xsToString(xsArg(0));
		FskColorRGBARecord color;
		if (KprParseColor(the, s, &color)) {
			FskCanvas2dContext ctx = xsGetHostData(xsThis);
			if (stroke)
				FskCanvas2dSetStrokeStyleColor(ctx, &color);
			else
				FskCanvas2dSetFillStyleColor(ctx, &color);
		}
	}
	else
		xsArg(0) = xsCall2(xsArg(0), xsID("setStyle"), xsThis, xsBoolean(stroke));
}
Пример #5
0
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));
}
Пример #6
0
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;
}
Пример #7
0
void KPR_host_set_debugging(xsMachine* the)
{
#ifdef mxDebug
	KprHost self = xsGetHostData(xsThis);
	KprApplication application = (KprApplication)self->first;
	Boolean flag = xsToBoolean(xsArg(0));
	xsBeginHost(application->the);
	{
		(void)xsCall1(xsGet(xsGet(xsGlobal, xsID("xs")), xsID("debug")), xsID("setConnected"), xsBoolean(flag));
	}
	xsEndHost(application->the);
#endif
}