aboutsummaryrefslogtreecommitdiff
path: root/py/obj.h
AgeCommit message (Collapse)Author
2014-03-03py: Factor and improve issubclass.Damien George
2014-03-03Add mp_obj_is_subclass_fast() - intended for fast argument checking.Paul Sokolovsky
I.e. as replacement of MP_OBJ_IS_TYPE(), which takes into account subclassing.
2014-02-26py: Reduce size of mp_obj_fun_native_t struct by packing ints.Damien George
2014-02-26py: Take out bitfield entries from their own structure.Damien George
Don't need to wrap bitfields in their own struct. Compiler does the correct thing without it.
2014-02-26py: Remove name of var arg from macros with var args.Damien George
2014-02-22Add arbitrary precision integer support.Damien George
Some functionality is still missing (eg and, or, bit shift), and some things are buggy (eg subtract).
2014-02-16Support passing positional args as keywords to bytecode functions.Paul Sokolovsky
For this, record argument names along with each bytecode function. The code still includes extensive debug logging support so far.
2014-02-16py: Implement *vargs support.Damien George
Addresses issue #295.
2014-02-15Implement proper exception type hierarchy.Damien George
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-15Change mp_obj_type_t.name from const char * to qstr.Damien George
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-12Remove mp_obj_new_exception_msg_1_arg and _2_arg.Damien George
2014-02-10Factor out mp_seq_count_obj() and implement tuple.count().Paul Sokolovsky
2014-02-10Factor out mp_seq_index_obj() function to implement .index() on sequences.Paul Sokolovsky
2014-02-08Implement tuple addition.Paul Sokolovsky
2014-02-08Refactor list comparison code to mp_seq_cmp_objs().Paul Sokolovsky
2014-02-08unix microsocket: Add dummy makefile() method.Paul Sokolovsky
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-08Make mp_obj_str_get_data return char* instead of byte*.Damien George
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-06Add staticmethod and classmethod to builtin namespace.Damien George
2014-02-05py: Add built-in super.Damien George
2014-02-02Fix thinko with how bitfields were added to mp_obj_fun_native_t.Paul Sokolovsky
Structure is back to expected 16 bytes.
2014-02-02Implement str/bytes rich comparisons.Paul Sokolovsky
2014-02-02Implement slicing for lists.Paul Sokolovsky
2014-02-02Factor out m_seq_get_fast_slice_indexes() fucntions as sequence helper.Paul Sokolovsky
Takes slice object and sequence length and computes subsequence indexes for case of slice step=1.
2014-02-01Implement default function arguments (for Python functions).Paul Sokolovsky
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-01-29py: Simplify fastn in VM; reduce size of unique code struct.Damien George
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-29mp_obj_new_bytearray_by_ref(): Allow to create array by reference.Paul Sokolovsky
This is special feature for FFI.
2014-01-28Factor out quoted string print function for reuse (mp_str_print_quoted()).Paul Sokolovsky
2014-01-26Add MP_OBJ_IS_INT(), for symmetry with MP_OBJ_IS_STR().Paul Sokolovsky
2014-01-25Implement mp_parse_node_free; print properly repr(string).Damien George
2014-01-25py: Implement iterator support for object that has __getitem__.Damien George
Addresses Issue #203.
2014-01-24Add basic implementation of bytes type, piggybacking on str.Paul Sokolovsky
This reuses as much str implementation as possible, from this we can make them more separate as needed.
2014-01-22Second stage of qstr revamp: uPy str object can be qstr or not.Damien George
2014-01-21Add len() support for arrays.Paul Sokolovsky
2014-01-21sequence.c: Start to refactor sequence operations for reuse among types.Paul Sokolovsky
2014-01-20mp_identity(): Add generic identity function.Paul Sokolovsky
Useful as getiter method for objects which are their own iterators, etc.
2014-01-20Properly print MP_OBJ_QSTR objects.Paul Sokolovsky
2014-01-20Implement modules as singletons Python semantics.Paul Sokolovsky
In Python, importing module several times returns same underlying module object. This also fixes import statement handling for builtin modules. There're still issues: 1. CPython exposes set of loaded modules as sys.modules, we may want to do that either. 2. Builtin modules are implicitly imported, which is not really correct. We should separate registering a (builtin) module and importing a module. CPython keeps builtin module names in sys.builtin_module_names .
2014-01-19Change int to uint for n_args in function with variable arguments.Damien George
2014-01-19py: Add full traceback to exception printing.Damien George
2014-01-19py: Add module/function/class name to exceptions.Damien George
Exceptions know source file, line and block name. Also tidy up some debug printing functions and provide a global flag to enable/disable them.
2014-01-18Merge pull request #192 from pfalcon/arraysDamien George
Add skeleton implementation of array.array and bytearray.
2014-01-18Add source file name and line number to error messages.Damien George
Byte code has a map from byte-code offset to source-code line number, used to give better error messages.
2014-01-18Add skeleton implementation of array.array and bytearray.Paul Sokolovsky
So far, only storage, initialization, repr() and buffer protocol is implemented - alredy suitable for passing binary data around.
2014-01-18Merge pull request #191 from pfalcon/store-itemDamien George
Add store_item() virtual method to type to implement container[index] = val
2014-01-18Merge branch 'master' of github.com:dpgeorge/micropythonDamien George
2014-01-18int: Add value accessors: mp_obj_int_get() & mp_obj_int_get_checked().Paul Sokolovsky
mp_obj_int_get() can be used when just full resolution of C machine_int_t is required (returns truncated value of long int). mp_obj_int_get_checked() will throw exception if Python int value not representable in machine_int_t.
2014-01-18Make VM stack grow upwards, and so no reversed args arrays.Damien George
Change state layout in VM so the stack starts at state[0] and grows upwards. Locals are at the top end of the state and number downwards. This cleans up a lot of the interface connecting the VM to C: now all functions that take an array of Micro Python objects are in order (ie no longer in reverse). Also clean up C API with keyword arguments (call_n and call_n_kw replaced with single call method that takes keyword arguments). And now make_new takes keyword arguments. emitnative.c has not yet been changed to comply with the new order of stack layout.
2014-01-18Add store_item() virtual method to type to implement container[index] = val.Paul Sokolovsky
2014-01-15stm: Fix print methods with new kind argument.Damien George
2014-01-15Merge branch 'str2int' of github.com:xyb/micropython into xyb-str2intDamien George
Conflicts: py/objint.c unix-cpy/Makefile unix/Makefile