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; }
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)); }
public static RefObject GetRefObjectFromPtr(global::System.IntPtr cPtr) { RefObject ret = new RefObject(cPtr, false); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/// <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; }
// 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); } }
/// <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; }
/// <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; }
/// <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; }
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); } }
/// <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; }
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); }