flutter_flutter/engine/bindings/scripts/templates/interface_dart.template
Matt Perry 4c5aee62cd Sky: different tack for custom Rect type in the Canvas API.
Rect is now a dart-only type, defined in its own .dart file. I use
DartConverter when passing a Rect into C++. I also special-cased Rect in the
IDL compiler so that it's passed by value, instead of allocating a new
Rect object on the heap.

This also adds a mechanism to add custom .dart files to dart_sky.dart - used by
Rect.dart.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1151673002
2015-05-20 17:58:38 -04:00

61 lines
2.4 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 dart.sky;
{% 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 -%}
{% if not constructors and not custom_constructors %}abstract {% endif -%}
class {{interface_name}} extends
{{ parent_interface if parent_interface else 'NativeFieldWrapperClass2' }} {
// Constructors
{# TODO(eseidel): We only ever have one constructor. #}
{%- for constructor in constructors + custom_constructors %}
void _constructor(
{%- for arg in constructor.arguments -%}
{{ arg.dart_type }} {{ arg.name }}{% if not loop.last %}, {% endif %}
{%- endfor -%}
) native "{{interface_name}}_constructorCallback";
{{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 %}
// Operators
{% if named_property_getter %}
String operator[](String name) native "{{interface_name}}___getter___Callback";
{% endif %}
{% if named_property_setter %}
void operator[]=(String name, String value) native "{{interface_name}}___setter___Callback";
{% endif %}
}