aboutsummaryrefslogtreecommitdiff
path: root/py/objtype.c
AgeCommit message (Collapse)Author
2014-04-29objtype: Implement basic framework for subclassing native types.Paul Sokolovsky
This implements checking of base types, allocation and basic initialization, and optimized support for special method lookups. Other features are not yet supported.
2014-04-25py: Support instance __call__ method.Paul Sokolovsky
2014-04-21py: Fix super() bug, where it didn't allow instance access.Damien George
This is a one-liner fix. It gets the class-super.py test passing, but is probably not a complete fix.
2014-04-17py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George
Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
2014-04-17py: Merge BINARY_OP_SUBSCR and store_subscr (w/ delete) into subscr.Damien George
mp_obj_t->subscr now does load/store/delete.
2014-04-15py: Implement __delitem__ method for classes.Paul Sokolovsky
2014-04-13py: Add property object, with basic functionality.Damien George
Enabled by MICROPY_ENABLE_PROPERTY.
2014-04-08py: Remove DELETE_SUBSCR opcode, combine with STORE_SUBSCR.Damien George
This makes the runtime and object APIs more consistent. mp_store_subscr functionality now moved into objects (ie list and dict store_item).
2014-04-08py: Finish implementation of all del opcodes.Damien George
At this point, all opcodes are now implemented! Some del opcodes have been combined with store opcodes, with the value to store being MP_OBJ_NULL.
2014-04-05py: Make all objects and instances derive from object.Damien George
This makes isinstance(X, object) and issubclass(X, object) true for all X.
2014-04-05py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George
This does not affect code size or performance when debugging turned off. To address issue #420.
2014-04-05objtype: Add equality test for type types.Paul Sokolovsky
2014-04-02py: Factor out static/class method unwrapping code; add tests.Damien George
2014-03-31py: Implement __getattr__.Damien George
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-31objtype: Wrap .__name__ handling in MICROPY_CPYTHON_COMPAT.Paul Sokolovsky
Because it's runtime reflection feature, not required for many apps. Rant time: Python could really use better str() vs repr() distinction, for example, repr(type) could be "<class 'foo'>" (as it is now), and str(type) just "foo". But alas, getting straight name requires adhoc attribute.
2014-03-31objtype: Add virtual __name__ attribute.Paul Sokolovsky
It's virtual because it's not shown in dir(...). (That's also how CPython has it).
2014-03-30Merge map.h into obj.h.Damien George
Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
2014-03-30Rename rt_* to mp_*.Damien George
Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
2014-03-29py: Rename old const type objects to mp_type_* for consistency.Damien George
2014-03-29py: Change mp_const_* objects to macros.Damien George
Addresses issue #388.
2014-03-27py: Fix bug in type_store_attr, trying to store to ROM.Damien George
2014-03-26py: Fix logic bugs in object attribute/method extraction.Damien George
2014-03-26Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George
Originally, .methods was used for methods in a ROM class, and locals_dict for methods in a user-created class. That distinction is unnecessary, and we can use locals_dict for ROM classes now that we have ROMable maps. This removes an entry in the bloated mp_obj_type_t struct, saving a word for each ROM object and each RAM object. ROM objects that have a methods table (now a locals_dict) need an extra word in total (removed the methods pointer (1 word), no longer need the sentinel (2 words), but now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a word because they never used the methods entry. Overall the ROM usage is down by a few hundred bytes, and RAM usage is down 1 word per user-defined type/class. There is less code (no need to check 2 tables), and now consistent with the way ROM modules have their tables initialised. Efficiency is very close to equivaluent.
2014-03-26Change mp_method_t.name from const char * to qstr.Damien George
Addresses issue #377.
2014-03-26py: Add support for user-defined iterators via __iter__, __next__.Damien George
2014-03-17py: Clean up includes.xbe
Remove unnecessary includes. Add includes that improve portability.
2014-03-16Implement support for __str__ and __repr__ special methods in classes.Paul Sokolovsky
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-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-12Replace global "static" -> "STATIC", to allow "analysis builds". Part 1.Paul Sokolovsky
Some tools do not support local/static symbols (one example is GNU ld map file). Exposing all functions will allow to do detailed size comparisons, etc. Also, added bunch of statics where they were missing, and replaced few identity functions with global mp_identity().
2014-02-08py: Add some qstrs to the global table.Damien George
2014-02-06Add staticmethod and classmethod to builtin namespace.Damien George
2014-02-05py: Fix bug with dual initialisation of RT_UNARY_OP_NOT.Damien George
Fixes Issue #261.
2014-02-05py: Add built-in super.Damien George
2014-02-02py: Add very basic implementation of dir() builtin.Damien George
Only works on modules and class instances.
2014-02-02py: Partially fix native emitter to work with latest runtime.Damien George
Native emitter has been broken since stack order has changed from reverse to standard. This fix gets it partially working.
2014-02-01py: Tidy up BINARY_OPs; negation done by special NOT bytecode.Damien George
IS_NOT and NOT_IN are now compiled to IS + NOT and IN + NOT, with a new special NOT bytecode.
2014-01-30py: Improve __bool__ and __len__ dispatch; add slots for them.Damien George
2014-01-25Remove obsoleted comment.Damien George
2014-01-25py: Implement iterator support for object that has __getitem__.Damien George
Addresses Issue #203.
2014-01-22Second stage of qstr revamp: uPy str object can be qstr or not.Damien George
2014-01-21Revamp qstrs: they now include length and hash.Damien George
Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
2014-01-18Improve method lookup in mp_obj_class_lookup.Damien George
Now searches both locals_dict and methods. Partly addresses Issue #145.
2014-01-18Implement framework for class-defined built-in operators.Damien George
Now working for class-defined methods: __getitem__, __setitem__, __add__, __sub__. Easy to add others.
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-15type->print(): Distinguish str() and repr() variety by passing extra param.Paul Sokolovsky
2014-01-11py: Implement staticmethod and classmethod (internally).Damien George
Still need to make built-ins by these names, and write tests.