Update Blink integration

This both makes changes to follow changes in Blink and adds stubs for
SetFooCallback methods
This commit is contained in:
Corentin Wallez 2017-10-25 15:39:00 -04:00 committed by Corentin Wallez
parent 61ff48c640
commit 0d045029fa
5 changed files with 53 additions and 9 deletions

View File

@ -343,6 +343,9 @@ def c_native_methods(types, typ):
Method(Name('release'), types['void'], []),
]
def js_native_methods(types, typ):
return cpp_native_methods(types, typ)
def debug(text):
print(text)
@ -435,18 +438,19 @@ def main():
if 'wire' in targets:
renders.append(FileRender('wire/WireCmd.h', 'wire/WireCmd_autogen.h', base_backend_params))
renders.append(FileRender('wire/WireCmd.cpp', 'wire/WireCmd.cpp', base_backend_params))
renders.append(FileRender('wire/WireCmd.cpp', 'wire/WireCmd_autogen.cpp', base_backend_params))
renders.append(FileRender('wire/WireClient.cpp', 'wire/WireClient.cpp', base_backend_params))
renders.append(FileRender('wire/WireServer.cpp', 'wire/WireServer.cpp', base_backend_params))
if 'blink' in targets:
renders.append(FileRender('blink/autogen.gni', 'autogen.gni', [base_params, api_params]))
renders.append(FileRender('blink/Objects.cpp', 'NXT.cpp', [base_params, api_params]))
renders.append(FileRender('blink/Forward.h', 'Forward.h', [base_params, api_params]))
js_params = {'native_methods': lambda typ: js_native_methods(api_params['types'], typ)}
renders.append(FileRender('blink/autogen.gni', 'autogen.gni', [base_params, api_params, js_params]))
renders.append(FileRender('blink/Objects.cpp', 'NXT.cpp', [base_params, api_params, js_params]))
renders.append(FileRender('blink/Forward.h', 'Forward.h', [base_params, api_params, js_params]))
for typ in api_params['by_category']['object']:
file_prefix = 'NXT' + typ.name.CamelCase()
params = [base_params, api_params, {'type': typ}]
params = [base_params, api_params, js_params, {'type': typ}]
renders.append(FileRender('blink/Object.h', file_prefix + '.h', params))
renders.append(FileRender('blink/Object.idl', file_prefix + '.idl', params))

View File

@ -21,6 +21,16 @@ namespace blink {
class NXT{{other_type.name.CamelCase()}};
{% endfor %}
class V8NXTDeviceErrorCallback;
using NXTDeviceErrorCallback = V8NXTDeviceErrorCallback*;
class V8NXTBuilderErrorCallback;
using NXTBuilderErrorCallback = V8NXTBuilderErrorCallback*;
class V8NXTBufferMapReadCallback;
using NXTBufferMapReadCallback = V8NXTBufferMapReadCallback*;
using NXTCallbackUserdata = uint64_t;
}
struct nxtProcTable_s;

View File

@ -17,6 +17,8 @@
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 -%}
@ -27,7 +29,7 @@
#ifndef {{Class}}_H
#define {{Class}}_H
#include "bindings/core/v8/ScriptWrappable.h"
#include "platform/bindings/ScriptWrappable.h"
#include "platform/heap/GarbageCollected.h"
#include "platform/wtf/text/WTFString.h"
@ -54,7 +56,7 @@ class {{Class}} final :
{{Class}}({{as_cType(type.name)}} self, Member<NXTState> state);
void Dispose();
{% for method in type.methods %}
{% for method in native_methods(type) %}
{% if method.return_type.name.concatcase() == "void" %}
{{Class}}*
{%- else %}

View File

@ -13,12 +13,21 @@
//* 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 -%}
@ -33,7 +42,7 @@ interface {{idlType(type)}} {
{% endfor %}
{% endif %}
{% for method in type.methods %}
{% for method in native_methods(type) %}
{% if method.return_type.name.concatcase() == "void" %}
{{idlType(type)}}
{%- else %}
@ -47,7 +56,7 @@ interface {{idlType(type)}} {
{%- elif arg.annotation == "const*" and arg.length == "strlen" -%}
DOMString {{as_varName(arg.name)}}
{%- else -%}
{{idlType(arg.type)}}[] {{as_varName(arg.name)}}
sequence<{{idlType(arg.type)}}> {{as_varName(arg.name)}}
{%- endif -%}
{%- endfor -%}
);

View File

@ -17,6 +17,8 @@
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 -%}
@ -110,8 +112,25 @@ namespace blink {
}
{% endfor %}
{% if type.is_builder %}
{{Class}}* {{Class}}::setErrorCallback(V8NXTBuilderErrorCallback*, unsigned long, unsigned long) {
//TODO
return this;
}
{% endif %}
{{as_cType(type.name)}} {{Class}}::GetNXT() {
return self_;
}
{% endfor %}
NXTDevice* NXTDevice::setErrorCallback(V8NXTDeviceErrorCallback*, unsigned long) {
return this;
}
NXTBuffer* NXTBuffer::mapReadAsync(unsigned int, unsigned int, V8NXTBufferMapReadCallback*, unsigned long) {
return this;
}
}