diff --git a/CHANGELOG.md b/CHANGELOG.md
index be98e9ad..e8e031cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,39 @@
+# 4.0.0-dev.0
+- Added support for generating typedefs (_referred_ typedefs only).
+
+
+Example C Code |
+Generated Dart typedef |
+
+
+
+
+```C++
+typedef struct A{
+ ...
+} TA, *PA;
+
+TA func(PA ptr);
+```
+ |
+
+
+```dart
+class A extends ffi.Struct {...}
+typedef TA = A;
+typedef PA = ffi.Pointer;
+TA func(PA ptr){...}
+```
+ |
+
+
+
+- All declarations that are excluded by the user are now only included if being
+used somewhere.
+- Improved struct/union include/exclude. These declarations can now be targetted
+by their actual name, or if they are unnamed then by the name of the first
+typedef that refers to them.
+
# 3.1.0-dev.1
- Users can now specify exact path to dynamic library in `llvm-path`.
diff --git a/README.md b/README.md
index 10911df5..25d0d8d8 100644
--- a/README.md
+++ b/README.md
@@ -36,11 +36,9 @@ class NativeLibrary {
return _sum(a, b);
}
- late final _sum_ptr = _lookup>('sum');
- late final _dart_sum _sum = _sum_ptr.asFunction<_dart_sum>();
+ late final _sum_ptr = _lookup>('sum');
+ late final _sum = _sum_ptr.asFunction();
}
-typedef _c_sum = Int32 Function(Int32 a, Int32 b);
-typedef _dart_sum = int Function(int a, int b);
```
## Using this package
- Add `ffigen` under `dev_dependencies` in your `pubspec.yaml`.
@@ -233,6 +231,27 @@ globals:
# Removes '_' from
# beginning of a name.
'_(.*)': '$1'
+```
+
+
+
+ typedefs |
+ Filters for referred typedefs.
+ Options -
+ - Include/Exclude (referred typedefs only).
+ - Rename typedefs.
+ Note: Typedefs that are not referred to anywhere will not be generated.
+ |
+
+
+```yaml
+typedefs:
+ exclude:
+ # Typedefs starting with `p` are not generated.
+ - 'p.*'
+ rename:
+ # Removes '_' from beginning of a typedef.
+ '_(.*)': '$1'
```
|
@@ -511,3 +530,16 @@ functions:
- 'myFunc'
- '.*' # Do this to expose all pointers.
```
+
+### How are Structs/Unions/Enums that are reffered to via typedefs handled?
+
+Named declarations use their own names even when inside another typedef.
+However, unnamed declarations inside typedefs take the name of the _first_ typedef
+that refers to them.
+
+### Why are some typedefs not generated?
+
+The following typedefs are not generated -
+- They are not referred to anywhere in the included declarations.
+- They refer to a struct/union having the same name as itself.
+- They refer to a boolean, enum, inline array, Handle or any unsupported type.
diff --git a/example/c_json/cjson_generated_bindings.dart b/example/c_json/cjson_generated_bindings.dart
index 2b9d0a8a..d0fb894d 100644
--- a/example/c_json/cjson_generated_bindings.dart
+++ b/example/c_json/cjson_generated_bindings.dart
@@ -43,9 +43,10 @@ class CJson {
}
late final _cJSON_Version_ptr =
- _lookup>('cJSON_Version');
- late final _dart_cJSON_Version _cJSON_Version =
- _cJSON_Version_ptr.asFunction<_dart_cJSON_Version>();
+ _lookup Function()>>(
+ 'cJSON_Version');
+ late final _cJSON_Version =
+ _cJSON_Version_ptr.asFunction Function()>();
void cJSON_InitHooks(
ffi.Pointer hooks,
@@ -56,9 +57,10 @@ class CJson {
}
late final _cJSON_InitHooks_ptr =
- _lookup>('cJSON_InitHooks');
- late final _dart_cJSON_InitHooks _cJSON_InitHooks =
- _cJSON_InitHooks_ptr.asFunction<_dart_cJSON_InitHooks>();
+ _lookup)>>(
+ 'cJSON_InitHooks');
+ late final _cJSON_InitHooks = _cJSON_InitHooks_ptr
+ .asFunction)>();
ffi.Pointer cJSON_Parse(
ffi.Pointer value,
@@ -68,10 +70,11 @@ class CJson {
);
}
- late final _cJSON_Parse_ptr =
- _lookup>('cJSON_Parse');
- late final _dart_cJSON_Parse _cJSON_Parse =
- _cJSON_Parse_ptr.asFunction<_dart_cJSON_Parse>();
+ late final _cJSON_Parse_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(ffi.Pointer)>>('cJSON_Parse');
+ late final _cJSON_Parse = _cJSON_Parse_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_ParseWithOpts(
ffi.Pointer value,
@@ -85,11 +88,15 @@ class CJson {
);
}
- late final _cJSON_ParseWithOpts_ptr =
- _lookup>(
- 'cJSON_ParseWithOpts');
- late final _dart_cJSON_ParseWithOpts _cJSON_ParseWithOpts =
- _cJSON_ParseWithOpts_ptr.asFunction<_dart_cJSON_ParseWithOpts>();
+ late final _cJSON_ParseWithOpts_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer,
+ ffi.Pointer>,
+ cJSON_bool)>>('cJSON_ParseWithOpts');
+ late final _cJSON_ParseWithOpts = _cJSON_ParseWithOpts_ptr.asFunction<
+ ffi.Pointer Function(
+ ffi.Pointer, ffi.Pointer>, int)>();
ffi.Pointer cJSON_Print(
ffi.Pointer item,
@@ -99,10 +106,11 @@ class CJson {
);
}
- late final _cJSON_Print_ptr =
- _lookup>('cJSON_Print');
- late final _dart_cJSON_Print _cJSON_Print =
- _cJSON_Print_ptr.asFunction<_dart_cJSON_Print>();
+ late final _cJSON_Print_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(ffi.Pointer)>>('cJSON_Print');
+ late final _cJSON_Print = _cJSON_Print_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_PrintUnformatted(
ffi.Pointer item,
@@ -112,11 +120,12 @@ class CJson {
);
}
- late final _cJSON_PrintUnformatted_ptr =
- _lookup>(
- 'cJSON_PrintUnformatted');
- late final _dart_cJSON_PrintUnformatted _cJSON_PrintUnformatted =
- _cJSON_PrintUnformatted_ptr.asFunction<_dart_cJSON_PrintUnformatted>();
+ late final _cJSON_PrintUnformatted_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer)>>('cJSON_PrintUnformatted');
+ late final _cJSON_PrintUnformatted = _cJSON_PrintUnformatted_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_PrintBuffered(
ffi.Pointer item,
@@ -130,11 +139,12 @@ class CJson {
);
}
- late final _cJSON_PrintBuffered_ptr =
- _lookup>(
- 'cJSON_PrintBuffered');
- late final _dart_cJSON_PrintBuffered _cJSON_PrintBuffered =
- _cJSON_PrintBuffered_ptr.asFunction<_dart_cJSON_PrintBuffered>();
+ late final _cJSON_PrintBuffered_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(ffi.Pointer, ffi.Int32,
+ cJSON_bool)>>('cJSON_PrintBuffered');
+ late final _cJSON_PrintBuffered = _cJSON_PrintBuffered_ptr.asFunction<
+ ffi.Pointer Function(ffi.Pointer, int, int)>();
int cJSON_PrintPreallocated(
ffi.Pointer item,
@@ -150,11 +160,12 @@ class CJson {
);
}
- late final _cJSON_PrintPreallocated_ptr =
- _lookup>(
- 'cJSON_PrintPreallocated');
- late final _dart_cJSON_PrintPreallocated _cJSON_PrintPreallocated =
- _cJSON_PrintPreallocated_ptr.asFunction<_dart_cJSON_PrintPreallocated>();
+ late final _cJSON_PrintPreallocated_ptr = _lookup<
+ ffi.NativeFunction<
+ cJSON_bool Function(ffi.Pointer, ffi.Pointer,
+ ffi.Int32, cJSON_bool)>>('cJSON_PrintPreallocated');
+ late final _cJSON_PrintPreallocated = _cJSON_PrintPreallocated_ptr.asFunction<
+ int Function(ffi.Pointer, ffi.Pointer, int, int)>();
void cJSON_Delete(
ffi.Pointer item,
@@ -165,9 +176,10 @@ class CJson {
}
late final _cJSON_Delete_ptr =
- _lookup>('cJSON_Delete');
- late final _dart_cJSON_Delete _cJSON_Delete =
- _cJSON_Delete_ptr.asFunction<_dart_cJSON_Delete>();
+ _lookup)>>(
+ 'cJSON_Delete');
+ late final _cJSON_Delete =
+ _cJSON_Delete_ptr.asFunction)>();
int cJSON_GetArraySize(
ffi.Pointer array,
@@ -178,9 +190,10 @@ class CJson {
}
late final _cJSON_GetArraySize_ptr =
- _lookup>('cJSON_GetArraySize');
- late final _dart_cJSON_GetArraySize _cJSON_GetArraySize =
- _cJSON_GetArraySize_ptr.asFunction<_dart_cJSON_GetArraySize>();
+ _lookup)>>(
+ 'cJSON_GetArraySize');
+ late final _cJSON_GetArraySize =
+ _cJSON_GetArraySize_ptr.asFunction)>();
ffi.Pointer cJSON_GetArrayItem(
ffi.Pointer array,
@@ -192,10 +205,12 @@ class CJson {
);
}
- late final _cJSON_GetArrayItem_ptr =
- _lookup>('cJSON_GetArrayItem');
- late final _dart_cJSON_GetArrayItem _cJSON_GetArrayItem =
- _cJSON_GetArrayItem_ptr.asFunction<_dart_cJSON_GetArrayItem>();
+ late final _cJSON_GetArrayItem_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer, ffi.Int32)>>('cJSON_GetArrayItem');
+ late final _cJSON_GetArrayItem = _cJSON_GetArrayItem_ptr
+ .asFunction Function(ffi.Pointer, int)>();
ffi.Pointer cJSON_GetObjectItem(
ffi.Pointer object,
@@ -207,11 +222,12 @@ class CJson {
);
}
- late final _cJSON_GetObjectItem_ptr =
- _lookup>(
- 'cJSON_GetObjectItem');
- late final _dart_cJSON_GetObjectItem _cJSON_GetObjectItem =
- _cJSON_GetObjectItem_ptr.asFunction<_dart_cJSON_GetObjectItem>();
+ late final _cJSON_GetObjectItem_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(ffi.Pointer,
+ ffi.Pointer)>>('cJSON_GetObjectItem');
+ late final _cJSON_GetObjectItem = _cJSON_GetObjectItem_ptr.asFunction<
+ ffi.Pointer Function(ffi.Pointer, ffi.Pointer)>();
ffi.Pointer cJSON_GetObjectItemCaseSensitive(
ffi.Pointer object,
@@ -223,12 +239,14 @@ class CJson {
);
}
- late final _cJSON_GetObjectItemCaseSensitive_ptr =
- _lookup>(
- 'cJSON_GetObjectItemCaseSensitive');
- late final _dart_cJSON_GetObjectItemCaseSensitive
- _cJSON_GetObjectItemCaseSensitive = _cJSON_GetObjectItemCaseSensitive_ptr
- .asFunction<_dart_cJSON_GetObjectItemCaseSensitive>();
+ late final _cJSON_GetObjectItemCaseSensitive_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(ffi.Pointer,
+ ffi.Pointer)>>('cJSON_GetObjectItemCaseSensitive');
+ late final _cJSON_GetObjectItemCaseSensitive =
+ _cJSON_GetObjectItemCaseSensitive_ptr.asFunction<
+ ffi.Pointer Function(
+ ffi.Pointer, ffi.Pointer)>();
int cJSON_HasObjectItem(
ffi.Pointer object,
@@ -240,20 +258,22 @@ class CJson {
);
}
- late final _cJSON_HasObjectItem_ptr =
- _lookup>(
- 'cJSON_HasObjectItem');
- late final _dart_cJSON_HasObjectItem _cJSON_HasObjectItem =
- _cJSON_HasObjectItem_ptr.asFunction<_dart_cJSON_HasObjectItem>();
+ late final _cJSON_HasObjectItem_ptr = _lookup<
+ ffi.NativeFunction<
+ cJSON_bool Function(ffi.Pointer,
+ ffi.Pointer)>>('cJSON_HasObjectItem');
+ late final _cJSON_HasObjectItem = _cJSON_HasObjectItem_ptr
+ .asFunction, ffi.Pointer)>();
ffi.Pointer cJSON_GetErrorPtr() {
return _cJSON_GetErrorPtr();
}
late final _cJSON_GetErrorPtr_ptr =
- _lookup>('cJSON_GetErrorPtr');
- late final _dart_cJSON_GetErrorPtr _cJSON_GetErrorPtr =
- _cJSON_GetErrorPtr_ptr.asFunction<_dart_cJSON_GetErrorPtr>();
+ _lookup Function()>>(
+ 'cJSON_GetErrorPtr');
+ late final _cJSON_GetErrorPtr =
+ _cJSON_GetErrorPtr_ptr.asFunction Function()>();
ffi.Pointer cJSON_GetStringValue(
ffi.Pointer item,
@@ -263,11 +283,12 @@ class CJson {
);
}
- late final _cJSON_GetStringValue_ptr =
- _lookup>(
- 'cJSON_GetStringValue');
- late final _dart_cJSON_GetStringValue _cJSON_GetStringValue =
- _cJSON_GetStringValue_ptr.asFunction<_dart_cJSON_GetStringValue>();
+ late final _cJSON_GetStringValue_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer)>>('cJSON_GetStringValue');
+ late final _cJSON_GetStringValue = _cJSON_GetStringValue_ptr
+ .asFunction Function(ffi.Pointer)>();
int cJSON_IsInvalid(
ffi.Pointer item,
@@ -278,9 +299,10 @@ class CJson {
}
late final _cJSON_IsInvalid_ptr =
- _lookup>('cJSON_IsInvalid');
- late final _dart_cJSON_IsInvalid _cJSON_IsInvalid =
- _cJSON_IsInvalid_ptr.asFunction<_dart_cJSON_IsInvalid>();
+ _lookup)>>(
+ 'cJSON_IsInvalid');
+ late final _cJSON_IsInvalid =
+ _cJSON_IsInvalid_ptr.asFunction)>();
int cJSON_IsFalse(
ffi.Pointer item,
@@ -291,9 +313,10 @@ class CJson {
}
late final _cJSON_IsFalse_ptr =
- _lookup>('cJSON_IsFalse');
- late final _dart_cJSON_IsFalse _cJSON_IsFalse =
- _cJSON_IsFalse_ptr.asFunction<_dart_cJSON_IsFalse>();
+ _lookup)>>(
+ 'cJSON_IsFalse');
+ late final _cJSON_IsFalse =
+ _cJSON_IsFalse_ptr.asFunction)>();
int cJSON_IsTrue(
ffi.Pointer item,
@@ -304,9 +327,10 @@ class CJson {
}
late final _cJSON_IsTrue_ptr =
- _lookup>('cJSON_IsTrue');
- late final _dart_cJSON_IsTrue _cJSON_IsTrue =
- _cJSON_IsTrue_ptr.asFunction<_dart_cJSON_IsTrue>();
+ _lookup)>>(
+ 'cJSON_IsTrue');
+ late final _cJSON_IsTrue =
+ _cJSON_IsTrue_ptr.asFunction)>();
int cJSON_IsBool(
ffi.Pointer item,
@@ -317,9 +341,10 @@ class CJson {
}
late final _cJSON_IsBool_ptr =
- _lookup>('cJSON_IsBool');
- late final _dart_cJSON_IsBool _cJSON_IsBool =
- _cJSON_IsBool_ptr.asFunction<_dart_cJSON_IsBool>();
+ _lookup)>>(
+ 'cJSON_IsBool');
+ late final _cJSON_IsBool =
+ _cJSON_IsBool_ptr.asFunction)>();
int cJSON_IsNull(
ffi.Pointer item,
@@ -330,9 +355,10 @@ class CJson {
}
late final _cJSON_IsNull_ptr =
- _lookup>('cJSON_IsNull');
- late final _dart_cJSON_IsNull _cJSON_IsNull =
- _cJSON_IsNull_ptr.asFunction<_dart_cJSON_IsNull>();
+ _lookup)>>(
+ 'cJSON_IsNull');
+ late final _cJSON_IsNull =
+ _cJSON_IsNull_ptr.asFunction)>();
int cJSON_IsNumber(
ffi.Pointer item,
@@ -343,9 +369,10 @@ class CJson {
}
late final _cJSON_IsNumber_ptr =
- _lookup>('cJSON_IsNumber');
- late final _dart_cJSON_IsNumber _cJSON_IsNumber =
- _cJSON_IsNumber_ptr.asFunction<_dart_cJSON_IsNumber>();
+ _lookup)>>(
+ 'cJSON_IsNumber');
+ late final _cJSON_IsNumber =
+ _cJSON_IsNumber_ptr.asFunction)>();
int cJSON_IsString(
ffi.Pointer item,
@@ -356,9 +383,10 @@ class CJson {
}
late final _cJSON_IsString_ptr =
- _lookup>('cJSON_IsString');
- late final _dart_cJSON_IsString _cJSON_IsString =
- _cJSON_IsString_ptr.asFunction<_dart_cJSON_IsString>();
+ _lookup)>>(
+ 'cJSON_IsString');
+ late final _cJSON_IsString =
+ _cJSON_IsString_ptr.asFunction)>();
int cJSON_IsArray(
ffi.Pointer item,
@@ -369,9 +397,10 @@ class CJson {
}
late final _cJSON_IsArray_ptr =
- _lookup>('cJSON_IsArray');
- late final _dart_cJSON_IsArray _cJSON_IsArray =
- _cJSON_IsArray_ptr.asFunction<_dart_cJSON_IsArray>();
+ _lookup)>>(
+ 'cJSON_IsArray');
+ late final _cJSON_IsArray =
+ _cJSON_IsArray_ptr.asFunction)>();
int cJSON_IsObject(
ffi.Pointer item,
@@ -382,9 +411,10 @@ class CJson {
}
late final _cJSON_IsObject_ptr =
- _lookup>('cJSON_IsObject');
- late final _dart_cJSON_IsObject _cJSON_IsObject =
- _cJSON_IsObject_ptr.asFunction<_dart_cJSON_IsObject>();
+ _lookup)>>(
+ 'cJSON_IsObject');
+ late final _cJSON_IsObject =
+ _cJSON_IsObject_ptr.asFunction)>();
int cJSON_IsRaw(
ffi.Pointer item,
@@ -395,36 +425,40 @@ class CJson {
}
late final _cJSON_IsRaw_ptr =
- _lookup>('cJSON_IsRaw');
- late final _dart_cJSON_IsRaw _cJSON_IsRaw =
- _cJSON_IsRaw_ptr.asFunction<_dart_cJSON_IsRaw>();
+ _lookup)>>(
+ 'cJSON_IsRaw');
+ late final _cJSON_IsRaw =
+ _cJSON_IsRaw_ptr.asFunction)>();
ffi.Pointer cJSON_CreateNull() {
return _cJSON_CreateNull();
}
late final _cJSON_CreateNull_ptr =
- _lookup>('cJSON_CreateNull');
- late final _dart_cJSON_CreateNull _cJSON_CreateNull =
- _cJSON_CreateNull_ptr.asFunction<_dart_cJSON_CreateNull>();
+ _lookup Function()>>(
+ 'cJSON_CreateNull');
+ late final _cJSON_CreateNull =
+ _cJSON_CreateNull_ptr.asFunction Function()>();
ffi.Pointer cJSON_CreateTrue() {
return _cJSON_CreateTrue();
}
late final _cJSON_CreateTrue_ptr =
- _lookup>('cJSON_CreateTrue');
- late final _dart_cJSON_CreateTrue _cJSON_CreateTrue =
- _cJSON_CreateTrue_ptr.asFunction<_dart_cJSON_CreateTrue>();
+ _lookup Function()>>(
+ 'cJSON_CreateTrue');
+ late final _cJSON_CreateTrue =
+ _cJSON_CreateTrue_ptr.asFunction Function()>();
ffi.Pointer cJSON_CreateFalse() {
return _cJSON_CreateFalse();
}
late final _cJSON_CreateFalse_ptr =
- _lookup>('cJSON_CreateFalse');
- late final _dart_cJSON_CreateFalse _cJSON_CreateFalse =
- _cJSON_CreateFalse_ptr.asFunction<_dart_cJSON_CreateFalse>();
+ _lookup Function()>>(
+ 'cJSON_CreateFalse');
+ late final _cJSON_CreateFalse =
+ _cJSON_CreateFalse_ptr.asFunction Function()>();
ffi.Pointer cJSON_CreateBool(
int boolean,
@@ -435,9 +469,10 @@ class CJson {
}
late final _cJSON_CreateBool_ptr =
- _lookup>('cJSON_CreateBool');
- late final _dart_cJSON_CreateBool _cJSON_CreateBool =
- _cJSON_CreateBool_ptr.asFunction<_dart_cJSON_CreateBool>();
+ _lookup Function(cJSON_bool)>>(
+ 'cJSON_CreateBool');
+ late final _cJSON_CreateBool =
+ _cJSON_CreateBool_ptr.asFunction Function(int)>();
ffi.Pointer cJSON_CreateNumber(
double num,
@@ -448,9 +483,10 @@ class CJson {
}
late final _cJSON_CreateNumber_ptr =
- _lookup>('cJSON_CreateNumber');
- late final _dart_cJSON_CreateNumber _cJSON_CreateNumber =
- _cJSON_CreateNumber_ptr.asFunction<_dart_cJSON_CreateNumber>();
+ _lookup Function(ffi.Double)>>(
+ 'cJSON_CreateNumber');
+ late final _cJSON_CreateNumber =
+ _cJSON_CreateNumber_ptr.asFunction Function(double)>();
ffi.Pointer cJSON_CreateString(
ffi.Pointer string,
@@ -460,10 +496,12 @@ class CJson {
);
}
- late final _cJSON_CreateString_ptr =
- _lookup>('cJSON_CreateString');
- late final _dart_cJSON_CreateString _cJSON_CreateString =
- _cJSON_CreateString_ptr.asFunction<_dart_cJSON_CreateString>();
+ late final _cJSON_CreateString_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer)>>('cJSON_CreateString');
+ late final _cJSON_CreateString = _cJSON_CreateString_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_CreateRaw(
ffi.Pointer raw,
@@ -473,28 +511,32 @@ class CJson {
);
}
- late final _cJSON_CreateRaw_ptr =
- _lookup>('cJSON_CreateRaw');
- late final _dart_cJSON_CreateRaw _cJSON_CreateRaw =
- _cJSON_CreateRaw_ptr.asFunction<_dart_cJSON_CreateRaw>();
+ late final _cJSON_CreateRaw_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer)>>('cJSON_CreateRaw');
+ late final _cJSON_CreateRaw = _cJSON_CreateRaw_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_CreateArray() {
return _cJSON_CreateArray();
}
late final _cJSON_CreateArray_ptr =
- _lookup>('cJSON_CreateArray');
- late final _dart_cJSON_CreateArray _cJSON_CreateArray =
- _cJSON_CreateArray_ptr.asFunction<_dart_cJSON_CreateArray>();
+ _lookup Function()>>(
+ 'cJSON_CreateArray');
+ late final _cJSON_CreateArray =
+ _cJSON_CreateArray_ptr.asFunction Function()>();
ffi.Pointer cJSON_CreateObject() {
return _cJSON_CreateObject();
}
late final _cJSON_CreateObject_ptr =
- _lookup>('cJSON_CreateObject');
- late final _dart_cJSON_CreateObject _cJSON_CreateObject =
- _cJSON_CreateObject_ptr.asFunction<_dart_cJSON_CreateObject>();
+ _lookup Function()>>(
+ 'cJSON_CreateObject');
+ late final _cJSON_CreateObject =
+ _cJSON_CreateObject_ptr.asFunction Function()>();
ffi.Pointer cJSON_CreateStringReference(
ffi.Pointer string,
@@ -504,12 +546,12 @@ class CJson {
);
}
- late final _cJSON_CreateStringReference_ptr =
- _lookup>(
- 'cJSON_CreateStringReference');
- late final _dart_cJSON_CreateStringReference _cJSON_CreateStringReference =
- _cJSON_CreateStringReference_ptr
- .asFunction<_dart_cJSON_CreateStringReference>();
+ late final _cJSON_CreateStringReference_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer)>>('cJSON_CreateStringReference');
+ late final _cJSON_CreateStringReference = _cJSON_CreateStringReference_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_CreateObjectReference(
ffi.Pointer child,
@@ -519,12 +561,11 @@ class CJson {
);
}
- late final _cJSON_CreateObjectReference_ptr =
- _lookup>(
- 'cJSON_CreateObjectReference');
- late final _dart_cJSON_CreateObjectReference _cJSON_CreateObjectReference =
- _cJSON_CreateObjectReference_ptr
- .asFunction<_dart_cJSON_CreateObjectReference>();
+ late final _cJSON_CreateObjectReference_ptr = _lookup<
+ ffi.NativeFunction Function(ffi.Pointer)>>(
+ 'cJSON_CreateObjectReference');
+ late final _cJSON_CreateObjectReference = _cJSON_CreateObjectReference_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_CreateArrayReference(
ffi.Pointer child,
@@ -534,12 +575,11 @@ class CJson {
);
}
- late final _cJSON_CreateArrayReference_ptr =
- _lookup>(
- 'cJSON_CreateArrayReference');
- late final _dart_cJSON_CreateArrayReference _cJSON_CreateArrayReference =
- _cJSON_CreateArrayReference_ptr
- .asFunction<_dart_cJSON_CreateArrayReference>();
+ late final _cJSON_CreateArrayReference_ptr = _lookup<
+ ffi.NativeFunction Function(ffi.Pointer)>>(
+ 'cJSON_CreateArrayReference');
+ late final _cJSON_CreateArrayReference = _cJSON_CreateArrayReference_ptr
+ .asFunction Function(ffi.Pointer)>();
ffi.Pointer cJSON_CreateIntArray(
ffi.Pointer numbers,
@@ -551,11 +591,12 @@ class CJson {
);
}
- late final _cJSON_CreateIntArray_ptr =
- _lookup>(
- 'cJSON_CreateIntArray');
- late final _dart_cJSON_CreateIntArray _cJSON_CreateIntArray =
- _cJSON_CreateIntArray_ptr.asFunction<_dart_cJSON_CreateIntArray>();
+ late final _cJSON_CreateIntArray_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer, ffi.Int32)>>('cJSON_CreateIntArray');
+ late final _cJSON_CreateIntArray = _cJSON_CreateIntArray_ptr
+ .asFunction Function(ffi.Pointer, int)>();
ffi.Pointer cJSON_CreateFloatArray(
ffi.Pointer numbers,
@@ -567,11 +608,12 @@ class CJson {
);
}
- late final _cJSON_CreateFloatArray_ptr =
- _lookup>(
- 'cJSON_CreateFloatArray');
- late final _dart_cJSON_CreateFloatArray _cJSON_CreateFloatArray =
- _cJSON_CreateFloatArray_ptr.asFunction<_dart_cJSON_CreateFloatArray>();
+ late final _cJSON_CreateFloatArray_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer, ffi.Int32)>>('cJSON_CreateFloatArray');
+ late final _cJSON_CreateFloatArray = _cJSON_CreateFloatArray_ptr
+ .asFunction Function(ffi.Pointer, int)>();
ffi.Pointer cJSON_CreateDoubleArray(
ffi.Pointer numbers,
@@ -583,11 +625,12 @@ class CJson {
);
}
- late final _cJSON_CreateDoubleArray_ptr =
- _lookup>(
- 'cJSON_CreateDoubleArray');
- late final _dart_cJSON_CreateDoubleArray _cJSON_CreateDoubleArray =
- _cJSON_CreateDoubleArray_ptr.asFunction<_dart_cJSON_CreateDoubleArray>();
+ late final _cJSON_CreateDoubleArray_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(
+ ffi.Pointer, ffi.Int32)>>('cJSON_CreateDoubleArray');
+ late final _cJSON_CreateDoubleArray = _cJSON_CreateDoubleArray_ptr
+ .asFunction Function(ffi.Pointer, int)>();
ffi.Pointer cJSON_CreateStringArray(
ffi.Pointer> strings,
@@ -599,11 +642,12 @@ class CJson {
);
}
- late final _cJSON_CreateStringArray_ptr =
- _lookup>(
- 'cJSON_CreateStringArray');
- late final _dart_cJSON_CreateStringArray _cJSON_CreateStringArray =
- _cJSON_CreateStringArray_ptr.asFunction<_dart_cJSON_CreateStringArray>();
+ late final _cJSON_CreateStringArray_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Pointer Function(ffi.Pointer>,
+ ffi.Int32)>>('cJSON_CreateStringArray');
+ late final _cJSON_CreateStringArray = _cJSON_CreateStringArray_ptr.asFunction<
+ ffi.Pointer Function(ffi.Pointer>, int)>();
void cJSON_AddItemToArray(
ffi.Pointer array,
@@ -615,11 +659,12 @@ class CJson {
);
}
- late final _cJSON_AddItemToArray_ptr =
- _lookup>(
- 'cJSON_AddItemToArray');
- late final _dart_cJSON_AddItemToArray _cJSON_AddItemToArray =
- _cJSON_AddItemToArray_ptr.asFunction<_dart_cJSON_AddItemToArray>();
+ late final _cJSON_AddItemToArray_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Void Function(
+ ffi.Pointer, ffi.Pointer)>>('cJSON_AddItemToArray');
+ late final _cJSON_AddItemToArray = _cJSON_AddItemToArray_ptr
+ .asFunction, ffi.Pointer)>();
void cJSON_AddItemToObject(
ffi.Pointer object,
@@ -633,11 +678,13 @@ class CJson {
);
}
- late final _cJSON_AddItemToObject_ptr =
- _lookup>(
- 'cJSON_AddItemToObject');
- late final _dart_cJSON_AddItemToObject _cJSON_AddItemToObject =
- _cJSON_AddItemToObject_ptr.asFunction<_dart_cJSON_AddItemToObject>();
+ late final _cJSON_AddItemToObject_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Void Function(ffi.Pointer, ffi.Pointer,
+ ffi.Pointer)>>('cJSON_AddItemToObject');
+ late final _cJSON_AddItemToObject = _cJSON_AddItemToObject_ptr.asFunction<
+ void Function(
+ ffi.Pointer, ffi.Pointer, ffi.Pointer)>();
void cJSON_AddItemToObjectCS(
ffi.Pointer object,
@@ -651,11 +698,13 @@ class CJson {
);
}
- late final _cJSON_AddItemToObjectCS_ptr =
- _lookup>(
- 'cJSON_AddItemToObjectCS');
- late final _dart_cJSON_AddItemToObjectCS _cJSON_AddItemToObjectCS =
- _cJSON_AddItemToObjectCS_ptr.asFunction<_dart_cJSON_AddItemToObjectCS>();
+ late final _cJSON_AddItemToObjectCS_ptr = _lookup<
+ ffi.NativeFunction<
+ ffi.Void Function(ffi.Pointer, ffi.Pointer,
+ ffi.Pointer)>>('cJSON_AddItemToObjectCS');
+ late final _cJSON_AddItemToObjectCS = _cJSON_AddItemToObjectCS_ptr.asFunction<
+ void Function(
+ ffi.Pointer