mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
48b83b6a07
commit
b42a2d5b26
@ -21,7 +21,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#define PK_VERSION "1.1.3"
|
#define PK_VERSION "1.1.4"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
|
@ -49,7 +49,7 @@ struct Dict{
|
|||||||
PyObject* try_get(PyObject* key) const;
|
PyObject* try_get(PyObject* key) const;
|
||||||
|
|
||||||
bool contains(PyObject* key) const;
|
bool contains(PyObject* key) const;
|
||||||
void erase(PyObject* key);
|
bool erase(PyObject* key);
|
||||||
void update(const Dict& other);
|
void update(const Dict& other);
|
||||||
|
|
||||||
template<typename __Func>
|
template<typename __Func>
|
||||||
|
@ -102,10 +102,10 @@ namespace pkpy{
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dict::erase(PyObject* key){
|
bool Dict::erase(PyObject* key){
|
||||||
bool ok; int i;
|
bool ok; int i;
|
||||||
_probe(key, ok, i);
|
_probe(key, ok, i);
|
||||||
if(!ok) return;
|
if(!ok) return false;
|
||||||
_items[i].first = nullptr;
|
_items[i].first = nullptr;
|
||||||
_items[i].second = nullptr;
|
_items[i].second = nullptr;
|
||||||
_size--;
|
_size--;
|
||||||
@ -127,6 +127,7 @@ namespace pkpy{
|
|||||||
}
|
}
|
||||||
_nodes[i].prev = -1;
|
_nodes[i].prev = -1;
|
||||||
_nodes[i].next = -1;
|
_nodes[i].next = -1;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dict::update(const Dict& other){
|
void Dict::update(const Dict& other){
|
||||||
|
@ -1077,8 +1077,8 @@ void init_builtins(VM* _vm) {
|
|||||||
|
|
||||||
_vm->bind__delitem__(_vm->tp_dict, [](VM* vm, PyObject* obj, PyObject* key) {
|
_vm->bind__delitem__(_vm->tp_dict, [](VM* vm, PyObject* obj, PyObject* key) {
|
||||||
Dict& self = _CAST(Dict&, obj);
|
Dict& self = _CAST(Dict&, obj);
|
||||||
if(!self.contains(key)) vm->KeyError(key);
|
bool ok = self.erase(key);
|
||||||
self.erase(key);
|
if(!ok) vm->KeyError(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
_vm->bind_method<1>("dict", "pop", [](VM* vm, ArgsView args) {
|
_vm->bind_method<1>("dict", "pop", [](VM* vm, ArgsView args) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user