Merge pull request #13434 from s-hadinger/berry_json_dump

Berry json dump for subclasses
This commit is contained in:
s-hadinger 2021-10-21 22:02:08 +02:00 committed by GitHub
commit 1360d68540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -45,8 +45,19 @@ static const char* match_char(const char *json, int ch)
static int is_object(bvm *vm, const char *class, int idx) static int is_object(bvm *vm, const char *class, int idx)
{ {
if (be_isinstance(vm, idx)) { if (be_isinstance(vm, idx)) {
be_pushvalue(vm, idx);
while (1) {
be_getsuper(vm, -1);
if (be_isnil(vm, -1)) {
be_pop(vm, 1);
break;
}
be_remove(vm, -2);
}
const char *name = be_classname(vm, idx); const char *name = be_classname(vm, idx);
return !strcmp(name, class); bbool ret = !strcmp(name, class);
be_pop(vm, 1);
return ret;
} }
return 0; return 0;
} }