int ISQLite3Provider.sqlite3_create_collation(IntPtr db, string name, object v, delegate_collation func) { if (_collation_hooks.ContainsKey(name)) { collation_hook_info hi = _collation_hooks[name]; // TODO maybe turn off the hook here, for now hi.free(); _collation_hooks.Remove(name); } GCHandle pinned = GCHandle.Alloc(util.to_utf8(name), GCHandleType.Pinned); IntPtr ptr = pinned.AddrOfPinnedObject(); int rc; // 1 is SQLITE_UTF8 if (func != null) { collation_hook_info hi = new collation_hook_info(func, v); rc = SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), ptr.ToInt64(), 1, hi.ptr.ToInt64(), Marshal.GetFunctionPointerForDelegate(new callback_collation(collation_hook_bridge)).ToInt64()); if (rc == 0) { _collation_hooks[name] = hi; } } else { rc = SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), ptr.ToInt64(), 1, IntPtr.Zero.ToInt64(), IntPtr.Zero.ToInt64()); } pinned.Free(); return(rc); }
int ISQLite3Provider.Sqlite3CreateCollation(IntPtr db, IntPtr collationName, IntPtr compare) { return(SQLite3RuntimeProvider.sqlite3_create_collation(db.ToInt64(), collationName.ToInt64(), 0x1, IntPtr.Zero.ToInt64(), compare.ToInt64())); }