Commit Graph

41 Commits

Author SHA1 Message Date
Paul Sokolovsky
98a627dc03 py: Add "io" module.
So far just includes "open" function, which should be supplied by a port.

TODO: Make the module #ifdef'ed.
2014-04-03 22:08:57 +03:00
Damien George
4881566874 py: Add support for sep and end keywords in print. 2014-04-02 10:34:44 +01:00
Damien George
e44d26ae0c py: Implement __getattr__.
It's not completely satisfactory, because a failed call to __getattr__
should not raise an exception.

__setattr__ could be implemented, but it would slow down all stores to a
user created object.  Need to implement some caching system.
2014-03-31 22:57:56 +01:00
Paul Sokolovsky
44307d5ef8 vm: Implement "with" statement (SETUP_WITH and WITH_CLEANUP bytecodes). 2014-03-29 04:39:24 +02:00
Paul Sokolovsky
e9137b94f2 py: Implement getattr() builtin. 2014-03-27 00:11:36 +02:00
Damien George
c12b2213c1 Change mp_method_t.name from const char * to qstr.
Addresses issue #377.
2014-03-26 20:15:40 +00:00
Damien George
9e6e935df0 py: Add support for user-defined iterators via __iter__, __next__. 2014-03-26 18:37:06 +00:00
Damien George
ffb5cfc8d8 py: Removed some unnecessary exception objects.
They still exist in commented-out form in objexcept.c if they are ever
needed.
2014-03-25 14:29:40 +00:00
Paul Sokolovsky
9512e9e817 objexcept: Add "args" exception attribute, as well as StopIteration.value. 2014-03-25 01:42:01 +02:00
Damien George
c91097223d py: Remove some unnecessary exception objects. 2014-03-22 23:40:02 +00:00
Damien George
3ec0a1a32d py: Add 'object' object. 2014-03-22 21:31:28 +00:00
Rachel Dowdall
721c55dced Added exception hierarchy except for OSError and UnicodeError (requires arguments). Comment out the errors that aren't needed if memory becomes an issue. 2014-03-22 15:28:16 +00:00
Rachel Dowdall
249b9c761d Fixed broken math functions that return bool and added some more. 2014-03-22 14:39:33 +00:00
Rachel Dowdall
300c8bd4c2 Added ZeroDivisionError to float division. 2014-03-20 22:40:38 +00:00
Rachel Dowdall
5a14a1d690 Added various simple functions to math module. 2014-03-20 21:26:51 +00:00
Damien George
a925639247 py: Add math.e constant. 2014-03-20 16:39:22 +00:00
Paul Sokolovsky
51bbf6a006 Implement support for __str__ and __repr__ special methods in classes. 2014-03-16 15:18:22 +02:00
Damien George
8854e1fa05 py: Add expm1 to math module. 2014-03-12 21:31:41 +00:00
Damien George
0c36da0b59 Implement ROMable modules. Add math module.
mp_module_obj_t can now be put in ROM.

Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.

math module has basic math functions.  For STM port, these are not yet
implemented (they are just stub functions).
2014-03-08 15:24:39 +00:00
Paul Sokolovsky
d08fd68664 Add basic collections.namedtuple implementation. 2014-03-03 11:42:53 +08:00
Damien George
c5966128c7 Implement proper exception type hierarchy.
Each built-in exception is now a type, with base type BaseException.
C exceptions are created by passing a pointer to the exception type to
make an instance of.  When raising an exception from the VM, an
instance is created automatically if an exception type is raised (as
opposed to an exception instance).

Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper.

Handling of parse error changed to match new exceptions.

mp_const_type renamed to mp_type_type for consistency.
2014-02-15 16:10:44 +00:00
Damien George
a71c83a1d1 Change mp_obj_type_t.name from const char * to qstr.
Ultimately all static strings should be qstr.  This entry in the type
structure is only used for printing error messages (to tell the type of
the bad argument), and printing objects that don't supply a .print method.
2014-02-15 11:34:50 +00:00
Damien George
8c2b333aff Merge branch 'master' of github.com:micropython/micropython 2014-02-10 21:41:14 +00:00
Paul Sokolovsky
76f06de96d Add NotImplementedError. 2014-02-09 13:17:36 +02:00
Damien George
7d0bfbedd2 py: Add some qstrs to the global table. 2014-02-08 19:01:47 +00:00
Damien George
64131f3215 Add staticmethod and classmethod to builtin namespace. 2014-02-06 20:31:44 +00:00
Damien George
cdcb4906d4 Merge pull request #262 from pfalcon/sys-path
Implement sys.path support
2014-02-05 21:27:05 +00:00
Damien George
35e2a4e6bb py: Add built-in super. 2014-02-05 00:51:47 +00:00
Paul Sokolovsky
e11b17c25f Implement support for sys.path when loading modules.
sys.path is not initialized by rt_init(), that's left for platform-specific
startup code. (For example, bare metal port may have some hardcoded defaults,
and let user change sys.path directly; while port for OS with environment
feature can take path from environment). If it's not explicitly initialized,
modules will be imported only from a current directory.
2014-02-05 01:40:41 +02:00
Paul Sokolovsky
0c59db1973 Use qstr id to create sys module. 2014-02-04 19:36:00 +02:00
Paul Sokolovsky
7cd54d79db Add ImportError. 2014-02-04 03:33:55 +02:00
Paul Sokolovsky
1d938c9503 Expose __import__() function. 2014-02-04 00:47:06 +02:00
Damien George
ca4767984b py: Implement builtin exec. 2014-02-03 22:44:10 +00:00
Damien George
4acb2452b3 py: Add very basic implementation of dir() builtin.
Only works on modules and class instances.
2014-02-02 22:07:44 +00:00
xbe
0ebf8534ab Implement and add tests for the id() builtin function. 2014-02-01 19:00:41 -08:00
Damien George
09a0c64bce py: Improve __bool__ and __len__ dispatch; add slots for them. 2014-01-30 10:05:33 +00:00
Damien George
b829b5caec Implement mp_parse_node_free; print properly repr(string). 2014-01-25 13:51:19 +00:00
Damien George
7c9c667633 py: Implement iterator support for object that has __getitem__.
Addresses Issue #203.
2014-01-25 00:17:36 +00:00
Paul Sokolovsky
ab5d08280b Allow qstr's with non-ident chars, construct good identifier for them.
Also, add qstr's for string appearing in unix REPL loop, gross effect
being less allocations for each command run.
2014-01-24 02:34:22 +02:00
Damien George
12eaccacda Merge branch 'master' of github.com:micropython/micropython
Conflicts:
	py/objstr.c
	py/py.mk
	py/stream.c
	unix/main.c
	unix/socket.c
2014-01-21 21:54:15 +00:00
Damien George
55baff4c9b Revamp qstrs: they now include length and hash.
Can now have null bytes in strings.  Can define ROM qstrs per port using
qstrdefsport.h
2014-01-21 21:40:13 +00:00