Skip to content

Commit 0b45401

Browse files
committed
Port code to assume native assets only
1 parent 82ac861 commit 0b45401

21 files changed

+1311
-4746
lines changed

sqlite3/assets/sqlite3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int sqlite3_open_v2(sqlite3_char *filename, sqlite3 **ppDb, int flags,
2020
sqlite3_char *zVfs);
2121
int sqlite3_close_v2(sqlite3 *db);
2222
sqlite3_char *sqlite3_db_filename(sqlite3 *db, sqlite3_char *zDbName);
23+
int sqlite3_compileoption_used(const sqlite3_char *zOptName);
2324
const sqlite3_char *sqlite3_compileoption_get(int N);
2425

2526
// Error handling

sqlite3/lib/native_assets.dart

Lines changed: 0 additions & 16 deletions
This file was deleted.

sqlite3/lib/open.dart

Lines changed: 0 additions & 9 deletions
This file was deleted.

sqlite3/lib/src/ffi/api.dart

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import 'dart:ffi';
22

3-
import '../../open.dart';
43
import '../database.dart';
54
import '../sqlite3.dart';
65
import '../statement.dart';
76
import 'implementation.dart';
87

9-
Sqlite3? _sqlite3;
10-
118
/// Provides access to `sqlite3` functions, such as opening new databases.
129
///
1310
/// {@category native}
14-
Sqlite3 get sqlite3 {
15-
return _sqlite3 ??= FfiSqlite3(open.openSqlite());
16-
}
11+
const Sqlite3 sqlite3 = FfiSqlite3();
1712

1813
/// Provides access to `sqlite3` functions, such as opening new databases.
1914
///
@@ -46,6 +41,18 @@ abstract interface class Sqlite3 implements CommonSqlite3 {
4641
/// For a more in-depth discussion, including links to an example, see the
4742
/// documentation for [SqliteExtension].
4843
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;
4956
}
5057

5158
/// Information used to load an extension through `sqlite3_auto_extension`,
@@ -73,27 +80,13 @@ abstract interface class SqliteExtension {
7380
/// For the exact signature of [extensionEntrypoint], see
7481
/// [sqlite3_auto_extension](https://www.sqlite.org/c3ref/auto_extension.html).
7582
factory SqliteExtension(Pointer<Void> extensionEntrypoint) {
76-
return SqliteExtensionImpl((_) => extensionEntrypoint);
83+
return SqliteExtensionImpl(() => extensionEntrypoint);
7784
}
7885

7986
/// A sqlite extension from another library with a given symbol as an
8087
/// entrypoint.
8188
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));
9790
}
9891
}
9992

0 commit comments

Comments
 (0)