mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add filter for dir()
This commit is contained in:
parent
bf63ac206a
commit
d77e7f3f2d
@ -85,7 +85,7 @@ class SysObj:
|
||||
|
||||
@staticmethod
|
||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||
def dir(obj: object) -> list: ...
|
||||
def dir(obj: any) -> list: ...
|
||||
|
||||
@staticmethod
|
||||
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
||||
|
@ -569,7 +569,13 @@ int32_t __dir_each(Arg* argEach, Args* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PikaObj* PikaStdLib_SysObj_dir(PikaObj* self, PikaObj* obj) {
|
||||
PikaObj* PikaStdLib_SysObj_dir(PikaObj* self, Arg* arg) {
|
||||
if (!argType_isObject(arg_getType(arg))) {
|
||||
obj_setErrorCode(self, 1);
|
||||
__platform_printf("[Error] dir: arg is not object.\r\n");
|
||||
return NULL;
|
||||
}
|
||||
PikaObj* obj = arg_getPtr(arg);
|
||||
PikaObj* New_PikaStdData_List(Args * args);
|
||||
PikaObj* list = newNormalObj(New_PikaStdData_List);
|
||||
__vm_List___init__(list);
|
||||
@ -683,6 +689,6 @@ void PikaStdLib_SysObj_help(PikaObj* self, char* name) {
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdLib_SysObj_reboot(PikaObj *self){
|
||||
void PikaStdLib_SysObj_reboot(PikaObj* self) {
|
||||
pika_platform_reboot();
|
||||
}
|
||||
|
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
"--gtest_filter=VM._3_3"
|
||||
"--gtest_filter=vm.dir_issue"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
@ -85,7 +85,7 @@ class SysObj:
|
||||
|
||||
@staticmethod
|
||||
@PIKA_C_MACRO_IF("!PIKA_NANO_ENABLE")
|
||||
def dir(obj: object) -> list: ...
|
||||
def dir(obj: any) -> list: ...
|
||||
|
||||
@staticmethod
|
||||
@PIKA_C_MACRO_IF("PIKA_EXEC_ENABLE")
|
||||
|
@ -569,7 +569,13 @@ int32_t __dir_each(Arg* argEach, Args* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PikaObj* PikaStdLib_SysObj_dir(PikaObj* self, PikaObj* obj) {
|
||||
PikaObj* PikaStdLib_SysObj_dir(PikaObj* self, Arg* arg) {
|
||||
if (!argType_isObject(arg_getType(arg))) {
|
||||
obj_setErrorCode(self, 1);
|
||||
__platform_printf("[Error] dir: arg is not object.\r\n");
|
||||
return NULL;
|
||||
}
|
||||
PikaObj* obj = arg_getPtr(arg);
|
||||
PikaObj* New_PikaStdData_List(Args * args);
|
||||
PikaObj* list = newNormalObj(New_PikaStdData_List);
|
||||
__vm_List___init__(list);
|
||||
@ -683,6 +689,6 @@ void PikaStdLib_SysObj_help(PikaObj* self, char* name) {
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdLib_SysObj_reboot(PikaObj *self){
|
||||
void PikaStdLib_SysObj_reboot(PikaObj* self) {
|
||||
pika_platform_reboot();
|
||||
}
|
||||
|
@ -2491,6 +2491,24 @@ TEST(vm, num_issue_lakj) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(vm, dir_issue) {
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
obj_run(pikaMain,
|
||||
"class test:\n"
|
||||
" pass\n"
|
||||
"dir(test)\n"
|
||||
);
|
||||
/* collect */
|
||||
/* assert */
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_END
|
Loading…
x
Reference in New Issue
Block a user