Skip to content

File tree

3 files changed

+135
-102
lines changed

3 files changed

+135
-102
lines changed

build/WebIDL.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# from http://mxr.mozilla.org/mozilla-central/source/dom/bindings/parser/WebIDL.py
1+
## JavascriptSubtitlesOctopus
2+
## Patched to:
3+
## - add integer pointers (IntPtr)
4+
## From https://github.com/emscripten-core/emscripten/blob/f36f9fcaf83db93e6a6d0f0cdc47ab6379ade139/third_party/WebIDL.py
5+
6+
# from https://hg.mozilla.org/mozilla-central/file/tip/dom/bindings/parser/WebIDL.py
27
# rev 501baeb3a034
38

49
# This Source Code Form is subject to the terms of the Mozilla Public
@@ -4923,11 +4928,12 @@ def p_error(self, p):
49234928

49244929
def __init__(self, outputdir='', lexer=None):
49254930
Tokenizer.__init__(self, outputdir, lexer)
4926-
self.parser = yacc.yacc(module=self,
4931+
self.parser = yacc.yacc(debug=0,
4932+
module=self,
49274933
outputdir=outputdir,
49284934
tabmodule='webidlyacc',
4929-
errorlog=yacc.NullLogger(),
4930-
picklefile='WebIDLGrammar.pkl')
4935+
write_tables=0,
4936+
errorlog=yacc.NullLogger())
49314937
self._globalScope = IDLScope(BuiltinLocation("<Global Scope>"), None, None)
49324938
self._installBuiltins(self._globalScope)
49334939
self._productions = []

build/tempfiles.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
## JavascriptSubtitlesOctopus
2+
## From https://github.com/emscripten-core/emscripten/blob/c834ef7d69ccb4100239eeba0b0f6573fed063bc/tools/tempfiles.py
3+
14
# Copyright 2013 The Emscripten Authors. All rights reserved.
25
# Emscripten is available under two separate licenses, the MIT license and the
36
# University of Illinois/NCSA Open Source License. Both these licenses can be
47
# found in the LICENSE file.
58

6-
from __future__ import print_function
79
import os
810
import shutil
911
import tempfile
@@ -28,13 +30,14 @@ def try_delete(pathname):
2830
if not os.path.exists(pathname):
2931
return
3032

31-
write_bits = stat.S_IWRITE | stat.S_IWGRP | stat.S_IWOTH
33+
# Ensure all files are readable and writable by the current user.
34+
permission_bits = stat.S_IWRITE | stat.S_IREAD
3235

3336
def is_writable(path):
34-
return (os.stat(path).st_mode & write_bits) == write_bits
37+
return (os.stat(path).st_mode & permission_bits) != permission_bits
3538

3639
def make_writable(path):
37-
os.chmod(path, os.stat(path).st_mode | write_bits)
40+
os.chmod(path, os.stat(path).st_mode | permission_bits)
3841

3942
# Some tests make files and subdirectories read-only, so rmtree/unlink will not delete
4043
# them. Force-make everything writable in the subdirectory to make it
@@ -54,9 +57,9 @@ def make_writable(path):
5457
pass
5558

5659

57-
class TempFiles(object):
58-
def __init__(self, tmp, save_debug_files=False):
59-
self.tmp = tmp
60+
class TempFiles:
61+
def __init__(self, tmpdir, save_debug_files):
62+
self.tmpdir = tmpdir
6063
self.save_debug_files = save_debug_files
6164
self.to_clean = []
6265

@@ -67,17 +70,19 @@ def note(self, filename):
6770

6871
def get(self, suffix):
6972
"""Returns a named temp file with the given prefix."""
70-
named_file = tempfile.NamedTemporaryFile(dir=self.tmp, suffix=suffix, delete=False)
73+
named_file = tempfile.NamedTemporaryFile(dir=self.tmpdir, suffix=suffix, delete=False)
7174
self.note(named_file.name)
7275
return named_file
7376

7477
def get_file(self, suffix):
75-
"""Returns an object representing a RAII-like access to a temp file, that has convenient pythonesque
76-
semantics for being used via a construct 'with TempFiles.get_file(..) as filename:'. The file will be
77-
deleted immediately once the 'with' block is exited."""
78-
class TempFileObject(object):
78+
"""Returns an object representing a RAII-like access to a temp file
79+
that has convenient pythonesque semantics for being used via a construct
80+
'with TempFiles.get_file(..) as filename:'.
81+
The file will be deleted immediately once the 'with' block is exited.
82+
"""
83+
class TempFileObject:
7984
def __enter__(self_):
80-
self_.file = tempfile.NamedTemporaryFile(dir=self.tmp, suffix=suffix, delete=False)
85+
self_.file = tempfile.NamedTemporaryFile(dir=self.tmpdir, suffix=suffix, delete=False)
8186
self_.file.close() # NamedTemporaryFile passes out open file handles, but callers prefer filenames (and open their own handles manually if needed)
8287
return self_.file.name
8388

@@ -88,20 +93,14 @@ def __exit__(self_, type, value, traceback):
8893

8994
def get_dir(self):
9095
"""Returns a named temp directory with the given prefix."""
91-
directory = tempfile.mkdtemp(dir=self.tmp)
96+
directory = tempfile.mkdtemp(dir=self.tmpdir)
9297
self.note(directory)
9398
return directory
9499

95100
def clean(self):
96101
if self.save_debug_files:
97-
print('not cleaning up temp files since in debug-save mode, see them in %s' % (self.tmp,), file=sys.stderr)
102+
print(f'not cleaning up temp files since in debug-save mode, see them in {self.tmpdir}', file=sys.stderr)
98103
return
99104
for filename in self.to_clean:
100105
try_delete(filename)
101106
self.to_clean = []
102-
103-
def run_and_clean(self, func):
104-
try:
105-
return func()
106-
finally:
107-
self.clean()

0 commit comments

Comments
 (0)