-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
We should consider exposing our Abi enum and allow users to have ABI-specific types. This would avoid us having to continuously increase the set of types we support in the core dart:ffi library. It would also allow a ffi bindings generator to produce ABI agnostic bindings.
We would support the primitive integer, double and pointer types in dart:ffi anything else can be user defined.
One option would be using non-function type aliases (see dart-lang/language#65), which could look like this:
typedef WChar = AbiSpecificType<Int8, Int16, ...>;
class MyStruct extends Struct {
@WChar()
int char;
}
void foo(Pointer<WChar> chars);where dart:ffi would have
class AbiSpecificType<ABI1, ABI2, ...> {}When the VM compiles code it will know which ABI it runs on and can use the corresponding type from the instantiated AbiSpecificType.
One downside here is that we would have a hard time adding more ABIs in the future (though in reality we rarely add new architectures / operating systems / compilers)
/cc @dcharkes wdyt?