Ejemplo n.º 1
0
        public static void *buildDelegateType(IntPtr typeName, void *returnType, void *argTypes)
        {
            var result = DelegateAdapter.Build(Marshal.PtrToStringUni(typeName),
                                               (Type)FromPointer <DotNetContainer>(returnType).Target,
                                               (Type[])FromPointer <DotNetContainer>(argTypes).Target);

            return(ToPointer(new DotNetContainer(result)));
        }
Ejemplo n.º 2
0
        public static void SetFunctionPointers(IntPtr callback, IntPtr release)
        {
            var cb_delegate = Marshal.GetDelegateForFunctionPointer(callback, typeof(CallbackDelegate))
                              as CallbackDelegate;
            var release_delegate =
                Marshal.GetDelegateForFunctionPointer(release, typeof(DelegateAdapter.ReleaseDelegate))
                as DelegateAdapter.ReleaseDelegate;

            DelegateAdapter.SetFunctions(
                (i, args) =>
            {
                var ptr = cb_delegate(i, ToPointer(new DotNetContainer(args)));
                return(FromPointer <DotNetContainer>(ptr).Target);
            },
                release_delegate);
        }