diff --git a/init.sh b/init.sh index 5a4499993..3c0efa6b1 100644 --- a/init.sh +++ b/init.sh @@ -8,6 +8,7 @@ git checkout master cd $ROOT rm build -rf mkdir build +sh api-make.sh cd build cmake -DCMAKE_BUILD_TYPE=Debug .. cd $ROOT diff --git a/src/boot/banchmark/main.c b/src/boot/banchmark/main.c index 034398f02..20364a107 100644 --- a/src/boot/banchmark/main.c +++ b/src/boot/banchmark/main.c @@ -1,6 +1,6 @@ /* banchmark for memory */ #include "BaseObj.h" -#include "SysObj.h" +#include "PikaStdLib_SysObj.h" #include void checker_printMem(char *info, uint32_t size) @@ -68,7 +68,7 @@ int32_t main() { checker_objMemChecker(New_TinyObj, "tiny"); checker_objMemChecker(New_BaseObj, "base"); - checker_objMemChecker(New_SysObj, "sys"); + checker_objMemChecker(New_PikaStdLib_SysObj, "sys"); { Arg *arg = New_arg(NULL); checker_printMemUsage("void arg"); diff --git a/src/boot/demo05-sysobject/main.c b/src/boot/demo05-sysobject/main.c index 9c375faf1..4df3f827e 100644 --- a/src/boot/demo05-sysobject/main.c +++ b/src/boot/demo05-sysobject/main.c @@ -1,6 +1,5 @@ /* this demo shows the usage of method */ - -#include "SysObj.h" +#include "PikaStdLib_SysObj.h" #include void obj_runWithInfo(PikaObj *self, char *cmd) @@ -13,23 +12,23 @@ void obj_runWithInfo(PikaObj *self, char *cmd) int main() { /* new root object */ - PikaObj *root = newRootObj("root", New_SysObj); + PikaObj *root = newRootObj("root", New_PikaStdLib_SysObj); obj_runWithInfo(root, "set('a',1)"); obj_runWithInfo(root, "print(a)"); obj_runWithInfo(root, "type('a')"); - obj_runWithInfo(root, "del('a')"); + obj_runWithInfo(root, "remove('a')"); obj_runWithInfo(root, "set('a','test')"); obj_runWithInfo(root, "print(a)"); obj_runWithInfo(root, "type('a')"); - obj_runWithInfo(root, "del('a')"); + obj_runWithInfo(root, "remove('a')"); obj_runWithInfo(root, "set('a',1)"); obj_runWithInfo(root, "set('b',a)"); obj_runWithInfo(root, "print(b)"); - obj_runWithInfo(root, "del('a')"); - obj_runWithInfo(root, "del('b')"); + obj_runWithInfo(root, "remove('a')"); + obj_runWithInfo(root, "remove('b')"); printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); diff --git a/src/package/pikascript/CMakeLists.txt b/src/package/pikascript/CMakeLists.txt index 31ad3641f..f6d93e222 100644 --- a/src/package/pikascript/CMakeLists.txt +++ b/src/package/pikascript/CMakeLists.txt @@ -4,4 +4,6 @@ set(BINARY ${CMAKE_PROJECT_NAME}) file(GLOB_RECURSE SOURCES LIST_DIRECTORIES true *.h *.c) set(SOURCES ${SOURCES}) -add_library(${BINARY}-core STATIC ${SOURCES}) +add_library(${BINARY}-core + STATIC + ${SOURCES}) diff --git a/src/package/pikascript/pikascript-core b/src/package/pikascript/pikascript-core index 5b5a363ef..d65a013ec 160000 --- a/src/package/pikascript/pikascript-core +++ b/src/package/pikascript/pikascript-core @@ -1 +1 @@ -Subproject commit 5b5a363ef2aa5cac0069008b1559cf19cfee0289 +Subproject commit d65a013ec80bbbb4f708762097845dcbd2e129dd diff --git a/src/package/pikascript/pikascript-lib/PikaStdLib_SysObj.c b/src/package/pikascript/pikascript-lib/PikaStdLib_SysObj.c index 4eb0bca03..bcd525b80 100644 --- a/src/package/pikascript/pikascript-lib/PikaStdLib_SysObj.c +++ b/src/package/pikascript/pikascript-lib/PikaStdLib_SysObj.c @@ -41,7 +41,7 @@ void PikaStdLib_SysObj_ls(PikaObj *self, char *objPath) /* no input obj path, use current obj */ args_foreach(self->attributeList, __foreach_listEachArg, args); obj_setSysOut(self, args_getStr(args, "stringOut")); - return; + goto exit; } PikaObj *obj = obj_getObj(self, objPath, 0); if (NULL == obj) @@ -49,12 +49,13 @@ void PikaStdLib_SysObj_ls(PikaObj *self, char *objPath) /* do not find obj */ obj_setSysOut(self, "[error] list: object no found."); obj_setErrorCode(self, 1); - return; + goto exit; } /* list args */ args_foreach(obj->attributeList, __foreach_listEachArg, args); obj_setSysOut(self, args_getStr(args, "stringOut")); - return; +exit: + args_deinit(args); } void PikaStdLib_SysObj_new(PikaObj *self, char *classPath, char *objPath) diff --git a/src/test/object-test.cpp b/src/test/object-test.cpp index f8705d9d7..9506e6459 100644 --- a/src/test/object-test.cpp +++ b/src/test/object-test.cpp @@ -1,7 +1,7 @@ #include "gtest/gtest.h" extern "C" { -#include "SysObj.h" +#include "PikaStdLib_SysObj.h" #include "TinyObj.h" #include "BaseObj.h" } @@ -52,7 +52,7 @@ void add(PikaObj *obj, Args *args) PikaObj *New_PikaObj_test(Args *args) { - PikaObj *self = New_SysObj(args); + PikaObj *self = New_PikaStdLib_SysObj(args); class_defineMethod(self, (char *)"hello(name:str, isShow:int)", hello); class_defineMethod(self, (char *)"hello2(name1:str, name2:str, name3:str, isShow:int)", hello2); class_defineMethod(self, (char *)"testFloat(val1:float, val2:float, isShow:int)->float", testFloat); @@ -100,7 +100,7 @@ PikaObj *New_MYROOT1(Args *args) TEST(object_test, test1) { - PikaObj *process = newRootObj((char *)"sys", New_SysObj); + PikaObj *process = newRootObj((char *)"sys", New_PikaStdLib_SysObj); float floatTest = 12.231; obj_bindFloat(process, (char *)"testFloatBind", &floatTest); EXPECT_TRUE(strEqu((char *)"12.231000", obj_print(process, (char *)"testFloatBind"))); @@ -163,7 +163,7 @@ TEST(object_test, test6) TEST(object_test, test7) { - PikaObj *sys = newRootObj((char *)"sys", New_SysObj); + PikaObj *sys = newRootObj((char *)"sys", New_PikaStdLib_SysObj); int32_t a = 0; obj_bind(sys, (char *)"int", (char *)"a", &a); obj_run(sys, (char *)"set('a', 1)"); @@ -174,16 +174,16 @@ TEST(object_test, test7) TEST(object_test, test8) { - PikaObj *sys = newRootObj((char *)"sys", New_SysObj); + PikaObj *sys = newRootObj((char *)"sys", New_PikaStdLib_SysObj); obj_run(sys, (char *)"set('a', 1)"); - obj_run(sys, (char *)"del('a')"); + obj_run(sys, (char *)"remove('a')"); obj_deinit(sys); EXPECT_EQ(pikaMemNow(), 0); } TEST(object_test, test9) { - PikaObj *sys = newRootObj((char *)"sys", New_SysObj); + PikaObj *sys = newRootObj((char *)"sys", New_PikaStdLib_SysObj); obj_run(sys, (char *)"ls()"); obj_setPtr(sys, (char *)"baseClass", (void *)New_TinyObj); obj_run(sys, (char *)"ls()"); diff --git a/src/test/sysObj-test.cpp b/src/test/sysObj-test.cpp index 86dd4c6b7..5de464d50 100644 --- a/src/test/sysObj-test.cpp +++ b/src/test/sysObj-test.cpp @@ -1,13 +1,13 @@ #include "gtest/gtest.h" extern "C" { -#include "SysObj.h" +#include "PikaStdLib_SysObj.h" #include "TinyObj.h" #include "BaseObj.h" } TEST(sysObj, print) { - PikaObj *obj = newRootObj((char *)"test", New_SysObj); + PikaObj *obj = newRootObj((char *)"test", New_PikaStdLib_SysObj); Args *res = obj_runDirect(obj, (char *)"print('hello world')"); char *sysOut = args_getSysOut(res); int errCode = args_getErrorCode(res); @@ -21,7 +21,7 @@ TEST(sysObj, print) TEST(sysObj, set) { - PikaObj *obj = newRootObj((char *)"test", New_SysObj); + PikaObj *obj = newRootObj((char *)"test", New_PikaStdLib_SysObj); Args *res = obj_runDirect(obj, (char *)"set('a', 1)"); int a = obj_getInt(obj, (char *)"a"); char *sysOut = args_getSysOut(res); @@ -37,7 +37,7 @@ TEST(sysObj, set) TEST(sysObj, noMethod) { - PikaObj *obj = newRootObj((char *)"test", New_SysObj); + PikaObj *obj = newRootObj((char *)"test", New_PikaStdLib_SysObj); Args *res = obj_runDirect(obj, (char *)"printttt('hello world')"); char *sysOut = args_getSysOut(res); int errCode = args_getErrorCode(res);