2.1 --- a/micropython/inspect.py Sat Jan 19 00:11:55 2008 +0100
2.2 +++ b/micropython/inspect.py Sat Jan 19 01:06:21 2008 +0100
2.3 @@ -319,14 +319,20 @@
2.4
2.5 # Add parameters to the namespace.
2.6
2.7 - for name in argnames:
2.8 - self[name] = None
2.9 + self._add_parameters(argnames)
2.10
2.11 # Image generation details.
2.12
2.13 self.location = None
2.14 self.code_location = None
2.15
2.16 + def _add_parameters(self, argnames):
2.17 + for name in argnames:
2.18 + if isinstance(name, tuple):
2.19 + self._add_parameters(name)
2.20 + else:
2.21 + self[name] = None
2.22 +
2.23 def __repr__(self):
2.24 return "Function(%r, %r, %r, %r, %r, location=%r)" % (
2.25 self.name, self.parent_name, self.argnames, self.has_star, self.has_dstar, self.location
2.26 @@ -887,12 +893,21 @@
2.27 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError',
2.28 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning',
2.29 'ValueError', 'Warning', 'ZeroDivisionError',
2.30 - 'bool', 'buffer', 'complex', 'dict', 'file', 'float', 'int', 'list',
2.31 - 'long', 'object', 'slice', 'str', 'tuple', 'type', 'unicode',
2.32 - 'xrange']:
2.33 + 'basestring', 'bool', 'buffer', 'complex', 'dict', 'file', 'float',
2.34 + 'frozenset', 'int', 'list', 'long', 'object', 'set', 'slice', 'str',
2.35 + 'tuple', 'type', 'unicode', 'xrange']:
2.36 self[key] = Class(key, self.full_name(), self)
2.37
2.38 - for key in ['id', 'len']:
2.39 + # NOTE: Incomplete: some functions have more than one parameter.
2.40 +
2.41 + for key in ['__import__', 'abs', 'all', 'any', 'callable', 'chr',
2.42 + 'classmethod', 'cmp', 'compile', 'delattr', 'dir', 'divmod',
2.43 + 'enumerate', 'eval', 'execfile', 'filter', 'getattr', 'globals',
2.44 + 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'isinstance',
2.45 + 'issubclass', 'iter', 'len', 'locals', 'map', 'max', 'min', 'oct',
2.46 + 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce',
2.47 + 'reload', 'repr', 'reversed', 'round', 'setattr', 'sorted',
2.48 + 'staticmethod', 'sum', 'super', 'unichr', 'vars', 'zip']:
2.49 self[key] = Function(key, self.full_name(), ['arg'], 0, 0, self)
2.50
2.51 builtins = Builtins()