/// <summary> /// Increases the ref count on an object ensuring that it will not be collected. /// </summary> public static void Py_INCREF(object key) { EnsureRefCountTable(); lock (_refCountTable) { if (!_refCountTable.TryGetValue(key, out RefCountInfo info)) { _refCountTable[key] = info = new RefCountInfo(); // TODO: this only works w/ blittable types, what to do for others? info.Handle = GCHandle.Alloc(key, GCHandleType.Pinned); } info.RefCount++; } }
/// <summary> /// Increases the ref count on an object ensuring that it will not be collected. /// </summary> public static void Py_INCREF(object key) { EnsureRefCountTable(); lock (_refCountTable) { RefCountInfo info; if (!_refCountTable.TryGetValue(key, out info)) { _refCountTable[key] = info = new RefCountInfo(); // TODO: this only works w/ blittable types, what to do for others? info.Handle = GCHandle.Alloc(key, GCHandleType.Pinned); } info.RefCount++; } }