public static void RegisterCallBacks() { //------------------ //built in listener //------------------ NativeV8JsInterOp.RegisterManagedListener(engineListenerDel); }
public void SetResultAutoWrap <T>(T result) where T : class, new() { var jsTypeDef = this.context.GetJsTypeDefinition <T>(result); 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 static void LoadV8(string v8bridgeDll) { IntPtr v8mod = UnsafeNativeMethods.LoadLibrary(v8bridgeDll); hModuleV8 = v8mod; if (v8mod == IntPtr.Zero) { return; } NativeV8JsInterOp.V8Init(); }
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); } var proxy = this.context.CreateWrapper(result, jsTypeDef); NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, this.context.Converter.ToJsValue(proxy)); }
public NativeJsInstanceProxy CreateProxyForObject(object o, JsTypeDefinition jsTypeDefinition) { NativeJsInstanceProxy found; if (this.createdWrappers.TryGetValue(o, out found)) { return(found); } var proxyObject = new NativeJsInstanceProxy( nativeRefList.Count, o, jsTypeDefinition); nativeRefList.Add(proxyObject); this.createdWrappers.Add(o, proxyObject); //register NativeV8JsInterOp.CreateNativePart(ownerContext, proxyObject); return(proxyObject); }
internal JsContext(int id, JsEngine engine, HandleRef engineHandle, Action <int> notifyDispose, JsTypeDefinitionBuilder jsTypeDefBuilder) { _id = id; _engine = engine; _notifyDispose = notifyDispose; _keepalives = new KeepAliveDictionaryStore(); _context = new HandleRef(this, jscontext_new(id, engineHandle)); _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); }
//-------------------------------------------------------------------- public void SetResult(bool value) { NativeV8JsInterOp.ResultSetBool(metArgsPtr, value); }
public static void V8Init() { NativeV8JsInterOp.V8Init(); }
public void SetResultObj(object result) { NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, this.context.Converter.AnyToJsValue(result)); }
public void SetResultUndefined() { NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Empty); }
public void SetResultNull() { NativeV8JsInterOp.ResultSetJsValue(metArgsPtr, JsValue.Null); }
public void SetResult(float value) { NativeV8JsInterOp.ResultSetFloat(metArgsPtr, value); }
public void SetResult(double value) { NativeV8JsInterOp.ResultSetDouble(metArgsPtr, value); }
public void SetResult(string value) { NativeV8JsInterOp.ResultSetString(metArgsPtr, value); }
public void SetResult(int value) { NativeV8JsInterOp.ResultSetInt32(metArgsPtr, value); }
//--------------------------------------------- #if DEBUG public static void dbugTestCallbacks() { NativeV8JsInterOp.RegisterCallBacks(); NativeV8JsInterOp.TestCallBack(); }
public object GetArgAsObject(int index) { var value = NativeV8JsInterOp.ArgGetObject(this.metArgsPtr, index); return(this.context.Converter.FromJsValue(value)); }
public object GetThisArg() { var value = NativeV8JsInterOp.ArgGetThis(this.metArgsPtr); return(this.context.Converter.FromJsValue(value)); }