Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Events and Styles String Mutation, closes #77 #122

Merged
merged 4 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions build/WebIDL.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# from http://mxr.mozilla.org/mozilla-central/source/dom/bindings/parser/WebIDL.py
## JavascriptSubtitlesOctopus
## Patched to:
## - add integer pointers (IntPtr)
## - add [Owner] Extended attribute
## 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

# This Source Code Form is subject to the terms of the Mozilla Public
Expand Down Expand Up @@ -2858,6 +2864,7 @@ def handleExtendedAttribute(self, attr):
identifier == "AvailableIn" or
identifier == "Const" or
identifier == "Value" or
identifier == "Owner" or
identifier == "BoundsChecked" or
identifier == "NewObject"):
# Known attributes that we don't need to do anything with here
Expand Down Expand Up @@ -2933,7 +2940,7 @@ def addExtendedAttributes(self, attrs):
self.enforceRange = True
elif identifier == "TreatNonCallableAsNull":
self._allowTreatNonCallableAsNull = True
elif identifier in ['Ref', 'Const']:
elif identifier in ['Ref', 'Const', 'Owner']:
# ok in emscripten
self._extraAttributes[identifier] = True
else:
Expand Down Expand Up @@ -4923,11 +4930,12 @@ def p_error(self, p):

def __init__(self, outputdir='', lexer=None):
Tokenizer.__init__(self, outputdir, lexer)
self.parser = yacc.yacc(module=self,
self.parser = yacc.yacc(debug=0,
module=self,
outputdir=outputdir,
tabmodule='webidlyacc',
errorlog=yacc.NullLogger(),
picklefile='WebIDLGrammar.pkl')
write_tables=0,
errorlog=yacc.NullLogger())
self._globalScope = IDLScope(BuiltinLocation("<Global Scope>"), None, None)
self._installBuiltins(self._globalScope)
self._productions = []
Expand Down
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

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

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

Loading