Ejemplo n.º 1
0
 internal RefObject GetObjectPtr()
 {
     global::System.IntPtr cPtr = NDalicPINVOKE.BaseHandle_GetObjectPtr(swigCPtr);
     RefObject ret = (cPtr == global::System.IntPtr.Zero) ? null : new RefObject(cPtr, false);
     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Ejemplo n.º 2
0
        internal static BaseHandle GetManagedBaseHandleFromNativePtr(BaseHandle baseHandle)
        {
            RefObject refObj       = baseHandle.GetObjectPtr();
            IntPtr    refObjectPtr = (IntPtr)RefObject.getCPtr(refObj);

            // we store a dictionary of ref-obects (C++ land) to managed obects (C# land)
            return(GetManagedBaseHandleFromRefObject(refObjectPtr));
        }
Ejemplo n.º 3
0
        public static RefObject GetRefObjectFromPtr(global::System.IntPtr cPtr)
        {
            RefObject ret = new RefObject(cPtr, false);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes this instance of BaseHandle (C# base class) and native part from the mapping table.
        /// </summary>
        /// <param name="baseHandle"> The instance of BaseHandle (C# base class)</param>
        internal static void Unregister(BaseHandle baseHandle)
        {
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            if (Instance._controlMap.ContainsKey(refCptr))
            {
                Instance._controlMap.Remove(refCptr);
            }

            return;
        }
Ejemplo n.º 5
0
        // Callback for ObjectRegistry ObjectDestroyedSignal
        private void OnObjectDestroyed(IntPtr refObject)
        {
            ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();

            // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
            e.RefObject = RefObject.GetRefObjectFromPtr(refObject);

            if (_objectRegistryObjectDestroyedEventHandler != null)
            {
                //here we send all data to user event handlers
                _objectRegistryObjectDestroyedEventHandler(this, e);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Removes this instance of BaseHandle (C# base class) and native part from the mapping table.
        /// </summary>
        /// <param name="baseHandle"> The instance of BaseHandle (C# base class)</param>
        internal static void Unregister(BaseHandle baseHandle)
        {
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            RegistryCurrentThreadCheck();
            WeakReference refe;

            if (Instance._controlMap.TryRemove(refCptr, out refe) != true)
            {
                NUILog.Debug("something wrong when removing refCptr!");
            }

            return;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Stores the mapping between this instance of BaseHandle (C# base class) and native part.
        /// </summary>
        /// <param name="baseHandle">The instance of BaseHandle (C# base class).</param>
        internal static void Register(BaseHandle baseHandle)
        {
            // We store a pointer to the RefObject for the control
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            RegistryCurrentThreadCheck();

            if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, false)) != true)
            {
                NUILog.Debug("refCptr is already exist! OR something wrong!");
            }

            return;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Stores the mapping between this instance of BaseHandle (C# base class) and native part.
        /// </summary>
        /// <param name="baseHandle">The instance of BaseHandle (C# base class).</param>
        internal static void Register(BaseHandle baseHandle)
        {
            // We store a pointer to the RefObject for the control
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            //NUILog.Debug("Storing ref object cptr in control map Hex: {0:X}" + refCptr);

            if (!Instance._controlMap.ContainsKey(refCptr))
            {
                Instance._controlMap.Add(refCptr, new WeakReference(baseHandle, false));
            }

            return;
        }
Ejemplo n.º 9
0
        internal static BaseHandle GetManagedBaseHandleFromNativePtr(BaseHandle baseHandle)
        {
            RefObject refObj       = baseHandle.GetObjectPtr();
            IntPtr    refObjectPtr = (IntPtr)RefObject.getCPtr(refObj);

            if (refObjectPtr != null)
            {
                // we store a dictionary of ref-obects (C++ land) to managed obects (C# land)
                return(GetManagedBaseHandleFromRefObject(refObjectPtr));
            }
            else
            {
                NUILog.Error("NUI Registry RefObjectPtr is NULL!");
                return(null);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Stores the mapping between this instance of BaseHandle (C# base class) and native part.
        /// </summary>
        /// <param name="baseHandle">The instance of BaseHandle (C# base class).</param>
        internal static void Register(BaseHandle baseHandle)
        {
            if (savedApplicationThread?.ManagedThreadId != Thread.CurrentThread.ManagedThreadId)
            {
                throw new global::System.ApplicationException("NUI object is attempt to be created in another thread. It should be created in main thread only!");
            }

            // We store a pointer to the RefObject for the control
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            NUILog.Debug("Storing ref object cptr in control map Hex: {0:X}" + refCptr);

            if (!Instance._controlMap.ContainsKey(refCptr))
            {
                Instance._controlMap.Add(refCptr, new WeakReference(baseHandle, false));
            }

            return;
        }
Ejemplo n.º 11
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RefObject obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }