mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This actually makes [Named] work, previously it was generating invalid dart. TBR=abarth@chromium.org BUG= Review URL: https://codereview.chromium.org/931273002
47 lines
1.9 KiB
Plaintext
47 lines
1.9 KiB
Plaintext
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// WARNING: Do not edit - generated code.
|
|
part of sky.core;
|
|
|
|
{% 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 %} {{ ':' if arg.is_named else '='}} {{ arg.dart_default_value }}
|
|
{#- 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 -%}
|
|
|
|
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 -%}
|
|
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 -%}
|
|
{{ arg.name }}{% if not loop.last %}, {% endif %}
|
|
{%- endfor -%}
|
|
);
|
|
{% endfor %}
|
|
|
|
// Attributes
|
|
{% for attribute in attributes %}
|
|
{{ attribute.dart_type }} get {{ attribute.name }} native "{{interface_name}}_{{ attribute.name }}_Getter";
|
|
{% if not attribute.is_read_only %}
|
|
void set {{ attribute.name }}({{ attribute.dart_type }} value) native "{{interface_name}}_{{ attribute.name }}_Setter";
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
// Methods
|
|
{% for method in methods %}
|
|
{{method.dart_type}} {{method.name}}({{ args_macro(method.arguments)}}) native "{{interface_name}}_{{ method.name }}_Callback";
|
|
{% endfor %}
|
|
}
|