private void ForceRemoveCallbacksImpl() { if (4294967295u != this.CallbackId) { Methods.RemoveObjectRefCountChangedCallback(this.CallbackId); this.Callback = null; this.CallbackId = 4294967295u; } }
private void AddTableReferenceImpl(IntPtr rawCppThis, object obj, bool strong) { if (rawCppThis == IntPtr.Zero) { throw new Exception(string.Format("error: A 'null' rawCppThis pointer may not be used as a WrappedObjectsTable key.", new object[0])); } if (null == this.WrappedObjectsTable) { this.WrappedObjectsTable = new Hashtable(); this.Callback = new Methods.ObjectRefCountChangedCallback(this.Instance_ObjectRefCountChangedCallback); this.CallbackId = Methods.AddObjectRefCountChangedCallback(this.Callback); } lock (this.WrappedObjectsTable.SyncRoot) { if (this.WrappedObjectsTable.ContainsKey(rawCppThis)) { WeakReference weakReference = this.WrappedObjectsTable[rawCppThis] as WeakReference; if (null == weakReference) { throw new Exception(string.Format("error: Duplicate rawCppThis - existing strong reference. Attempting to add '0x{0:x8}' again.", (long)rawCppThis)); } if (weakReference.IsAlive) { if (strong) { throw new Exception(string.Format("error: Duplicate rawCppThis - weak reference that is still alive. Attempting to add '0x{0:x8}' again.", (long)rawCppThis)); } Methods.Trace(""); Methods.Trace(string.Format("error: potential refcounting error: Duplicate rawCppThis - weak reference that is still alive. Attempting to add '0x{0:x8}' again.", (long)rawCppThis)); Methods.Trace(string.Format(" Allowing new wrapped object to take over table key...", new object[0])); Methods.Trace(string.Format(" Original object should *not* have been destroyed while we still had it in our table without notifying us...", new object[0])); Methods.Trace(""); } } if (strong) { this.WrappedObjectsTable[rawCppThis] = obj; if (Methods.TraceInternalCalls) { Methods.Trace(string.Format("rawCppThis '0x{0:x8}' added as strong table reference", (long)rawCppThis)); } } else { this.WrappedObjectsTable[rawCppThis] = new WeakReference(obj); if (Methods.TraceInternalCalls) { Methods.Trace(string.Format("rawCppThis '0x{0:x8}' added as weak table reference", (long)rawCppThis)); } } } }
private static uint AddObjectRefCountChangedCallback(Methods.ObjectRefCountChangedCallback cb) { return(Methods.Kitware_mummy_Runtime_AddObjectRefCountChangedCallback(cb)); }
private static extern uint Kitware_mummy_Runtime_AddObjectRefCountChangedCallback(Methods.ObjectRefCountChangedCallback cb);