|
| 1 | +From 2e7bb7592195c94853c4e3b6718d47677e1555bf Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Thiago=20Fran=C3=A7a=20da=20Silva?= |
| 3 | + <tfsthiagobr98@outlook.com> |
| 4 | +Date: Fri, 18 Feb 2022 21:19:20 -0300 |
| 5 | +Subject: [PATCH 2/4] WebIDL: Implement Integer Pointer type (IntPtr) |
| 6 | + |
| 7 | +This allows compatibility with `changed` parameter of the `renderImage` function |
| 8 | +--- |
| 9 | + build/WebIDL.py | 15 +++++++++++++++ |
| 10 | + build/webidl_binder.py | 4 ++++ |
| 11 | + 2 files changed, 19 insertions(+) |
| 12 | + |
| 13 | +diff --git a/build/WebIDL.py b/build/WebIDL.py |
| 14 | +index 8892616..d140f8f 100644 |
| 15 | +--- a/build/WebIDL.py |
| 16 | ++++ b/build/WebIDL.py |
| 17 | +@@ -1,4 +1,6 @@ |
| 18 | + ## JavascriptSubtitlesOctopus |
| 19 | ++## Patched to: |
| 20 | ++## - add integer pointers (IntPtr) |
| 21 | + ## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/third_party/WebIDL.py |
| 22 | + |
| 23 | + # from https://hg.mozilla.org/mozilla-central/file/tip/dom/bindings/parser/WebIDL.py |
| 24 | +@@ -2165,6 +2167,7 @@ class IDLBuiltinType(IDLType): |
| 25 | + 'date', |
| 26 | + 'void', |
| 27 | + # Funny stuff |
| 28 | ++ 'IntPtr', |
| 29 | + 'ArrayBuffer', |
| 30 | + 'ArrayBufferView', |
| 31 | + 'Int8Array', |
| 32 | +@@ -2184,6 +2187,7 @@ class IDLBuiltinType(IDLType): |
| 33 | + Types.short: IDLType.Tags.int16, |
| 34 | + Types.unsigned_short: IDLType.Tags.uint16, |
| 35 | + Types.long: IDLType.Tags.int32, |
| 36 | ++ Types.IntPtr: IDLType.Tags.int32, |
| 37 | + Types.unsigned_long: IDLType.Tags.uint32, |
| 38 | + Types.long_long: IDLType.Tags.int64, |
| 39 | + Types.unsigned_long_long: IDLType.Tags.uint64, |
| 40 | +@@ -2380,6 +2384,9 @@ BuiltinTypes = { |
| 41 | + IDLBuiltinType.Types.any: |
| 42 | + IDLBuiltinType(BuiltinLocation("<builtin type>"), "Any", |
| 43 | + IDLBuiltinType.Types.any), |
| 44 | ++ IDLBuiltinType.Types.IntPtr: |
| 45 | ++ IDLBuiltinType(BuiltinLocation("<builtin type>"), "IntPtr", |
| 46 | ++ IDLBuiltinType.Types.IntPtr), |
| 47 | + IDLBuiltinType.Types.domstring: |
| 48 | + IDLBuiltinType(BuiltinLocation("<builtin type>"), "String", |
| 49 | + IDLBuiltinType.Types.domstring), |
| 50 | +@@ -3622,6 +3629,7 @@ class Tokenizer(object): |
| 51 | + "...": "ELLIPSIS", |
| 52 | + "::": "SCOPE", |
| 53 | + "Date": "DATE", |
| 54 | ++ "IntPtr": "INTPTR", |
| 55 | + "DOMString": "DOMSTRING", |
| 56 | + "ByteString": "BYTESTRING", |
| 57 | + "any": "ANY", |
| 58 | +@@ -4507,6 +4515,7 @@ class Parser(Tokenizer): |
| 59 | + | DATE |
| 60 | + | DOMSTRING |
| 61 | + | BYTESTRING |
| 62 | ++ | INTPTR |
| 63 | + | ANY |
| 64 | + | ATTRIBUTE |
| 65 | + | BOOLEAN |
| 66 | +@@ -4573,6 +4582,12 @@ class Parser(Tokenizer): |
| 67 | + """ |
| 68 | + p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.any], p[2]) |
| 69 | + |
| 70 | ++ def p_SingleTypeIntPtrType(self, p): |
| 71 | ++ """ |
| 72 | ++ SingleType : INTPTR TypeSuffixStartingWithArray |
| 73 | ++ """ |
| 74 | ++ p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.IntPtr], p[2]) |
| 75 | ++ |
| 76 | + def p_UnionType(self, p): |
| 77 | + """ |
| 78 | + UnionType : LPAREN UnionMemberType OR UnionMemberType UnionMemberTypes RPAREN |
| 79 | +diff --git a/build/webidl_binder.py b/build/webidl_binder.py |
| 80 | +index 687a5ba..e9a56e5 100644 |
| 81 | +--- a/build/webidl_binder.py |
| 82 | ++++ b/build/webidl_binder.py |
| 83 | +@@ -1,4 +1,6 @@ |
| 84 | + ## JavascriptSubtitlesOctopus |
| 85 | ++## Patched to: |
| 86 | ++## - add integer pointers (IntPtr) |
| 87 | + ## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/tools/webidl_binder.py |
| 88 | + |
| 89 | + # Copyright 2014 The Emscripten Authors. All rights reserved. |
| 90 | +@@ -337,6 +339,8 @@ def type_to_c(t, non_pointing=False): |
| 91 | + ret = 'bool' |
| 92 | + elif t == 'Any' or t == 'VoidPtr': |
| 93 | + ret = 'void*' |
| 94 | ++ elif t == 'IntPtr': |
| 95 | ++ ret = 'int*' |
| 96 | + elif t in interfaces: |
| 97 | + ret = (interfaces[t].getExtendedAttribute('Prefix') or [''])[0] + t + ('' if non_pointing else '*') |
| 98 | + else: |
| 99 | +-- |
| 100 | +2.35.1 |
| 101 | + |
0 commit comments