public static profile_hook_info from_ptr(IntPtr p) { GCHandle h = (GCHandle)p; profile_hook_info hi = h.Target as profile_hook_info; return(hi); }
internal static profile_hook_info from_ptr(IntPtr p) { GCHandle h = (GCHandle)p; profile_hook_info hi = h.Target as profile_hook_info; // TODO assert(hi._h == h) return(hi); }
void ISQLite3Provider.sqlite3_profile(IntPtr db, delegate_profile func, object v) { if (_profile_hook != null) { // TODO maybe turn off the hook here, for now _profile_hook.free(); _profile_hook = null; } if (func != null) { _profile_hook = new profile_hook_info(func, v); SQLite3RuntimeProvider.sqlite3_profile(db.ToInt64(), Marshal.GetFunctionPointerForDelegate(new callback_profile(profile_hook_bridge)).ToInt64(), _profile_hook.ptr.ToInt64()); } else { SQLite3RuntimeProvider.sqlite3_profile(db.ToInt64(), IntPtr.Zero.ToInt64(), IntPtr.Zero.ToInt64()); } }
void ISQLite3Provider.sqlite3_profile(IntPtr db, delegate_profile func, object v) { if (_profile_hook != null) { // TODO maybe turn off the hook here, for now _profile_hook.free(); _profile_hook = null; } if (func != null) { _profile_hook = new profile_hook_info(func, v); NativeMethods.sqlite3_profile(db, profile_hook_bridge, _profile_hook.ptr); } else { NativeMethods.sqlite3_profile(db, null, IntPtr.Zero); } }
static private void profile_hook_bridge(IntPtr p, IntPtr s, long elapsed) { profile_hook_info hi = profile_hook_info.from_ptr(p); hi.call(util.from_utf8(s), elapsed); }