Beispiel #1
0
void KPR_application_purge(xsMachine *the)
{
	KprApplication self = kprGetHostData(xsThis, this, application);
	FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentBeginCollect, self);
	xsCollectGarbage();
	FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentEndCollect, self);
	KprContextPurge(self, false);
}
Beispiel #2
0
void KPR_host_purge(xsMachine* the)
{
	KprHost self = xsGetHostData(xsThis);
	KprApplication application = (KprApplication)self->first;
	xsBeginHostSandboxCode(application->the, NULL);
	{
		FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentBeginCollect, self);
		xsCollectGarbage();
		FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentEndCollect, self);
	}
	xsEndHostSandboxCode();
	KprContextPurge(application, false);
}
Beispiel #3
0
void* fxAllocateChunks(txMachine* the, txSize theSize)
{
	txByte* aData;
	txBlock* aBlock;

	if ((theSize < the->minimumChunksSize) && !(the->collectFlag & XS_SKIPPED_COLLECT_FLAG))
		theSize = the->minimumChunksSize;
	theSize += sizeof(txBlock);
	aData = (txByte *)c_malloc(theSize);
	if (!aData)
		fxJump(the);
	aBlock = (txBlock*)aData;
	aBlock->nextBlock = the->firstBlock;
	aBlock->current = aData + sizeof(txBlock);
	aBlock->limit = aData + theSize;
	aBlock->temporary = C_NULL;
	the->firstBlock = aBlock;
	the->maximumChunksSize += theSize;
#if mxReport
	fxReport(the, "# Chunk allocation: reserved %ld used %ld peak %ld bytes\n", 
		the->maximumChunksSize, the->currentChunksSize, the->peakChunksSize);
#endif
#if __FSK_LAYER__
	FskInstrumentedItemSendMessageNormal(the, kFskXSInstrAllocateChunks, the);
#endif

	return aData;
}
Beispiel #4
0
void KprHostDispose(void* it)
{
	KprHost self = it;
	FskInstrumentedItemSendMessageNormal(self, kprInstrumentedContentDeleteMachine, self->first);
	xsDeleteMachine(self->first->the);
	KprContainerDispose(it);
}
Beispiel #5
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;
}
Beispiel #6
0
FskErr FskAudioFilterStop(FskAudioFilter filter)
{
	FskInstrumentedItemSendMessageNormal(filter, kFskAudioFilterInstrStop, NULL);
	return filter->dispatch->doStop ? (filter->dispatch->doStop)(filter, filter->state) : kFskErrNone;
}