Skip to content

Commit

Permalink
new attempt to fix #506. this is the code change from #507, but limit…
Browse files Browse the repository at this point in the history
…ed to use on windows platforms, to avoid apparent iOS AOT bug mentioned in #516.
  • Loading branch information
ericsink committed Sep 16, 2022
1 parent d460d94 commit 9adcbfc
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 139 deletions.
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<Copyright>Copyright 2014-2022 SourceGear, LLC</Copyright>
<Company>SourceGear</Company>
<Authors>Eric Sink</Authors>
<Version>2.1.1-pre20220726160216</Version>
<AssemblyVersion>2.1.1.1667</AssemblyVersion>
<FileVersion>2.1.1.1667</FileVersion>
<Version>2.1.2-pre20220916104546</Version>
<AssemblyVersion>2.1.2.1719</AssemblyVersion>
<FileVersion>2.1.2.1719</FileVersion>
<Description>SQLitePCLRaw is a Portable Class Library (PCL) for low-level (raw) access to SQLite</Description>
<ProviderLangVersion>10.0</ProviderLangVersion>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
Expand Down
10 changes: 5 additions & 5 deletions gen_providers/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let main argv =
gen_provider "dynamic_cdecl" null None "Cdecl" "dynamic" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/true"
gen_provider "dynamic_stdcall" null None "StdCall" "dynamic" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/true"
gen_provider "internal" "__Internal" (Some "legacy") "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider "internal" "__Internal" (Some "funcptrs") "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/true" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider "internal" "__Internal" (Some "funcptrs") "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/plain" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"

// TODO do we need prenet5 and funcptrs versions of this one?
gen_provider "winsqlite3" "winsqlite3" None "StdCall" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"
Expand All @@ -58,14 +58,14 @@ let main argv =
for s in ["e_sqlite3"; "sqlite3"; ] do
gen_provider s s (Some subname_prenet5_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_prenet5_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/true" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/true" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/callingconv" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/plain" "FEATURE_KEY/false" "FEATURE_LOADEXTENSION/false"

for s in ["e_sqlcipher"; "sqlcipher"; ] do
gen_provider s s (Some subname_prenet5_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_prenet5_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/true" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/true" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/callingconv" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/plain" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"

0 // return an integer exit code

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<file src="$cb_bin_path$\e_sqlite3\linux\s390x\libe_sqlite3.so" target="runtimes\linux-s390x\native\libe_sqlite3.so" />
<file src="$cb_bin_path$\e_sqlite3\wasm\net6.0\e_sqlite3.a" target="runtimes\browser-wasm\nativeassets\net6.0\e_sqlite3.a" />
<file src="$cb_bin_path$\e_sqlite3\wasm\net7.0\e_sqlite3.a" target="runtimes\browser-wasm\nativeassets\net7.0\e_sqlite3.a" />
<file src=".\SQLitePCLRaw.lib.e_sqlite3.props" target="buildTransitive\" />
<file src=".\net461\SQLitePCLRaw.lib.e_sqlite3.targets" target="buildTransitive\net461" />
<file src=".\net6.0\SQLitePCLRaw.lib.e_sqlite3.targets" target="buildTransitive\net6.0" />
<file src=".\net7.0\SQLitePCLRaw.lib.e_sqlite3.targets" target="buildTransitive\net7.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace SQLitePCL
{
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -154,7 +155,7 @@ void ISQLite3Provider.sqlite3_interrupt(sqlite3 db)
NativeMethods.sqlite3_interrupt(db);
}

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static int exec_hook_bridge_impl(IntPtr p, int n, IntPtr values_ptr, IntPtr names_ptr)
{
exec_hook_info hi = exec_hook_info.from_ptr(p);
Expand All @@ -166,7 +167,7 @@ unsafe int ISQLite3Provider.sqlite3_exec(sqlite3 db, utf8z sql, delegate_exec fu
{
int rc;

delegate* unmanaged <IntPtr, int, IntPtr, IntPtr, int> cb;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, IntPtr, int> cb;
exec_hook_info hi;
if (func != null)
{
Expand Down Expand Up @@ -613,7 +614,7 @@ unsafe int ISQLite3Provider.sqlite3_load_extension(sqlite3 db, utf8z zFile, utf8
// is shared but not portable. It is in the util.cs file which is compiled
// into each platform assembly.

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static int commit_hook_bridge_impl(IntPtr p)
{
commit_hook_info hi = commit_hook_info.from_ptr(p);
Expand All @@ -631,7 +632,7 @@ unsafe void ISQLite3Provider.sqlite3_commit_hook(sqlite3 db, delegate_commit fun
info.commit = null;
}

delegate* unmanaged <IntPtr, int> cb;
delegate* unmanaged[Cdecl] <IntPtr, int> cb;
commit_hook_info hi;
if (func != null)
{
Expand All @@ -653,7 +654,7 @@ unsafe void ISQLite3Provider.sqlite3_commit_hook(sqlite3 db, delegate_commit fun
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void scalar_function_hook_bridge_impl(IntPtr context, int num_args, IntPtr argsptr)
{
IntPtr p = NativeMethods.sqlite3_user_data(context);
Expand All @@ -673,7 +674,7 @@ unsafe int ISQLite3Provider.sqlite3_create_function(sqlite3 db, byte[] name, int

// 1 is SQLITE_UTF8
int arg4 = 1 | flags;
delegate* unmanaged <IntPtr, int, IntPtr, void> cb;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, void> cb;
function_hook_info hi;
if (func != null)
{
Expand All @@ -698,7 +699,7 @@ unsafe int ISQLite3Provider.sqlite3_create_function(sqlite3 db, byte[] name, int

static IDisposable disp_log_hook_handle;

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void log_hook_bridge_impl(IntPtr p, int rc, IntPtr s)
{
log_hook_info hi = log_hook_info.from_ptr(p);
Expand All @@ -715,7 +716,7 @@ unsafe int ISQLite3Provider.sqlite3_config_log(delegate_log func, object v)
disp_log_hook_handle = null;
}

delegate* unmanaged <IntPtr, int, IntPtr, void> cb;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, void> cb;
log_hook_info hi;
if (func != null)
{
Expand Down Expand Up @@ -747,7 +748,7 @@ unsafe void ISQLite3Provider.sqlite3_log(int errcode, utf8z s)
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void agg_function_step_hook_bridge_impl(IntPtr context, int num_args, IntPtr argsptr)
{
IntPtr agg = NativeMethods.sqlite3_aggregate_context(context, 8);
Expand All @@ -758,7 +759,7 @@ static void agg_function_step_hook_bridge_impl(IntPtr context, int num_args, Int
hi.call_step(context, agg, num_args, argsptr);
}

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void agg_function_final_hook_bridge_impl(IntPtr context)
{
IntPtr agg = NativeMethods.sqlite3_aggregate_context(context, 8);
Expand All @@ -782,8 +783,8 @@ unsafe int ISQLite3Provider.sqlite3_create_function(sqlite3 db, byte[] name, int

// 1 is SQLITE_UTF8
int arg4 = 1 | flags;
delegate* unmanaged <IntPtr, int, IntPtr, void> cb_step;
delegate* unmanaged <IntPtr, void> cb_final;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, void> cb_step;
delegate* unmanaged[Cdecl] <IntPtr, void> cb_final;
function_hook_info hi;
if (func_step != null)
{
Expand Down Expand Up @@ -812,7 +813,7 @@ unsafe int ISQLite3Provider.sqlite3_create_function(sqlite3 db, byte[] name, int
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static int collation_hook_bridge_impl(IntPtr p, int len1, IntPtr pv1, int len2, IntPtr pv2)
{
collation_hook_info hi = collation_hook_info.from_ptr(p);
Expand All @@ -835,7 +836,7 @@ unsafe int ISQLite3Provider.sqlite3_create_collation(sqlite3 db, byte[] name, ob
// TODO maybe turn off the hook here, for now
}

delegate* unmanaged <IntPtr, int, IntPtr, int, IntPtr, int> cb;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, int, IntPtr, int> cb;
collation_hook_info hi;
if (func != null)
{
Expand All @@ -862,7 +863,7 @@ unsafe int ISQLite3Provider.sqlite3_create_collation(sqlite3 db, byte[] name, ob
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void update_hook_bridge_impl(IntPtr p, int typ, IntPtr db, IntPtr tbl, Int64 rowid)
{
update_hook_info hi = update_hook_info.from_ptr(p);
Expand All @@ -880,7 +881,7 @@ unsafe void ISQLite3Provider.sqlite3_update_hook(sqlite3 db, delegate_update fun
info.update = null;
}

delegate* unmanaged <IntPtr, int, IntPtr, IntPtr, Int64, void> cb;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, IntPtr, Int64, void> cb;
update_hook_info hi;
if (func != null)
{
Expand All @@ -902,7 +903,7 @@ unsafe void ISQLite3Provider.sqlite3_update_hook(sqlite3 db, delegate_update fun
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void rollback_hook_bridge_impl(IntPtr p)
{
rollback_hook_info hi = rollback_hook_info.from_ptr(p);
Expand All @@ -920,7 +921,7 @@ unsafe void ISQLite3Provider.sqlite3_rollback_hook(sqlite3 db, delegate_rollback
info.rollback = null;
}

delegate* unmanaged <IntPtr, void> cb;
delegate* unmanaged[Cdecl] <IntPtr, void> cb;
rollback_hook_info hi;
if (func != null)
{
Expand All @@ -942,7 +943,7 @@ unsafe void ISQLite3Provider.sqlite3_rollback_hook(sqlite3 db, delegate_rollback
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void trace_hook_bridge_impl(IntPtr p, IntPtr s)
{
trace_hook_info hi = trace_hook_info.from_ptr(p);
Expand All @@ -960,7 +961,7 @@ unsafe void ISQLite3Provider.sqlite3_trace(sqlite3 db, delegate_trace func, obje
info.trace = null;
}

delegate* unmanaged <IntPtr, IntPtr, void> cb;
delegate* unmanaged[Cdecl] <IntPtr, IntPtr, void> cb;
trace_hook_info hi;
if (func != null)
{
Expand All @@ -982,7 +983,7 @@ unsafe void ISQLite3Provider.sqlite3_trace(sqlite3 db, delegate_trace func, obje
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static void profile_hook_bridge_impl(IntPtr p, IntPtr s, long elapsed)
{
profile_hook_info hi = profile_hook_info.from_ptr(p);
Expand All @@ -1000,7 +1001,7 @@ unsafe void ISQLite3Provider.sqlite3_profile(sqlite3 db, delegate_profile func,
info.profile = null;
}

delegate* unmanaged <IntPtr, IntPtr, long, void> cb;
delegate* unmanaged[Cdecl] <IntPtr, IntPtr, long, void> cb;
profile_hook_info hi;
if (func != null)
{
Expand All @@ -1022,7 +1023,7 @@ unsafe void ISQLite3Provider.sqlite3_profile(sqlite3 db, delegate_profile func,
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static int progress_handler_hook_bridge_impl(IntPtr p)
{
progress_hook_info hi = progress_hook_info.from_ptr(p);
Expand All @@ -1040,7 +1041,7 @@ unsafe void ISQLite3Provider.sqlite3_progress_handler(sqlite3 db, int instructio
info.progress = null;
}

delegate* unmanaged <IntPtr, int> cb;
delegate* unmanaged[Cdecl] <IntPtr, int> cb;
progress_hook_info hi;
if (func != null)
{
Expand All @@ -1064,7 +1065,7 @@ unsafe void ISQLite3Provider.sqlite3_progress_handler(sqlite3 db, int instructio
// Passing a callback into SQLite is tricky. See comments near commit_hook
// implementation in pinvoke/SQLite3Provider.cs

[UnmanagedCallersOnly]
[UnmanagedCallersOnly (CallConvs = new[] { typeof(CallConvCdecl) })]
static int authorizer_hook_bridge_impl(IntPtr p, int action_code, IntPtr param0, IntPtr param1, IntPtr dbName, IntPtr inner_most_trigger_or_view)
{
authorizer_hook_info hi = authorizer_hook_info.from_ptr(p);
Expand All @@ -1082,7 +1083,7 @@ unsafe int ISQLite3Provider.sqlite3_set_authorizer(sqlite3 db, delegate_authoriz
info.authorizer = null;
}

delegate* unmanaged <IntPtr, int, IntPtr, IntPtr, IntPtr, IntPtr, int> cb;
delegate* unmanaged[Cdecl] <IntPtr, int, IntPtr, IntPtr, IntPtr, IntPtr, int> cb;
authorizer_hook_info hi;
if (func != null)
{
Expand Down
Loading

0 comments on commit 9adcbfc

Please sign in to comment.