blob: 7dbee3ab3dd439d49df47e9d6bf9ce46591dff93 [file] [log] [blame]
//* Copyright 2017 The NXT Authors
//*
//* Licensed under the Apache License, Version 2.0 (the "License");
//* you may not use this file except in compliance with the License.
//* You may obtain a copy of the License at
//*
//* http://www.apache.org/licenses/LICENSE-2.0
//*
//* Unless required by applicable law or agreed to in writing, software
//* distributed under the License is distributed on an "AS IS" BASIS,
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//* See the License for the specific language governing permissions and
//* limitations under the License.
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;
typedef boolean bool;
typedef unsigned long long NXTCallbackUserdata;
callback NXTDeviceErrorCallback = void(DOMString message);
callback NXTBuilderErrorCallback = void(uint32_t status, DOMString message);
callback NXTBufferMapReadCallback = void(uint32_t status, ArrayBufferView data);
{% macro idlType(type) -%}
{%- if type.category == "object" -%}
NXT{{type.name.CamelCase()}}
{%- elif type.category == "enum" or type.category == "bitmask" -%}
uint32_t
{%- elif type.category == "natively defined" -%}
NXT{{type.name.CamelCase()}}
{%- else -%}
{{as_cType(type.name)}}
{%- endif -%}
{%- endmacro %}
interface {{idlType(type)}} {
{% if type.name.canonical_case() == "device" %}
{% for type in by_category["enum"] + by_category["bitmask"] %}
{% for value in type.values %}
const uint32_t {{type.name.SNAKE_CASE()}}_{{value.name.SNAKE_CASE()}} = 0x{{format(value.value, "08X")}};
{% endfor %}
{% endfor %}
{% endif %}
{% for method in native_methods(type) %}
{% if method.return_type.name.concatcase() == "void" %}
{{idlType(type)}}
{%- else %}
{{idlType(method.return_type)}}
{%- endif -%}
{{" "}}{{method.name.camelCase()}}(
{%- for arg in method.arguments -%}
{%- if not loop.first %}, {% endif -%}
{%- if arg.annotation == "value" -%}
{{idlType(arg.type)}} {{as_varName(arg.name)}}
{%- elif arg.annotation == "const*" and arg.length == "strlen" -%}
DOMString {{as_varName(arg.name)}}
{%- else -%}
sequence<{{idlType(arg.type)}}> {{as_varName(arg.name)}}
{%- endif -%}
{%- endfor -%}
);
{% endfor %}
};