public object GetArgAsObject(int index) { JsValue output = new JsValue(); NativeV8JsInterOp.ArgGetObject(this.metArgsPtr, index, ref output); return(this.context.Converter.FromJsValue(ref output)); }
public void SetResultObj(object result) { JsValue output = new JsValue(); this.context.Converter.AnyToJsValue(result, ref output); NativeV8JsInterOp.ResultSetValue(metArgsPtr, ref output); }
public object GetThisArg() { JsValue output = new JsValue(); NativeV8JsInterOp.ArgGetThis(this.metArgsPtr, ref output); return(this.context.Converter.FromJsValue(ref output)); }
public static void RegisterCallBacks() { //------------------ //built in listener //------------------ NativeV8JsInterOp.RegisterManagedListener(engineListenerDel); }
public void SetResultAutoWrap <T>(T result) where T : class, new() { Type actualType = result.GetType(); var jsTypeDef = this.context.GetJsTypeDefinition(actualType); var proxy = this.context.CreateWrapper(result, jsTypeDef); NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, this.context.Converter.ToJsValue(proxy)); }
public void Dispose() { int j = nativeRefList.Count; for (int i = nativeRefList.Count - 1; i > -1; --i) { NativeV8JsInterOp.UnRegisterNativePart(nativeRefList[i]); } nativeRefList.Clear(); }
public void SetResultAutoWrap <T>(T result) where T : class, new() { Type actualType = result.GetType(); JsTypeDefinition jsTypeDef = this.context.GetJsTypeDefinition(actualType); INativeScriptable proxy = this.context.CreateWrapper(result, jsTypeDef); JsValue output = new JsValue(); this.context.Converter.ToJsValue(proxy, ref output); NativeV8JsInterOp.ResultSetValue(metArgsPtr, ref output); }
public void SetResultObj(object result, JsTypeDefinition jsTypeDef) { if (!jsTypeDef.IsRegisterd) { this.context.RegisterTypeDefinition(jsTypeDef); } var proxy = this.context.CreateWrapper(result, jsTypeDef); NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, this.context.Converter.ToJsValue(proxy)); }
public INativeRef CreateProxyForTypeDefinition(JsTypeDefinition jsTypeDefinition) { var proxyObject = new NativeRef(nativeRefList.Count, jsTypeDefinition); //store data this side too jsTypeDefinition.nativeProxy = proxyObject; //store in exported list nativeRefList.Add(proxyObject); //register type definition NativeV8JsInterOp.RegisterTypeDef(ownerContext, jsTypeDefinition); return(proxyObject); }
public void SetResultObj(object result, JsTypeDefinition jsTypeDef) { if (!jsTypeDef.IsRegisterd) { this.context.RegisterTypeDefinition(jsTypeDef); } INativeScriptable proxy = this.context.CreateWrapper(result, jsTypeDef); JsValue output = new JsValue(); this.context.Converter.ToJsValue(proxy, ref output); NativeV8JsInterOp.ResultSetValue(metArgsPtr, ref output); }
public static void LoadV8(string dllfile, bool doV8Init = true) { hModuleV8 = LoadLibrary(dllfile); if (hModuleV8 == IntPtr.Zero) { return; } //------------------- if (doV8Init) { //sometime we set to false , and let underlying lib init the v8 engine. NativeV8JsInterOp.V8Init(); } }
public NativeJsInstanceProxy CreateProxyForObject(object o, JsTypeDefinition jsTypeDefinition) { if (_createdWrappers.TryGetValue(o, out NativeJsInstanceProxy found)) { return(found); } var proxyObject = new NativeJsInstanceProxy( _nativeRefList.Count, o, jsTypeDefinition); _nativeRefList.Add(proxyObject); _createdWrappers.Add(o, proxyObject); //register NativeV8JsInterOp.CreateNativePart(_ownerContext, proxyObject); return(proxyObject); }
internal JsContext(int id, JsEngine engine, Action <int> notifyDispose, JsTypeDefinitionBuilder jsTypeDefBuilder) { _id = id; _notifyDispose = notifyDispose; _engine = engine; _keepalives = new KeepAliveDictionaryStore(); //create native js context _context = new HandleRef(this, jscontext_new(id, engine.UnmanagedEngineHandler)); _convert = new JsConvert(this); this.jsTypeDefBuilder = jsTypeDefBuilder; engineMethodCallbackDel = new ManagedMethodCallDel(EngineListener_MethodCall); NativeV8JsInterOp.CtxRegisterManagedMethodCall(this, engineMethodCallbackDel); registerMethods.Add(null); //first is null registerProperties.Add(null); //first is null proxyStore = new NativeObjectProxyStore(this); }
internal JsContext(int id, JsEngine engine, Action <int> notifyDispose, IntPtr nativeJsContext, JsTypeDefinitionBuilder jsTypeDefBuilder) { //constructor setup _id = id; _notifyDispose = notifyDispose; _engine = engine; _keepalives = new KeepAliveDictionaryStore(); //create native js context _context = new HandleRef(this, nativeJsContext); _convert = new JsConvert(this); _jsTypeDefBuilder = jsTypeDefBuilder; _engineMethodCallbackDel = new ManagedMethodCallDel(EngineListener_MethodCall); NativeV8JsInterOp.CtxRegisterManagedMethodCall(this, _engineMethodCallbackDel); _registerMethods.Add(null); //first is null _registerProperties.Add(null); //first is null _proxyStore = new NativeObjectProxyStore(this); }
public void SetResult(int value) { NativeV8JsInterOp.ResultSetInt32(metArgsPtr, value); }
public void SetResultNull() { NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Null); }
public void SetResultUndefined() { NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Empty); }
public void SetResultUndefined() { //TODO: review here again NativeV8JsInterOp.ResultSetJsVoid(metArgsPtr); }
public void SetResultNull() { NativeV8JsInterOp.ResultSetJsNull(metArgsPtr); }
public void SetResult(float value) { NativeV8JsInterOp.ResultSetFloat(metArgsPtr, value); }
public object GetArgAsObject(int index) { var value = NativeV8JsInterOp.ArgGetObject(this.metArgsPtr, index); return(this.context.Converter.FromJsValue(value)); }
public static void V8Init() { NativeV8JsInterOp.V8Init(); }
public void SetResultObj(object result) { NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, this.context.Converter.AnyToJsValue(result)); }
//-------------------------------------------------------------------- public void SetResult(bool value) { NativeV8JsInterOp.ResultSetBool(metArgsPtr, value); }
public void SetResult(string value) { NativeV8JsInterOp.ResultSetString(metArgsPtr, value); }
public void SetResult(double value) { NativeV8JsInterOp.ResultSetDouble(metArgsPtr, value); }
public static void dbugTestCallbacks() { NativeV8JsInterOp.RegisterCallBacks(); NativeV8JsInterOp.TestCallBack(); }
public object GetThisArg() { var value = NativeV8JsInterOp.ArgGetThis(this.metArgsPtr); return(this.context.Converter.FromJsValue(value)); }