Commit Graph

21 Commits

Author SHA1 Message Date
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 d46ca25757 Fix some int casting that failed on 64 bit architecture. 2014-02-10 21:46:47 +00:00
Paul Sokolovsky 2e24ee8d80 socket: Tighten up int-to-str conversion. 2014-02-10 18:39:10 +02:00
Paul Sokolovsky 8c25201d9d socket: Make sure that symbol definitions are const. 2014-02-10 18:39:06 +02:00
Paul Sokolovsky 557c9d5264 unix microsocket: Add dummy makefile() method.
Unlike CPython socket, microsocket object already implements stream protocol
(read/write methods), so makefile() just returns object itself. TODO: this
doesn't take care of arguments CPython's makefile() may accept.
2014-02-08 22:00:20 +02:00
Paul Sokolovsky 1e19b24ea0 io.File, socket types: Add fileno() method.
Implementation is duplicated, but tolerate this for now, because there's
no clear idea how to de-dup it.
2014-02-08 21:20:32 +02:00
Paul Sokolovsky 9945f33886 Rename "rawsocket" module to "microsocket".
It's no longer intended to provide just "raw" socket interface, may include
some convenience methods for compatibility with CPython socket - but anyway
just minimal set required to deal with socket client and servers, not wider
network functionality.
2014-02-08 21:20:32 +02:00
Damien George 698ec21e46 Make mp_obj_str_get_data return char* instead of byte*.
Can't decide which is better for string type, char or byte pointer.
Changing to char removes a few casts.  Really need to do proper unicode.
2014-02-08 18:17:23 +00:00
Damien George 56bb636014 Change -Og to -O0 in unix-cpy/Makefile; cast to small int in socket.c. 2014-01-26 17:52:23 +00:00
Paul Sokolovsky a88c30c64a unix socket: Add setsockopt() method. 2014-01-26 02:03:07 +02:00
Paul Sokolovsky 5d362d3209 unix socket: Add few more socket constants. 2014-01-26 02:03:07 +02:00
Paul Sokolovsky db0b282d45 unix socket: Store module constants in data structure.
-147 bytes on x86.
2014-01-26 02:03:07 +02:00
Damien George 5fa93b6755 Second stage of qstr revamp: uPy str object can be qstr or not. 2014-01-22 14:35:10 +00: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
Paul Sokolovsky f0cfb8cb45 Don't preimport socket module. 2014-01-20 20:37:01 +02:00
Paul Sokolovsky fc35aa6828 unix socket: Add send() and recv() methods.
CPython _socket actually have only those and doesn't provide stream
interface (higher-level CPython "socket" what adds this).

+516 bytes x86.
2014-01-20 20:37:01 +02:00
Damien George a11ceca807 Change int to uint for n_args in function with variable arguments. 2014-01-19 16:02:09 +00:00
Damien George a8a6db2a1d Fix warnings about int/pointer casting. 2014-01-18 23:50:12 +00:00
Paul Sokolovsky fc92608237 Add lean ("raw") socket module. 2014-01-19 00:16:39 +02:00