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
66eaf84b8c
py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.
2014-03-26 19:27:58 +00:00
Damien George
9c817b9465
Merge branch 'master' of github.com:micropython/micropython
2014-03-26 18:56:02 +00:00
Damien George
752ba554cc
Merge branch 'gen-close-ret-val' of github.com:pfalcon/micropython into pfalcon-gen-close-ret-val
2014-03-26 18:46:06 +00:00
Damien George
9e6e935df0
py: Add support for user-defined iterators via __iter__, __next__.
2014-03-26 18:37:06 +00:00
Paul Sokolovsky
af1ae30399
objexcept: Add mp_obj_exception_get_value() convenience function.
...
This gets "value" of exceptions in the sense as it's defined for
StopIteration.value (i.e. args[0] or None).
TODO: This really should be inline function.
2014-03-26 19:29:36 +02:00
Paul Sokolovsky
962b1cd1b1
objgenerator: Implement return with value and .close() method.
...
Return with value gets converted to StopIteration(value). Implementation
keeps optimizing against creating of possibly unneeded exception objects,
so there're considerable refactoring to implement these features.
2014-03-26 15:40:58 +02: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
Damien George
caac542b23
Proper support for registering builtin modules in ROM.
...
Comes with some refactoring of code and renaming of files. All modules
are now named mod*.[ch].
2014-03-25 14:18:18 +00:00
Damien George
1dfde891e3
Merge pull request #373 from iabdalkader/module_register
...
Add mp_obj_module_register
2014-03-25 13:21:51 +00:00
mux
89d45248ee
Add mp_obj_module_register
...
* Add function to load static modules.
* Use module_register to pyb module.
2014-03-25 00:25:27 +02:00
Damien George
24ff063e80
py: Remove obsolete declarations; make mp_obj_get_array consistent.
2014-03-24 10:47:13 +00:00
Damien George
3ec0a1a32d
py: Add 'object' object.
2014-03-22 21:31:28 +00:00
Damien George
eabdf6718a
py: Add function to convert long int to float.
2014-03-22 20:54:01 +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
300c8bd4c2
Added ZeroDivisionError to float division.
2014-03-20 22:40:38 +00:00
Damien George
7f8be59111
py: Allow hashing of functions and tuples.
2014-03-20 19:20:59 +00:00
xbe
9e1e8cd642
Implement str.count and add tests for it.
...
Also modify mp_get_index to accept:
1. Indices that are or evaluate to a boolean.
2. Slice indices.
Add tests for these two cases.
2014-03-12 22:57:16 -07:00
Damien George
9d68e9ccdd
py: Implement integer overflow checking for * and << ops.
...
If operation will overflow, a multi-precision integer is created.
2014-03-12 15:38:15 +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
Damien George
715101580b
py: Factor and improve issubclass.
2014-03-03 22:38:13 +00:00
Paul Sokolovsky
d86d22e1e7
Add mp_obj_is_subclass_fast() - intended for fast argument checking.
...
I.e. as replacement of MP_OBJ_IS_TYPE(), which takes into account subclassing.
2014-03-03 11:42:53 +08:00
Damien George
d5e81826ec
py: Reduce size of mp_obj_fun_native_t struct by packing ints.
2014-02-26 17:47:05 +00:00
Damien George
510477557d
py: Take out bitfield entries from their own structure.
...
Don't need to wrap bitfields in their own struct. Compiler does the
correct thing without it.
2014-02-26 17:40:52 +00:00
Damien George
1dc76af7bf
py: Remove name of var arg from macros with var args.
2014-02-26 16:57:08 +00:00
Damien George
438c88dd2f
Add arbitrary precision integer support.
...
Some functionality is still missing (eg and, or, bit shift), and some
things are buggy (eg subtract).
2014-02-22 19:25:23 +00:00
Paul Sokolovsky
ac2e28c654
Support passing positional args as keywords to bytecode functions.
...
For this, record argument names along with each bytecode function. The code
still includes extensive debug logging support so far.
2014-02-16 18:36:33 +02:00
Damien George
2e482cdb7b
py: Implement *vargs support.
...
Addresses issue #295 .
2014-02-16 00:01:29 +00: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
099a9cb575
Remove mp_obj_new_exception_msg_1_arg and _2_arg.
2014-02-12 23:02:19 +00:00
Paul Sokolovsky
ac0134d427
Factor out mp_seq_count_obj() and implement tuple.count().
2014-02-10 07:13:32 +02:00
Paul Sokolovsky
0cd1dc06e6
Factor out mp_seq_index_obj() function to implement .index() on sequences.
2014-02-10 07:13:32 +02:00
Paul Sokolovsky
ee4aaf7cdd
Implement tuple addition.
2014-02-08 23:17:51 +02:00
Paul Sokolovsky
1a996c48ac
Refactor list comparison code to mp_seq_cmp_objs().
2014-02-08 22:56:36 +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
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
64131f3215
Add staticmethod and classmethod to builtin namespace.
2014-02-06 20:31:44 +00:00
Damien George
35e2a4e6bb
py: Add built-in super.
2014-02-05 00:51:47 +00:00
Paul Sokolovsky
0473e2790b
Fix thinko with how bitfields were added to mp_obj_fun_native_t.
...
Structure is back to expected 16 bytes.
2014-02-02 17:58:44 +02:00
Paul Sokolovsky
87e85b7dc7
Implement str/bytes rich comparisons.
2014-02-02 08:58:16 +02:00
Paul Sokolovsky
13cfabd1b2
Implement slicing for lists.
2014-02-02 03:32:55 +02:00
Paul Sokolovsky
7364af2d8c
Factor out m_seq_get_fast_slice_indexes() fucntions as sequence helper.
...
Takes slice object and sequence length and computes subsequence indexes
for case of slice step=1.
2014-02-02 02:38:22 +02:00
Paul Sokolovsky
90750029df
Implement default function arguments (for Python functions).
...
TODO: Decide if we really need separate bytecode for creating functions
with default arguments - we would need same for closures, then there're
keywords arguments too. Having all combinations is a small exponential
explosion, likely we need just 2 cases - simplest (no defaults, no kw),
and full - defaults & kw.
2014-02-01 15:38:22 +02:00
Damien George
d0691ccaec
py: Simplify fastn in VM; reduce size of unique code struct.
...
We still have FAST_[0,1,2] byte codes, but they now just access the
fastn array (before they had special local variables). It's now
simpler, a bit faster, and uses a bit less stack space (on STM at least,
which is most important).
The only reason now to keep FAST_[0,1,2] byte codes is for compressed
byte code size.
2014-01-29 20:30:52 +00:00
Paul Sokolovsky
7f11c794a5
mp_obj_new_bytearray_by_ref(): Allow to create array by reference.
...
This is special feature for FFI.
2014-01-29 00:21:41 +02:00
Paul Sokolovsky
0b7e29c025
Factor out quoted string print function for reuse (mp_str_print_quoted()).
2014-01-28 03:40:06 +02:00
Paul Sokolovsky
2ca84aa01e
Add MP_OBJ_IS_INT(), for symmetry with MP_OBJ_IS_STR().
2014-01-26 02:03:07 +02: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