Skip to content

Commit

Permalink
WebIDL: Use malloc/strcpy on Struct String setters, fix libass#77
Browse files Browse the repository at this point in the history
  • Loading branch information
TFSThiagoBR98 committed Feb 18, 2022
1 parent 921e9d3 commit 9391c33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build/webidl_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## Patched to:
## - add integer pointers (IntPtr)
## - implement ByteString type
## - fix string setter for structs
## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/tools/webidl_binder.py

# Copyright 2014 The Emscripten Authors. All rights reserved.
Expand Down Expand Up @@ -723,7 +724,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'''
Expand Down

0 comments on commit 9391c33

Please sign in to comment.