ceylon-dart
ceylon-dart copied to clipboard
support default implementations in native headers
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.
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:
- Initially use a compiler annotation, to get something that works. Then,
- 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.)