private void write(IntPtr vm, string text) { if (Write == null) { return; } Write(WrenVM.GetVM(vm), text); }
internal void AllocateInternal(IntPtr vm) { if (Allocate == null) { return; } usedVM = WrenVM.GetVM(vm); Allocate(usedVM); }
private WrenForeignClassMethodsInternal bindForeignClass(IntPtr vm, string module, string className) { if (BindForeignClass == null) { return(new WrenForeignClassMethodsInternal()); } // Only one of the multiple possible BindForeignClass implementations must actually return the ForeignClassMethods var results = BindForeignClass.GetInvocationList().Cast <WrenBindForeignClass>() .Select(bindForeignClass => bindForeignClass(WrenVM.GetVM(vm), module, className)); var result = results.Single(res => res != null); // Have to save struct, so the delegates aren't GCed var methods = new WrenForeignClassMethodsInternal(result); classMethods.Add(result, methods); return(methods); }
private IntPtr loadModule(IntPtr vm, string name) { if (LoadModule == null) { return(IntPtr.Zero); } // Only one of the multiple possible LoadModule implementations must actually return the source for the module var result = LoadModule.GetInvocationList().Cast <WrenLoadModule>() .Select(loadModule => loadModule(WrenVM.GetVM(vm), name)) .Single(res => res != null); if (result == null) { return(IntPtr.Zero); } // Possibly have to free this again var resultPtr = Marshal.StringToCoTaskMemAnsi(result); return(resultPtr); }
private WrenForeignMethodInternal bindForeignMethod(IntPtr vm, string module, string className, bool isStatic, string signature) { if (BindForeignMethod == null) { return(null); } // Only one of the multiple possible BindForeignMethod implementations must actually return a method. var result = BindForeignMethod.GetInvocationList().Cast <WrenBindForeignMethod>() .Select(bindForeignMethod => bindForeignMethod(WrenVM.GetVM(vm), module, className, isStatic, signature)) .SingleOrDefault(res => res != null); if (result == null) { return(null); } // Have to save the delegate so it isn't GCed WrenForeignMethodInternal wrappedResult = vmPtr => result(WrenVM.GetVM(vmPtr)); wrappedResults.Add(wrappedResult); return(wrappedResult); }
internal WrenHandle(WrenVM vm, IntPtr handlePtr) { vmRef = new WeakReference <WrenVM>(vm); HandlePtr = handlePtr; }
internal WrenFunctionHandle(WrenVM vm, IntPtr handlePtr) : base(vm, handlePtr) { }
internal WrenValueHandle(WrenVM vm, IntPtr handlePtr) : base(vm, handlePtr) { }