diff --git a/build/WebIDL.py b/build/WebIDL.py index 22eba1be..c1b41aeb 100644 --- a/build/WebIDL.py +++ b/build/WebIDL.py @@ -1,3 +1,6 @@ +# from https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/third_party/WebIDL.py +# patched to add int pointers support + # from https://hg.mozilla.org/mozilla-central/file/tip/dom/bindings/parser/WebIDL.py # rev 501baeb3a034 @@ -4582,7 +4585,7 @@ def p_SingleTypeIntPtrType(self, p): SingleType : INTPTR TypeSuffixStartingWithArray """ p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.IntPtr], p[2]) - + def p_UnionType(self, p): """ UnionType : LPAREN UnionMemberType OR UnionMemberType UnionMemberTypes RPAREN diff --git a/build/webidl_binder.py b/build/webidl_binder.py index 79d5eef1..13dff642 100644 --- a/build/webidl_binder.py +++ b/build/webidl_binder.py @@ -3,6 +3,10 @@ # University of Illinois/NCSA Open Source License. Both these licenses can be # found in the LICENSE file. +## JavascriptSubtitlesOctopus +## Patched to add int pointers support and fix string setter for structs +## Based in https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/tools/webidl_binder.py + """WebIDL binder https://emscripten.org/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder.html @@ -719,7 +723,12 @@ def render_function(class_name, func_name, sigs, return_type, non_pointer, get_sigs = {0: []} set_sigs = {1: [Dummy({'type': m.type})]} get_call_content = take_addr_if_nonpointer(m) + 'self->' + attr - set_call_content = 'self->' + attr + ' = ' + deref_if_nonpointer(m) + 'arg0' + if m.type.isDOMString(): + set_call_content = """ char* copy = (char*)malloc(strlen(%s) + 1); + strcpy(copy, %s); + self->%s = copy""" % (deref_if_nonpointer(m) + 'arg0', deref_if_nonpointer(m) + 'arg0', attr) + else: + set_call_content = 'self->' + attr + ' = ' + deref_if_nonpointer(m) + 'arg0' get_name = 'get_' + attr mid_js += [r'''