コード例 #1
0
ファイル: NDLLFunction.cs プロジェクト: innogames/hxp
        public Object Call5(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
        {
            if (numArgs != 5)
            {
                throw new InvalidOperationException();
            }

            CSHandleScope scope  = CSHandleScope.Create();
            Call5Delegate cfunc  = (Call5Delegate)func;
            GCHandle      gch1   = GCHandle.Alloc(arg1);
            GCHandle      gch2   = GCHandle.Alloc(arg2);
            GCHandle      gch3   = GCHandle.Alloc(arg3);
            GCHandle      gch4   = GCHandle.Alloc(arg4);
            GCHandle      gch5   = GCHandle.Alloc(arg5);
            object        result = HandleUtils.GetObjectFromIntPtr(cfunc(GCHandle.ToIntPtr(gch1),
                                                                         GCHandle.ToIntPtr(gch2), GCHandle.ToIntPtr(gch3), GCHandle.ToIntPtr(gch4), GCHandle.ToIntPtr(gch5)));

            scope.Destroy();
            gch1.Free();
            gch2.Free();
            gch3.Free();
            gch4.Free();
            gch5.Free();
            return(result);
        }
コード例 #2
0
ファイル: NDLLFunction.cs プロジェクト: innogames/hxp
        public object CallMult(Array args)
        {
            if (numArgs != -1)
            {
                throw new InvalidOperationException();
            }

            Array <object> hxArray = (Array <object>)args;
            CSHandleScope  scope   = CSHandleScope.Create();

            GCHandle[] handles = new GCHandle[hxArray.length];
            for (int i = 0; i < hxArray.length; ++i)
            {
                handles[i] = GCHandle.Alloc(hxArray[i]);
            }
            IntPtr[] pointers = new IntPtr[hxArray.length];
            for (int i = 0; i < hxArray.length; ++i)
            {
                pointers[i] = GCHandle.ToIntPtr(handles[i]);
            }
            GCHandle pinnedArray = GCHandle.Alloc(pointers, GCHandleType.Pinned);

            CallMultDelegate cfunc  = (CallMultDelegate)func;
            object           result = HandleUtils.GetObjectFromIntPtr(cfunc(pinnedArray.AddrOfPinnedObject()));

            scope.Destroy();
            for (int i = 0; i < hxArray.length; ++i)
            {
                handles[i].Free();
            }
            pinnedArray.Free();
            return(result);
        }
コード例 #3
0
ファイル: NDLLFunction.cs プロジェクト: innogames/hxp
        public object Call0()
        {
            if (numArgs != 0)
            {
                throw new InvalidOperationException();
            }

            CSHandleScope scope  = CSHandleScope.Create();
            Call0Delegate cfunc  = (Call0Delegate)func;
            object        result = HandleUtils.GetObjectFromIntPtr(cfunc());

            scope.Destroy();
            return(result);
        }
コード例 #4
0
ファイル: NDLLFunction.cs プロジェクト: innogames/hxp
        public object Call1(object arg1)
        {
            if (numArgs != 1)
            {
                throw new InvalidOperationException();
            }

            CSHandleScope scope  = CSHandleScope.Create();
            Call1Delegate cfunc  = (Call1Delegate)func;
            GCHandle      gch1   = GCHandle.Alloc(arg1);
            object        result = HandleUtils.GetObjectFromIntPtr(cfunc(GCHandle.ToIntPtr(gch1)));

            scope.Destroy();
            gch1.Free();
            return(result);
        }