Skip to content

Handle more data marshaling in generated code? #444

Closed
@craiglabenz

Description

@craiglabenz

Right now, for a function like this in C:

char* my_function(char* value) { ... }

ffigen generates bindings like this:

Pointer<Char> myFunction(Pointer<Char> value) { ... }

Requiring calling Dart code to look like so:

final results = bindings.myFunction(
  'a string'.toNativeUtf8().cast<Char>(),
);

print(results.cast<Utf8>().toDartString());

If instead, ffigen generated the following code:

String myFunction(String value) { 
  final result = nativeFunction(value.toNativeUtf8().cast<Char>());
  return result.cast<Utf8>().toDartString();
}

then using ffigen would become tremendously more straightforward.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions