Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Berry change internal storage of parent class for methods #21490

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
- GPIOViewer from v1.5.2 to v1.5.3 (No functional change)
- ESP32 I2S audio improvements (#21433)
- Support W5500 SPI ethernet using four SPI GPIOs only without IRQ and RESET
- Berry change internal storage of parent class for methods

### Fixed
- Domoticz re-subscribe on MQTT reconnect. Regression from v13.4.0.3 (#21281)
Expand Down
2 changes: 1 addition & 1 deletion lib/libesp32/berry/src/be_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ bbool be_module_setmember(bvm *vm, bmodule *module, bstring *attr, bvalue *src)
return bfalse;
}

const char* be_module_name(bmodule *module)
const char* be_module_name(const bmodule *module)
{
if (gc_isconst(module)) {
return module->info.name;
Expand Down
2 changes: 1 addition & 1 deletion lib/libesp32/berry/src/be_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int be_module_load(bvm *vm, bstring *path);
void be_cache_module(bvm *vm, bstring *name);
int be_module_attr(bvm *vm, bmodule *module, bstring *attr, bvalue *dst);
bbool be_module_setmember(bvm *vm, bmodule *module, bstring *attr, bvalue *src);
const char* be_module_name(bmodule *module);
const char* be_module_name(const bmodule *module);
bbool be_module_setname(bmodule *module, bstring *name);

#endif
14 changes: 5 additions & 9 deletions lib/libesp32/berry/src/be_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,11 @@
#define BE_MODULE 22
#define BE_COMOBJ 23 /* common object */

#define BE_NTVFUNC ((0 << 5) | BE_FUNCTION)
#define BE_CLOSURE ((1 << 5) | BE_FUNCTION)
#define BE_NTVCLOS ((2 << 5) | BE_FUNCTION)
#define BE_CTYPE_FUNC ((3 << 5) | BE_FUNCTION)
#define BE_STATIC (1 << 7)

#define func_isstatic(o) (((o)->type & BE_STATIC) != 0)
#define func_setstatic(o) ((o)->type |= BE_STATIC)
#define func_clearstatic(o) ((o)->type &= ~BE_STATIC)
#define BE_NTVFUNC ((0 << 5) | BE_FUNCTION) /* 6 */
#define BE_CLOSURE ((1 << 5) | BE_FUNCTION) /* 38 */
#define BE_NTVCLOS ((2 << 5) | BE_FUNCTION) /* 70 */
#define BE_CTYPE_FUNC ((3 << 5) | BE_FUNCTION) /* 102 */
#define BE_STATIC (1 << 7) /* 128 */

/* values for bproto.varg */
#define BE_VA_VARARG (1 << 0) /* function has variable number of arguments */
Expand Down
16 changes: 11 additions & 5 deletions lib/libesp32/berry/src/be_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ static void setupvals(bfuncinfo *finfo)
}

/* Function is complete, finalize bproto */
static void end_func(bparser *parser)
static void end_func(bparser *parser, bclass *c)
{
bvm *vm = parser->vm;
bfuncinfo *finfo = parser->finfo;
Expand All @@ -324,8 +324,14 @@ static void end_func(bparser *parser)
proto->codesize = finfo->pc;
proto->ktab = be_vector_release(vm, &finfo->kvec);
proto->nconst = be_vector_count(&finfo->kvec);
proto->ptab = be_vector_release(vm, &finfo->pvec);
/* special case here */
proto->nproto = be_vector_count(&finfo->pvec);
if (proto->nproto == 0) {
proto->ptab = (void*) c;
} else {
be_vector_push_c(vm, &finfo->pvec, (void*) &c);
proto->ptab = be_vector_release(vm, &finfo->pvec);
}
#if BE_USE_MEM_ALIGNED
proto->code = be_move_to_aligned(vm, proto->code, proto->codesize * sizeof(binstruction)); /* move `code` to 4-bytes aligned memory region */
proto->ktab = be_move_to_aligned(vm, proto->ktab, proto->nconst * sizeof(bvalue)); /* move `ktab` to 4-bytes aligned memory region */
Expand Down Expand Up @@ -638,7 +644,7 @@ static bproto* funcbody(bparser *parser, bstring *name, bclass *c, int type)
finfo.proto->varg |= BE_VA_STATICMETHOD;
}
stmtlist(parser); /* parse statement without final `end` */
end_func(parser); /* close function context */
end_func(parser, c); /* close function context */
match_token(parser, KeyEnd); /* skip 'end' */
return finfo.proto; /* return fully constructed `bproto` */
}
Expand Down Expand Up @@ -694,7 +700,7 @@ static void lambda_expr(bparser *parser, bexpdesc *e)
expr(parser, &e1);
check_var(parser, &e1);
be_code_ret(parser->finfo, &e1);
end_func(parser);
end_func(parser, NULL);
init_exp(e, ETPROTO, be_code_proto(parser->finfo, finfo.proto));
be_stackpop(parser->vm, 1);
}
Expand Down Expand Up @@ -1810,7 +1816,7 @@ static void mainfunc(bparser *parser, bclosure *cl)
cl->proto = finfo.proto;
be_remove(parser->vm, -3); /* pop proto from stack */
stmtlist(parser);
end_func(parser);
end_func(parser, NULL);
match_token(parser, TokenEOS); /* skip EOS */
}

Expand Down
Loading