Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] tutorial frb_example/with_flutter breaks when running the generator #472

Closed
thomas725 opened this issue May 22, 2022 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@thomas725
Copy link
Contributor

Describe the bug

I've tried out the tutorial and managed to get it to run on my linux desktop and on my android phone.

But after running the optional code generator as described:

flutter_rust_bridge_codegen --rust-input frb_example/with_flutter/rust/src/api.rs --dart-output frb_example/with_flutter/lib/bridge_generated.dart --c-output frb_example/with_flutter/ios/Runner/bridge_generated.h

The sample stops working:

   Compiling flutter_rust_bridge_example v0.1.0 (~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust)
    Finished dev [unoptimized + debuginfo] target(s) in 6.45s
ERROR: lib/bridge_generated.dart:765:9: Error: The parameter 'ptr' of the method 'FlutterRustBridgeExampleWire.store_dart_post_cobject' has type 'int', which does not match the corresponding type, 'Pointer<NativeFunction<Uint8 Function(Int64, Pointer<Void>)>>', in the overridden method, 'FlutterRustBridgeWireBase.store_dart_post_cobject'.
ERROR:  - 'Pointer' is from 'dart:ffi'.
ERROR:  - 'NativeFunction' is from 'dart:ffi'.
ERROR:  - 'Uint8' is from 'dart:ffi'.
ERROR:  - 'Int64' is from 'dart:ffi'.
ERROR:  - 'Void' is from 'dart:ffi'.
ERROR: Change to a supertype of 'Pointer<NativeFunction<Uint8 Function(Int64, Pointer<Void>)>>', or, for a covariant parameter, a subtype.
ERROR:     int ptr,
ERROR:         ^
ERROR: ../../frb_dart/lib/src/basic.dart:153:8: Context: This is the overridden method ('store_dart_post_cobject').
ERROR:   void store_dart_post_cobject(
ERROR:        ^
Building Linux application...                                           
Exception: Build process failed

Codegen logs with RUST_LOG=debug env variable

RUST_LOG=debug flutter_rust_bridge_codegen --rust-input frb_example/with_flutter/rust/src/api.rs --dart-output frb_example/with_flutter/lib/bridge_generated.dart --c-output frb_example/with_flutter/ios/Runner/bridge_generated.h

[2022-05-22T18:22:00Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "dart pub global list"] current_dir=None cmd="sh" "-c" "dart pub global list"
[2022-05-22T18:22:00Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "dart pub global list" stdout=ffigen 4.1.3
     stderr=
[2022-05-22T18:22:00Z INFO  lib_flutter_rust_bridge_codegen] Picked config: Opts { rust_input_path: "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/api.rs", dart_output_path: "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart", dart_decl_output_path: None, c_output_path: ["~/Development/git/flutter_rust_bridge/frb_example/with_flutter/ios/Runner/bridge_generated.h"], rust_crate_dir: "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust", rust_output_path: "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/bridge_generated.rs", class_name: "FlutterRustBridgeExample", dart_format_line_length: 80, skip_add_mod_to_lib: false, llvm_path: ["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/Program Files/LLVM", "C:/msys64/mingw64"], llvm_compiler_opts: "", manifest_path: "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/Cargo.toml", dart_root: Some("~/Development/git/flutter_rust_bridge/frb_example/with_flutter"), build_runner: true }
[2022-05-22T18:22:00Z INFO  lib_flutter_rust_bridge_codegen] Phase: Parse source code to AST
[2022-05-22T18:22:00Z INFO  lib_flutter_rust_bridge_codegen] Phase: Parse AST to IR
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/api.rs"
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/bridge_generated.rs"
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::source_graph] Trying to parse "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/off_topic_code.rs"
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(draw_mandelbrot)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(passing_complex_structs)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(returning_structs_with_boxed_fields)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_input_array)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_output_zero_copy_buffer)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_output_vec_u8)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_input_vec_of_object)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_output_vec_of_object)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_input_complex_struct)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_memory_test_output_complex_struct)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_deliberately_return_error)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::parser] parse_function function name: Ident(off_topic_deliberately_panic)
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen] parsed functions: IrFile { funcs: [IrFunc { name: "draw_mandelbrot", inputs: [IrField { ty: StructRef(IrTypeStructRef { name: "Size" }), name: IrIdent { raw: "image_size" }, is_final: true, comments: [] }, IrField { ty: StructRef(IrTypeStructRef { name: "Point" }), name: IrIdent { raw: "zoom_point" }, is_final: true, comments: [] }, IrField { ty: Primitive(F64), name: IrIdent { raw: "scale" }, is_final: true, comments: [] }, IrField { ty: Primitive(I32), name: IrIdent { raw: "num_threads" }, is_final: true, comments: [] }], output: Delegate(ZeroCopyBufferVecPrimitive(U8)), fallible: true, mode: Normal, comments: [] }, IrFunc { name: "passing_complex_structs", inputs: [IrField { ty: StructRef(IrTypeStructRef { name: "TreeNode" }), name: IrIdent { raw: "root" }, is_final: true, comments: [] }], output: Delegate(String), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "returning_structs_with_boxed_fields", inputs: [], output: StructRef(IrTypeStructRef { name: "BoxedPoint" }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_input_array", inputs: [IrField { ty: PrimitiveList(IrTypePrimitiveList { primitive: U8 }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_zero_copy_buffer", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: Delegate(ZeroCopyBufferVecPrimitive(U8)), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_vec_u8", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: PrimitiveList(IrTypePrimitiveList { primitive: U8 }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_input_vec_of_object", inputs: [IrField { ty: GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "Size" }) }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_vec_of_object", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "Size" }) }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_input_complex_struct", inputs: [IrField { ty: StructRef(IrTypeStructRef { name: "TreeNode" }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_complex_struct", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: StructRef(IrTypeStructRef { name: "TreeNode" }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_deliberately_return_error", inputs: [], output: Primitive(I32), fallible: true, mode: Normal, comments: [] }, IrFunc { name: "off_topic_deliberately_panic", inputs: [], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }], struct_pool: {"Size": IrStruct { name: "Size", wrapper_name: None, path: Some(["crate", "api", "Size"]), fields: [IrField { ty: Primitive(I32), name: IrIdent { raw: "width" }, is_final: true, comments: [] }, IrField { ty: Primitive(I32), name: IrIdent { raw: "height" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }, "Point": IrStruct { name: "Point", wrapper_name: None, path: Some(["crate", "api", "Point"]), fields: [IrField { ty: Primitive(F64), name: IrIdent { raw: "x" }, is_final: true, comments: [] }, IrField { ty: Primitive(F64), name: IrIdent { raw: "y" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }, "BoxedPoint": IrStruct { name: "BoxedPoint", wrapper_name: None, path: Some(["crate", "api", "BoxedPoint"]), fields: [IrField { ty: Boxed(IrTypeBoxed { exist_in_real_api: true, inner: StructRef(IrTypeStructRef { name: "Point" }) }), name: IrIdent { raw: "point" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }, "TreeNode": IrStruct { name: "TreeNode", wrapper_name: None, path: Some(["crate", "api", "TreeNode"]), fields: [IrField { ty: Delegate(String), name: IrIdent { raw: "name" }, is_final: true, comments: [] }, IrField { ty: GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), name: IrIdent { raw: "children" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }}, enum_pool: {}, has_executor: false }
[2022-05-22T18:22:01Z INFO  lib_flutter_rust_bridge_codegen] Phase: Transform IR
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::transformer] transform_func_input_add_boxed wrap Boxed to field=IrField { ty: StructRef(IrTypeStructRef { name: "Size" }), name: IrIdent { raw: "image_size" }, is_final: true, comments: [] }
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::transformer] transform_func_input_add_boxed wrap Boxed to field=IrField { ty: StructRef(IrTypeStructRef { name: "Point" }), name: IrIdent { raw: "zoom_point" }, is_final: true, comments: [] }
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::transformer] transform_func_input_add_boxed wrap Boxed to field=IrField { ty: StructRef(IrTypeStructRef { name: "TreeNode" }), name: IrIdent { raw: "root" }, is_final: true, comments: [] }
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::transformer] transform_func_input_add_boxed wrap Boxed to field=IrField { ty: StructRef(IrTypeStructRef { name: "TreeNode" }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen] transformed functions: IrFile { funcs: [IrFunc { name: "draw_mandelbrot", inputs: [IrField { ty: Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "Size" }) }), name: IrIdent { raw: "image_size" }, is_final: true, comments: [] }, IrField { ty: Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "Point" }) }), name: IrIdent { raw: "zoom_point" }, is_final: true, comments: [] }, IrField { ty: Primitive(F64), name: IrIdent { raw: "scale" }, is_final: true, comments: [] }, IrField { ty: Primitive(I32), name: IrIdent { raw: "num_threads" }, is_final: true, comments: [] }], output: Delegate(ZeroCopyBufferVecPrimitive(U8)), fallible: true, mode: Normal, comments: [] }, IrFunc { name: "passing_complex_structs", inputs: [IrField { ty: Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), name: IrIdent { raw: "root" }, is_final: true, comments: [] }], output: Delegate(String), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "returning_structs_with_boxed_fields", inputs: [], output: StructRef(IrTypeStructRef { name: "BoxedPoint" }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_input_array", inputs: [IrField { ty: PrimitiveList(IrTypePrimitiveList { primitive: U8 }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_zero_copy_buffer", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: Delegate(ZeroCopyBufferVecPrimitive(U8)), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_vec_u8", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: PrimitiveList(IrTypePrimitiveList { primitive: U8 }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_input_vec_of_object", inputs: [IrField { ty: GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "Size" }) }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_vec_of_object", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "Size" }) }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_input_complex_struct", inputs: [IrField { ty: Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), name: IrIdent { raw: "input" }, is_final: true, comments: [] }], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_memory_test_output_complex_struct", inputs: [IrField { ty: Primitive(I32), name: IrIdent { raw: "len" }, is_final: true, comments: [] }], output: StructRef(IrTypeStructRef { name: "TreeNode" }), fallible: false, mode: Normal, comments: [] }, IrFunc { name: "off_topic_deliberately_return_error", inputs: [], output: Primitive(I32), fallible: true, mode: Normal, comments: [] }, IrFunc { name: "off_topic_deliberately_panic", inputs: [], output: Primitive(I32), fallible: false, mode: Normal, comments: [] }], struct_pool: {"Size": IrStruct { name: "Size", wrapper_name: None, path: Some(["crate", "api", "Size"]), fields: [IrField { ty: Primitive(I32), name: IrIdent { raw: "width" }, is_final: true, comments: [] }, IrField { ty: Primitive(I32), name: IrIdent { raw: "height" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }, "Point": IrStruct { name: "Point", wrapper_name: None, path: Some(["crate", "api", "Point"]), fields: [IrField { ty: Primitive(F64), name: IrIdent { raw: "x" }, is_final: true, comments: [] }, IrField { ty: Primitive(F64), name: IrIdent { raw: "y" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }, "BoxedPoint": IrStruct { name: "BoxedPoint", wrapper_name: None, path: Some(["crate", "api", "BoxedPoint"]), fields: [IrField { ty: Boxed(IrTypeBoxed { exist_in_real_api: true, inner: StructRef(IrTypeStructRef { name: "Point" }) }), name: IrIdent { raw: "point" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }, "TreeNode": IrStruct { name: "TreeNode", wrapper_name: None, path: Some(["crate", "api", "TreeNode"]), fields: [IrField { ty: Delegate(String), name: IrIdent { raw: "name" }, is_final: true, comments: [] }, IrField { ty: GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), name: IrIdent { raw: "children" }, is_final: true, comments: [] }], is_fields_named: true, comments: [] }}, enum_pool: {}, has_executor: false }
[2022-05-22T18:22:01Z INFO  lib_flutter_rust_bridge_codegen] Phase: Generate Rust code
[2022-05-22T18:22:01Z INFO  lib_flutter_rust_bridge_codegen] Phase: Generate Dart code
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::generator::dart] distinct_input_types=[Delegate(String), Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "Point" }) }), Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "Size" }) }), Boxed(IrTypeBoxed { exist_in_real_api: false, inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), Primitive(F64), Primitive(I32), GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "Size" }) }), GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), StructRef(IrTypeStructRef { name: "Point" }), StructRef(IrTypeStructRef { name: "Size" }), StructRef(IrTypeStructRef { name: "TreeNode" }), Primitive(U8), PrimitiveList(IrTypePrimitiveList { primitive: U8 })]
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::generator::dart] distinct_output_types=[Delegate(String), Delegate(ZeroCopyBufferVecPrimitive(U8)), Boxed(IrTypeBoxed { exist_in_real_api: true, inner: StructRef(IrTypeStructRef { name: "Point" }) }), StructRef(IrTypeStructRef { name: "BoxedPoint" }), Primitive(F64), Primitive(I32), GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "Size" }) }), GeneralList(IrTypeGeneralList { inner: StructRef(IrTypeStructRef { name: "TreeNode" }) }), StructRef(IrTypeStructRef { name: "Point" }), StructRef(IrTypeStructRef { name: "Size" }), StructRef(IrTypeStructRef { name: "TreeNode" }), Primitive(U8), PrimitiveList(IrTypePrimitiveList { primitive: U8 })]
[2022-05-22T18:22:01Z INFO  lib_flutter_rust_bridge_codegen] Phase: Other things
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute format_rust path=~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/bridge_generated.rs
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=rustfmt args=["~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/bridge_generated.rs"] current_dir=None cmd="rustfmt" "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/bridge_generated.rs"
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="rustfmt" "~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/bridge_generated.rs" stdout= stderr=
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute cbindgen rust_crate_dir=~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust c_output_path=/tmp/.tmp9lXuqN.h
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] cbindgen config: Config { header: None, includes: [], sys_includes: ["stdbool.h", "stdint.h", "stdlib.h"], after_includes: None, trailer: None, include_guard: None, pragma_once: false, no_includes: true, autogen_warning: None, include_version: false, namespace: None, namespaces: None, using_namespaces: None, braces: SameLine, line_length: 100, tab_width: 2, line_endings: LF, language: C, cpp_compat: false, style: Both, sort_by: None, usize_is_size_t: false, parse: ParseConfig { parse_deps: false, include: None, exclude: [], expand: ParseExpandConfig { crates: [], all_features: false, default_features: true, features: None, profile: Debug }, clean: false, extra_bindings: [] }, export: ExportConfig { include: ["\"wire_BoxedPoint\"", "\"wire_Point\"", "\"wire_Size\"", "\"wire_TreeNode\""], exclude: [], rename: {}, pre_body: {}, body: {}, prefix: None, item_types: [], renaming_overrides_prefixing: false, mangle: MangleConfig { rename_types: None, remove_underscores: false } }, macro_expansion: MacroExpansionConfig { bitflags: false }, layout: LayoutConfig { packed: None, aligned_n: None }, function: FunctionConfig { prefix: None, postfix: None, must_use: None, args: Auto, rename_args: None, swift_name_macro: None, sort_by: None, no_return: None }, structure: StructConfig { rename_fields: None, derive_constructor: false, derive_eq: false, derive_neq: false, derive_lt: false, derive_lte: false, derive_gt: false, derive_gte: false, derive_ostream: false, associated_constants_in_body: false, must_use: None }, enumeration: EnumConfig { rename_variants: None, rename_variant_name_fields: SnakeCase, add_sentinel: false, prefix_with_name: false, derive_helper_methods: false, derive_const_casts: false, derive_mut_casts: false, cast_assert_name: None, must_use: None, derive_tagged_enum_destructor: false, derive_tagged_enum_copy_constructor: false, derive_tagged_enum_copy_assignment: false, derive_ostream: false, enum_class: true, private_default_tagged_enum_constructor: false }, constant: ConstantConfig { allow_static_const: true, allow_constexpr: true, sort_by: None }, defines: {}, documentation: true, documentation_style: Auto, documentation_length: Full, pointer: PtrConfig { non_null_attribute: None }, only_target_dependencies: false, cython: CythonConfig { header: None, cimports: {} } }
[2022-05-22T18:22:01Z DEBUG cbindgen::bindgen::parser] Parsing crate flutter_rust_bridge_example
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::Size - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::Point - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::TreeNode - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::BoxedPoint - opaque (Struct is not marked #[repr(C)] or #[repr(transparent)].).
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_draw_mandelbrot.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_passing_complex_structs.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_returning_structs_with_boxed_fields.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_input_array.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_output_zero_copy_buffer.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_output_vec_u8.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_input_vec_of_object.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_output_vec_of_object.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_input_complex_struct.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_memory_test_output_complex_struct.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_deliberately_return_error.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_off_topic_deliberately_panic.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_list_size.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_list_tree_node.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_Point.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_Size.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_TreeNode.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::wire_uint_8_list.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::new_box_autoadd_point.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::new_box_autoadd_size.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::new_box_autoadd_tree_node.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::new_list_size.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::new_list_tree_node.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::new_uint_8_list.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::free_WireSyncReturnStruct.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::DartPort.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::DartPostCObjectFnType.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::store_dart_post_cobject.
[2022-05-22T18:22:01Z INFO  cbindgen::bindgen::parser] Take flutter_rust_bridge_example::WireSyncReturnStruct.
[2022-05-22T18:22:01Z WARN  cbindgen::bindgen::parser] Skip flutter_rust_bridge_example::A - (not `pub`).
[2022-05-22T18:22:01Z WARN  cbindgen::bindgen::parser] Skip flutter_rust_bridge_example::B - (not `pub`).
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute ffigen c_path=/tmp/.tmp9lXuqN.h dart_path=/tmp/.tmpYz4wXY llvm_path=["/opt/homebrew/opt/llvm", "/usr/local/opt/llvm", "/usr/lib/llvm-9", "/usr/lib/llvm-10", "/usr/lib/llvm-11", "/usr/lib/llvm-12", "/usr/lib/llvm-13", "/usr/lib/llvm-14", "/usr/lib/", "/usr/lib64/", "C:/Program Files/llvm", "C:/Program Files/LLVM", "C:/msys64/mingw64"]
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] ffigen config: 
            output: '/tmp/.tmpYz4wXY'
            name: 'FlutterRustBridgeExampleWire'
            description: 'generated by flutter_rust_bridge'
            headers:
              entry-points:
                - '/tmp/.tmp9lXuqN.h'
              include-directives:
                - '/tmp/.tmp9lXuqN.h'
            comments: false
            preamble: |
              // ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names
            
            llvm-path:
               - '/opt/homebrew/opt/llvm'
               - '/usr/local/opt/llvm'
               - '/usr/lib/llvm-9'
               - '/usr/lib/llvm-10'
               - '/usr/lib/llvm-11'
               - '/usr/lib/llvm-12'
               - '/usr/lib/llvm-13'
               - '/usr/lib/llvm-14'
               - '/usr/lib/'
               - '/usr/lib64/'
               - 'C:/Program Files/llvm'
               - 'C:/Program Files/LLVM'
               - 'C:/msys64/mingw64'
    
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] ffigen config_file: NamedTempFile("/tmp/.tmpsCqlDh")
[2022-05-22T18:22:01Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "dart pub global run ffigen --config \"/tmp/.tmpsCqlDh\""] current_dir=None cmd="sh" "-c" "dart pub global run ffigen --config \"/tmp/.tmpsCqlDh\""
[2022-05-22T18:22:04Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "dart pub global run ffigen --config \"/tmp/.tmpsCqlDh\"" stdout=Running in Directory: '~/Development/git/flutter_rust_bridge'
    Input Headers: [/tmp/.tmp9lXuqN.h]
    [SEVERE] : Header /tmp/.tmp9lXuqN.h: Total errors/warnings: 1.
    [SEVERE] :     /tmp/.tmp9lXuqN.h:1:10: fatal error: 'stdbool.h' file not found [Lexical or Preprocessor Issue]
    Finished, Bindings generated in /tmp/.tmpYz4wXY
     stderr=
[2022-05-22T18:22:04Z WARN  lib_flutter_rust_bridge_codegen::commands] See keywords such as `error` in command output. Maybe there is a problem? command="sh" "-c" "dart pub global run ffigen --config \"/tmp/.tmpsCqlDh\"" output=Output { status: ExitStatus(unix_wait_status(0)), stdout: "Running in Directory: '~/Development/git/flutter_rust_bridge'\nInput Headers: [/tmp/.tmp9lXuqN.h]\n[SEVERE] : Header /tmp/.tmp9lXuqN.h: Total errors/warnings: 1.\n[SEVERE] :     /tmp/.tmp9lXuqN.h:1:10: fatal error: 'stdbool.h' file not found [Lexical or Preprocessor Issue]\nFinished, Bindings generated in /tmp/.tmpYz4wXY\n", stderr: "" }
[2022-05-22T18:22:04Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute format_dart path=~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart line_length=80
[2022-05-22T18:22:04Z DEBUG lib_flutter_rust_bridge_codegen::commands] execute command: bin=sh args=["-c", "dart format ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart --line-length 80"] current_dir=None cmd="sh" "-c" "dart format ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart --line-length 80"
[2022-05-22T18:22:06Z DEBUG lib_flutter_rust_bridge_codegen::commands] command="sh" "-c" "dart format ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart --line-length 80" stdout=Formatted ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart
    Formatted 1 file (1 changed) in 0.81 seconds.
     stderr=
[2022-05-22T18:22:06Z INFO  lib_flutter_rust_bridge_codegen] Success!
[2022-05-22T18:22:06Z INFO  flutter_rust_bridge_codegen] Now go and use it :)

To Reproduce

No response

Expected behavior

No response

Generated binding code

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct wire_Size {
  int32_t width;
  int32_t height;
} wire_Size;

typedef struct wire_Point {
  double x;
  double y;
} wire_Point;

typedef struct wire_uint_8_list {
  uint8_t *ptr;
  int32_t len;
} wire_uint_8_list;

typedef struct wire_list_tree_node {
  struct wire_TreeNode *ptr;
  int32_t len;
} wire_list_tree_node;

typedef struct wire_TreeNode {
  struct wire_uint_8_list *name;
  struct wire_list_tree_node *children;
} wire_TreeNode;

typedef struct wire_list_size {
  struct wire_Size *ptr;
  int32_t len;
} wire_list_size;

typedef struct WireSyncReturnStruct {
  uint8_t *ptr;
  int32_t len;
  bool success;
} WireSyncReturnStruct;

typedef int64_t DartPort;

typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message);

void wire_draw_mandelbrot(int64_t port_,
                          struct wire_Size *image_size,
                          struct wire_Point *zoom_point,
                          double scale,
                          int32_t num_threads);

void wire_passing_complex_structs(int64_t port_, struct wire_TreeNode *root);

void wire_returning_structs_with_boxed_fields(int64_t port_);

void wire_off_topic_memory_test_input_array(int64_t port_, struct wire_uint_8_list *input);

void wire_off_topic_memory_test_output_zero_copy_buffer(int64_t port_, int32_t len);

void wire_off_topic_memory_test_output_vec_u8(int64_t port_, int32_t len);

void wire_off_topic_memory_test_input_vec_of_object(int64_t port_, struct wire_list_size *input);

void wire_off_topic_memory_test_output_vec_of_object(int64_t port_, int32_t len);

void wire_off_topic_memory_test_input_complex_struct(int64_t port_, struct wire_TreeNode *input);

void wire_off_topic_memory_test_output_complex_struct(int64_t port_, int32_t len);

void wire_off_topic_deliberately_return_error(int64_t port_);

void wire_off_topic_deliberately_panic(int64_t port_);

struct wire_Point *new_box_autoadd_point(void);

struct wire_Size *new_box_autoadd_size(void);

struct wire_TreeNode *new_box_autoadd_tree_node(void);

struct wire_list_size *new_list_size(int32_t len);

struct wire_list_tree_node *new_list_tree_node(int32_t len);

struct wire_uint_8_list *new_uint_8_list(int32_t len);

void free_WireSyncReturnStruct(struct WireSyncReturnStruct val);

void store_dart_post_cobject(DartPostCObjectFnType ptr);

static int64_t dummy_method_to_enforce_bundling(void) {
    int64_t dummy_var = 0;
    dummy_var ^= ((int64_t) (void*) wire_draw_mandelbrot);
    dummy_var ^= ((int64_t) (void*) wire_passing_complex_structs);
    dummy_var ^= ((int64_t) (void*) wire_returning_structs_with_boxed_fields);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_input_array);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_output_zero_copy_buffer);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_output_vec_u8);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_input_vec_of_object);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_output_vec_of_object);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_input_complex_struct);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_memory_test_output_complex_struct);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_deliberately_return_error);
    dummy_var ^= ((int64_t) (void*) wire_off_topic_deliberately_panic);
    dummy_var ^= ((int64_t) (void*) new_box_autoadd_point);
    dummy_var ^= ((int64_t) (void*) new_box_autoadd_size);
    dummy_var ^= ((int64_t) (void*) new_box_autoadd_tree_node);
    dummy_var ^= ((int64_t) (void*) new_list_size);
    dummy_var ^= ((int64_t) (void*) new_list_tree_node);
    dummy_var ^= ((int64_t) (void*) new_uint_8_list);
    dummy_var ^= ((int64_t) (void*) free_WireSyncReturnStruct);
    dummy_var ^= ((int64_t) (void*) store_dart_post_cobject);
    return dummy_var;
}

//////////////////////////////////////////////////////////////////////
/// above = frb_example/with_flutter/ios/Runner/bridge_generated.h ///
//////////////////////////////////////////////////////////////////////
///// below = frb_example/with_flutter/lib/bridge_generated.dart /////
//////////////////////////////////////////////////////////////////////

// AUTO GENERATED FILE, DO NOT EDIT.
// Generated by `flutter_rust_bridge`.

// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, prefer_single_quotes, prefer_const_constructors

import 'dart:convert';
import 'dart:typed_data';

import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter_rust_bridge/flutter_rust_bridge.dart';
import 'dart:ffi' as ffi;

abstract class FlutterRustBridgeExample {
  Future<Uint8List> drawMandelbrot(
      {required Size imageSize,
      required Point zoomPoint,
      required double scale,
      required int numThreads,
      dynamic hint});

  Future<String> passingComplexStructs({required TreeNode root, dynamic hint});

  Future<BoxedPoint> returningStructsWithBoxedFields({dynamic hint});

  Future<int> offTopicMemoryTestInputArray(
      {required Uint8List input, dynamic hint});

  Future<Uint8List> offTopicMemoryTestOutputZeroCopyBuffer(
      {required int len, dynamic hint});

  Future<Uint8List> offTopicMemoryTestOutputVecU8(
      {required int len, dynamic hint});

  Future<int> offTopicMemoryTestInputVecOfObject(
      {required List<Size> input, dynamic hint});

  Future<List<Size>> offTopicMemoryTestOutputVecOfObject(
      {required int len, dynamic hint});

  Future<int> offTopicMemoryTestInputComplexStruct(
      {required TreeNode input, dynamic hint});

  Future<TreeNode> offTopicMemoryTestOutputComplexStruct(
      {required int len, dynamic hint});

  Future<int> offTopicDeliberatelyReturnError({dynamic hint});

  Future<int> offTopicDeliberatelyPanic({dynamic hint});
}

class BoxedPoint {
  final Point point;

  BoxedPoint({
    required this.point,
  });
}

class Point {
  final double x;
  final double y;

  Point({
    required this.x,
    required this.y,
  });
}

class Size {
  final int width;
  final int height;

  Size({
    required this.width,
    required this.height,
  });
}

class TreeNode {
  final String name;
  final List<TreeNode> children;

  TreeNode({
    required this.name,
    required this.children,
  });
}

class FlutterRustBridgeExampleImpl
    extends FlutterRustBridgeBase<FlutterRustBridgeExampleWire>
    implements FlutterRustBridgeExample {
  factory FlutterRustBridgeExampleImpl(ffi.DynamicLibrary dylib) =>
      FlutterRustBridgeExampleImpl.raw(FlutterRustBridgeExampleWire(dylib));

  FlutterRustBridgeExampleImpl.raw(FlutterRustBridgeExampleWire inner)
      : super(inner);

  Future<Uint8List> drawMandelbrot(
          {required Size imageSize,
          required Point zoomPoint,
          required double scale,
          required int numThreads,
          dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) => inner.wire_draw_mandelbrot(
            port_,
            _api2wire_box_autoadd_size(imageSize),
            _api2wire_box_autoadd_point(zoomPoint),
            _api2wire_f64(scale),
            _api2wire_i32(numThreads)),
        parseSuccessData: _wire2api_ZeroCopyBuffer_Uint8List,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "draw_mandelbrot",
          argNames: ["imageSize", "zoomPoint", "scale", "numThreads"],
        ),
        argValues: [imageSize, zoomPoint, scale, numThreads],
        hint: hint,
      ));

  Future<String> passingComplexStructs(
          {required TreeNode root, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) => inner.wire_passing_complex_structs(
            port_, _api2wire_box_autoadd_tree_node(root)),
        parseSuccessData: _wire2api_String,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "passing_complex_structs",
          argNames: ["root"],
        ),
        argValues: [root],
        hint: hint,
      ));

  Future<BoxedPoint> returningStructsWithBoxedFields({dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_returning_structs_with_boxed_fields(port_),
        parseSuccessData: _wire2api_boxed_point,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "returning_structs_with_boxed_fields",
          argNames: [],
        ),
        argValues: [],
        hint: hint,
      ));

  Future<int> offTopicMemoryTestInputArray(
          {required Uint8List input, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) => inner.wire_off_topic_memory_test_input_array(
            port_, _api2wire_uint_8_list(input)),
        parseSuccessData: _wire2api_i32,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_input_array",
          argNames: ["input"],
        ),
        argValues: [input],
        hint: hint,
      ));

  Future<Uint8List> offTopicMemoryTestOutputZeroCopyBuffer(
          {required int len, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_off_topic_memory_test_output_zero_copy_buffer(
                port_, _api2wire_i32(len)),
        parseSuccessData: _wire2api_ZeroCopyBuffer_Uint8List,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_output_zero_copy_buffer",
          argNames: ["len"],
        ),
        argValues: [len],
        hint: hint,
      ));

  Future<Uint8List> offTopicMemoryTestOutputVecU8(
          {required int len, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) => inner.wire_off_topic_memory_test_output_vec_u8(
            port_, _api2wire_i32(len)),
        parseSuccessData: _wire2api_uint_8_list,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_output_vec_u8",
          argNames: ["len"],
        ),
        argValues: [len],
        hint: hint,
      ));

  Future<int> offTopicMemoryTestInputVecOfObject(
          {required List<Size> input, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_off_topic_memory_test_input_vec_of_object(
                port_, _api2wire_list_size(input)),
        parseSuccessData: _wire2api_i32,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_input_vec_of_object",
          argNames: ["input"],
        ),
        argValues: [input],
        hint: hint,
      ));

  Future<List<Size>> offTopicMemoryTestOutputVecOfObject(
          {required int len, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_off_topic_memory_test_output_vec_of_object(
                port_, _api2wire_i32(len)),
        parseSuccessData: _wire2api_list_size,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_output_vec_of_object",
          argNames: ["len"],
        ),
        argValues: [len],
        hint: hint,
      ));

  Future<int> offTopicMemoryTestInputComplexStruct(
          {required TreeNode input, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_off_topic_memory_test_input_complex_struct(
                port_, _api2wire_box_autoadd_tree_node(input)),
        parseSuccessData: _wire2api_i32,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_input_complex_struct",
          argNames: ["input"],
        ),
        argValues: [input],
        hint: hint,
      ));

  Future<TreeNode> offTopicMemoryTestOutputComplexStruct(
          {required int len, dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_off_topic_memory_test_output_complex_struct(
                port_, _api2wire_i32(len)),
        parseSuccessData: _wire2api_tree_node,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_memory_test_output_complex_struct",
          argNames: ["len"],
        ),
        argValues: [len],
        hint: hint,
      ));

  Future<int> offTopicDeliberatelyReturnError({dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) =>
            inner.wire_off_topic_deliberately_return_error(port_),
        parseSuccessData: _wire2api_i32,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_deliberately_return_error",
          argNames: [],
        ),
        argValues: [],
        hint: hint,
      ));

  Future<int> offTopicDeliberatelyPanic({dynamic hint}) =>
      executeNormal(FlutterRustBridgeTask(
        callFfi: (port_) => inner.wire_off_topic_deliberately_panic(port_),
        parseSuccessData: _wire2api_i32,
        constMeta: const FlutterRustBridgeTaskConstMeta(
          debugName: "off_topic_deliberately_panic",
          argNames: [],
        ),
        argValues: [],
        hint: hint,
      ));

  // Section: api2wire
  ffi.Pointer<wire_uint_8_list> _api2wire_String(String raw) {
    return _api2wire_uint_8_list(utf8.encoder.convert(raw));
  }

  ffi.Pointer<wire_Point> _api2wire_box_autoadd_point(Point raw) {
    final ptr = inner.new_box_autoadd_point();
    _api_fill_to_wire_point(raw, ptr.ref);
    return ptr;
  }

  ffi.Pointer<wire_Size> _api2wire_box_autoadd_size(Size raw) {
    final ptr = inner.new_box_autoadd_size();
    _api_fill_to_wire_size(raw, ptr.ref);
    return ptr;
  }

  ffi.Pointer<wire_TreeNode> _api2wire_box_autoadd_tree_node(TreeNode raw) {
    final ptr = inner.new_box_autoadd_tree_node();
    _api_fill_to_wire_tree_node(raw, ptr.ref);
    return ptr;
  }

  double _api2wire_f64(double raw) {
    return raw;
  }

  int _api2wire_i32(int raw) {
    return raw;
  }

  ffi.Pointer<wire_list_size> _api2wire_list_size(List<Size> raw) {
    final ans = inner.new_list_size(raw.length);
    for (var i = 0; i < raw.length; ++i) {
      _api_fill_to_wire_size(raw[i], ans.ref.ptr[i]);
    }
    return ans;
  }

  ffi.Pointer<wire_list_tree_node> _api2wire_list_tree_node(
      List<TreeNode> raw) {
    final ans = inner.new_list_tree_node(raw.length);
    for (var i = 0; i < raw.length; ++i) {
      _api_fill_to_wire_tree_node(raw[i], ans.ref.ptr[i]);
    }
    return ans;
  }

  int _api2wire_u8(int raw) {
    return raw;
  }

  ffi.Pointer<wire_uint_8_list> _api2wire_uint_8_list(Uint8List raw) {
    final ans = inner.new_uint_8_list(raw.length);
    ans.ref.ptr.asTypedList(raw.length).setAll(0, raw);
    return ans;
  }

  // Section: api_fill_to_wire

  void _api_fill_to_wire_box_autoadd_point(
      Point apiObj, ffi.Pointer<wire_Point> wireObj) {
    _api_fill_to_wire_point(apiObj, wireObj.ref);
  }

  void _api_fill_to_wire_box_autoadd_size(
      Size apiObj, ffi.Pointer<wire_Size> wireObj) {
    _api_fill_to_wire_size(apiObj, wireObj.ref);
  }

  void _api_fill_to_wire_box_autoadd_tree_node(
      TreeNode apiObj, ffi.Pointer<wire_TreeNode> wireObj) {
    _api_fill_to_wire_tree_node(apiObj, wireObj.ref);
  }

  void _api_fill_to_wire_point(Point apiObj, wire_Point wireObj) {
    wireObj.x = _api2wire_f64(apiObj.x);
    wireObj.y = _api2wire_f64(apiObj.y);
  }

  void _api_fill_to_wire_size(Size apiObj, wire_Size wireObj) {
    wireObj.width = _api2wire_i32(apiObj.width);
    wireObj.height = _api2wire_i32(apiObj.height);
  }

  void _api_fill_to_wire_tree_node(TreeNode apiObj, wire_TreeNode wireObj) {
    wireObj.name = _api2wire_String(apiObj.name);
    wireObj.children = _api2wire_list_tree_node(apiObj.children);
  }
}

// Section: wire2api
String _wire2api_String(dynamic raw) {
  return raw as String;
}

Uint8List _wire2api_ZeroCopyBuffer_Uint8List(dynamic raw) {
  return raw as Uint8List;
}

Point _wire2api_box_point(dynamic raw) {
  return _wire2api_point(raw);
}

BoxedPoint _wire2api_boxed_point(dynamic raw) {
  final arr = raw as List<dynamic>;
  if (arr.length != 1)
    throw Exception('unexpected arr length: expect 1 but see ${arr.length}');
  return BoxedPoint(
    point: _wire2api_box_point(arr[0]),
  );
}

double _wire2api_f64(dynamic raw) {
  return raw as double;
}

int _wire2api_i32(dynamic raw) {
  return raw as int;
}

List<Size> _wire2api_list_size(dynamic raw) {
  return (raw as List<dynamic>).map(_wire2api_size).toList();
}

List<TreeNode> _wire2api_list_tree_node(dynamic raw) {
  return (raw as List<dynamic>).map(_wire2api_tree_node).toList();
}

Point _wire2api_point(dynamic raw) {
  final arr = raw as List<dynamic>;
  if (arr.length != 2)
    throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
  return Point(
    x: _wire2api_f64(arr[0]),
    y: _wire2api_f64(arr[1]),
  );
}

Size _wire2api_size(dynamic raw) {
  final arr = raw as List<dynamic>;
  if (arr.length != 2)
    throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
  return Size(
    width: _wire2api_i32(arr[0]),
    height: _wire2api_i32(arr[1]),
  );
}

TreeNode _wire2api_tree_node(dynamic raw) {
  final arr = raw as List<dynamic>;
  if (arr.length != 2)
    throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
  return TreeNode(
    name: _wire2api_String(arr[0]),
    children: _wire2api_list_tree_node(arr[1]),
  );
}

int _wire2api_u8(dynamic raw) {
  return raw as int;
}

Uint8List _wire2api_uint_8_list(dynamic raw) {
  return raw as Uint8List;
}

// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names

// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.

/// generated by flutter_rust_bridge
class FlutterRustBridgeExampleWire implements FlutterRustBridgeWireBase {
  /// Holds the symbol lookup function.
  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
      _lookup;

  /// The symbols are looked up in [dynamicLibrary].
  FlutterRustBridgeExampleWire(ffi.DynamicLibrary dynamicLibrary)
      : _lookup = dynamicLibrary.lookup;

  /// The symbols are looked up with [lookup].
  FlutterRustBridgeExampleWire.fromLookup(
      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
          lookup)
      : _lookup = lookup;

  void wire_draw_mandelbrot(
    int port_,
    ffi.Pointer<wire_Size> image_size,
    ffi.Pointer<wire_Point> zoom_point,
    double scale,
    int num_threads,
  ) {
    return _wire_draw_mandelbrot(
      port_,
      image_size,
      zoom_point,
      scale,
      num_threads,
    );
  }

  late final _wire_draw_mandelbrotPtr = _lookup<
      ffi.NativeFunction<
          ffi.Void Function(
              ffi.Int64,
              ffi.Pointer<wire_Size>,
              ffi.Pointer<wire_Point>,
              ffi.Double,
              ffi.Int32)>>('wire_draw_mandelbrot');
  late final _wire_draw_mandelbrot = _wire_draw_mandelbrotPtr.asFunction<
      void Function(
          int, ffi.Pointer<wire_Size>, ffi.Pointer<wire_Point>, double, int)>();

  void wire_passing_complex_structs(
    int port_,
    ffi.Pointer<wire_TreeNode> root,
  ) {
    return _wire_passing_complex_structs(
      port_,
      root,
    );
  }

  late final _wire_passing_complex_structsPtr = _lookup<
      ffi.NativeFunction<
          ffi.Void Function(ffi.Int64,
              ffi.Pointer<wire_TreeNode>)>>('wire_passing_complex_structs');
  late final _wire_passing_complex_structs = _wire_passing_complex_structsPtr
      .asFunction<void Function(int, ffi.Pointer<wire_TreeNode>)>();

  void wire_returning_structs_with_boxed_fields(
    int port_,
  ) {
    return _wire_returning_structs_with_boxed_fields(
      port_,
    );
  }

  late final _wire_returning_structs_with_boxed_fieldsPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>(
          'wire_returning_structs_with_boxed_fields');
  late final _wire_returning_structs_with_boxed_fields =
      _wire_returning_structs_with_boxed_fieldsPtr
          .asFunction<void Function(int)>();

  void wire_off_topic_memory_test_input_array(
    int port_,
    ffi.Pointer<wire_uint_8_list> input,
  ) {
    return _wire_off_topic_memory_test_input_array(
      port_,
      input,
    );
  }

  late final _wire_off_topic_memory_test_input_arrayPtr = _lookup<
          ffi.NativeFunction<
              ffi.Void Function(ffi.Int64, ffi.Pointer<wire_uint_8_list>)>>(
      'wire_off_topic_memory_test_input_array');
  late final _wire_off_topic_memory_test_input_array =
      _wire_off_topic_memory_test_input_arrayPtr
          .asFunction<void Function(int, ffi.Pointer<wire_uint_8_list>)>();

  void wire_off_topic_memory_test_output_zero_copy_buffer(
    int port_,
    int len,
  ) {
    return _wire_off_topic_memory_test_output_zero_copy_buffer(
      port_,
      len,
    );
  }

  late final _wire_off_topic_memory_test_output_zero_copy_bufferPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Int32)>>(
          'wire_off_topic_memory_test_output_zero_copy_buffer');
  late final _wire_off_topic_memory_test_output_zero_copy_buffer =
      _wire_off_topic_memory_test_output_zero_copy_bufferPtr
          .asFunction<void Function(int, int)>();

  void wire_off_topic_memory_test_output_vec_u8(
    int port_,
    int len,
  ) {
    return _wire_off_topic_memory_test_output_vec_u8(
      port_,
      len,
    );
  }

  late final _wire_off_topic_memory_test_output_vec_u8Ptr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Int32)>>(
          'wire_off_topic_memory_test_output_vec_u8');
  late final _wire_off_topic_memory_test_output_vec_u8 =
      _wire_off_topic_memory_test_output_vec_u8Ptr
          .asFunction<void Function(int, int)>();

  void wire_off_topic_memory_test_input_vec_of_object(
    int port_,
    ffi.Pointer<wire_list_size> input,
  ) {
    return _wire_off_topic_memory_test_input_vec_of_object(
      port_,
      input,
    );
  }

  late final _wire_off_topic_memory_test_input_vec_of_objectPtr = _lookup<
          ffi.NativeFunction<
              ffi.Void Function(ffi.Int64, ffi.Pointer<wire_list_size>)>>(
      'wire_off_topic_memory_test_input_vec_of_object');
  late final _wire_off_topic_memory_test_input_vec_of_object =
      _wire_off_topic_memory_test_input_vec_of_objectPtr
          .asFunction<void Function(int, ffi.Pointer<wire_list_size>)>();

  void wire_off_topic_memory_test_output_vec_of_object(
    int port_,
    int len,
  ) {
    return _wire_off_topic_memory_test_output_vec_of_object(
      port_,
      len,
    );
  }

  late final _wire_off_topic_memory_test_output_vec_of_objectPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Int32)>>(
          'wire_off_topic_memory_test_output_vec_of_object');
  late final _wire_off_topic_memory_test_output_vec_of_object =
      _wire_off_topic_memory_test_output_vec_of_objectPtr
          .asFunction<void Function(int, int)>();

  void wire_off_topic_memory_test_input_complex_struct(
    int port_,
    ffi.Pointer<wire_TreeNode> input,
  ) {
    return _wire_off_topic_memory_test_input_complex_struct(
      port_,
      input,
    );
  }

  late final _wire_off_topic_memory_test_input_complex_structPtr = _lookup<
          ffi.NativeFunction<
              ffi.Void Function(ffi.Int64, ffi.Pointer<wire_TreeNode>)>>(
      'wire_off_topic_memory_test_input_complex_struct');
  late final _wire_off_topic_memory_test_input_complex_struct =
      _wire_off_topic_memory_test_input_complex_structPtr
          .asFunction<void Function(int, ffi.Pointer<wire_TreeNode>)>();

  void wire_off_topic_memory_test_output_complex_struct(
    int port_,
    int len,
  ) {
    return _wire_off_topic_memory_test_output_complex_struct(
      port_,
      len,
    );
  }

  late final _wire_off_topic_memory_test_output_complex_structPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.Int32)>>(
          'wire_off_topic_memory_test_output_complex_struct');
  late final _wire_off_topic_memory_test_output_complex_struct =
      _wire_off_topic_memory_test_output_complex_structPtr
          .asFunction<void Function(int, int)>();

  void wire_off_topic_deliberately_return_error(
    int port_,
  ) {
    return _wire_off_topic_deliberately_return_error(
      port_,
    );
  }

  late final _wire_off_topic_deliberately_return_errorPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>(
          'wire_off_topic_deliberately_return_error');
  late final _wire_off_topic_deliberately_return_error =
      _wire_off_topic_deliberately_return_errorPtr
          .asFunction<void Function(int)>();

  void wire_off_topic_deliberately_panic(
    int port_,
  ) {
    return _wire_off_topic_deliberately_panic(
      port_,
    );
  }

  late final _wire_off_topic_deliberately_panicPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>(
          'wire_off_topic_deliberately_panic');
  late final _wire_off_topic_deliberately_panic =
      _wire_off_topic_deliberately_panicPtr.asFunction<void Function(int)>();

  ffi.Pointer<wire_Point> new_box_autoadd_point() {
    return _new_box_autoadd_point();
  }

  late final _new_box_autoadd_pointPtr =
      _lookup<ffi.NativeFunction<ffi.Pointer<wire_Point> Function()>>(
          'new_box_autoadd_point');
  late final _new_box_autoadd_point = _new_box_autoadd_pointPtr
      .asFunction<ffi.Pointer<wire_Point> Function()>();

  ffi.Pointer<wire_Size> new_box_autoadd_size() {
    return _new_box_autoadd_size();
  }

  late final _new_box_autoadd_sizePtr =
      _lookup<ffi.NativeFunction<ffi.Pointer<wire_Size> Function()>>(
          'new_box_autoadd_size');
  late final _new_box_autoadd_size =
      _new_box_autoadd_sizePtr.asFunction<ffi.Pointer<wire_Size> Function()>();

  ffi.Pointer<wire_TreeNode> new_box_autoadd_tree_node() {
    return _new_box_autoadd_tree_node();
  }

  late final _new_box_autoadd_tree_nodePtr =
      _lookup<ffi.NativeFunction<ffi.Pointer<wire_TreeNode> Function()>>(
          'new_box_autoadd_tree_node');
  late final _new_box_autoadd_tree_node = _new_box_autoadd_tree_nodePtr
      .asFunction<ffi.Pointer<wire_TreeNode> Function()>();

  ffi.Pointer<wire_list_size> new_list_size(
    int len,
  ) {
    return _new_list_size(
      len,
    );
  }

  late final _new_list_sizePtr = _lookup<
          ffi.NativeFunction<ffi.Pointer<wire_list_size> Function(ffi.Int32)>>(
      'new_list_size');
  late final _new_list_size =
      _new_list_sizePtr.asFunction<ffi.Pointer<wire_list_size> Function(int)>();

  ffi.Pointer<wire_list_tree_node> new_list_tree_node(
    int len,
  ) {
    return _new_list_tree_node(
      len,
    );
  }

  late final _new_list_tree_nodePtr = _lookup<
      ffi.NativeFunction<
          ffi.Pointer<wire_list_tree_node> Function(
              ffi.Int32)>>('new_list_tree_node');
  late final _new_list_tree_node = _new_list_tree_nodePtr
      .asFunction<ffi.Pointer<wire_list_tree_node> Function(int)>();

  ffi.Pointer<wire_uint_8_list> new_uint_8_list(
    int len,
  ) {
    return _new_uint_8_list(
      len,
    );
  }

  late final _new_uint_8_listPtr = _lookup<
      ffi.NativeFunction<
          ffi.Pointer<wire_uint_8_list> Function(
              ffi.Int32)>>('new_uint_8_list');
  late final _new_uint_8_list = _new_uint_8_listPtr
      .asFunction<ffi.Pointer<wire_uint_8_list> Function(int)>();

  void free_WireSyncReturnStruct(
    WireSyncReturnStruct val,
  ) {
    return _free_WireSyncReturnStruct(
      val,
    );
  }

  late final _free_WireSyncReturnStructPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(WireSyncReturnStruct)>>(
          'free_WireSyncReturnStruct');
  late final _free_WireSyncReturnStruct = _free_WireSyncReturnStructPtr
      .asFunction<void Function(WireSyncReturnStruct)>();

  void store_dart_post_cobject(
    int ptr,
  ) {
    return _store_dart_post_cobject(
      ptr,
    );
  }

  late final _store_dart_post_cobjectPtr =
      _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int32)>>(
          'store_dart_post_cobject');
  late final _store_dart_post_cobject =
      _store_dart_post_cobjectPtr.asFunction<void Function(int)>();
}

class wire_Size extends ffi.Struct {
  @ffi.Int32()
  external int width;

  @ffi.Int32()
  external int height;
}

class wire_Point extends ffi.Struct {
  @ffi.Double()
  external double x;

  @ffi.Double()
  external double y;
}

class wire_uint_8_list extends ffi.Struct {
  external ffi.Pointer<ffi.Uint8> ptr;

  @ffi.Int32()
  external int len;
}

class wire_list_tree_node extends ffi.Struct {
  external ffi.Pointer<wire_TreeNode> ptr;

  @ffi.Int32()
  external int len;
}

class wire_TreeNode extends ffi.Struct {
  external ffi.Pointer<wire_uint_8_list> name;

  external ffi.Pointer<wire_list_tree_node> children;
}

class wire_list_size extends ffi.Struct {
  external ffi.Pointer<wire_Size> ptr;

  @ffi.Int32()
  external int len;
}

OS

Manjaro (~Arch) Linux

Version of flutter_rust_bridge_codegen

1.30.0

Flutter info

[✓] Flutter (Channel stable, 2.10.5, on Manjaro Linux 5.16.18-1-MANJARO, locale en_US.UTF-8)
    • Flutter version 2.10.5 at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (5 weeks ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at ~/Android/Sdk
    • Platform android-31, build-tools 30.0.3
    • ANDROID_HOME = ~/Android/Sdk
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 13.0.1
    • cmake version 3.23.1
    • ninja version 1.10.2
    • pkg-config version 1.8.0

[✓] Android Studio (version 2021.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 64.1.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Manjaro Linux 5.16.18-1-MANJARO
    • Chrome (web)    • chrome • web-javascript • Chromium 101.0.4951.64 Manjaro Linux

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Version of clang++

13.0.1

Version of ffigen

4.1.3

Additional context

No response

@thomas725 thomas725 added the bug Something isn't working label May 22, 2022
@welcome
Copy link

welcome bot commented May 22, 2022

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented May 22, 2022

[2022-05-22T18:22:04Z WARN lib_flutter_rust_bridge_codegen::commands] See keywords such as error in command output. Maybe there is a problem? command="sh" "-c" "dart pub global run ffigen --config "/tmp/.tmpsCqlDh"" output=Output { status: ExitStatus(unix_wait_status(0)), stdout: "Running in Directory: '~/Development/git/flutter_rust_bridge'\nInput Headers: [/tmp/.tmp9lXuqN.h]\n[SEVERE] : Header /tmp/.tmp9lXuqN.h: Total errors/warnings: 1.\n[SEVERE] : /tmp/.tmp9lXuqN.h:1:10: fatal error: 'stdbool.h' file not found [Lexical or Preprocessor Issue]\nFinished, Bindings generated in /tmp/.tmpYz4wXY\n", stderr: "" }

@fzyzcjy
Copy link
Owner

fzyzcjy commented May 22, 2022

#108

@thomas725
Copy link
Contributor Author

Ah, thanks and sorry for not looking for an existing solution hard enough before opening this bug report.
Running the code generator from the root directory with the 3 parameter paths adapted worked!

flutter_rust_bridge_codegen --rust-input ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/rust/src/api.rs --dart-output ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/lib/bridge_generated.dart --c-output ~/Development/git/flutter_rust_bridge/frb_example/with_flutter/ios/Runner/bridge_generated.h

@fzyzcjy
Copy link
Owner

fzyzcjy commented May 23, 2022

🎉

@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants