internal static rollback_hook_info from_ptr(IntPtr p) { GCHandle h = (GCHandle)p; rollback_hook_info hi = h.Target as rollback_hook_info; // TODO assert(hi._h == h) return(hi); }
void ISQLite3Provider.sqlite3_rollback_hook(IntPtr db, delegate_rollback func, object v) { if (_rollback_hook != null) { // TODO maybe turn off the hook here, for now _rollback_hook.free(); _rollback_hook = null; } if (func != null) { _rollback_hook = new rollback_hook_info(func, v); SQLite3RuntimeProvider.sqlite3_rollback_hook(db.ToInt64(), Marshal.GetFunctionPointerForDelegate(new callback_rollback(rollback_hook_bridge)).ToInt64(), _rollback_hook.ptr.ToInt64()); } else { SQLite3RuntimeProvider.sqlite3_rollback_hook(db.ToInt64(), IntPtr.Zero.ToInt64(), IntPtr.Zero.ToInt64()); } }
void ISQLite3Provider.sqlite3_rollback_hook(IntPtr db, delegate_rollback func, object v) { if (_rollback_hook != null) { // TODO maybe turn off the hook here, for now _rollback_hook.free(); _rollback_hook = null; } if (func != null) { _rollback_hook = new rollback_hook_info(func, v); NativeMethods.sqlite3_rollback_hook(db, rollback_hook_bridge, _rollback_hook.ptr); } else { NativeMethods.sqlite3_rollback_hook(db, null, IntPtr.Zero); } }
static private void rollback_hook_bridge(IntPtr p) { rollback_hook_info hi = rollback_hook_info.from_ptr(p); hi.call(); }