aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-11-06 11:48:23 -0700
committerAlon Zakai <azakai@mozilla.com>2010-11-06 11:48:23 -0700
commit38cf88b3607066a9fa1d3f7ca0518e2bc9844ff6 (patch)
tree9922c65c3a96701ae0a591535990f8bab5cbd67c
parent906a8745c2a70d3bf797bce28c5c0ba055f8b98a (diff)
working integration test
-rw-r--r--tests/runner.py9
-rw-r--r--tools/namespacer.py28
2 files changed, 16 insertions, 21 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 407a9c57..f84be41a 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1010,14 +1010,19 @@ if 'benchmark' not in sys.argv:
int ScriptMe::mulVal(int mul) { value *= mul; }
'''
script_src = '''
- // TODO
+ var sme = Scriptable.ScriptMe.__alloc__();
+ Scriptable.ScriptMe.ScriptMe(sme, 83);
+ Scriptable.ScriptMe.mulVal(sme, 2);
+ print('*' + Scriptable.ScriptMe.getVal(sme) + '*');
+ _free(sme);
+ print('*ok*');
'''
def post(filename):
Popen(['python', DEMANGLER, filename, '.'], stdout=open(filename + '.tmp', 'w')).communicate()
Popen(['python', NAMESPACER, filename + '.tmp'], stdout=open(filename + '.tmp2', 'w')).communicate()
src = open(filename, 'r').read() + 'var Scriptable = ' + open(filename + '.tmp2', 'r').read().rstrip() + ';\n\n' + script_src
open(filename, 'w').write(src)
- self.do_test(src, '', post_build=post)
+ self.do_test(src, '*166*\n*ok*', post_build=post)
# Generate tests for all our compilers
def make_test(compiler, embetter):
diff --git a/tools/namespacer.py b/tools/namespacer.py
index 2fae222d..507c580c 100644
--- a/tools/namespacer.py
+++ b/tools/namespacer.py
@@ -51,25 +51,15 @@ for line in data:
currspace = space
for part in funcparts[:-1]:
currspace = currspace.setdefault(part, {})
- currspace.setdefault(funcparts[-1], []).append((realname,params));
-
-def clean(currspace):
- if type(currspace) is list:
- if len(currspace) == 1:
- return currspace[0][0]
- else:
- ret = {}
- for item in currspace:
- i = str(len(ret)/2)
- ret[i] = item[0]
- ret[i + '_params'] = item[1]
- return ret
- else:
- for key in currspace.keys():
- currspace[key] = clean(currspace[key])
- return currspace
-
-space = clean(space)
+
+ i = 0
+ base = funcparts[-1]
+ while funcparts[-1] in currspace:
+ funcparts[-1] = base + '_' + str(i)
+ currspace[funcparts[-1]] = realname
+ currspace[funcparts[-1] + '_params'] = params
+ if funcparts[-1] == funcparts[-2]:
+ currspace['__alloc__'] = 'function() { return _malloc(_struct_%s___SIZE) }' % funcparts[-1]
def finalize(line):
try: