コード例 #1
0
        private void InternalJoin(Delegate callback, object state)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            IntPtr ptr = MarshalAs.ObjectToIUnknown(state);

            nsjs_virtualmachine_join(this.Handle, NSJSFunction.DelegateToFunctionPtr(callback), ptr);
        }
コード例 #2
0
        public static NSJSVirtualMachine From(IntPtr handle)
        {
            if (handle == NULL)
            {
                return(null);
            }
            NSJSVirtualMachine machine;

            if (machines.TryGetValue(handle, out machine))
            {
                return(machine);
            }
            return(MarshalAs.CookieToObject(handle) as NSJSVirtualMachine);
        }
コード例 #3
0
 public object MarshalNativeToManaged(IntPtr pNativeData)
 {
     if (pNativeData == NULL)
     {
         return(null);
     }
     if (this.kind == MarshalAsKind.kStateObject)
     {
         return(MarshalAs.IUnknownToObject(pNativeData));
     }
     if (this.kind == MarshalAsKind.kVirtualMachine)
     {
         return(NSJSVirtualMachine.From(pNativeData));
     }
     return(null);
 }
コード例 #4
0
        public virtual T GetData <T>(int solt)
        {
            IntPtr p = this.GetData(solt);

            if (typeof(T) == typeof(IntPtr))
            {
                return((T)(object)p);
            }
            object obj = MarshalAs.IUnknownToObject(p);

            if (obj == null || !typeof(T).IsInstanceOfType(obj))
            {
                return(default(T));
            }
            return((T)obj);
        }
コード例 #5
0
 public IntPtr MarshalManagedToNative(object ManagedObj)
 {
     if (ManagedObj == null)
     {
         return(NULL);
     }
     if (this.kind == MarshalAsKind.kVirtualMachine)
     {
         NSJSVirtualMachine machine = ManagedObj as NSJSVirtualMachine;
         if (machine == null)
         {
             return(NULL);
         }
         return(machine.Isolate);
     }
     else if (this.kind == MarshalAsKind.kStateObject)
     {
         return(MarshalAs.ObjectToIUnknown(ManagedObj));
     }
     return(NULL);
 }
コード例 #6
0
 public static T FunctionPtrToDelegate <T>(IntPtr ptr)
 {
     return(MarshalAs.FunctionPtrToDelegate <T>(ptr));
 }
コード例 #7
0
 public static IntPtr DelegateToFunctionPtr(Delegate d)
 {
     return(MarshalAs.DelegateToFunctionPtr(d));
 }
コード例 #8
0
        public unsafe static extern void CopyMemory([Out] void *dest, [In] void *src,
#if WIN64
                                                    [In, MarshalAs(UnmanagedType.U8)] ulong
#else
                                                    [In, MarshalAs(UnmanagedType.U4)] uint
コード例 #9
0
 public virtual void SetData(int solt, object value)
 {
     this.SetData(solt, MarshalAs.ObjectToIUnknown(value));
 }