-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add webidl_binder patches for future reference
- Loading branch information
1 parent
ffdffab
commit bcce36d
Showing
4 changed files
with
510 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
build/patches/webidl_binder/0001-WebIDL-Add-headers-and-make-it-work-under-SubtitlesO.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
From d9b7e2738213d631810ace5e5f47cc8bc210fa8c Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Thiago=20Fran=C3=A7a=20da=20Silva?= | ||
<[email protected]> | ||
Date: Fri, 18 Feb 2022 21:18:04 -0300 | ||
Subject: [PATCH 1/4] WebIDL: Add headers and make it work under | ||
SubtitlesOctopus project | ||
|
||
--- | ||
build/WebIDL.py | 3 +++ | ||
build/tempfiles.py | 3 +++ | ||
build/webidl_binder.py | 20 ++++++++++---------- | ||
3 files changed, 16 insertions(+), 10 deletions(-) | ||
|
||
diff --git a/build/WebIDL.py b/build/WebIDL.py | ||
index 14689cb..8892616 100644 | ||
--- a/build/WebIDL.py | ||
+++ b/build/WebIDL.py | ||
@@ -1,3 +1,6 @@ | ||
+## JavascriptSubtitlesOctopus | ||
+## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/third_party/WebIDL.py | ||
+ | ||
# from https://hg.mozilla.org/mozilla-central/file/tip/dom/bindings/parser/WebIDL.py | ||
# rev 501baeb3a034 | ||
|
||
diff --git a/build/tempfiles.py b/build/tempfiles.py | ||
index e1c9dcc..6487516 100644 | ||
--- a/build/tempfiles.py | ||
+++ b/build/tempfiles.py | ||
@@ -1,3 +1,6 @@ | ||
+## JavascriptSubtitlesOctopus | ||
+## From https://github.com/emscripten-core/emscripten/blob/c834ef7d69ccb4100239eeba0b0f6573fed063bc/tools/tempfiles.py | ||
+ | ||
# Copyright 2013 The Emscripten Authors. All rights reserved. | ||
# Emscripten is available under two separate licenses, the MIT license and the | ||
# University of Illinois/NCSA Open Source License. Both these licenses can be | ||
diff --git a/build/webidl_binder.py b/build/webidl_binder.py | ||
index da864f8..687a5ba 100644 | ||
--- a/build/webidl_binder.py | ||
+++ b/build/webidl_binder.py | ||
@@ -1,3 +1,6 @@ | ||
+## JavascriptSubtitlesOctopus | ||
+## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/tools/webidl_binder.py | ||
+ | ||
# Copyright 2014 The Emscripten Authors. All rights reserved. | ||
# Emscripten is available under two separate licenses, the MIT license and the | ||
# University of Illinois/NCSA Open Source License. Both these licenses can be | ||
@@ -10,15 +13,12 @@ https://emscripten.org/docs/porting/connecting_cpp_and_javascript/WebIDL-Binder. | ||
|
||
import os | ||
import sys | ||
+from tempfiles import try_delete | ||
|
||
-__scriptdir__ = os.path.dirname(os.path.abspath(__file__)) | ||
-__rootdir__ = os.path.dirname(__scriptdir__) | ||
-sys.path.append(__rootdir__) | ||
- | ||
-from tools import shared, utils | ||
+def path_from_root(*pathelems): | ||
+ return os.path.join(os.path.join('/', 'emsdk', 'upstream', 'emscripten'), *pathelems) | ||
|
||
-sys.path.append(utils.path_from_root('third_party')) | ||
-sys.path.append(utils.path_from_root('third_party/ply')) | ||
+sys.path.append(path_from_root('third_party', 'ply')) | ||
|
||
import WebIDL | ||
|
||
@@ -50,14 +50,14 @@ class Dummy: | ||
input_file = sys.argv[1] | ||
output_base = sys.argv[2] | ||
|
||
-shared.try_delete(output_base + '.cpp') | ||
-shared.try_delete(output_base + '.js') | ||
+try_delete(output_base + '.cpp') | ||
+try_delete(output_base + '.js') | ||
|
||
p = WebIDL.Parser() | ||
p.parse(r''' | ||
interface VoidPtr { | ||
}; | ||
-''' + utils.read_file(input_file)) | ||
+''' + open(input_file).read()) | ||
data = p.finish() | ||
|
||
interfaces = {} | ||
-- | ||
2.35.1 | ||
|
101 changes: 101 additions & 0 deletions
101
build/patches/webidl_binder/0002-WebIDL-Implement-Integer-Pointer-type-IntPtr.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
From 2e7bb7592195c94853c4e3b6718d47677e1555bf Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Thiago=20Fran=C3=A7a=20da=20Silva?= | ||
<[email protected]> | ||
Date: Fri, 18 Feb 2022 21:19:20 -0300 | ||
Subject: [PATCH 2/4] WebIDL: Implement Integer Pointer type (IntPtr) | ||
|
||
This allows compatibility with `changed` parameter of the `renderImage` function | ||
--- | ||
build/WebIDL.py | 15 +++++++++++++++ | ||
build/webidl_binder.py | 4 ++++ | ||
2 files changed, 19 insertions(+) | ||
|
||
diff --git a/build/WebIDL.py b/build/WebIDL.py | ||
index 8892616..d140f8f 100644 | ||
--- a/build/WebIDL.py | ||
+++ b/build/WebIDL.py | ||
@@ -1,4 +1,6 @@ | ||
## JavascriptSubtitlesOctopus | ||
+## Patched to: | ||
+## - add integer pointers (IntPtr) | ||
## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/third_party/WebIDL.py | ||
|
||
# from https://hg.mozilla.org/mozilla-central/file/tip/dom/bindings/parser/WebIDL.py | ||
@@ -2165,6 +2167,7 @@ class IDLBuiltinType(IDLType): | ||
'date', | ||
'void', | ||
# Funny stuff | ||
+ 'IntPtr', | ||
'ArrayBuffer', | ||
'ArrayBufferView', | ||
'Int8Array', | ||
@@ -2184,6 +2187,7 @@ class IDLBuiltinType(IDLType): | ||
Types.short: IDLType.Tags.int16, | ||
Types.unsigned_short: IDLType.Tags.uint16, | ||
Types.long: IDLType.Tags.int32, | ||
+ Types.IntPtr: IDLType.Tags.int32, | ||
Types.unsigned_long: IDLType.Tags.uint32, | ||
Types.long_long: IDLType.Tags.int64, | ||
Types.unsigned_long_long: IDLType.Tags.uint64, | ||
@@ -2380,6 +2384,9 @@ BuiltinTypes = { | ||
IDLBuiltinType.Types.any: | ||
IDLBuiltinType(BuiltinLocation("<builtin type>"), "Any", | ||
IDLBuiltinType.Types.any), | ||
+ IDLBuiltinType.Types.IntPtr: | ||
+ IDLBuiltinType(BuiltinLocation("<builtin type>"), "IntPtr", | ||
+ IDLBuiltinType.Types.IntPtr), | ||
IDLBuiltinType.Types.domstring: | ||
IDLBuiltinType(BuiltinLocation("<builtin type>"), "String", | ||
IDLBuiltinType.Types.domstring), | ||
@@ -3622,6 +3629,7 @@ class Tokenizer(object): | ||
"...": "ELLIPSIS", | ||
"::": "SCOPE", | ||
"Date": "DATE", | ||
+ "IntPtr": "INTPTR", | ||
"DOMString": "DOMSTRING", | ||
"ByteString": "BYTESTRING", | ||
"any": "ANY", | ||
@@ -4507,6 +4515,7 @@ class Parser(Tokenizer): | ||
| DATE | ||
| DOMSTRING | ||
| BYTESTRING | ||
+ | INTPTR | ||
| ANY | ||
| ATTRIBUTE | ||
| BOOLEAN | ||
@@ -4573,6 +4582,12 @@ class Parser(Tokenizer): | ||
""" | ||
p[0] = self.handleModifiers(BuiltinTypes[IDLBuiltinType.Types.any], p[2]) | ||
|
||
+ 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 687a5ba..e9a56e5 100644 | ||
--- a/build/webidl_binder.py | ||
+++ b/build/webidl_binder.py | ||
@@ -1,4 +1,6 @@ | ||
## JavascriptSubtitlesOctopus | ||
+## Patched to: | ||
+## - add integer pointers (IntPtr) | ||
## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/tools/webidl_binder.py | ||
|
||
# Copyright 2014 The Emscripten Authors. All rights reserved. | ||
@@ -337,6 +339,8 @@ def type_to_c(t, non_pointing=False): | ||
ret = 'bool' | ||
elif t == 'Any' or t == 'VoidPtr': | ||
ret = 'void*' | ||
+ elif t == 'IntPtr': | ||
+ ret = 'int*' | ||
elif t in interfaces: | ||
ret = (interfaces[t].getExtendedAttribute('Prefix') or [''])[0] + t + ('' if non_pointing else '*') | ||
else: | ||
-- | ||
2.35.1 | ||
|
35 changes: 35 additions & 0 deletions
35
build/patches/webidl_binder/0003-WebIDL-Implement-ByteString-type.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From ea9c45b10d807966510711da723ea1ae558efd45 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Thiago=20Fran=C3=A7a=20da=20Silva?= | ||
<[email protected]> | ||
Date: Mon, 14 Feb 2022 22:27:57 -0300 | ||
Subject: [PATCH 3/4] WebIDL: Implement ByteString type | ||
|
||
This allows compatibility with `bitmap` attribute of the ASS_Image struct | ||
--- | ||
build/webidl_binder.py | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/build/webidl_binder.py b/build/webidl_binder.py | ||
index e9a56e5..faedf10 100644 | ||
--- a/build/webidl_binder.py | ||
+++ b/build/webidl_binder.py | ||
@@ -1,6 +1,7 @@ | ||
## JavascriptSubtitlesOctopus | ||
## Patched to: | ||
## - add integer pointers (IntPtr) | ||
+## - implement ByteString type | ||
## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/tools/webidl_binder.py | ||
|
||
# Copyright 2014 The Emscripten Authors. All rights reserved. | ||
@@ -327,6 +328,8 @@ def type_to_c(t, non_pointing=False): | ||
ret = 'char' | ||
elif t == 'Octet': | ||
ret = 'unsigned char' | ||
+ elif t == 'ByteString': | ||
+ ret = 'unsigned char*' | ||
elif t == 'Void': | ||
ret = 'void' | ||
elif t == 'String': | ||
-- | ||
2.35.1 | ||
|
Oops, something went wrong.