diff --git a/port/linux/.vscode/launch.json b/port/linux/.vscode/launch.json index c96f78e6d..2a5ff4d60 100644 --- a/port/linux/.vscode/launch.json +++ b/port/linux/.vscode/launch.json @@ -11,9 +11,14 @@ "program": "${workspaceFolder}/build/test/pikascript_test", // "program": "${workspaceFolder}/../build/src/boot/demo06-pikamain/pikascript_demo06-pikamain", "args": [ - // "--gtest_filter=queueObj.currentObj" + // "--gtest_filter=queue*" // "--gtest_filter=parser*" - // "--gtest_filter=VM.RUN_local_b" + // "--gtest_filter=args*", + // "--gtest_filter=content*", + // "--gtest_filter=object_test.printa", + "--gtest_filter=object_test*", + // "--gtest_filter=stack*", + // "--gtest_filter=strs*", // "--gtest_filter=block.ifrun2" // "--gtest_filter=sysObj.print" // "--gtest_filter=object_test.a_b" diff --git a/port/linux/package/pikascript/PikaStdLib.py b/port/linux/package/pikascript/PikaStdLib.py index 7e0b5e137..81a1abcbb 100644 --- a/port/linux/package/pikascript/PikaStdLib.py +++ b/port/linux/package/pikascript/PikaStdLib.py @@ -15,8 +15,5 @@ class SysObj(BaseObj): def type(argPath: str): pass - def ls(objPath: str): - pass - def remove(argPath: str): pass diff --git a/port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdLib_SysObj.c b/port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdLib_SysObj.c index 9ab31ffa1..02a84d27c 100644 --- a/port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdLib_SysObj.c +++ b/port/linux/package/pikascript/pikascript-lib/PikaStdLib/PikaStdLib_SysObj.c @@ -1,56 +1,6 @@ #include "BaseObj.h" #include "dataStrs.h" -static int32_t __foreach_listEachArg(Arg* argEach, Args* handleArgs) { - Args* buffs = handleArgs; - if (NULL == handleArgs) { - /* error: not handleArgs input */ - return 1; - } - - char* argName = strsCopy(buffs, arg_getNameHash(argEach)); - if (strIsStartWith(argName, "[")) { - /* skip */ - return 0; - } - - char* stringOut = args_getStr(handleArgs, "stringOut"); - if (NULL == stringOut) { - // stringOut no found - return 1; - } - - stringOut = strsAppend(buffs, stringOut, argName); - stringOut = strsAppend(buffs, stringOut, " "); - args_setStr(handleArgs, "stringOut", stringOut); - return 0; -} - -void PikaStdLib_SysObj_ls(PikaObj* self, char* objPath) { - obj_setErrorCode(self, 0); - Args* args = New_args(NULL); - args_setStr(args, "stringOut", ""); - obj_setSysOut(self, ""); - if (NULL == objPath) { - /* no input obj path, use current obj */ - args_foreach(self->attributeList, __foreach_listEachArg, args); - obj_setSysOut(self, args_getStr(args, "stringOut")); - goto exit; - } - PikaObj* obj = obj_getObj(self, objPath, 0); - if (NULL == obj) { - /* do not find obj */ - obj_setSysOut(self, "[error] list: object no found."); - obj_setErrorCode(self, 1); - goto exit; - } - /* list args */ - args_foreach(obj->attributeList, __foreach_listEachArg, args); - obj_setSysOut(self, args_getStr(args, "stringOut")); -exit: - args_deinit(args); -} - void PikaStdLib_SysObj_remove(PikaObj* self, char* argPath) { obj_setErrorCode(self, 0); int32_t res = obj_removeArg(self, argPath); diff --git a/port/linux/test/content-test.cpp b/port/linux/test/content-test.cpp index 265ce19dd..fcd34aa57 100644 --- a/port/linux/test/content-test.cpp +++ b/port/linux/test/content-test.cpp @@ -73,7 +73,7 @@ TEST(content, set) { ASSERT_EQ(content[3], 4); ASSERT_EQ(totleSize, 24); - ASSERT_EQ(hash_time33("name"), nameHash); + ASSERT_EQ(hash_time33((char *)"name"), nameHash); ASSERT_STREQ("type", type); content_deinit(self); diff --git a/src/PikaObj.c b/src/PikaObj.c index 634256c8a..a50a5a5b0 100644 --- a/src/PikaObj.c +++ b/src/PikaObj.c @@ -416,7 +416,8 @@ int32_t obj_removeArg(PikaObj* self, char* argPath) { goto exit; } char* argName = strsGetLastToken(buffs, argPath, '.'); - int32_t res = args_removeArg(objHost->attributeList, argName); + int32_t res = args_removeArg(objHost->attributeList, + args_getArg(objHost->attributeList, argName)); if (1 == res) { /*[error] not found arg*/ err = 2; diff --git a/src/PikaVM.c b/src/PikaVM.c index 088e8183e..b3cda347b 100644 --- a/src/PikaVM.c +++ b/src/PikaVM.c @@ -433,7 +433,8 @@ int32_t __clearInvokeQueues(Parameters* locals) { Queue* queue = (Queue*)args_getPtr(locals->attributeList, deepth); if (NULL != queue) { args_deinit(queue); - args_removeArg(locals->attributeList, deepth); + args_removeArg(locals->attributeList, + args_getArg(locals->attributeList, deepth)); } } return 0; diff --git a/src/dataQueue.c b/src/dataQueue.c index 2551f985a..6e774b78f 100644 --- a/src/dataQueue.c +++ b/src/dataQueue.c @@ -11,25 +11,26 @@ #include "dataArgs.h" static uint16_t const str100p[100] = { - 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, 0x3930, - 0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731, 0x3831, 0x3931, - 0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732, 0x3832, 0x3932, - 0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733, 0x3833, 0x3933, - 0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734, 0x3834, 0x3934, - 0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735, 0x3835, 0x3935, - 0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736, 0x3836, 0x3936, - 0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737, 0x3837, 0x3937, - 0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738, 0x3838, 0x3938, - 0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739, 0x3839, 0x3939, }; + 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730, 0x3830, + 0x3930, 0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731, + 0x3831, 0x3931, 0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, + 0x3732, 0x3832, 0x3932, 0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, + 0x3633, 0x3733, 0x3833, 0x3933, 0x3034, 0x3134, 0x3234, 0x3334, 0x3434, + 0x3534, 0x3634, 0x3734, 0x3834, 0x3934, 0x3035, 0x3135, 0x3235, 0x3335, + 0x3435, 0x3535, 0x3635, 0x3735, 0x3835, 0x3935, 0x3036, 0x3136, 0x3236, + 0x3336, 0x3436, 0x3536, 0x3636, 0x3736, 0x3836, 0x3936, 0x3037, 0x3137, + 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737, 0x3837, 0x3937, 0x3038, + 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738, 0x3838, 0x3938, + 0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739, 0x3839, + 0x3939, +}; -char *fast_itoa(char *buf, uint32_t val) -{ - char *p = &buf[10]; +char* fast_itoa(char* buf, uint32_t val) { + char* p = &buf[10]; *p = '\0'; - while(val >= 100) - { + while (val >= 100) { uint32_t const old = val; p -= 2; @@ -61,7 +62,7 @@ int32_t queue_pushInt(Queue* queue, int val) { Args* args = queue; uint64_t top = args_getInt(args, "top"); char buff[11]; - char *topStr = fast_itoa(buff, top); + char* topStr = fast_itoa(buff, top); /* add top */ args_setInt(args, "top", top + 1); return args_setInt(args, topStr, val); @@ -71,11 +72,11 @@ int64_t queue_popInt(Queue* queue) { Args* args = queue; uint64_t bottom = args_getInt(args, "bottom"); char buff[11]; - char *bottomStr = fast_itoa(buff, bottom); + char* bottomStr = fast_itoa(buff, bottom); /* add bottom */ args_setInt(args, "bottom", bottom + 1); int64_t res = args_getInt(args, bottomStr); - args_removeArg(args, bottomStr); + args_removeArg(args, args_getArg(args, bottomStr)); return res; } @@ -83,7 +84,7 @@ int32_t queue_pushFloat(Queue* queue, float val) { Args* args = queue; uint64_t top = args_getInt(args, "top"); char buff[11]; - char *topStr = fast_itoa(buff, top); + char* topStr = fast_itoa(buff, top); /* add top */ args_setInt(args, "top", top + 1); return args_setFloat(args, topStr, val); @@ -93,11 +94,11 @@ float queue_popFloat(Queue* queue) { Args* args = queue; uint64_t bottom = args_getInt(args, "bottom"); char buff[11]; - char *bottomStr = fast_itoa(buff, bottom); + char* bottomStr = fast_itoa(buff, bottom); /* add bottom */ args_setInt(args, "bottom", bottom + 1); float res = args_getFloat(args, bottomStr); - args_removeArg(args, bottomStr); + args_removeArg(args, args_getArg(args, bottomStr)); return res; } @@ -106,7 +107,7 @@ int32_t queue_pushStr(Queue* queue, char* str) { uint64_t top = args_getInt(args, "top"); char buff[11]; /* add top */ - char *topStr = fast_itoa(buff, top); + char* topStr = fast_itoa(buff, top); args_setInt(args, "top", top + 1); return args_setStr(args, topStr, str); } @@ -117,7 +118,7 @@ char* queue_popStr(Queue* queue) { char buff[11]; /* add bottom */ args_setInt(args, "bottom", bottom + 1); - return args_getStr(args, fast_itoa(buff, bottom)); + return args_getStr(args, fast_itoa(buff, bottom)); } int32_t queue_pushArg(Queue* queue, Arg* arg) { @@ -125,7 +126,7 @@ int32_t queue_pushArg(Queue* queue, Arg* arg) { uint64_t top = args_getInt(args, "top"); /* add top */ args_setInt(args, "top", top + 1); - char buff[11]; + char buff[11]; arg = arg_setName(arg, fast_itoa(buff, top)); return args_setArg(args, arg); } @@ -135,7 +136,7 @@ Arg* queue_popArg(Queue* queue) { uint64_t bottom = args_getInt(args, "bottom"); /* add bottom */ args_setInt(args, "bottom", bottom + 1); - char buff[11]; - Arg* res = args_getArg(args, fast_itoa(buff, bottom)); + char buff[11]; + Arg* res = args_getArg(args, fast_itoa(buff, bottom)); return res; } \ No newline at end of file diff --git a/src/dataStack.c b/src/dataStack.c index 23e6627a5..74cf588e1 100644 --- a/src/dataStack.c +++ b/src/dataStack.c @@ -29,6 +29,6 @@ char* stack_popStr(Stack* queue, char* outBuff) { args_setInt(args, "top", top); char* topStr = fast_itoa(buff, top); strcpy(outBuff, args_getStr(args, topStr)); - args_removeArg(args, topStr); + args_removeArg(args, args_getArg(args, topStr)); return outBuff; } \ No newline at end of file