Skip to content

Commit cc8d0a5

Browse files
committed
Merge branch 'release/0.7.4'
2 parents 1e9a870 + 312288b commit cc8d0a5

File tree

11 files changed

+57
-49
lines changed

11 files changed

+57
-49
lines changed

dart_native/.fvm/fvm_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"flutterSdkVersion": "stable",
2+
"flutterSdkVersion": "2.2.3",
33
"flavors": {}
44
}

dart_native/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.7.4
2+
3+
* [Fix] Errors and warnings.
4+
* [Fix] Dart exceptions on Android.
5+
16
## 0.7.3
27

38
* [Fix] Garbage characters on Android.

dart_native/example/pubspec.lock

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ packages:
1414
name: analyzer
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.7.2"
17+
version: "1.7.1"
1818
args:
1919
dependency: transitive
2020
description:
@@ -28,7 +28,7 @@ packages:
2828
name: async
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "2.8.2"
31+
version: "2.6.1"
3232
boolean_selector:
3333
dependency: transitive
3434
description:
@@ -98,14 +98,14 @@ packages:
9898
name: characters
9999
url: "https://pub.dartlang.org"
100100
source: hosted
101-
version: "1.2.0"
101+
version: "1.1.0"
102102
charcode:
103103
dependency: transitive
104104
description:
105105
name: charcode
106106
url: "https://pub.dartlang.org"
107107
source: hosted
108-
version: "1.3.1"
108+
version: "1.2.0"
109109
checked_yaml:
110110
dependency: transitive
111111
description:
@@ -140,7 +140,7 @@ packages:
140140
name: collection
141141
url: "https://pub.dartlang.org"
142142
source: hosted
143-
version: "1.16.0"
143+
version: "1.15.0"
144144
convert:
145145
dependency: transitive
146146
description:
@@ -168,7 +168,7 @@ packages:
168168
path: ".."
169169
relative: true
170170
source: path
171-
version: "0.7.3"
171+
version: "0.7.4"
172172
dart_native_gen:
173173
dependency: transitive
174174
description:
@@ -189,7 +189,7 @@ packages:
189189
name: fake_async
190190
url: "https://pub.dartlang.org"
191191
source: hosted
192-
version: "1.3.0"
192+
version: "1.2.0"
193193
ffi:
194194
dependency: transitive
195195
description:
@@ -297,21 +297,14 @@ packages:
297297
name: matcher
298298
url: "https://pub.dartlang.org"
299299
source: hosted
300-
version: "0.12.11"
301-
material_color_utilities:
302-
dependency: transitive
303-
description:
304-
name: material_color_utilities
305-
url: "https://pub.dartlang.org"
306-
source: hosted
307-
version: "0.1.4"
300+
version: "0.12.10"
308301
meta:
309302
dependency: transitive
310303
description:
311304
name: meta
312305
url: "https://pub.dartlang.org"
313306
source: hosted
314-
version: "1.7.0"
307+
version: "1.3.0"
315308
mime:
316309
dependency: transitive
317310
description:
@@ -332,7 +325,7 @@ packages:
332325
name: path
333326
url: "https://pub.dartlang.org"
334327
source: hosted
335-
version: "1.8.1"
328+
version: "1.8.0"
336329
pedantic:
337330
dependency: transitive
338331
description:
@@ -393,7 +386,7 @@ packages:
393386
name: source_span
394387
url: "https://pub.dartlang.org"
395388
source: hosted
396-
version: "1.8.2"
389+
version: "1.8.1"
397390
stack_trace:
398391
dependency: transitive
399392
description:
@@ -435,7 +428,7 @@ packages:
435428
name: test_api
436429
url: "https://pub.dartlang.org"
437430
source: hosted
438-
version: "0.4.9"
431+
version: "0.3.0"
439432
timing:
440433
dependency: transitive
441434
description:
@@ -456,7 +449,7 @@ packages:
456449
name: vector_math
457450
url: "https://pub.dartlang.org"
458451
source: hosted
459-
version: "2.1.2"
452+
version: "2.1.0"
460453
watcher:
461454
dependency: transitive
462455
description:
@@ -479,5 +472,5 @@ packages:
479472
source: hosted
480473
version: "3.1.0"
481474
sdks:
482-
dart: ">=2.17.0-0 <3.0.0"
475+
dart: ">=2.13.0 <3.0.0"
483476
flutter: ">=2.2.0"

dart_native/lib/src/android/runtime/functions.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final Pointer<Void> Function(
5757
Pointer<NativeFunction<InvokeCallback>>,
5858
int dartPort,
5959
int thread,
60-
bool isInterface) nativeInvoke =
60+
int isInterface) nativeInvoke =
6161
nativeDylib
6262
.lookup<
6363
NativeFunction<
@@ -72,7 +72,7 @@ final Pointer<Void> Function(
7272
Pointer<NativeFunction<InvokeCallback>>,
7373
Int64 dartPort,
7474
Int32 thread,
75-
Bool isInterface)>>('InvokeNativeMethod')
75+
Int32 isInterface)>>('InvokeNativeMethod')
7676
.asFunction();
7777

7878
// bind dart object lifecycle with java object

dart_native/lib/src/android/runtime/messenger.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ void _invokeCallback(Pointer<Void> result, Pointer<Utf8> method,
6868
}
6969

7070
/// remove assigned signature
71-
_assignedSignatureMap[method]?.forEach((ptr) {
72-
calloc.free(ptr);
73-
});
71+
_assignedSignatureMap[method]?.forEach(calloc.free);
7472
_assignedSignatureMap.remove(method);
7573

7674
calloc.free(typePtrs);
@@ -122,7 +120,7 @@ dynamic _doInvoke(
122120
callbackPtr,
123121
nativePort,
124122
thread.index,
125-
isInterface);
123+
isInterface ? 1 : 0);
126124

127125
dynamic result;
128126
if (callback == null) {
@@ -132,9 +130,7 @@ dynamic _doInvoke(
132130
.elementAt(args?.length ?? 0)
133131
.value
134132
.toDartString());
135-
assignedSignaturePtr?.forEach((ptr) {
136-
calloc.free(ptr);
137-
});
133+
assignedSignaturePtr?.forEach(calloc.free);
138134
calloc.free(nativeArguments.typePointers);
139135
}
140136
return result;

dart_native/lib/src/common/finalizer.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:ffi';
22

33
import 'package:dart_native/src/common/native_dylib.dart';
4-
import 'package:dart_native/src/darwin/common/callback_manager.dart';
54
import 'package:ffi/ffi.dart';
65

76
typedef DartFinalizerFunction = void Function();

dart_native/lib/src/common/native_dylib.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import 'dart:ffi';
22
import 'dart:io';
33

44
import 'package:dart_native/src/android/common/library.dart' as library_android
5-
show nativeDylib;
5+
show nativeDylib, nativePort;
6+
67
import 'package:dart_native/src/darwin/common/library.dart' as library_darwin
78
show nativeDylib;
9+
import 'package:dart_native/src/darwin/common/callback_manager.dart'
10+
as callback_darwin show nativePort;
811

912
DynamicLibrary? _nativeDylib;
1013
DynamicLibrary get nativeDylib {
@@ -22,3 +25,20 @@ DynamicLibrary get nativeDylib {
2225

2326
return _nativeDylib!;
2427
}
28+
29+
int _nativePort = 0;
30+
int get nativePort {
31+
if (_nativePort != 0) {
32+
return _nativePort;
33+
}
34+
35+
if (Platform.isIOS || Platform.isMacOS) {
36+
_nativePort = callback_darwin.nativePort;
37+
} else if (Platform.isAndroid) {
38+
_nativePort = library_android.nativePort;
39+
} else {
40+
throw 'Platform not supported: ${Platform.localeName}';
41+
}
42+
43+
return _nativePort;
44+
}

dart_native/lib/src/darwin/common/callback_register.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bool registerMethodCallback(
1818
.setCallbackForSelectorOnTarget(targetPtr, selectorPtr, function);
1919
List<String> dartTypes = dartTypeStringForFunction(function);
2020
List<String> nativeTypes = nativeTypeStringForDartTypes(dartTypes);
21-
bool returnString = nativeTypes.first == 'String';
21+
int returnString = nativeTypes.first == 'String' ? 1 : 0;
2222
int result = nativeAddMethod(
2323
targetPtr, selectorPtr, types, returnString, _callbackPtr, nativePort);
2424
return result != 0;

dart_native/lib/src/darwin/runtime/block.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@ class Block extends id {
6161
List<String> nativeTypes = nativeTypeStringForDartTypes(dartTypes);
6262
Pointer<Utf8> typeStringPtr = nativeTypes.join(', ').toNativeUtf8();
6363
Pointer<Void> blockPtr =
64-
blockCreate(typeStringPtr, _callbackPtr, shouldReturnAsync, nativePort);
64+
blockCreate(typeStringPtr, _callbackPtr, shouldReturnAsync ? 0 : 1, nativePort);
6565
assert(blockPtr != nullptr);
6666
if (blockPtr == nullptr) {
6767
return nilBlock;
6868
}
6969
int sequence = _blockSequence(blockPtr);
70-
Block result = Block.fromPointer(blockPtr);
70+
Block result = Block.fromPointer(blockPtr, function: function);
7171
calloc.free(typeStringPtr);
7272
result.types = dartTypes;
73-
result.function = function;
7473
result.shouldReturnAsync = shouldReturnAsync;
7574
result.typeEncodingsPtrPtr = _blockTypeEncodings(blockPtr);
7675
result.sequence = sequence;
@@ -84,7 +83,7 @@ class Block extends id {
8483
/// Creating a [Block] from a [Pointer].
8584
///
8685
/// [Block] created by this method do NOT have [function] property.
87-
Block.fromPointer(Pointer<Void> ptr) : super(ptr);
86+
Block.fromPointer(Pointer<Void> ptr, {this.function}) : super(ptr);
8887

8988
/// This [isa] block in iOS, but it's meaningless for a block created
9089
/// by Dart function.
@@ -134,12 +133,8 @@ class Block extends id {
134133
if (newPtr == pointer) {
135134
return this;
136135
}
137-
Block result = Block.fromPointer(newPtr);
138-
// Block created by function.
139-
if (function != null) {
140-
result.function = function;
141-
result.types = types;
142-
}
136+
Block result = Block.fromPointer(newPtr, function: function);
137+
result.types = types;
143138
return result;
144139
}
145140

dart_native/lib/src/darwin/runtime/internal/native_runtime.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ typedef AddMethodC = Int32 Function(
2121
Pointer<Void> target,
2222
Pointer<Void> selector,
2323
Pointer<Utf8> types,
24-
Bool returnString,
24+
Int32 returnString,
2525
Pointer<NativeFunction<MethodIMPCallbackC>> callback,
2626
Int64 dartPort);
2727
typedef AddMethodD = int Function(
2828
Pointer<Void> target,
2929
Pointer<Void> selector,
3030
Pointer<Utf8> types,
31-
bool returnString,
31+
int returnString,
3232
Pointer<NativeFunction<MethodIMPCallbackC>> callback,
3333
int dartPort);
3434
final AddMethodD nativeAddMethod =
@@ -107,12 +107,12 @@ typedef BlockCallbackC = Void Function(
107107
typedef BlockCreateC = Pointer<Void> Function(
108108
Pointer<Utf8> typeEncodings,
109109
Pointer<NativeFunction<BlockCallbackC>> callback,
110-
Bool shouldReturnAsync,
110+
Int32 shouldReturnAsync,
111111
Int64 dartPort);
112112
typedef BlockCreateD = Pointer<Void> Function(
113113
Pointer<Utf8> typeEncodings,
114114
Pointer<NativeFunction<BlockCallbackC>> callback,
115-
bool shouldReturnAsync,
115+
int shouldReturnAsync,
116116
int dartPort);
117117
final BlockCreateD blockCreate = nativeDylib
118118
.lookupFunction<BlockCreateC, BlockCreateD>('native_block_create');

0 commit comments

Comments
 (0)