-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
mock_sdk.dart
1665 lines (1299 loc) · 36.9 KB
/
mock_sdk.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:convert';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:meta/meta.dart';
final MockSdkLibrary _LIB_ASYNC = MockSdkLibrary('async', [
MockSdkLibraryUnit(
'async/async.dart',
'''
library dart.async;
import 'dart:_internal' show Since;
import 'dart:math';
part 'stream.dart';
abstract class Future<T> {
factory Future(FutureOr<T> computation()) {
throw 0;
}
factory Future.delayed(Duration duration, [FutureOr<T> computation()?]) {
throw 0;
}
factory Future.error(Object error, [StackTrace? stackTrace]) {
throw 0;
}
factory Future.microtask(FutureOr<T> computation()) {
throw 0;
}
factory Future.value([FutureOr<T>? result]) {
throw 0;
}
Future<T> catchError(Function onError, {bool test(Object error)});
Future<R> then<R>(FutureOr<R> onValue(T value), {Function? onError});
Future<T> whenComplete(action());
static Future<List<T>> wait<T>(Iterable<Future<T>> futures,
{void cleanUp(T successValue)?}) => throw 0;
}
abstract class FutureOr<T> {}
abstract class Completer<T> {
factory Completer() {
throw 0;
}
factory Completer.sync() {
throw 0;
}
Future<T> get future;
bool get isCompleted;
void complete([FutureOr<T>? value]);
void completeError(Object error, [StackTrace? stackTrace]);
}
abstract class Timer {
factory Timer(Duration duration, void Function() callback) {
throw 0;
}
static void run(void callback()) {}
}
@Since("2.15")
void unawaited(Future<void>? future) {}
''',
),
MockSdkLibraryUnit(
'async/stream.dart',
r'''
part of dart.async;
abstract class Stream<T> {
Stream();
factory Stream.fromIterable(Iterable<T> data) {
throw 0;
}
@Since("2.5")
factory Stream.value(T value) {
throw 0;
}
Future<T> get first;
StreamSubscription<T> listen(void onData(T event)?,
{Function? onError, void onDone()?, bool? cancelOnError});
Stream<T> handleError(Function onError, {bool test(dynamic error)});
}
abstract class StreamIterator<T> {}
abstract class StreamSubscription<T> {
bool get isPaused;
Future<E> asFuture<E>([E? futureValue]);
Future cancel();
void onData(void handleData(T data)?);
void onError(Function? handleError);
void onDone(void handleDone()?);
void pause([Future<void>? resumeSignal]);
void resume();
}
abstract class StreamTransformer<S, T> {}
''',
)
]);
final MockSdkLibrary _LIB_ASYNC2 = MockSdkLibrary('async2', [
MockSdkLibraryUnit(
'async2/async2.dart',
'''
library dart.async2;
class Future {}
''',
)
]);
final MockSdkLibrary _LIB_COLLECTION = MockSdkLibrary('collection', [
MockSdkLibraryUnit(
'collection/collection.dart',
'''
library dart.collection;
abstract class HashMap<K, V> implements Map<K, V> {
external factory HashMap(
{bool Function(K, K)? equals,
int Function(K)? hashCode,
bool Function(dynamic)? isValidKey});
external factory HashMap.identity();
factory HashMap.from(Map<dynamic, dynamic> other) {
throw 0;
}
factory HashMap.of(Map<K, V> other) {
throw 0;
}
factory HashMap.fromIterable(Iterable iterable,
{K Function(dynamic element)? key, V Function(dynamic element)? value}) {
throw 0;
}
factory HashMap.fromIterables(Iterable<K> keys, Iterable<V> values) {
throw 0;
}
@Since("2.1")
factory HashMap.fromEntries(Iterable<MapEntry<K, V>> entries) {
throw 0;
}
}
abstract mixin class IterableMixin<E> implements Iterable<E> { }
abstract class LinkedHashMap<K, V> implements Map<K, V> {
external factory LinkedHashMap(
{bool Function(K, K)? equals,
int Function(K)? hashCode,
bool Function(dynamic)? isValidKey});
external factory LinkedHashMap.identity();
factory LinkedHashMap.from(Map<dynamic, dynamic> other) {
throw 0;
}
factory LinkedHashMap.of(Map<K, V> other) {
throw 0;
}
factory LinkedHashMap.fromIterable(Iterable iterable,
{K Function(dynamic element)? key, V Function(dynamic element)? value}) {
throw 0;
}
factory LinkedHashMap.fromIterables(Iterable<K> keys, Iterable<V> values) {
throw 0;
}
@Since("2.1")
factory LinkedHashMap.fromEntries(Iterable<MapEntry<K, V>> entries) {
throw 0;
}
}
abstract class LinkedHashSet<E> implements Set<E> {
external factory LinkedHashSet(
{bool Function(E, E)? equals,
int Function(E)? hashCode,
bool Function(dynamic)? isValidKey});
external factory LinkedHashSet.identity();
factory LinkedHashSet.from(Iterable<dynamic> elements) {
throw 0;
}
factory LinkedHashSet.of(Iterable<E> elements) {
throw 0;
}
}
abstract base mixin class LinkedListEntry<E extends LinkedListEntry<E>> { }
abstract mixin class ListMixin<E> implements List<E> { }
abstract mixin class MapMixin<K, V> implements Map<K, V> { }
abstract mixin class SetMixin<E> implements Set<E> { }
abstract class Queue<E> implements Iterable<E> {
bool remove(Object? value);
}
''',
)
]);
final MockSdkLibrary _LIB_CONVERT = MockSdkLibrary(
'convert',
[
MockSdkLibraryUnit(
'convert/convert.dart',
'''
library dart.convert;
import 'dart:async';
abstract class Converter<S, T> implements StreamTransformer {}
abstract class Encoding {}
class JsonDecoder extends Converter<String, Object> {}
const JsonCodec json = JsonCodec();
class JsonCodec {
const JsonCodec();
String encode(Object? value, {Object? toEncodable(dynamic object)?}) => '';
}
abstract mixin class StringConversionSink { }
typedef StringConversionSinkMixin = StringConversionSink;
String jsonEncode(Object? object,
{Object? toEncodable(Object? nonEncodable)?}) => '';
''',
)
],
);
final MockSdkLibrary _LIB_CORE = MockSdkLibrary(
'core',
[
MockSdkLibraryUnit(
'core/core.dart',
'''
library dart.core;
import "dart:_internal" hide Symbol;
import "dart:_internal" as internal show Symbol;
@Since("2.1")
export 'dart:async' show Future, Stream;
const deprecated = const Deprecated("next release");
const override = const _Override();
external bool identical(Object? a, Object? b);
void print(Object? object) {}
class ArgumentError extends Error {
ArgumentError([message]);
@Since("2.1")
static T checkNotNull<@Since("2.8") T>(T? argument, [String? name]) => argument!;
}
abstract final class BigInt implements Comparable<BigInt> {
int compareTo(BigInt other) => 0;
static BigInt parse(String source, {int? radix}) => throw 0;
}
abstract final class bool extends Object {
external const factory bool.fromEnvironment(String name,
{bool defaultValue = false});
external const factory bool.hasEnvironment(String name);
@Since("2.1")
bool operator &(bool other);
@Since("2.1")
bool operator |(bool other);
@Since("2.1")
bool operator ^(bool other);
}
abstract class Comparable<T> {
int compareTo(T other);
static int compare(Comparable a, Comparable b) => a.compareTo(b);
}
typedef Comparator<T> = int Function(T a, T b);
class DateTime extends Object {
external DateTime._now();
DateTime.now() : this._now();
external bool isBefore(DateTime other);
external int get millisecondsSinceEpoch;
}
class Deprecated extends Object {
final String message;
const Deprecated(this.message);
}
class pragma {
final String name;
final Object? options;
const pragma(this.name, [this.options]);
}
abstract final class double extends num {
static const double nan = 0.0 / 0.0;
static const double infinity = 1.0 / 0.0;
static const double negativeInfinity = -infinity;
static const double minPositive = 5e-324;
static const double maxFinite = 1.7976931348623157e+308;
bool get isNaN;
double get sign;
double operator %(num other);
double operator *(num other);
double operator +(num other);
double operator -(num other);
double operator -();
double operator /(num other);
int operator ~/(num other);
double abs();
int ceil();
double ceilToDouble();
int floor();
double floorToDouble();
double remainder(num other);
int round();
double roundToDouble();
int truncate();
double truncateToDouble();
external static double parse(String source,
[@deprecated double onError(String source)?]);
external static double? tryParse(String source);
}
class Duration implements Comparable<Duration> {
static const Duration zero = Duration(seconds: 0);
const Duration({int days = 0,
int hours = 0,
int minutes = 0,
int seconds = 0,
int milliseconds = 0,
int microseconds = 0});
int compareTo(Duration other) => 0;
}
@Since("2.14")
abstract class Enum {
int get index; // Enum
String get _name;
}
abstract class _Enum implements Enum {
final int index;
final String _name;
const _Enum(this.index, this._name);
}
class Error {
Error();
static String safeToString(Object? object) => '';
external StackTrace? get stackTrace;
}
class Exception {
factory Exception([var message]) {
throw 0;
}
}
class FormatException implements Exception {}
abstract final class Function {}
abstract final class int extends num {
external const factory int.fromEnvironment(String name,
{int defaultValue = 0});
bool get isEven => false;
bool get isNegative;
bool get isOdd;
int get sign;
int operator &(int other);
int operator -();
int operator <<(int shiftAmount);
int operator >>(int shiftAmount);
int operator >>>(int shiftAmount);
int operator ^(int other);
int operator |(int other);
int operator ~();
int abs();
int ceil();
int gcd(int other);
String toString();
int truncate();
external static int parse(String source,
{int? radix, @deprecated int onError(String source)?});
external static int? tryParse(String source, {int? radix});
}
abstract class Invocation {}
abstract class Iterable<E> {
E get first;
bool get isEmpty;
bool get isNotEmpty;
Iterator<E> get iterator;
int get length;
const Iterable();
const factory Iterable.empty() = EmptyIterable<E>;
bool contains(Object? element);
Iterable<T> expand<T>(Iterable<T> f(E element));
E firstWhere(bool test(E element), {E orElse()?});
R fold<R>(R initialValue, R combine(R previousValue, E element));
void forEach(void f(E element));
E lastWhere(bool test(E element), {E orElse()?});
Iterable<R> map<R>(R f(E e));
E singleWhere(bool test(E element), {E orElse()?});
List<E> toList({bool growable = true});
Set<E> toSet();
Iterable<E> where(bool test(E element));
Iterable<T> whereType<T>();
}
abstract class Iterator<E> {
E get current;
bool moveNext();
}
class List<E> implements Iterable<E> {
external factory List.filled(int length, E fill, {bool growable = false});
@Since("2.9")
external factory List.empty({bool growable = false});
external factory List.from(Iterable elements, {bool growable = true});
external factory List.of(Iterable<E> elements, {bool growable = true});
external factory List.generate(int length, E generator(int index),
{bool growable = true});
external factory List.unmodifiable(Iterable elements);
E get last => throw 0;
set length(int newLength) {}
E operator [](int index) => throw 0;
void operator []=(int index, E value) {}
void set first(E value) {}
void add(E value) {}
void addAll(Iterable<E> iterable) {}
Map<int, E> asMap() => throw 0;
void clear() {}
int indexOf(E element, [int start = 0]);
bool remove(Object? value);
E removeLast() => throw 0;
noSuchMethod(Invocation invocation) => null;
}
abstract class Map<K, V> {
external factory Map();
external factory Map.from();
external Map.of(Map<K, V> other);
external factory Map.unmodifiable(Map<dynamic, dynamic> other);
external factory Map.identity();
external factory Map.fromIterable(Iterable iterable,
{K key(element)?, V value(element)?});
external factory Map.fromIterables(Iterable<K> keys, Iterable<V> values);
external factory Map.fromEntries(Iterable<MapEntry<K, V>> entries);
Iterable<K> get keys;
bool get isEmpty;
bool get isNotEmpty;
int get length => 0;
Iterable<V> get values;
V? operator [](Object? key);
void operator []=(K key, V value);
void addAll(Map<K, V> other);
Map<RK, RV> cast<RK, RV>();
bool containsKey(Object? key);
bool containsValue(Object? value);
void forEach(void action(K key, V value));
V putIfAbsent(K key, V ifAbsent());
V? remove(Object? key);
}
final class Null extends Object {
factory Null._uninstantiable() {
throw 0;
}
}
final class MapEntry<K, V> {
final K key;
final V value;
const factory MapEntry(K key, V value) = MapEntry<K, V>._;
const MapEntry._(this.key, this.value);
}
sealed class num implements Comparable<num> {
num operator %(num other);
num operator *(num other);
num operator +(num other);
num operator -(num other);
num operator -();
double operator /(num other);
bool operator <(num other);
int operator <<(int other);
bool operator <=(num other);
bool operator ==(Object other);
bool operator >(num other);
bool operator >=(num other);
int operator >>(int other);
int operator ^(int other);
int operator |(int other);
int operator ~();
int operator ~/(num other);
num abs();
num clamp(num lowerLimit, num upperLimit);
int floor();
num remainder(num other);
int round();
double toDouble();
int toInt();
}
abstract class Match {
int get start;
}
class Object {
const Object();
external int get hashCode;
external Type get runtimeType;
external bool operator ==(Object other);
external String toString();
external dynamic noSuchMethod(Invocation invocation);
@Since("2.14")
static int hash(Object? object1, Object? object2) => 0;
@Since("2.14")
static int hashAll(Iterable<Object?> objects) => 0;
@Since("2.14")
static int hashAllUnordered(Iterable<Object?> objects) => 0;
}
abstract class Pattern {
Iterable<Match> allMatches(String string, [int start = 0]);
}
abstract final class Record {}
abstract class RegExp implements Pattern {
external factory RegExp(String source, {bool unicode = false});
}
abstract class Set<E> implements Iterable<E> {
external factory Set();
external factory Set.identity();
external factory Set.from(Iterable elements);
external factory Set.of(Iterable<E> elements);
Set<R> cast<R>();
bool add(E value);
void addAll(Iterable<E> elements);
bool containsAll(Iterable<Object?> other);
Set<E> difference(Set<Object?> other);
Set<E> intersection(Set<Object?> other);
E? lookup(Object? object);
bool remove(Object? value);
void removeAll(Iterable<Object?> elements);
void retainAll(Iterable<Object?> elements);
static Set<T> castFrom<S, T>(Set<S> source, {Set<R> Function<R>()? newSet}) =>
throw '';
}
abstract class Sink {
void close();
}
class StackTrace {}
abstract final class String implements Comparable<String>, Pattern {
external factory String.fromCharCodes(Iterable<int> charCodes,
[int start = 0, int? end]);
external factory String.fromCharCode(int charCode);
external const factory String.fromEnvironment(String name,
{String defaultValue = ""});
List<int> get codeUnits;
bool get isEmpty => false;
bool get isNotEmpty => false;
int get length => 0;
bool operator ==(Object other);
String operator [](int index);
String operator +(String other);
String operator *(int times);
int codeUnitAt(int index);
bool contains(String other, [int startIndex = 0]);
int indexOf(Pattern pattern, [int start = 0]);
int lastIndexOf(Pattern pattern, [int? start]);
bool startsWith(Pattern pattern, [int index = 0]);
List<String> split(Pattern pattern);
String splitMapJoin(Pattern pattern,
{String Function(Match)? onMatch, String Function(String)? onNonMatch});
String substring(int startIndex, [int? endIndex]);
String toLowerCase();
String toUpperCase();
}
class StringBuffer implements StringSink {
external void write(Object? object);
}
abstract interface class StringSink {}
class Symbol {
const factory Symbol(String name) = internal.Symbol;
}
class Type {}
class TypeError extends Error {}
class UnsupportedError {
UnsupportedError(String message);
}
class Uri {
factory Uri({
String? scheme,
String? userInfo,
String? host,
int? port,
String? path,
Iterable<String>? pathSegments,
String? query,
Map<String, dynamic /*String?|Iterable<String>*/ >? queryParameters,
String? fragment,
}) {
throw 0;
}
static List<int> parseIPv6Address(String host, [int start = 0, int? end]) {
throw 0;
}
}
class _Override {
const _Override();
}
@Since("2.15")
extension EnumName on Enum {
String get name => _name;
}
''',
)
],
);
final MockSdkLibrary _LIB_FFI = MockSdkLibrary('ffi', [
MockSdkLibraryUnit(
'ffi/ffi.dart',
'''
@Since('2.6')
library dart.ffi;
abstract final class NativeType {}
@Since('3.4')
abstract final class SizedNativeType implements NativeType {}
@Since('2.9')
abstract final class Handle implements NativeType {}
@Since('2.12')
abstract base class Opaque implements NativeType {}
final class Void implements NativeType {}
final class Int8 implements SizedNativeType {
const Int8();
}
final class Uint8 implements SizedNativeType {
const Uint8();
}
final class Int16 implements SizedNativeType {
const Int16();
}
final class Uint16 implements SizedNativeType {
const Uint16();
}
final class Int32 implements SizedNativeType {
const Int32();
}
final class Uint32 implements SizedNativeType {
const Uint32();
}
final class Int64 implements SizedNativeType {
const Int64();
}
final class Uint64 implements SizedNativeType {
const Uint64();
}
final class Float implements SizedNativeType {
const Float();
}
final class Double implements SizedNativeType {
const Double();
}
@AbiSpecificIntegerMapping({
Abi.androidArm: Int32(),
Abi.androidArm64: Int64(),
Abi.androidIA32: Int32(),
Abi.androidX64: Int64(),
Abi.androidRiscv64: Int64(),
Abi.fuchsiaArm64: Int64(),
Abi.fuchsiaX64: Int64(),
Abi.fuchsiaRiscv64: Int64(),
Abi.iosArm: Int32(),
Abi.iosArm64: Int64(),
Abi.iosX64: Int64(),
Abi.linuxArm: Int32(),
Abi.linuxArm64: Int64(),
Abi.linuxIA32: Int32(),
Abi.linuxX64: Int64(),
Abi.linuxRiscv32: Int32(),
Abi.linuxRiscv64: Int64(),
Abi.macosArm64: Int64(),
Abi.macosX64: Int64(),
Abi.windowsArm64: Int64(),
Abi.windowsIA32: Int32(),
Abi.windowsX64: Int64(),
})
final class IntPtr extends AbiSpecificInteger {
const IntPtr();
}
final class Pointer<T extends NativeType> implements SizedNativeType {
external factory Pointer.fromAddress(int ptr);
static Pointer<NativeFunction<T>> fromFunction<T extends Function>(
@DartRepresentationOf("T") Function f,
[Object exceptionalReturn]) {}
}
final Pointer<Never> nullptr = Pointer.fromAddress(0);
class NativeCallable<T extends Function> {
NativeCallable.isolateLocal(
@DartRepresentationOf("T") Function callback,
{Object? exceptionalReturn}) {}
NativeCallable.listener(@DartRepresentationOf("T") Function callback) {}
Pointer<NativeFunction<T>> get nativeFunction;
void close();
}
extension NativeFunctionPointer<NF extends Function>
on Pointer<NativeFunction<NF>> {
external DF asFunction<DF extends Function>({bool isLeaf = false});
}
abstract final class _Compound implements NativeType {}
@Since('2.12')
abstract base class Struct extends _Compound implements SizedNativeType {}
@Since('2.14')
abstract base class Union extends _Compound implements SizedNativeType {}
@Since('2.13')
final class Packed {
final int memberAlignment;
const Packed(this.memberAlignment);
}
abstract final class DynamicLibrary {
external factory DynamicLibrary.open(String name);
external Pointer<T> lookup<T extends NativeType>(String symbolName);
}
extension DynamicLibraryExtension on DynamicLibrary {
external F lookupFunction<T extends Function, F extends Function>(
String symbolName, {bool isLeaf:false});
}
abstract final class NativeFunction<T extends Function> implements NativeType {}
final class DartRepresentationOf {
const DartRepresentationOf(String nativeType);
}
@Since('2.13')
final class Array<T extends NativeType> extends _Compound {
const factory Array(int dimension1,
[int dimension2,
int dimension3,
int dimension4,
int dimension5]) = _ArraySize<T>;
const factory Array.multi(List<int> dimensions) = _ArraySize<T>.multi;
}
final class _ArraySize<T extends NativeType> implements Array<T> {
final int? dimension1;
final int? dimension2;
final int? dimension3;
final int? dimension4;
final int? dimension5;
final List<int>? dimensions;
const _ArraySize(this.dimension1,
[this.dimension2, this.dimension3, this.dimension4, this.dimension5])
: dimensions = null;
const _ArraySize.multi(this.dimensions)
: dimension1 = null,
dimension2 = null,
dimension3 = null,
dimension4 = null,
dimension5 = null;
}
extension StructPointer<T extends Struct> on Pointer<T> {
external T get ref;
external T operator [](int index);
}
@Since('2.19')
final class Native<T> {
final String? symbol;
final String? asset;
final bool isLeaf;
const Native({
this.asset,
this.isLeaf: false,
this.symbol,
});
external static Pointer<T> addressOf<T extends NativeType>(
@DartRepresentationOf('T') Object object);
}
final class DefaultAsset {
final String id;
const DefaultAsset(this.id);
}
final class Asset {
final String asset;
const Asset(this.asset);
}
final class Abi {
static const androidArm = _androidArm;
static const androidArm64 = _androidArm64;
static const androidIA32 = _androidIA32;
static const linuxX64 = _linuxX64;
static const macosX64 = _macosX64;
static const _androidArm = Abi._(_Architecture.arm, _OS.android);
static const _androidArm64 = Abi._(_Architecture.arm64, _OS.android);
static const _androidIA32 = Abi._(_Architecture.ia32, _OS.android);
static const _linuxX64 = Abi._(_Architecture.x64, _OS.linux);
static const _macosX64 = Abi._(_Architecture.x64, _OS.macos);
final _OS _os;
final _Architecture _architecture;
const Abi._(this._architecture, this._os);
}
enum _Architecture {
arm,
arm64,
ia32,
x64,
}
enum _OS {
android,
fuchsia,
ios,
linux,
macos,
windows,
}
@Since('2.16')
base class AbiSpecificInteger implements SizedNativeType {
const AbiSpecificInteger();
}
@Since('2.16')
final class AbiSpecificIntegerMapping {
final Map<Abi, NativeType> mapping;
const AbiSpecificIntegerMapping(this.mapping);
}