From 2b6eb49cc31f8c225a0b1f9e6482f1f8c8ddb9d4 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 29 Aug 2021 09:00:44 -0400 Subject: [PATCH] format codes --- src/boot/banchmark/main.c | 232 +++++++++++++++---------------- src/boot/demo01-led/main.c | 94 ++++++------- src/boot/demo02-add/main.c | 96 ++++++------- src/boot/demo03-usart/main.c | 90 ++++++------ src/boot/demo04-usarts/main.c | 152 ++++++++++---------- src/boot/demo05-sysobject/main.c | 100 ++++++------- src/boot/demo06-pikamain/main.c | 48 +++---- src/test/arg-test.cpp | 2 +- src/test/dataTest.c | 2 +- src/test/dataTest.h | 2 +- src/test/link-test.cpp | 2 +- src/test/main.cpp | 4 +- src/test/object-test.cpp | 14 +- src/test/strs-test.cpp | 2 +- src/test/sysObj-test.cpp | 2 +- 15 files changed, 421 insertions(+), 421 deletions(-) diff --git a/src/boot/banchmark/main.c b/src/boot/banchmark/main.c index faabd060b..3ef95d8ef 100644 --- a/src/boot/banchmark/main.c +++ b/src/boot/banchmark/main.c @@ -6,139 +6,139 @@ void checker_printMem(char *info, uint32_t size) { - printf("%s", info); - if (size <= 1024) - { - printf("%d byte\r\n", size); - return; - } - printf("%0.2f Kb\r\n", size / 1024.0); - return; + printf("%s", info); + if (size <= 1024) + { + printf("%d byte\r\n", size); + return; + } + printf("%0.2f Kb\r\n", size / 1024.0); + return; } void checker_printMemUsage(char *testName) { - printf("---------------------------\r\n"); - printf("Testing :%s\r\n", testName); - checker_printMem(" max = ", pikaMemMax()); - checker_printMem(" now = ", pikaMemNow()); - printf("---------------------------\r\n"); + printf("---------------------------\r\n"); + printf("Testing :%s\r\n", testName); + checker_printMem(" max = ", pikaMemMax()); + checker_printMem(" now = ", pikaMemNow()); + printf("---------------------------\r\n"); } void checker_memInfo(void) { - printf("---------------------------\r\n"); - printf("Memory pool info:\r\n"); - checker_printMem(" mem state size = ", sizeof(PikaMemInfo)); - printf("---------------------------\r\n"); + printf("---------------------------\r\n"); + printf("Memory pool info:\r\n"); + checker_printMem(" mem state size = ", sizeof(PikaMemInfo)); + printf("---------------------------\r\n"); } void checker_assertMemFree() { - if (0 == pikaMemNow()) - { - pikaMemMaxReset(); - return; - } - printf("[Error]: Memory free error.\r\n"); - while (1) - ; + if (0 == pikaMemNow()) + { + pikaMemMaxReset(); + return; + } + printf("[Error]: Memory free error.\r\n"); + while (1) + ; } void checker_objMemChecker(void *NewFun, char *objName) { - { - /* new root object */ - PikaObj *obj = newRootObj("obj", NewFun); - Args *buffs = New_args(NULL); - char *testName = strsFormat(buffs, "Root %s object", objName); - checker_printMemUsage(testName); - obj_deinit(obj); - args_deinit(buffs); - checker_assertMemFree(); - } + { + /* new root object */ + PikaObj *obj = newRootObj("obj", NewFun); + Args *buffs = New_args(NULL); + char *testName = strsFormat(buffs, "Root %s object", objName); + checker_printMemUsage(testName); + obj_deinit(obj); + args_deinit(buffs); + checker_assertMemFree(); + } - { - PikaObj *obj = New_TinyObj(NULL); - Args *buffs = New_args(NULL); - checker_printMemUsage(strsFormat(buffs, "%s object", objName)); - obj_deinit(obj); - args_deinit(buffs); - checker_assertMemFree(); - } + { + PikaObj *obj = New_TinyObj(NULL); + Args *buffs = New_args(NULL); + checker_printMemUsage(strsFormat(buffs, "%s object", objName)); + obj_deinit(obj); + args_deinit(buffs); + checker_assertMemFree(); + } } int32_t main() { - checker_objMemChecker(New_TinyObj, "tiny"); - checker_objMemChecker(New_BaseObj, "base"); - checker_objMemChecker(New_PikaStdLib_SysObj, "sys"); - { - Arg *arg = New_arg(NULL); - checker_printMemUsage("void arg"); - arg_deinit(arg); - checker_assertMemFree(); - } - { - Link *link = New_link(NULL); - checker_printMemUsage("void link"); - link_deinit(link); - checker_assertMemFree(); - } - { - Arg *arg = New_arg(NULL); - arg_setInt(arg, 0); - checker_printMemUsage("int arg"); - arg_deinit(arg); - checker_assertMemFree(); - } - { - Arg *arg = New_arg(NULL); - arg_setFloat(arg, 0); - checker_printMemUsage("float arg"); - arg_deinit(arg); - checker_assertMemFree(); - } - { - Arg *arg = New_arg(NULL); - arg_setStr(arg, "test string"); - checker_printMemUsage("str arg"); - arg_deinit(arg); - checker_assertMemFree(); - } - { - Args *args = New_args(NULL); - checker_printMemUsage("void args"); - args_deinit(args); - checker_assertMemFree(); - } - { - Args *args = New_args(NULL); - args_setInt(args, "testInt", 0); - checker_printMemUsage("one int args"); - args_deinit(args); - checker_assertMemFree(); - } - { - Args *args = New_args(NULL); - args_setInt(args, "testInt1", 0); - args_setInt(args, "testInt2", 0); - checker_printMemUsage("two int args"); - args_deinit(args); - checker_assertMemFree(); - } - { - Args *args = New_args(NULL); - args_setFloat(args, "testFloat", 0); - checker_printMemUsage("one float args"); - args_deinit(args); - checker_assertMemFree(); - } - { - Args *args = New_args(NULL); - args_setFloat(args, "testFloat", 0); - args_setFloat(args, "testFLoat", 0); - checker_printMemUsage("two float args"); - args_deinit(args); - checker_assertMemFree(); - } - checker_memInfo(); + checker_objMemChecker(New_TinyObj, "tiny"); + checker_objMemChecker(New_BaseObj, "base"); + checker_objMemChecker(New_PikaStdLib_SysObj, "sys"); + { + Arg *arg = New_arg(NULL); + checker_printMemUsage("void arg"); + arg_deinit(arg); + checker_assertMemFree(); + } + { + Link *link = New_link(NULL); + checker_printMemUsage("void link"); + link_deinit(link); + checker_assertMemFree(); + } + { + Arg *arg = New_arg(NULL); + arg_setInt(arg, 0); + checker_printMemUsage("int arg"); + arg_deinit(arg); + checker_assertMemFree(); + } + { + Arg *arg = New_arg(NULL); + arg_setFloat(arg, 0); + checker_printMemUsage("float arg"); + arg_deinit(arg); + checker_assertMemFree(); + } + { + Arg *arg = New_arg(NULL); + arg_setStr(arg, "test string"); + checker_printMemUsage("str arg"); + arg_deinit(arg); + checker_assertMemFree(); + } + { + Args *args = New_args(NULL); + checker_printMemUsage("void args"); + args_deinit(args); + checker_assertMemFree(); + } + { + Args *args = New_args(NULL); + args_setInt(args, "testInt", 0); + checker_printMemUsage("one int args"); + args_deinit(args); + checker_assertMemFree(); + } + { + Args *args = New_args(NULL); + args_setInt(args, "testInt1", 0); + args_setInt(args, "testInt2", 0); + checker_printMemUsage("two int args"); + args_deinit(args); + checker_assertMemFree(); + } + { + Args *args = New_args(NULL); + args_setFloat(args, "testFloat", 0); + checker_printMemUsage("one float args"); + args_deinit(args); + checker_assertMemFree(); + } + { + Args *args = New_args(NULL); + args_setFloat(args, "testFloat", 0); + args_setFloat(args, "testFLoat", 0); + checker_printMemUsage("two float args"); + args_deinit(args); + checker_assertMemFree(); + } + checker_memInfo(); } diff --git a/src/boot/demo01-led/main.c b/src/boot/demo01-led/main.c index 040e7b044..4b09cb35c 100644 --- a/src/boot/demo01-led/main.c +++ b/src/boot/demo01-led/main.c @@ -5,76 +5,76 @@ void onMethod(PikaObj *self, Args *args) { - /* turn on the led */ - printf("the led is on! \r\n"); + /* turn on the led */ + printf("the led is on! \r\n"); } void offMethod(PikaObj *self, Args *args) { - /* turn off the led */ - printf("the led is off! \r\n"); + /* turn off the led */ + printf("the led is off! \r\n"); } PikaObj *New_LED(Args *args) { - /* Derive from the tiny object class. - Tiny object can not import sub object. - Tiny object is the smallest object. */ - PikaObj *self = New_TinyObj(args); + /* Derive from the tiny object class. + Tiny object can not import sub object. + Tiny object is the smallest object. */ + PikaObj *self = New_TinyObj(args); - /* bind the method */ - class_defineMethod(self, "on()", onMethod); - class_defineMethod(self, "off()", offMethod); + /* bind the method */ + class_defineMethod(self, "on()", onMethod); + class_defineMethod(self, "off()", offMethod); - /* return the object */ - return self; + /* return the object */ + return self; } PikaObj *New_MYROOT(Args *args) { - /* Derive from the base object class . - BaseObj is the smallest object that can - import sub object. */ - PikaObj *self = New_BaseObj(args); + /* Derive from the base object class . + BaseObj is the smallest object that can + import sub object. */ + PikaObj *self = New_BaseObj(args); - /* import LED class */ - obj_import(self, "LED", New_LED); + /* import LED class */ + obj_import(self, "LED", New_LED); - /* new led object bellow root object */ - obj_newObj(self, "led", "LED"); + /* new led object bellow root object */ + obj_newObj(self, "led", "LED"); - /* return the object */ - return self; + /* return the object */ + return self; } int32_t main() { - /* new root object */ - PikaObj *root = newRootObj("root", New_MYROOT); - /* user input buff */ - char inputBuff[256] = {0}; - /* run the script with check*/ - obj_run(root, "led.on()"); - printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); - printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); - while (1) - { - /* get user input */ - fgets(inputBuff, sizeof(inputBuff), stdin); + /* new root object */ + PikaObj *root = newRootObj("root", New_MYROOT); + /* user input buff */ + char inputBuff[256] = {0}; + /* run the script with check*/ + obj_run(root, "led.on()"); + printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); + printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); + while (1) + { + /* get user input */ + fgets(inputBuff, sizeof(inputBuff), stdin); - /* run PikaScript and get res */ - Args *resArgs = obj_runDirect(root, inputBuff); + /* run PikaScript and get res */ + Args *resArgs = obj_runDirect(root, inputBuff); - /* get system output of PikaScript*/ - char *sysOut = args_getSysOut(resArgs);; + /* get system output of PikaScript*/ + char *sysOut = args_getSysOut(resArgs);; - if (NULL != sysOut) - { - /* print32_t out the system output */ - printf("%s\r\n", sysOut); - } + if (NULL != sysOut) + { + /* print32_t out the system output */ + printf("%s\r\n", sysOut); + } - /* deinit the res */ - args_deinit(resArgs); - } + /* deinit the res */ + args_deinit(resArgs); + } } diff --git a/src/boot/demo02-add/main.c b/src/boot/demo02-add/main.c index 2d9614427..98fe134fe 100644 --- a/src/boot/demo02-add/main.c +++ b/src/boot/demo02-add/main.c @@ -5,73 +5,73 @@ void addMethod(PikaObj *self, Args* args) { - int32_t val1 = args_getInt(args, "val1"); - int32_t val2 = args_getInt(args, "val2"); - int32_t res = val1 + val2; - method_returnInt(args, res); + int32_t val1 = args_getInt(args, "val1"); + int32_t val2 = args_getInt(args, "val2"); + int32_t res = val1 + val2; + method_returnInt(args, res); } PikaObj *New_TEST(Args *args) { - /* Derive from the tiny object class. - Tiny object can not import sub object. - Tiny object is the smallest object. */ - PikaObj *self = New_TinyObj(args); + /* Derive from the tiny object class. + Tiny object can not import sub object. + Tiny object is the smallest object. */ + PikaObj *self = New_TinyObj(args); - /* bind the method */ - class_defineMethod(self, "add(val1:int, val2:int)->int", addMethod); + /* bind the method */ + class_defineMethod(self, "add(val1:int, val2:int)->int", addMethod); - /* return the object */ - return self; + /* return the object */ + return self; } PikaObj *New_MYROOT(Args *args) { - /* Derive from the base object class . - BaseObj is the smallest object that can - import sub object. */ - PikaObj *self = New_BaseObj(args); + /* Derive from the base object class . + BaseObj is the smallest object that can + import sub object. */ + PikaObj *self = New_BaseObj(args); - /* import LED class */ - obj_import(self, "TEST", New_TEST); + /* import LED class */ + obj_import(self, "TEST", New_TEST); - /* new led object bellow root object */ - obj_newObj(self, "test", "TEST"); + /* new led object bellow root object */ + obj_newObj(self, "test", "TEST"); - /* return the object */ - return self; + /* return the object */ + return self; } int32_t main() { - /* new root object */ - PikaObj *root = newRootObj("root", New_MYROOT); - /* user input buff */ - char inputBuff[256] = {0}; - /* run the script with check*/ - obj_run(root, "res = test.add(1, 2)"); - int32_t res = obj_getInt(root, "res"); - printf("the res of 'test.add(1, 2)' is %d \r\n", res); - printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); - printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); - while (1) - { - /* get user input */ - fgets(inputBuff, sizeof(inputBuff), stdin); + /* new root object */ + PikaObj *root = newRootObj("root", New_MYROOT); + /* user input buff */ + char inputBuff[256] = {0}; + /* run the script with check*/ + obj_run(root, "res = test.add(1, 2)"); + int32_t res = obj_getInt(root, "res"); + printf("the res of 'test.add(1, 2)' is %d \r\n", res); + printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); + printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); + while (1) + { + /* get user input */ + fgets(inputBuff, sizeof(inputBuff), stdin); - /* run PikaScript and get res */ - Args *resArgs = obj_runDirect(root, inputBuff); + /* run PikaScript and get res */ + Args *resArgs = obj_runDirect(root, inputBuff); - /* get system output of PikaScript*/ - char *sysOut = args_getSysOut(resArgs);; + /* get system output of PikaScript*/ + char *sysOut = args_getSysOut(resArgs);; - if (NULL != sysOut) - { - /* print32_t out the system output */ - printf("%s\r\n", sysOut); - } + if (NULL != sysOut) + { + /* print32_t out the system output */ + printf("%s\r\n", sysOut); + } - /* deinit the res */ - args_deinit(resArgs); - } + /* deinit the res */ + args_deinit(resArgs); + } } diff --git a/src/boot/demo03-usart/main.c b/src/boot/demo03-usart/main.c index dfa31e3ac..17e91d67c 100644 --- a/src/boot/demo03-usart/main.c +++ b/src/boot/demo03-usart/main.c @@ -5,71 +5,71 @@ void sendMethod(PikaObj *self, Args *args) { - char *data = args_getStr(args, "data"); - /* send to com1 */ - printf("[com1]: %s\r\n", data); + char *data = args_getStr(args, "data"); + /* send to com1 */ + printf("[com1]: %s\r\n", data); } PikaObj *New_USART(Args *args) { - /* Derive from the tiny object class. - Tiny object can not import sub object. - Tiny object is the smallest object. */ - PikaObj *self = New_TinyObj(args); + /* Derive from the tiny object class. + Tiny object can not import sub object. + Tiny object is the smallest object. */ + PikaObj *self = New_TinyObj(args); - /* bind the method */ - class_defineMethod(self, "send(data:str)", sendMethod); + /* bind the method */ + class_defineMethod(self, "send(data:str)", sendMethod); - /* return the object */ - return self; + /* return the object */ + return self; } PikaObj *New_MYROOT(Args *args) { - /* Derive from the base object class . - BaseObj is the smallest object that can - import sub object. */ - PikaObj *self = New_BaseObj(args); + /* Derive from the base object class . + BaseObj is the smallest object that can + import sub object. */ + PikaObj *self = New_BaseObj(args); - /* import LED class */ - obj_import(self, "USART", New_USART); + /* import LED class */ + obj_import(self, "USART", New_USART); - /* new led object bellow root object */ - obj_newObj(self, "usart", "USART"); + /* new led object bellow root object */ + obj_newObj(self, "usart", "USART"); - /* return the object */ - return self; + /* return the object */ + return self; } int32_t main() { - /* new root object */ - PikaObj *root = newRootObj("root", New_MYROOT); - /* user input buff */ - char inputBuff[256] = {0}; - /* run the script with check*/ - obj_run(root, "res = usart.send('hello world')"); + /* new root object */ + PikaObj *root = newRootObj("root", New_MYROOT); + /* user input buff */ + char inputBuff[256] = {0}; + /* run the script with check*/ + obj_run(root, "res = usart.send('hello world')"); - printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); - printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); - while (1) - { - /* get user input */ - fgets(inputBuff, sizeof(inputBuff), stdin); + printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); + printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); + while (1) + { + /* get user input */ + fgets(inputBuff, sizeof(inputBuff), stdin); - /* run PikaScript and get res */ - Args *resArgs = obj_runDirect(root, inputBuff); + /* run PikaScript and get res */ + Args *resArgs = obj_runDirect(root, inputBuff); - /* get system output of PikaScript*/ - char *sysOut = args_getSysOut(resArgs);; + /* get system output of PikaScript*/ + char *sysOut = args_getSysOut(resArgs);; - if (NULL != sysOut) - { - /* print32_t out the system output */ - printf("%s\r\n", sysOut); - } + if (NULL != sysOut) + { + /* print32_t out the system output */ + printf("%s\r\n", sysOut); + } - /* deinit the res */ - args_deinit(resArgs); - } + /* deinit the res */ + args_deinit(resArgs); + } } diff --git a/src/boot/demo04-usarts/main.c b/src/boot/demo04-usarts/main.c index 6db53f8f3..516de8f41 100644 --- a/src/boot/demo04-usarts/main.c +++ b/src/boot/demo04-usarts/main.c @@ -5,127 +5,127 @@ void sendMethod(PikaObj *self, Args *args) { - char *data = args_getStr(args, "data"); - /* send to com1 */ - printf("[com1]: %s\r\n", data); + char *data = args_getStr(args, "data"); + /* send to com1 */ + printf("[com1]: %s\r\n", data); } void setSpeedMethod(PikaObj *self, Args *args) { - int32_t speed = args_getInt(args, "speed"); - obj_setInt(self, "speed", speed); + int32_t speed = args_getInt(args, "speed"); + obj_setInt(self, "speed", speed); } void printSpeedMethod(PikaObj *self, Args *args) { - int32_t speed = obj_getInt(self, "speed"); - printf("%d\r\n", speed); + int32_t speed = obj_getInt(self, "speed"); + printf("%d\r\n", speed); } PikaObj *New_USART(Args *args) { - /* Derive from the tiny object class. - Tiny object can not import sub object. - Tiny object is the smallest object. */ - PikaObj *self = New_TinyObj(args); + /* Derive from the tiny object class. + Tiny object can not import sub object. + Tiny object is the smallest object. */ + PikaObj *self = New_TinyObj(args); - /* setArgs */ - obj_setInt(self, "speed", 9600); + /* setArgs */ + obj_setInt(self, "speed", 9600); - /* bind the method */ - class_defineMethod(self, "send(data:str)", sendMethod); - class_defineMethod(self, "setSpeed(speed:int)", setSpeedMethod); - class_defineMethod(self, "printSpeed()", printSpeedMethod); + /* bind the method */ + class_defineMethod(self, "send(data:str)", sendMethod); + class_defineMethod(self, "setSpeed(speed:int)", setSpeedMethod); + class_defineMethod(self, "printSpeed()", printSpeedMethod); - /* return the object */ - return self; + /* return the object */ + return self; } void sendFun2(PikaObj *self, Args *args) { - char *data = args_getStr(args, "data"); - /* send to com1 */ - printf("[com2]: %s\r\n", data); + char *data = args_getStr(args, "data"); + /* send to com1 */ + printf("[com2]: %s\r\n", data); } PikaObj *New_USART2(Args *args) { - /* Derive from the usart class.*/ - PikaObj *self = New_USART(args); + /* Derive from the usart class.*/ + PikaObj *self = New_USART(args); - /* override the method */ - class_defineMethod(self, "send(data:str)", sendFun2); + /* override the method */ + class_defineMethod(self, "send(data:str)", sendFun2); - /* return the object */ - return self; + /* return the object */ + return self; } PikaObj *New_MYROOT(Args *args) { - /* Derive from the base object class . - BaseObj is the smallest object that can - import sub object. */ - PikaObj *self = New_BaseObj(args); + /* Derive from the base object class . + BaseObj is the smallest object that can + import sub object. */ + PikaObj *self = New_BaseObj(args); - /* import LED class */ - obj_import(self, "USART", New_USART); - obj_import(self, "USART2", New_USART2); + /* import LED class */ + obj_import(self, "USART", New_USART); + obj_import(self, "USART2", New_USART2); - /* new object bellow root object */ - obj_newObj(self, "usart1", "USART"); - obj_newObj(self, "usart2", "USART2"); + /* new object bellow root object */ + obj_newObj(self, "usart1", "USART"); + obj_newObj(self, "usart2", "USART2"); - /* return the object */ - return self; + /* return the object */ + return self; } int32_t main() { - /* new root object */ - PikaObj *root = newRootObj("root", New_MYROOT); - /* user input buff */ - char inputBuff[256] = {0}; + /* new root object */ + PikaObj *root = newRootObj("root", New_MYROOT); + /* user input buff */ + char inputBuff[256] = {0}; - /* usart and usart2 can also be use the method in USART */ - printf("the speed of usart1 before set:"); - obj_run(root, "usart1.printSpeed()"); + /* usart and usart2 can also be use the method in USART */ + printf("the speed of usart1 before set:"); + obj_run(root, "usart1.printSpeed()"); - printf("the speed of usart2 before set:"); - obj_run(root, "usart2.printSpeed()"); + printf("the speed of usart2 before set:"); + obj_run(root, "usart2.printSpeed()"); - obj_run(root, "usart1.setSpeed(115200)"); - obj_run(root, "usart2.setSpeed(284000)"); + obj_run(root, "usart1.setSpeed(115200)"); + obj_run(root, "usart2.setSpeed(284000)"); - printf("the speed of usart1 after set:"); - obj_run(root, "usart1.printSpeed()"); + printf("the speed of usart1 after set:"); + obj_run(root, "usart1.printSpeed()"); - printf("the speed of usart2 after set:"); - obj_run(root, "usart2.printSpeed()"); + printf("the speed of usart2 after set:"); + obj_run(root, "usart2.printSpeed()"); - /* the send method is override in usart2 */ - obj_run(root, "usart1.send('hello world')"); - obj_run(root, "usart2.send('hello world')"); + /* the send method is override in usart2 */ + obj_run(root, "usart1.send('hello world')"); + obj_run(root, "usart2.send('hello world')"); - printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); - printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); - while (1) - { - /* get user input */ - fgets(inputBuff, sizeof(inputBuff), stdin); + printf("memory used max = %0.2f kB\r\n", pikaMemMax() / 1024.0); + printf("memory used now = %0.2f kB\r\n", pikaMemNow() / 1024.0); + while (1) + { + /* get user input */ + fgets(inputBuff, sizeof(inputBuff), stdin); - /* run PikaScript and get res */ - Args *resArgs = obj_runDirect(root, inputBuff); + /* run PikaScript and get res */ + Args *resArgs = obj_runDirect(root, inputBuff); - /* get system output of PikaScript*/ - char *sysOut = args_getSysOut(resArgs);; + /* get system output of PikaScript*/ + char *sysOut = args_getSysOut(resArgs);; - if (NULL != sysOut) - { - /* print32_t out the system output */ - printf("%s\r\n", sysOut); - } + if (NULL != sysOut) + { + /* print32_t out the system output */ + printf("%s\r\n", sysOut); + } - /* deinit the res */ - args_deinit(resArgs); - } + /* deinit the res */ + args_deinit(resArgs); + } } diff --git a/src/boot/demo05-sysobject/main.c b/src/boot/demo05-sysobject/main.c index 24d23ea76..a67a757b4 100644 --- a/src/boot/demo05-sysobject/main.c +++ b/src/boot/demo05-sysobject/main.c @@ -4,58 +4,58 @@ void obj_runWithInfo(PikaObj *self, char *cmd) { - printf(">>> %s\r\n", cmd); - obj_run(self, cmd); + printf(">>> %s\r\n", cmd); + obj_run(self, cmd); } int main() { - /* new root object */ - 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, "remove('a')"); - - obj_runWithInfo(root, "set('a','test')"); - obj_runWithInfo(root, "print(a)"); - obj_runWithInfo(root, "type('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, "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); - - printf(">>> "); - /* user input buff */ - char inputBuff[256] = {0}; - /* run the script with check*/ - while (1) - { - /* get user input */ - fgets(inputBuff, sizeof(inputBuff), stdin); - - /* run PikaScript and get res */ - Args *resArgs = obj_runDirect(root, inputBuff); - - /* get system output of PikaScript*/ - char *sysOut = args_getSysOut(resArgs); - ; - - if (!strEqu("", sysOut)) - { - /* print out the system output */ - printf("%s\r\n", sysOut); - } - printf(">>> "); - - /* deinit the res */ - args_deinit(resArgs); - } + /* new root object */ + 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, "remove('a')"); + + obj_runWithInfo(root, "set('a','test')"); + obj_runWithInfo(root, "print(a)"); + obj_runWithInfo(root, "type('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, "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); + + printf(">>> "); + /* user input buff */ + char inputBuff[256] = {0}; + /* run the script with check*/ + while (1) + { + /* get user input */ + fgets(inputBuff, sizeof(inputBuff), stdin); + + /* run PikaScript and get res */ + Args *resArgs = obj_runDirect(root, inputBuff); + + /* get system output of PikaScript*/ + char *sysOut = args_getSysOut(resArgs); + ; + + if (!strEqu("", sysOut)) + { + /* print out the system output */ + printf("%s\r\n", sysOut); + } + printf(">>> "); + + /* deinit the res */ + args_deinit(resArgs); + } } diff --git a/src/boot/demo06-pikamain/main.c b/src/boot/demo06-pikamain/main.c index f5343d838..d460c2cf0 100644 --- a/src/boot/demo06-pikamain/main.c +++ b/src/boot/demo06-pikamain/main.c @@ -4,36 +4,36 @@ void obj_runWithInfo(PikaObj *self, char *cmd) { - printf(">>> %s\r\n", cmd); - obj_run(self, cmd); + printf(">>> %s\r\n", cmd); + obj_run(self, cmd); } int main() { - PikaObj *pikaMain = pikaScriptInit(); - /* user input buff */ - char inputBuff[256] = {0}; - /* run the script with check*/ - printf(">>> "); - while (1) - { - /* get user input */ - fgets(inputBuff, sizeof(inputBuff), stdin); + PikaObj *pikaMain = pikaScriptInit(); + /* user input buff */ + char inputBuff[256] = {0}; + /* run the script with check*/ + printf(">>> "); + while (1) + { + /* get user input */ + fgets(inputBuff, sizeof(inputBuff), stdin); - /* run PikaScript and get res */ - Args *resArgs = obj_runDirect(pikaMain, inputBuff); + /* run PikaScript and get res */ + Args *resArgs = obj_runDirect(pikaMain, inputBuff); - /* get system output of PikaScript*/ - char *sysOut = args_getSysOut(resArgs); + /* get system output of PikaScript*/ + char *sysOut = args_getSysOut(resArgs); - if (!strEqu("", sysOut)) - { - /* print out the system output */ - printf("%s\r\n", sysOut); - } - printf(">>> "); + if (!strEqu("", sysOut)) + { + /* print out the system output */ + printf("%s\r\n", sysOut); + } + printf(">>> "); - /* deinit the res */ - args_deinit(resArgs); - } + /* deinit the res */ + args_deinit(resArgs); + } } diff --git a/src/test/arg-test.cpp b/src/test/arg-test.cpp index 0134e1f02..b66f4e560 100644 --- a/src/test/arg-test.cpp +++ b/src/test/arg-test.cpp @@ -65,4 +65,4 @@ TEST(arg_test, type) EXPECT_EQ(1, strEqu((char *)"test", type)); arg_deinit(arg); EXPECT_EQ(pikaMemNow(), 0); -} \ No newline at end of file +} diff --git a/src/test/dataTest.c b/src/test/dataTest.c index 6d6db62af..1827aaca8 100644 --- a/src/test/dataTest.c +++ b/src/test/dataTest.c @@ -29,4 +29,4 @@ dataTest_t *New_dataTest(Args *args) self->init = init; self->init(self, args); return self; -} \ No newline at end of file +} diff --git a/src/test/dataTest.h b/src/test/dataTest.h index 207c817c9..b715f0825 100644 --- a/src/test/dataTest.h +++ b/src/test/dataTest.h @@ -21,4 +21,4 @@ struct Class_dataTest }; dataTest_t *New_dataTest(Args *args); -#endif \ No newline at end of file +#endif diff --git a/src/test/link-test.cpp b/src/test/link-test.cpp index 83c416db8..7698a1e0c 100644 --- a/src/test/link-test.cpp +++ b/src/test/link-test.cpp @@ -32,4 +32,4 @@ TEST(link_test, test1) TEST(link_test, mem) { EXPECT_EQ(pikaMemNow(), 0); -} \ No newline at end of file +} diff --git a/src/test/main.cpp b/src/test/main.cpp index 772f208dc..dc42b1a7c 100644 --- a/src/test/main.cpp +++ b/src/test/main.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" - + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/src/test/object-test.cpp b/src/test/object-test.cpp index 9506e6459..7ff20cfbc 100644 --- a/src/test/object-test.cpp +++ b/src/test/object-test.cpp @@ -69,9 +69,9 @@ void sendMethod(PikaObj *self, Args *args) PikaObj *New_USART(Args *args) { - /* Derive from the tiny object class. - Tiny object can not import sub object. - Tiny object is the smallest object. */ + /* Derive from the tiny object class. + Tiny object can not import sub object. + Tiny object is the smallest object. */ PikaObj *self = New_TinyObj(args); /* bind the method */ @@ -83,9 +83,9 @@ PikaObj *New_USART(Args *args) PikaObj *New_MYROOT1(Args *args) { - /* Derive from the base object class . - BaseObj is the smallest object that can - import sub object. */ + /* Derive from the base object class . + BaseObj is the smallest object that can + import sub object. */ PikaObj *self = New_BaseObj(args); /* import LED class */ @@ -231,4 +231,4 @@ TEST(object_test, mem) { EXPECT_EQ(pikaMemNow(), 0); EXPECT_EQ(pikaMemNow(), 0); -} \ No newline at end of file +} diff --git a/src/test/strs-test.cpp b/src/test/strs-test.cpp index 59e888441..9b8caa7af 100644 --- a/src/test/strs-test.cpp +++ b/src/test/strs-test.cpp @@ -61,4 +61,4 @@ TEST(strs, format) TEST(strs, mem) { EXPECT_EQ(pikaMemNow(), mem); -} \ No newline at end of file +} diff --git a/src/test/sysObj-test.cpp b/src/test/sysObj-test.cpp index 6e0f34de7..e58378cd1 100644 --- a/src/test/sysObj-test.cpp +++ b/src/test/sysObj-test.cpp @@ -48,4 +48,4 @@ TEST(sysObj, noMethod) args_deinit(res); obj_deinit(obj); EXPECT_EQ(pikaMemNow(), 0); -} \ No newline at end of file +}