mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Berry instrospect.name()
to get names of functions, modules and classes (#18422)
This commit is contained in:
parent
21c3812826
commit
0feba56d8e
@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Berry `webserver.html_escape()` reusing the internal HTML escaping function
|
- Berry `webserver.html_escape()` reusing the internal HTML escaping function
|
||||||
- Support for GDK101 gamma radiation sensor by Petr Novacek (#18390)
|
- Support for GDK101 gamma radiation sensor by Petr Novacek (#18390)
|
||||||
- Matter support in now stabilized for Apple and Google (not tested with Alexa)
|
- Matter support in now stabilized for Apple and Google (not tested with Alexa)
|
||||||
|
- Berry `instrospect.name()` to get names of functions, modules and classes
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
@ -188,6 +188,31 @@ static int m_ismethod(bvm *vm)
|
|||||||
be_return_nil(vm);
|
be_return_nil(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int m_name(bvm *vm)
|
||||||
|
{
|
||||||
|
int top = be_top(vm);
|
||||||
|
if (top >= 1) {
|
||||||
|
bvalue *v = be_indexof(vm, 1);
|
||||||
|
const char* name = NULL;
|
||||||
|
switch (var_type(v)) {
|
||||||
|
case BE_CLOSURE:
|
||||||
|
name = str(((bclosure*) var_toobj(v))->proto->name);
|
||||||
|
break;
|
||||||
|
case BE_CLASS:
|
||||||
|
name = str(((bclass*) var_toobj(v))->name);
|
||||||
|
break;
|
||||||
|
case BE_MODULE:
|
||||||
|
name = be_module_name(var_toobj(v));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
be_pushstring(vm, name);
|
||||||
|
be_return(vm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
be_return_nil(vm);
|
||||||
|
}
|
||||||
|
|
||||||
#if !BE_USE_PRECOMPILED_OBJECT
|
#if !BE_USE_PRECOMPILED_OBJECT
|
||||||
be_native_module_attr_table(introspect) {
|
be_native_module_attr_table(introspect) {
|
||||||
be_native_module_function("members", m_attrlist),
|
be_native_module_function("members", m_attrlist),
|
||||||
@ -201,6 +226,8 @@ be_native_module_attr_table(introspect) {
|
|||||||
be_native_module_function("toptr", m_toptr),
|
be_native_module_function("toptr", m_toptr),
|
||||||
be_native_module_function("fromptr", m_fromptr),
|
be_native_module_function("fromptr", m_fromptr),
|
||||||
|
|
||||||
|
be_native_module_function("name", m_name),
|
||||||
|
|
||||||
be_native_module_function("ismethod", m_ismethod),
|
be_native_module_function("ismethod", m_ismethod),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -219,6 +246,8 @@ module introspect (scope: global, depend: BE_USE_INTROSPECT_MODULE) {
|
|||||||
toptr, func(m_toptr)
|
toptr, func(m_toptr)
|
||||||
fromptr, func(m_fromptr)
|
fromptr, func(m_fromptr)
|
||||||
|
|
||||||
|
name, func(m_name)
|
||||||
|
|
||||||
ismethod, func(m_ismethod)
|
ismethod, func(m_ismethod)
|
||||||
}
|
}
|
||||||
@const_object_info_end */
|
@const_object_info_end */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user