Example #1
0
 public static void AttachModule(JavaScriptValue module, AbstractJSModule subModule)
 {
     if (Native.JsSetProperty(module, JavaScriptPropertyId.FromString(subModule.GetId()),
                              subModule.GetModule(), false) != JavaScriptErrorCode.NoError)
     {
         throw new Exception("Failed to attach module");
     }
 }
Example #2
0
        protected override JavaScriptValue Main(JavaScriptValue callee, bool isConstructCall, JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData)
        {
            string           moduleKey = AbstractJSModule.JSValToString(arguments[1]);
            AbstractJSModule module;

            if (!modules.TryGetValue(moduleKey, out module))
            {
                return(JavaScriptValue.Undefined);
            }
            return(module.GetModule());
        }
Example #3
0
        public string Init()
        {
            if (Native.JsCreateRuntime(JavaScriptRuntimeAttributes.EnableIdleProcessing, null, out runtime) != JavaScriptErrorCode.NoError)
            {
                return("failed to create runtime.");
            }

            if (Native.JsCreateContext(runtime, out context) != JavaScriptErrorCode.NoError)
            {
                return("failed to create execution context.");
            }

            if (Native.JsSetCurrentContext(context) != JavaScriptErrorCode.NoError)
            {
                return("failed to set current context.");
            }


            if (Native.JsSetPromiseContinuationCallback(promiseContinuationDelegate, IntPtr.Zero) != JavaScriptErrorCode.NoError)
            {
                return("failed to setup callback for ES6 Promise");
            }

            if (Native.JsProjectWinRTNamespace("Windows") != JavaScriptErrorCode.NoError)
            {
                return("failed to project windows namespace.");
            }

            if (Native.JsStartDebugging() != JavaScriptErrorCode.NoError)
            {
                return("failed to start debugging.");
            }


            if (Native.JsGetGlobalObject(out jsAppGlobalObject) != JavaScriptErrorCode.NoError)
            {
                return("failed to get global object");
            }

            console = new JS.JSConsole();
            require = new JS.JSRequire();
            process = new JS.JSProcess();
            JS.AbstractJSModule.AttachModule(jsAppGlobalObject, require);
            JS.AbstractJSModule.AttachModule(jsAppGlobalObject, console);
            JS.AbstractJSModule.AttachModule(jsAppGlobalObject, process);

            return("NoError");
        }
Example #4
0
 public static void AttachProperty(AbstractJSModule module, JavaScriptValue method, string id)
 {
     AttachProperty(module.GetModule(), method, id);
 }
Example #5
0
 public static void AttachMethod(AbstractJSModule module, JavaScriptNativeFunction method, string id)
 {
     AttachMethod(module.GetModule(), method, id);
 }
Example #6
0
 public static void AttachModule(AbstractJSModule module, AbstractJSModule subModule)
 {
     AttachModule(module.GetModule(), subModule);
 }
Example #7
0
 public void AttachModule(AbstractJSModule subModule)
 {
     AttachModule(this, subModule);
 }
Example #8
0
 private void AddModule(AbstractJSModule module)
 {
     modules.Add(module.GetId(), module);
 }