|
1 | 1 | import 'dart:ffi'; |
2 | 2 |
|
3 | | -import '../../open.dart'; |
4 | 3 | import '../database.dart'; |
5 | 4 | import '../sqlite3.dart'; |
6 | 5 | import '../statement.dart'; |
7 | 6 | import 'implementation.dart'; |
8 | 7 |
|
9 | | -Sqlite3? _sqlite3; |
10 | | - |
11 | 8 | /// Provides access to `sqlite3` functions, such as opening new databases. |
12 | 9 | /// |
13 | 10 | /// {@category native} |
14 | | -Sqlite3 get sqlite3 { |
15 | | - return _sqlite3 ??= FfiSqlite3(open.openSqlite()); |
16 | | -} |
| 11 | +const Sqlite3 sqlite3 = FfiSqlite3(); |
17 | 12 |
|
18 | 13 | /// Provides access to `sqlite3` functions, such as opening new databases. |
19 | 14 | /// |
@@ -46,6 +41,18 @@ abstract interface class Sqlite3 implements CommonSqlite3 { |
46 | 41 | /// For a more in-depth discussion, including links to an example, see the |
47 | 42 | /// documentation for [SqliteExtension]. |
48 | 43 | void ensureExtensionLoaded(SqliteExtension extension); |
| 44 | + |
| 45 | + /// Whether the option, specified by its name, was defined at compile-time. |
| 46 | + /// |
| 47 | + /// The `SQLITE_` prefix may be omitted from the option [name]. |
| 48 | + /// |
| 49 | + /// See also: https://sqlite.org/c3ref/compileoption_get.html |
| 50 | + bool usedCompileOption(String name); |
| 51 | + |
| 52 | + /// An iterable over the list of options that were defined at compile time. |
| 53 | + /// |
| 54 | + /// See also: https://sqlite.org/c3ref/compileoption_get.html |
| 55 | + Iterable<String> get compileOptions; |
49 | 56 | } |
50 | 57 |
|
51 | 58 | /// Information used to load an extension through `sqlite3_auto_extension`, |
@@ -73,27 +80,13 @@ abstract interface class SqliteExtension { |
73 | 80 | /// For the exact signature of [extensionEntrypoint], see |
74 | 81 | /// [sqlite3_auto_extension](https://www.sqlite.org/c3ref/auto_extension.html). |
75 | 82 | factory SqliteExtension(Pointer<Void> extensionEntrypoint) { |
76 | | - return SqliteExtensionImpl((_) => extensionEntrypoint); |
| 83 | + return SqliteExtensionImpl(() => extensionEntrypoint); |
77 | 84 | } |
78 | 85 |
|
79 | 86 | /// A sqlite extension from another library with a given symbol as an |
80 | 87 | /// entrypoint. |
81 | 88 | factory SqliteExtension.inLibrary(DynamicLibrary library, String symbol) { |
82 | | - return SqliteExtensionImpl((_) => library.lookup(symbol)); |
83 | | - } |
84 | | - |
85 | | - /// A sqlite extension assumed to be statically linked into the sqlite3 |
86 | | - /// library loaded by this package. |
87 | | - /// |
88 | | - /// In most sqlite3 distributions, including the one from `sqlite3_flutter_libs`, |
89 | | - /// no extensions are available this way. |
90 | | - /// |
91 | | - /// One example where an extension would be available is if you added a |
92 | | - /// native dependency on the `sqlite3/spellfix1` pod on iOS or macOS. On those |
93 | | - /// platforms, you could then load the [spellfix](https://www.sqlite.org/spellfix1.html) |
94 | | - /// extension with `SqliteExtension.staticallyLinked('sqlite3_spellfix_init')`. |
95 | | - factory SqliteExtension.staticallyLinked(String symbol) { |
96 | | - return SqliteExtensionImpl((library) => library!.lookup(symbol)); |
| 89 | + return SqliteExtensionImpl(() => library.lookup(symbol)); |
97 | 90 | } |
98 | 91 | } |
99 | 92 |
|
|
0 commit comments