Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Listener/Async Blocks #601

Merged
merged 8 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [3.0.0]
# TODO: Change to 3.2.0 stable once it's released.
sdk: [3.2.0-114.0.dev]
liamappelbe marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand All @@ -44,7 +45,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: 3.0.0
sdk: 3.2.0-114.0.dev
- name: Install dependencies
run: dart pub get
- name: Install libclang-14-dev
Expand All @@ -61,7 +62,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: 3.0.0
sdk: 3.2.0-114.0.dev
- name: Install dependencies
run: dart pub get
- name: Build test dylib and bindings
Expand All @@ -83,7 +84,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: 3.0.0
sdk: 3.2.0-114.0.dev
- name: Install dependencies
run: dart pub get
- name: Build test dylib and bindings
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 10.0.0-dev.0

- Add support for ObjC Blocks that can be invoked from any thread, using
NativeCallable.listener.
- Bump min SDK version to 3.2.0-114.0.dev.

# 9.0.1

- Fix doc comment missing on struct/union array fields.
Expand Down
55 changes: 29 additions & 26 deletions example/c_json/cjson_generated_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ class CJson {
}

late final _cJSON_ParsePtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>>('cJSON_Parse');
ffi
.NativeFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>>(
'cJSON_Parse');
late final _cJSON_Parse = _cJSON_ParsePtr
.asFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>();

Expand Down Expand Up @@ -109,8 +110,9 @@ class CJson {
}

late final _cJSON_PrintPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>>('cJSON_Print');
ffi
.NativeFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>>(
'cJSON_Print');
late final _cJSON_Print = _cJSON_PrintPtr
.asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>();

Expand All @@ -123,9 +125,9 @@ class CJson {
}

late final _cJSON_PrintUnformattedPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.Char> Function(
ffi.Pointer<cJSON>)>>('cJSON_PrintUnformatted');
ffi
.NativeFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>>(
'cJSON_PrintUnformatted');
late final _cJSON_PrintUnformatted = _cJSON_PrintUnformattedPtr
.asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>();

Expand Down Expand Up @@ -286,9 +288,9 @@ class CJson {
}

late final _cJSON_GetStringValuePtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.Char> Function(
ffi.Pointer<cJSON>)>>('cJSON_GetStringValue');
ffi
.NativeFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>>(
'cJSON_GetStringValue');
late final _cJSON_GetStringValue = _cJSON_GetStringValuePtr
.asFunction<ffi.Pointer<ffi.Char> Function(ffi.Pointer<cJSON>)>();

Expand Down Expand Up @@ -499,9 +501,9 @@ class CJson {
}

late final _cJSON_CreateStringPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<cJSON> Function(
ffi.Pointer<ffi.Char>)>>('cJSON_CreateString');
ffi
.NativeFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>>(
'cJSON_CreateString');
late final _cJSON_CreateString = _cJSON_CreateStringPtr
.asFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>();

Expand All @@ -514,9 +516,9 @@ class CJson {
}

late final _cJSON_CreateRawPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<cJSON> Function(
ffi.Pointer<ffi.Char>)>>('cJSON_CreateRaw');
ffi
.NativeFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>>(
'cJSON_CreateRaw');
late final _cJSON_CreateRaw = _cJSON_CreateRawPtr
.asFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>();

Expand Down Expand Up @@ -549,9 +551,9 @@ class CJson {
}

late final _cJSON_CreateStringReferencePtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<cJSON> Function(
ffi.Pointer<ffi.Char>)>>('cJSON_CreateStringReference');
ffi
.NativeFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>>(
'cJSON_CreateStringReference');
late final _cJSON_CreateStringReference = _cJSON_CreateStringReferencePtr
.asFunction<ffi.Pointer<cJSON> Function(ffi.Pointer<ffi.Char>)>();

Expand Down Expand Up @@ -1199,9 +1201,9 @@ class CJson {
}

late final _cJSON_SetNumberHelperPtr = _lookup<
ffi.NativeFunction<
ffi.Double Function(
ffi.Pointer<cJSON>, ffi.Double)>>('cJSON_SetNumberHelper');
ffi
.NativeFunction<ffi.Double Function(ffi.Pointer<cJSON>, ffi.Double)>>(
'cJSON_SetNumberHelper');
late final _cJSON_SetNumberHelper = _cJSON_SetNumberHelperPtr
.asFunction<double Function(ffi.Pointer<cJSON>, double)>();

Expand Down Expand Up @@ -1256,12 +1258,13 @@ final class cJSON extends ffi.Struct {
}

final class cJSON_Hooks extends ffi.Struct {
external ffi.Pointer<
ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(ffi.Size sz)>>
external ffi
.Pointer<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(ffi.Size sz)>>
malloc_fn;

external ffi.Pointer<
ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void> ptr)>> free_fn;
external ffi
.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void> ptr)>>
free_fn;
}

typedef cJSON_bool = ffi.Int;
Expand Down
2 changes: 1 addition & 1 deletion example/c_json/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name: c_json_example

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.2.0-114.0.dev <4.0.0"

dependencies:
ffi: ^2.0.1
Expand Down
2 changes: 1 addition & 1 deletion example/ffinative/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name: ffinative_example

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.2.0-114.0.dev <4.0.0"

dependencies:
ffi: ^2.0.1
Expand Down
28 changes: 14 additions & 14 deletions example/libclang-example/generated_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ class LibClang {
}

late final _clang_CXIndex_setInvocationEmissionPathOptionPtr = _lookup<
ffi.NativeFunction<
NativeClang_CXIndex_setInvocationEmissionPathOption>>(
ffi
.NativeFunction<NativeClang_CXIndex_setInvocationEmissionPathOption>>(
'clang_CXIndex_setInvocationEmissionPathOption');
late final _clang_CXIndex_setInvocationEmissionPathOption =
_clang_CXIndex_setInvocationEmissionPathOptionPtr
Expand Down Expand Up @@ -2938,8 +2938,8 @@ class LibClang {
}

late final _clang_Cursor_getTemplateArgumentUnsignedValuePtr = _lookup<
ffi.NativeFunction<
NativeClang_Cursor_getTemplateArgumentUnsignedValue>>(
ffi
.NativeFunction<NativeClang_Cursor_getTemplateArgumentUnsignedValue>>(
'clang_Cursor_getTemplateArgumentUnsignedValue');
late final _clang_Cursor_getTemplateArgumentUnsignedValue =
_clang_Cursor_getTemplateArgumentUnsignedValuePtr
Expand Down Expand Up @@ -4849,8 +4849,8 @@ class LibClang {
}

late final _clang_CXXConstructor_isConvertingConstructorPtr = _lookup<
ffi.NativeFunction<
NativeClang_CXXConstructor_isConvertingConstructor>>(
ffi
.NativeFunction<NativeClang_CXXConstructor_isConvertingConstructor>>(
'clang_CXXConstructor_isConvertingConstructor');
late final _clang_CXXConstructor_isConvertingConstructor =
_clang_CXXConstructor_isConvertingConstructorPtr
Expand Down Expand Up @@ -6850,8 +6850,8 @@ class _SymbolAddresses {
get clang_CXIndex_getGlobalOptions =>
_library._clang_CXIndex_getGlobalOptionsPtr;
ffi.Pointer<
ffi.NativeFunction<
NativeClang_CXIndex_setInvocationEmissionPathOption>>
ffi
.NativeFunction<NativeClang_CXIndex_setInvocationEmissionPathOption>>
get clang_CXIndex_setInvocationEmissionPathOption =>
_library._clang_CXIndex_setInvocationEmissionPathOptionPtr;
ffi.Pointer<ffi.NativeFunction<NativeClang_getFileName>>
Expand Down Expand Up @@ -7148,8 +7148,8 @@ class _SymbolAddresses {
get clang_Cursor_getTemplateArgumentValue =>
_library._clang_Cursor_getTemplateArgumentValuePtr;
ffi.Pointer<
ffi.NativeFunction<
NativeClang_Cursor_getTemplateArgumentUnsignedValue>>
ffi
.NativeFunction<NativeClang_Cursor_getTemplateArgumentUnsignedValue>>
get clang_Cursor_getTemplateArgumentUnsignedValue =>
_library._clang_Cursor_getTemplateArgumentUnsignedValuePtr;
ffi.Pointer<ffi.NativeFunction<NativeClang_equalTypes>>
Expand Down Expand Up @@ -7406,8 +7406,8 @@ class _SymbolAddresses {
get clang_Module_getTopLevelHeader =>
_library._clang_Module_getTopLevelHeaderPtr;
ffi.Pointer<
ffi.NativeFunction<
NativeClang_CXXConstructor_isConvertingConstructor>>
ffi
.NativeFunction<NativeClang_CXXConstructor_isConvertingConstructor>>
get clang_CXXConstructor_isConvertingConstructor =>
_library._clang_CXXConstructor_isConvertingConstructorPtr;
ffi.Pointer<ffi.NativeFunction<NativeClang_CXXConstructor_isCopyConstructor>>
Expand Down Expand Up @@ -11104,8 +11104,8 @@ typedef DartClang_indexLoc_getCXSourceLocation = CXSourceLocation Function(
/// The visitor should return one of the \c CXVisitorResult values
/// to direct \c clang_Type_visitFields.
typedef CXFieldVisitor = ffi.Pointer<
ffi.NativeFunction<
ffi.Int32 Function(CXCursor C, CXClientData client_data)>>;
ffi
.NativeFunction<ffi.Int32 Function(CXCursor C, CXClientData client_data)>>;
typedef NativeClang_Type_visitFields = ffi.UnsignedInt Function(
CXType T, CXFieldVisitor visitor, CXClientData client_data);
typedef DartClang_Type_visitFields = int Function(
Expand Down
2 changes: 1 addition & 1 deletion example/libclang-example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name: libclang_example

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.2.0-114.0.dev <4.0.0"

dependencies:
ffi: ^2.0.1
Expand Down
Loading