Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: sky/engine/bindings/scripts/templates/interface_dart.template

Issue 923093003: Add support for named arguments to our bindings generation. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/bindings/scripts/dart_methods.py ('k') | sky/engine/core/dom/Node.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings/scripts/templates/interface_dart.template
diff --git a/sky/engine/bindings/scripts/templates/interface_dart.template b/sky/engine/bindings/scripts/templates/interface_dart.template
index 9037bd504581151760ec3669e2c5e44e2ad7204c..274760a300be6de8a44112430c0b05b7fdc23dd6 100644
--- a/sky/engine/bindings/scripts/templates/interface_dart.template
+++ b/sky/engine/bindings/scripts/templates/interface_dart.template
@@ -5,23 +5,24 @@
// WARNING: Do not edit - generated code.
part of sky.core;
-abstract class {{interface_name}} extends {{ parent_interface if parent_interface else 'NativeFieldWrapperClass2' }} {
-
{% macro args_macro(args) -%}
{%- for arg in args -%}
{%- if arg.is_optional and (loop.first or not args[arg.index-1].is_optional) -%}
- [
+ {{ '{' if arg.is_named else '[' }}
{%- endif -%}
{{ arg.dart_type }} {{ arg.name }}
{%- if arg.is_optional %} = {{ arg.dart_default_value }}
- {%- if loop.last -%}]{%- endif -%}
+ {#- TODO(eseidel): This does not support having both optional and named arguments! -#}
+ {%- if loop.last -%}{{ '}' if arg.is_named else ']' }}{%- endif -%}
{%- endif -%}
{%- if not loop.last %}, {% endif %}
{%- endfor -%}
-{%- endmacro %}
+{%- endmacro -%}
+abstract class {{interface_name}} extends {{ parent_interface if parent_interface else 'NativeFieldWrapperClass2' }} {
+ // Constructors
{# TODO(eseidel): We only ever have one constructor. #}
-{% for constructor in constructors %}
+{%- for constructor in constructors -%}
static {{interface_name}} _constructor({{ args_macro(constructor.arguments) }}) native "{{interface_name}}_constructorCallback";
factory {{interface_name}}({{ args_macro(constructor.arguments) }}) => _constructor(
{%- for arg in constructor.arguments -%}
@@ -30,6 +31,7 @@ abstract class {{interface_name}} extends {{ parent_interface if parent_interfac
);
{% endfor %}
+ // Attributes
{% for attribute in attributes %}
{{ attribute.dart_type }} get {{ attribute.name }} native "{{interface_name}}_{{ attribute.name }}_Getter";
{% if not attribute.is_read_only %}
@@ -37,7 +39,8 @@ abstract class {{interface_name}} extends {{ parent_interface if parent_interfac
{% endif %}
{% endfor %}
+ // Methods
{% for method in methods %}
- {{method.dart_type}} {{method.name}}({{ args_macro(method.arguments)}} ) native "{{interface_name}}_{{ method.name }}_Callback";
+ {{method.dart_type}} {{method.name}}({{ args_macro(method.arguments)}}) native "{{interface_name}}_{{ method.name }}_Callback";
{% endfor %}
}
« no previous file with comments | « sky/engine/bindings/scripts/dart_methods.py ('k') | sky/engine/core/dom/Node.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698