Example #1
0
        private void write(IntPtr vm, string text)
        {
            if (Write == null)
            {
                return;
            }

            Write(WrenVM.GetVM(vm), text);
        }
Example #2
0
        internal void AllocateInternal(IntPtr vm)
        {
            if (Allocate == null)
            {
                return;
            }

            usedVM = WrenVM.GetVM(vm);

            Allocate(usedVM);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        internal WrenHandle(WrenVM vm, IntPtr handlePtr)
        {
            vmRef = new WeakReference <WrenVM>(vm);

            HandlePtr = handlePtr;
        }
Example #7
0
 internal WrenFunctionHandle(WrenVM vm, IntPtr handlePtr)
     : base(vm, handlePtr)
 {
 }
Example #8
0
 internal WrenValueHandle(WrenVM vm, IntPtr handlePtr)
     : base(vm, handlePtr)
 {
 }