blob: a222fda4e3995505708b76c552ac1cfc42b0135f [file] [log] [blame]
// 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.
{% import "runtime_type_macros.tmpl" as runtime_type_macros %}
{% macro define(enum, typepkg, package) %}
type {{enum|name}} int32
const (
{% for field in enum.fields %}
{% if field.value %}
{{enum|name}}_{{field|name}} = {{field.value|expression_to_text}}
{% elif loop.first %}
{{enum|name}}_{{field|name}} = 0
{% else %}
{{enum|name}}_{{field|name}} = {{enum|name}}_{{enum.fields[loop.index0 - 1]|name}} + 1;
{% endif %}
{% endfor %}
)
{%- set type_name = enum|name(exported) %}
{{runtime_type_macros.maybeWriteStaticMojomTypeAccessor(typepkg, enum)}}
{{runtime_type_macros.maybeWriteMojomTypeAccessor(typepkg, enum,type_name)}}
{% endmacro %}