mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
support help('modules') for py modules
This commit is contained in:
parent
a3dd8a674d
commit
9718b1a482
@ -115,6 +115,10 @@ class SysObj:
|
||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||
def input(*info) -> str: ...
|
||||
|
||||
@staticmethod
|
||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||
def help(name: str): ...
|
||||
|
||||
|
||||
@PIKA_C_MACRO_IF("0")
|
||||
class RangeObj:
|
||||
|
@ -671,3 +671,10 @@ char* PikaStdLib_SysObj_input(PikaObj* self, PikaTuple* info) {
|
||||
arg_deinit(cfg.context);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern volatile PikaObj* __pikaMain;
|
||||
void PikaStdLib_SysObj_help(PikaObj* self, char* name) {
|
||||
if (strEqu(name, "modules")) {
|
||||
obj_printModules((PikaObj*)__pikaMain);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,10 @@ class SysObj:
|
||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||
def input(*info) -> str: ...
|
||||
|
||||
@staticmethod
|
||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||
def help(name: str): ...
|
||||
|
||||
|
||||
@PIKA_C_MACRO_IF("0")
|
||||
class RangeObj:
|
||||
|
@ -671,3 +671,10 @@ char* PikaStdLib_SysObj_input(PikaObj* self, PikaTuple* info) {
|
||||
arg_deinit(cfg.context);
|
||||
return res;
|
||||
}
|
||||
|
||||
extern volatile PikaObj* __pikaMain;
|
||||
void PikaStdLib_SysObj_help(PikaObj* self, char* name) {
|
||||
if (strEqu(name, "modules")) {
|
||||
obj_printModules((PikaObj*)__pikaMain);
|
||||
}
|
||||
}
|
||||
|
@ -365,6 +365,22 @@ int LibObj_loadLibrary(LibObj* self, uint8_t* library_bytes) {
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
|
||||
int32_t __foreach_handler_printModule(Arg* argEach, Args* context) {
|
||||
if (argType_isObject(arg_getType(argEach))) {
|
||||
PikaObj* module_obj = arg_getPtr(argEach);
|
||||
char* module_name = obj_getStr(module_obj, "name");
|
||||
if (NULL != module_name) {
|
||||
__platform_printf(module_name);
|
||||
__platform_printf("\r\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LibObj_printModules(LibObj* self) {
|
||||
args_foreach(self->list, __foreach_handler_printModule, NULL);
|
||||
}
|
||||
|
||||
int LibObj_loadLibraryFile(LibObj* self, char* lib_file_name) {
|
||||
Arg* file_arg = arg_loadFile(NULL, lib_file_name);
|
||||
if (NULL == file_arg) {
|
||||
|
@ -30,6 +30,7 @@ PIKA_RES pikaMaker_compileModuleWithDepends(PikaMaker* self, char* module_name);
|
||||
PIKA_RES pikaMaker_linkCompiledModulesFullPath(PikaMaker* self, char* lib_path);
|
||||
PIKA_RES pikaMaker_linkCompiledModules(PikaMaker* self, char* lib_name);
|
||||
int LibObj_loadLibrary(LibObj* self, uint8_t* library_bytes);
|
||||
void LibObj_printModules(LibObj* self);
|
||||
|
||||
#define LIB_VERSION_NUMBER 2
|
||||
#define LIB_INFO_BLOCK_SIZE 32
|
||||
|
@ -1448,6 +1448,11 @@ PikaObj* obj_linkLibrary(PikaObj* self, uint8_t* library_bytes) {
|
||||
return self;
|
||||
}
|
||||
|
||||
void obj_printModules(PikaObj* self) {
|
||||
LibObj* lib = obj_getObj(self, "@lib");
|
||||
LibObj_printModules(lib);
|
||||
}
|
||||
|
||||
PikaObj* obj_linkLibObj(PikaObj* self, LibObj* library) {
|
||||
obj_setPtr(self, "@lib", library);
|
||||
return self;
|
||||
|
@ -506,4 +506,6 @@ Arg* pks_eventLisener_sendSignalAwaitResult(PikaEventListener* self,
|
||||
uint32_t eventId,
|
||||
int eventSignal);
|
||||
|
||||
void obj_printModules(PikaObj* self);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user