diff options
Diffstat (limited to 'js/src/regexp/update-headers.py')
-rw-r--r-- | js/src/regexp/update-headers.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/js/src/regexp/update-headers.py b/js/src/regexp/update-headers.py new file mode 100644 index 000000000..0cff9d6ae --- /dev/null +++ b/js/src/regexp/update-headers.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +# +# This script modifies V8 regexp source files to make them suitable for +# inclusion in SpiderMonkey. Specifically, it: +# +# 1. Rewrites all #includes of V8 regexp headers to point to their location in +# the SM tree: src/regexp/* --> regexp/* +# 2. Removes all #includes of other V8 src/* headers. The required definitions +# will be provided by regexp-shim.h. +# +# Usage: +# cd js/src/regexp +# find . -name "*.h" -o -name "*.cc" | xargs ./update_headers.py +# + +import fileinput +import re +import sys + +# 1. Rewrite includes of V8 regexp headers +regexp_include = re.compile('#include "src/regexp') +regexp_include_new = '#include "regexp' + +# 2. Remove includes of other V8 headers +other_include = re.compile('#include "src/') + +for line in fileinput.input(inplace=1): + if regexp_include.search(line): + sys.stdout.write(re.sub(regexp_include, regexp_include_new, line)) + elif other_include.search(line): + pass + else: + sys.stdout.write(line) |