ceylon-dart icon indicating copy to clipboard operation
ceylon-dart copied to clipboard

support default implementations in native headers

Open jvasileff opened this issue 8 years ago • 1 comments

native headers may provide default implementations. For example:

native class C() {
    shared String defaultMember0 => "";
    native shared String defaultMember1 => "";
    native shared String defaultMember2 => ""; 
    native shared String nonDefaultMember;
}

native("dart") class C() {
    native("dart") shared String defaultMember2 => "";
    native("dart") shared String nonDefaultMember => "";
}

and toplevels

native String s => "";

For toplevel functions and values with default implementations, backend specific implementations are optional.

For toplevel classes, objects, and interfaces with default implementations for all members, it's unclear if backend specific implementations should be required.

Default members for Inner class and interface headers appear to be valid.

jvasileff avatar Oct 16 '16 17:10 jvasileff

A significant challenge will be how to indicate if there is an actual native Dart language implementation for a native header. We'll need to know this in order to suppress "no native implementation for backend" errors.

The javascript approach is to require specially named files to hold the native implementations, but that's not ideal for Dart since it will make editing the native implementations much more difficult.

Perhaps:

  1. Initially use a compiler annotation, to get something that works. Then,
  2. introduce some comment syntax to be used in the *.dart code that can indicate what toplevel declarations are present. (This would be much easier than trying to parse the dart code.)

jvasileff avatar Oct 16 '16 17:10 jvasileff