コード例 #1
0
ファイル: Js.cpp プロジェクト: sugarontop/D2DWindow
JsErrorCode CreateHostContext(JsRuntimeHandle runtime, int argc, wchar_t *argv [], int argumentsStart, JsContextRef *context)
{	
	JsCreateContext(runtime, context);
	
	JsSetCurrentContext(*context);

	
	JsValueRef hostObject;
	JsCreateObject(&hostObject);
	ghostObject = hostObject;

	JsValueRef globalObject;
	JsGetGlobalObject(&globalObject);
	
	JsPropertyIdRef hostPropertyId;
	JsGetPropertyIdFromName(L"app", &hostPropertyId); // app.XXXXX 

	JsSetProperty(globalObject, hostPropertyId, hostObject, true);

	//IfFailRet(DefineHostCallback(hostObject, L"msgbox", msgbox, nullptr));

	JsSetCurrentContext(JS_INVALID_REFERENCE);

	return JsNoError;
}
コード例 #2
0
ファイル: SDKLoader.cpp プロジェクト: basecq/gtasa.js
void SDKLoader::LoadSDK(queue<Task*>* taskQueue)
{
	JsValueRef global;
	JsGetGlobalObject(&global);

	JsValueRef game;
	JsCreateObject(&game);
	Js::AddPropertyToObject(global, L"game", game);

	JsValueRef addEventListenerFunction;
	JsCreateFunction(&addEventListener, taskQueue, &addEventListenerFunction);
	Js::AddPropertyToObject(game, L"addEventListener", addEventListenerFunction);
	Js::AddPropertyToObject(global, L"addEventListener", addEventListenerFunction);
}
コード例 #3
0
JsErrorCode ChakraHost::InitConsole()
{
    JsPropertyIdRef consolePropertyId;
    IfFailRet(JsGetPropertyIdFromName(L"console", &consolePropertyId));

    JsValueRef consoleObject;
    IfFailRet(JsCreateObject(&consoleObject));
    IfFailRet(JsSetProperty(globalObject, consolePropertyId, consoleObject, true));

    IfFailRet(DefineHostCallback(consoleObject, L"info", ConsoleInfo, nullptr));
    IfFailRet(DefineHostCallback(consoleObject, L"log", ConsoleLog, nullptr));
    IfFailRet(DefineHostCallback(consoleObject, L"warn", ConsoleWarn, nullptr));
    IfFailRet(DefineHostCallback(consoleObject, L"error", ConsoleError, nullptr));

    return JsNoError;
}