diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-11-06 14:59:41 -0700 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-11-06 14:59:41 -0700 |
commit | 7c94d4d98c7dbf81f57ad66550b59eabc8eaffa7 (patch) | |
tree | d975e522fd2da5a79bc2afc89dc18047d1f17735 /tools/namespacer.py | |
parent | f8b3b52c27b31656f2c12d63f16b2348c75dc1cb (diff) |
__new__ instead of __alloc__ in integration
Diffstat (limited to 'tools/namespacer.py')
-rw-r--r-- | tools/namespacer.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/namespacer.py b/tools/namespacer.py index 507c580c..008c2d00 100644 --- a/tools/namespacer.py +++ b/tools/namespacer.py @@ -31,6 +31,8 @@ data = open(sys.argv[1], 'r').readlines() space = {} +counts = {} + for line in data: line = line.rstrip() @@ -52,14 +54,19 @@ for line in data: for part in funcparts[:-1]: currspace = currspace.setdefault(part, {}) - i = 0 - base = funcparts[-1] - while funcparts[-1] in currspace: - funcparts[-1] = base + '_' + str(i) + key = str(funcparts) + if key in counts: + i = counts[key] + counts[key] += 1 + funcparts[-1] += '_' + str(i) + else: + counts[key] = 1 currspace[funcparts[-1]] = realname - currspace[funcparts[-1] + '_params'] = params - if funcparts[-1] == funcparts[-2]: - currspace['__alloc__'] = 'function() { return _malloc(_struct_%s___SIZE) }' % funcparts[-1] + currspace[funcparts[-1] + '__params'] = params + if len(funcparts) >= 2 and funcparts[-1] == funcparts[-2]: + currspace['__new__'] = 'function() { var ret = _malloc(_struct_%s___SIZE); Module._.%s.%s.apply(null, [ret].concat(Array.prototype.slice.apply(arguments))); return ret; }' % ( + funcparts[-1], funcparts[-1], funcparts[-1] + ) def finalize(line): try: |