mirror of https://github.com/arendst/Tasmota.git
Merge pull request #12990 from s-hadinger/berry_fix_deinit
Berry fix deinit
This commit is contained in:
commit
3e6768c2e1
|
@ -243,6 +243,20 @@ static int default_init_native_method(bvm *vm) {
|
|||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
/* Find instance member by name and copy value to `dst` */
|
||||
/* Do not look into virtual members */
|
||||
int be_instance_member_simple(bvm *vm, binstance *instance, bstring *name, bvalue *dst)
|
||||
{
|
||||
int type;
|
||||
be_assert(name != NULL);
|
||||
binstance * obj = instance_member(vm, instance, name, dst);
|
||||
type = var_type(dst);
|
||||
if (obj && type == MT_VARIABLE) {
|
||||
*dst = obj->members[dst->v.i];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/* Find instance member by name and copy value to `dst` */
|
||||
/* Input: none of `obj`, `name` and `dst` may not be NULL */
|
||||
/* Returns the type of the member or BE_NONE if member not found */
|
||||
|
|
|
@ -59,6 +59,7 @@ void be_closure_method_bind(bvm *vm, bclass *c, bstring *name, bclosure *cl);
|
|||
int be_class_closure_count(bclass *c);
|
||||
void be_class_upvalue_init(bvm *vm, bclass *c);
|
||||
bbool be_class_newobj(bvm *vm, bclass *c, bvalue *argv, int argc, int mode);
|
||||
int be_instance_member_simple(bvm *vm, binstance *obj, bstring *name, bvalue *dst);
|
||||
int be_instance_member(bvm *vm, binstance *obj, bstring *name, bvalue *dst);
|
||||
int be_class_member(bvm *vm, bclass *obj, bstring *name, bvalue *dst);
|
||||
bbool be_instance_setmember(bvm *vm, binstance *obj, bstring *name, bvalue *src);
|
||||
|
|
|
@ -458,7 +458,7 @@ static void destruct_object(bvm *vm, bgcobject *obj)
|
|||
int type;
|
||||
binstance *ins = cast_instance(obj);
|
||||
/* does not GC when creating the string "deinit". */
|
||||
type = be_instance_member(vm, ins, str_literal(vm, "deinit"), vm->top);
|
||||
type = be_instance_member_simple(vm, ins, str_literal(vm, "deinit"), vm->top);
|
||||
be_incrtop(vm);
|
||||
if (basetype(type) == BE_FUNCTION) {
|
||||
var_setinstance(vm->top, ins); /* push instance on stack as arg 1 */
|
||||
|
|
|
@ -267,7 +267,7 @@ bbool be_value2bool(bvm *vm, bvalue *v)
|
|||
static void obj_method(bvm *vm, bvalue *o, bstring *attr, bvalue *dst)
|
||||
{
|
||||
binstance *obj = var_toobj(o);
|
||||
int type = be_instance_member(vm, obj, attr, dst);
|
||||
int type = be_instance_member_simple(vm, obj, attr, dst);
|
||||
if (basetype(type) != BE_FUNCTION) {
|
||||
vm_error(vm, "attribute_error",
|
||||
"the '%s' object has no method '%s'",
|
||||
|
|
Loading…
Reference in New Issue