aboutsummaryrefslogtreecommitdiff
path: root/extmod/modbtree.c
AgeCommit message (Collapse)Author
2020-05-02extmod/modbtree: Retain reference to underlying stream so it's not GC'd.Damien George
For ports that have a system malloc which is not garbage collected (eg unix, esp32), the stream object for the DB must be retained separately to prevent it from being reclaimed by the MicroPython GC (because the berkeley-db library uses malloc to allocate the DB structure which stores the only reference to the stream). Although in some cases the user code will explicitly retain a reference to the underlying stream because it needs to call close() on it, this is not always the case, eg in cases where the DB is intended to live forever. Fixes issue #5940.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-13py: Add mp_raise_type helper macro and use it where appropriate.Damien George
This provides a more consistent C-level API to raise exceptions, ie moving away from nlr_raise towards mp_raise_XXX. It also reduces code size by a small amount on some ports.
2019-12-12extmod: Add dynamic-runtime guards to btree/framebuf/uheapq/ure/uzlib.Damien George
So they can be built as dynamic native modules, as well as existing static native modules.
2019-12-12extmod/modbtree: Use mp_printf instead of printf.Damien George
2019-11-01extmod/modbtree: Make FILEVTABLE const to put it in ROM.Damien George
2018-08-14extmod/modbtree: Update to work with new mp_stream_posix_XXX signatures.Damien George
2017-11-24py/runtime: Add MP_BINARY_OP_CONTAINS as reverse of MP_BINARY_OP_IN.Damien George
Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it meant that the args needed to be swapped, but coming from within the runtime meant that the args were already in the correct order. This lead to some confusion in the code and comments stating how args were reversed. It also lead to 2 bugs: 1) containment for a subclass of a native type didn't work; 2) the expression "{True} in True" would illegally succeed and return True. In both of these cases it was because the args to MP_BINARY_OP_IN ended up being reversed twice. To fix these things this patch introduces MP_BINARY_OP_CONTAINS which corresponds exactly to the __contains__ special method, and this is the operator that built-in types should implement. MP_BINARY_OP_IN is now only emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by swapping the arguments.
2017-10-04all: Remove inclusion of internal py header files.Damien George
Header files that are considered internal to the py core and should not normally be included directly are: py/nlr.h - internal nlr configuration and declarations py/bc0.h - contains bytecode macro definitions py/runtime0.h - contains basic runtime enums Instead, the top-level header files to include are one of: py/obj.h - includes runtime0.h and defines everything to use the mp_obj_t type py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h, and defines everything to use the general runtime support functions Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-08-29all: Convert mp_uint_t to mp_unary_op_t/mp_binary_op_t where appropriateDamien George
The unary-op/binary-op enums are already defined, and there are no arithmetic tricks used with these types, so it makes sense to use the correct enum type for arguments that take these values. It also reduces code size quite a bit for nan-boxing builds.
2017-07-24all: Don't include system errno.h when it's not needed.Damien George
2017-03-29extmod: Update for changes to mp_obj_str_get_data.Damien George
2017-02-16py: Add iter_buf to getiter type method.Damien George
Allows to iterate over the following without allocating on the heap: - tuple - list - string, bytes - bytearray, array - dict (not dict.keys, dict.values, dict.items) - set, frozenset Allows to call the following without heap memory: - all, any, min, max, sum TODO: still need to allocate stack memory in bytecode for iter_buf.
2016-12-05extmod/modbtree: Rename "sync" method to "flush" for consistency.Paul Sokolovsky
Rename recently introduced "sync" method to "flush" for consistency with usual files.
2016-12-02extmod/modbtree: Add method to sync the database.w4kpm
If you have longish operations on the db (such as logging data) it may be desirable to periodically sync the database to the disk. The added btree.sync() method merely exposes the berkley __bt_sync function to the user.
2016-10-07extmod: Use mp_raise_OSError helper function.Damien George
2016-09-22all: Remove 'name' member from mp_obj_module_t struct.Damien George
One can instead lookup __name__ in the modules dict to get the value.
2016-08-24extmod/modbtree: do CHECK_ERROR after __bt_seq()Krzysztof Blazewicz
In `btree_seq()`, when `__bt_seq()` gets called with invalid `flags` argument it will return `RET_ERROR` and it won't initialize `val`. If field `data` of uninitialized `val` is passed to `mp_obj_new_bytes()` it causes a segfault.
2016-08-06extmod/modbtree: open(): Add option kwargs.Paul Sokolovsky
Namely: flags, cachesize, pagesize, minkeypage.
2016-08-02extmod/modbtree: Implement __contains__ operation.Paul Sokolovsky
2016-07-31extmod/modbtree: Switch to accepting stream object instead of filename.Paul Sokolovsky
Requires "embedded" BerkeleyDB BTree implementation.
2016-07-24extmod/modbtree: Check __bt_open() return value for error.Paul Sokolovsky
2016-07-02extmod/modbtree: Fixes for nanbox build.Paul Sokolovsky
2016-07-02extmod/modbtree: Fix unused argument warning.Paul Sokolovsky
2016-06-23extmod/modbtree: Cleverly implement "for key in btree:" syntax.Paul Sokolovsky
I.e. make it work like btree.keys(), while still not using a separate iterator type.
2016-06-20extmod/modbtree: Implement keys(), values(), items() iterators.Paul Sokolovsky
Each takes optional args of starting key, ending key, and flags (ending key inclusive, reverse order).
2016-06-18extmod/modbtree: open(): Support "in-memory" database with filename=None.Paul Sokolovsky
It's not really in-memory though, just uses anonymous temporary file on disk.
2016-06-18extmod/modbtree: __getitem__() should raise KeyError for non-existing key.Paul Sokolovsky
2016-06-18extmod/modbtree: items(): Implement DESC flag.Paul Sokolovsky
2016-06-17extmod/modbtree: items(): Implement "end key inclusive" flag.Paul Sokolovsky
2016-06-16extmod/modbtree: Actually implement end key support for .items().Paul Sokolovsky
2016-06-16extmod/modbtree: Implement .items() iterator.Paul Sokolovsky
2016-06-15extmod/modbtree: Handle default value and error check.Paul Sokolovsky
2016-06-14extmod/modbtree: Initial implementation of "btree" module based on BerkeleyDB.Paul Sokolovsky
This implements basic wrapping of native get/put/seq API, and then dictionary access protocol. Native API is intended to be superceded going forward.