void KPR_canvas_set_size(xsMachine *the) { FskErr err = kFskErrNone; KprCanvas self = xsGetHostData(xsThis); SInt32 width = 0, height = 0; if (self->shell) { KprShellAdjust(self->shell); xsEnterSandbox(); if (xsFindInteger(xsArg(0), xsID_width, &width)) width -= self->bounds.width; if (xsFindInteger(xsArg(0), xsID_height, &height)) height -= self->bounds.height; xsLeaveSandbox(); KprContentSizeBy((KprContent)self, width, height); } else { FskRectangleRecord bounds; xsEnterSandbox(); if (!xsFindInteger(xsArg(0), xsID_width, &width)) width = self->coordinates.width; if (!xsFindInteger(xsArg(0), xsID_height, &height)) height = self->coordinates.height; xsLeaveSandbox(); if (self->cnv) FskBitmapGetBounds(FskGetCanvasBitmap(self->cnv), &bounds); else FskRectangleSetEmpty(&bounds); if ((width != bounds.width) || (height != bounds.height)) { FskCanvasDispose(self->cnv); self->cnv = NULL; if (width && height) { bailIfError(FskCanvasNew(width, height, PreferredPixelFormat(), &self->cnv)); FskCanvas2dSetOpenGLSourceAccelerated(self->cnv, true); } } } bail: return; }
void KPR_Debug(xsMachine *the) { KprDebug self = NULL; UInt32 port = 0; xsEnterSandbox(); if (xsIsInstanceOf(xsArg(0), xsObjectPrototype)) { (void)(xsFindInteger(xsArg(0), xsID_port, &port)); // add behavior? } xsLeaveSandbox(); xsThrowIfFskErr(KprDebugNew(&self, port)); xsSetHostData(xsResult, self); self->the = the; self->slot = xsResult; self->code = the->code; self->behavior = xsUndefined; xsRemember(self->slot); return; }