Skip to content

Commit

Permalink
Be more careful about calling conventions and struct layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Oct 30, 2023
1 parent 5286abd commit 3d06a71
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 240 deletions.
112 changes: 35 additions & 77 deletions src/SqlNotebook.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,150 +24,108 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "..\ext\Windows-API-
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SqlNotebookDb", "SqlNotebookDb\SqlNotebookDb.vcxproj", "{34743FAD-099D-4DB8-B8A6-C863FEC91C77}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypto", "crypto\crypto.vcxproj", "{BD15F169-473B-4178-8E8C-0E7F1F1313A5}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypto", "crypto\crypto.vcxproj", "{3450C322-3527-4A61-81A2-8D7552C3DE3E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzy", "fuzzy\fuzzy.vcxproj", "{FFBF7A77-5836-478A-AB16-F3857F5D65A1}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzy", "fuzzy\fuzzy.vcxproj", "{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stats", "stats\stats.vcxproj", "{1A08E209-1D92-4F52-9D3A-C5889D96C009}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stats", "stats\stats.vcxproj", "{2464AE91-59E7-404B-98D2-26F27AFA0496}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Debug|Any CPU.ActiveCfg = Debug|x64
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Debug|x64.ActiveCfg = Debug|x64
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Debug|x64.Build.0 = Debug|x64
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Debug|x86.ActiveCfg = Debug|x86
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Debug|x86.Build.0 = Debug|x86
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Release|Any CPU.ActiveCfg = Release|x64
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Release|x64.ActiveCfg = Release|x64
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Release|x64.Build.0 = Release|x64
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Release|x86.ActiveCfg = Release|x86
{4766090D-0E56-4A24-BDE7-3F9FB8D37C80}.Release|x86.Build.0 = Release|x86
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|x64.ActiveCfg = Debug|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|x64.Build.0 = Debug|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|x86.ActiveCfg = Debug|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Debug|x86.Build.0 = Debug|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|Any CPU.Build.0 = Release|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|x64.ActiveCfg = Release|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|x64.Build.0 = Release|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|x86.ActiveCfg = Release|Any CPU
{C75532C4-765B-418E-B09B-46D36B2ABDB1}.Release|x86.Build.0 = Release|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Debug|x64.ActiveCfg = Debug|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Debug|x64.Build.0 = Debug|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Debug|x86.ActiveCfg = Debug|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Debug|x86.Build.0 = Debug|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Release|Any CPU.Build.0 = Release|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Release|x64.ActiveCfg = Release|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Release|x64.Build.0 = Release|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Release|x86.ActiveCfg = Release|Any CPU
{4ED4FDB5-9FD0-49E6-876D-1635F727C755}.Release|x86.Build.0 = Release|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x64.ActiveCfg = Debug|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x64.Build.0 = Debug|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x86.ActiveCfg = Debug|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x86.Build.0 = Debug|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|Any CPU.Build.0 = Release|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x64.ActiveCfg = Release|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x64.Build.0 = Release|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x86.ActiveCfg = Release|Any CPU
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x86.Build.0 = Release|Any CPU
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Debug|Any CPU.ActiveCfg = Debug|x64
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x64.ActiveCfg = Debug|x64
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x64.Build.0 = Debug|x64
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x86.ActiveCfg = Debug|x86
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Debug|x86.Build.0 = Debug|x86
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x64.ActiveCfg = Release|x64
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x64.Build.0 = Release|x64
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x86.ActiveCfg = Release|x86
{2255C461-80D4-419C-AA57-60AF7D2C6305}.Release|x86.Build.0 = Release|x86
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Debug|x64.ActiveCfg = Debug|x64
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Debug|x64.Build.0 = Debug|x64
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Debug|x86.ActiveCfg = Debug|x86
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Debug|x86.Build.0 = Debug|x86
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Release|Any CPU.ActiveCfg = Release|x64
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Release|x64.ActiveCfg = Release|x64
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Release|x64.Build.0 = Release|x64
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Release|x86.ActiveCfg = Release|x86
{071687A4-D100-4FC4-8B42-CEE211CE9F05}.Release|x86.Build.0 = Release|x86
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Debug|x64.ActiveCfg = Debug|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Debug|x64.Build.0 = Debug|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Debug|x86.ActiveCfg = Debug|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Debug|x86.Build.0 = Debug|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Release|Any CPU.Build.0 = Release|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Release|x64.ActiveCfg = Release|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Release|x64.Build.0 = Release|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Release|x86.ActiveCfg = Release|Any CPU
{6600E45B-E354-48A9-AA23-CA276102E7BE}.Release|x86.Build.0 = Release|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Debug|x64.ActiveCfg = Debug|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Debug|x64.Build.0 = Debug|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Debug|x86.ActiveCfg = Debug|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Debug|x86.Build.0 = Debug|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Release|Any CPU.Build.0 = Release|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Release|x64.ActiveCfg = Release|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Release|x64.Build.0 = Release|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Release|x86.ActiveCfg = Release|Any CPU
{8B591728-BA7E-4E84-B103-E4971A984A68}.Release|x86.Build.0 = Release|Any CPU
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Debug|Any CPU.ActiveCfg = Debug|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Debug|Any CPU.Build.0 = Debug|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Debug|x64.ActiveCfg = Debug|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Debug|x64.Build.0 = Debug|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Debug|x86.ActiveCfg = Debug|Win32
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Debug|x86.Build.0 = Debug|Win32
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Release|Any CPU.ActiveCfg = Release|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Release|Any CPU.Build.0 = Release|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Release|x64.ActiveCfg = Release|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Release|x64.Build.0 = Release|x64
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Release|x86.ActiveCfg = Release|Win32
{34743FAD-099D-4DB8-B8A6-C863FEC91C77}.Release|x86.Build.0 = Release|Win32
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Debug|Any CPU.ActiveCfg = Debug|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Debug|Any CPU.Build.0 = Debug|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Debug|x64.ActiveCfg = Debug|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Debug|x64.Build.0 = Debug|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Debug|x86.ActiveCfg = Debug|Win32
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Debug|x86.Build.0 = Debug|Win32
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Release|Any CPU.ActiveCfg = Release|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Release|Any CPU.Build.0 = Release|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Release|x64.ActiveCfg = Release|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Release|x64.Build.0 = Release|x64
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Release|x86.ActiveCfg = Release|Win32
{BD15F169-473B-4178-8E8C-0E7F1F1313A5}.Release|x86.Build.0 = Release|Win32
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Debug|Any CPU.ActiveCfg = Debug|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Debug|Any CPU.Build.0 = Debug|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Debug|x64.ActiveCfg = Debug|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Debug|x64.Build.0 = Debug|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Debug|x86.ActiveCfg = Debug|Win32
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Debug|x86.Build.0 = Debug|Win32
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Release|Any CPU.ActiveCfg = Release|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Release|Any CPU.Build.0 = Release|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Release|x64.ActiveCfg = Release|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Release|x64.Build.0 = Release|x64
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Release|x86.ActiveCfg = Release|Win32
{FFBF7A77-5836-478A-AB16-F3857F5D65A1}.Release|x86.Build.0 = Release|Win32
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Debug|Any CPU.ActiveCfg = Debug|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Debug|Any CPU.Build.0 = Debug|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Debug|x64.ActiveCfg = Debug|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Debug|x64.Build.0 = Debug|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Debug|x86.ActiveCfg = Debug|Win32
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Debug|x86.Build.0 = Debug|Win32
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Release|Any CPU.ActiveCfg = Release|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Release|Any CPU.Build.0 = Release|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Release|x64.ActiveCfg = Release|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Release|x64.Build.0 = Release|x64
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Release|x86.ActiveCfg = Release|Win32
{1A08E209-1D92-4F52-9D3A-C5889D96C009}.Release|x86.Build.0 = Release|Win32
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Debug|x64.ActiveCfg = Debug|x64
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Debug|x64.Build.0 = Debug|x64
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Debug|x86.ActiveCfg = Debug|Win32
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Debug|x86.Build.0 = Debug|Win32
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Release|x64.ActiveCfg = Release|x64
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Release|x64.Build.0 = Release|x64
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Release|x86.ActiveCfg = Release|Win32
{3450C322-3527-4A61-81A2-8D7552C3DE3E}.Release|x86.Build.0 = Release|Win32
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Debug|x64.ActiveCfg = Debug|x64
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Debug|x64.Build.0 = Debug|x64
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Debug|x86.ActiveCfg = Debug|Win32
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Debug|x86.Build.0 = Debug|Win32
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Release|x64.ActiveCfg = Release|x64
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Release|x64.Build.0 = Release|x64
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Release|x86.ActiveCfg = Release|Win32
{63CA9325-9A8A-4D54-A9B1-4E0B2B2DBCAA}.Release|x86.Build.0 = Release|Win32
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Debug|x64.ActiveCfg = Debug|x64
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Debug|x64.Build.0 = Debug|x64
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Debug|x86.ActiveCfg = Debug|Win32
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Debug|x86.Build.0 = Debug|Win32
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Release|x64.ActiveCfg = Release|x64
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Release|x64.Build.0 = Release|x64
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Release|x86.ActiveCfg = Release|Win32
{2464AE91-59E7-404B-98D2-26F27AFA0496}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 2 additions & 0 deletions src/SqlNotebookDb/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@

// Compiler Linkage and Calling Convention Control
#define SQLITE_API __declspec(dllexport)
#define SQLITE_CDECL __cdecl
#define SQLITE_APICALL __cdecl

#include "sqlite3.c"

Expand Down
2 changes: 2 additions & 0 deletions src/SqlNotebookScript/Core/AdoModules/AdoModuleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public abstract class AdoModuleProvider : IDisposable

private static readonly UTF8Encoding _utf8 = new(false);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void FreeDelegate(IntPtr p);

private static readonly Lazy<(IntPtr Ptr, FreeDelegate Delegate)> _freeFunc =
Expand All @@ -84,6 +85,7 @@ public abstract class AdoModuleProvider : IDisposable
/// </summary>
protected static readonly Dictionary<int, AdoCreateInfo> _adoCreateInfos = new();

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void RemoveCreateInfoDelegate(IntPtr p);

private static readonly Lazy<(IntPtr Ptr, RemoveCreateInfoDelegate Delegate)> _removeCreateInfoFunc =
Expand Down
1 change: 1 addition & 0 deletions src/SqlNotebookScript/Core/CustomFunctionsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace SqlNotebookScript.Core;

public static class CustomFunctionsProvider
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void InvokeAction(IntPtr context, int argc, IntPtr argv);

/// <remarks>We need to keep these alive since they are unmanaged callbacks.</remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class GenericModuleProvider : IDisposable
/// </summary>
private static readonly Dictionary<int, CustomTableFunction> _customTableFunctions = new();

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void RemoveCustomTableFunctionDelegate(IntPtr p);

private static readonly Lazy<(
Expand Down
22 changes: 22 additions & 0 deletions src/SqlNotebookScript/Core/ModuleDelegates.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
using System;
using System.Runtime.InteropServices;

namespace SqlNotebookScript.Core.ModuleDelegates;

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleCreateDelegate(IntPtr db, IntPtr pAux, int argc, IntPtr argv, IntPtr ppVTab, IntPtr pzErr);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleBestIndexDelegate(IntPtr pVTab, IntPtr infoPtr);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleDestroyDelegate(IntPtr pVTab);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleOpenDelegate(IntPtr pVTab, IntPtr ppCursor);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleCloseDelegate(IntPtr pCur);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleFilterDelegate(IntPtr pCur, int idxNum, IntPtr idxStr, int argc, IntPtr argv);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleNextDelegate(IntPtr pCur);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleEofDelegate(IntPtr pCur);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleColumnDelegate(IntPtr pCur, IntPtr ctx, int n);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleRowidDelegate(IntPtr pCur, IntPtr pRowid);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int ModuleRenameDelegate(IntPtr pVtab, IntPtr zNew);
3 changes: 3 additions & 0 deletions src/SqlNotebookScript/Core/Notebook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public sealed class Notebook : IDisposable
// We disable all synchronization in SQLite, so this lock protects any call into SQLite.
private static readonly object _lock = new();

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void ExecuteGenericFunctionDelegate(IntPtr a, int b, IntPtr c);

private static readonly Lazy<(IntPtr Ptr, ExecuteGenericFunctionDelegate Delegate)> _executeGenericFunctionFunc =
new(() =>
{
Expand Down Expand Up @@ -253,6 +255,7 @@ static void LoadExtension(IntPtr db, string filename)
}
}

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate object GenericFunctionExecuteDelegate(IReadOnlyList<object> args);

private void RegisterGenericFunction(CustomScalarFunction scalarFunction)
Expand Down
2 changes: 2 additions & 0 deletions src/SqlNotebookScript/Core/PreparedStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace SqlNotebookScript.Core;

public sealed class PreparedStatement : IDisposable
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void FreeDelegate(IntPtr p);

private static readonly Lazy<(IntPtr Ptr, FreeDelegate Delegate)> _freeFunc =
new(() =>
{
Expand Down
Loading

0 comments on commit 3d06a71

Please sign in to comment.