Skip to content

Commit

Permalink
Remove export_as handling from generate-exports.py
Browse files Browse the repository at this point in the history
  • Loading branch information
elemoine committed Dec 18, 2013
1 parent 01d4990 commit 89141ee
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions bin/generate-exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,17 @@ def typedef(self):

class Symbol(Exportable):

def __init__(self, name, export_symbol, export_as=None):
def __init__(self, name, export_symbol):
Exportable.__init__(self, name)
self.export_symbol = export_symbol
self.export_as = export_as or self.name
self.props = set()

__repr__ = simplerepr

def export(self):
lines = []
if self.export_symbol:
lines.append('\n\ngoog.exportSymbol(\n \'%s\',\n %s);\n' % (self.name, self.export_as))
lines.append('\n\ngoog.exportSymbol(\n \'%s\',\n %s);\n' % (self.name, self.name))
lines.extend('goog.exportProperty(\n %s,\n \'%s\',\n %s.%s);\n' % (self.name, prop, self.name, prop) for prop in sorted(self.props))
return ''.join(lines)

Expand Down Expand Up @@ -165,20 +164,18 @@ def main(argv):
objects[name] = symbol
symbol.props.add(prop)
continue
m = re.match(r'@exportSymbol\s+(?P<name>\S+)(?:\s+(?P<export_as>\S+))?\Z', line)
m = re.match(r'@exportSymbol\s+(?P<name>\S+)\Z', line)
if m:
name = m.group('name')
if name in objects:
raise RuntimeError(line) # Name already defined
export_as = m.group('export_as')
symbol = Symbol(name, True, export_as)
symbol = Symbol(name, True)
objects[name] = symbol
if not export_as:
components = m.group('name').split('.')
if re.match(r'[A-Z]', components[-1]):
requires.add(name)
elif len(components) > 1:
requires.add('.'.join(components[:-1]))
components = m.group('name').split('.')
if re.match(r'[A-Z]', components[-1]):
requires.add(name)
else:
requires.add('.'.join(components[:-1]))
continue
raise RuntimeError(line)

Expand Down

0 comments on commit 89141ee

Please sign in to comment.