format codes

This commit is contained in:
Meco Man 2021-08-29 09:00:44 -04:00
parent 9bac8063d9
commit 99dd007345
15 changed files with 412 additions and 412 deletions

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
/* 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',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','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')");
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("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);
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);
/* 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 (!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);
}
}

View File

@ -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);
}
}

View File

@ -65,4 +65,4 @@ TEST(arg_test, type)
EXPECT_EQ(1, strEqu((char *)"test", type));
arg_deinit(arg);
EXPECT_EQ(pikaMemNow(), 0);
}
}

View File

@ -29,4 +29,4 @@ dataTest_t *New_dataTest(Args *args)
self->init = init;
self->init(self, args);
return self;
}
}

View File

@ -21,4 +21,4 @@ struct Class_dataTest
};
dataTest_t *New_dataTest(Args *args);
#endif
#endif

View File

@ -32,4 +32,4 @@ TEST(link_test, test1)
TEST(link_test, mem)
{
EXPECT_EQ(pikaMemNow(), 0);
}
}

View File

@ -1,6 +1,6 @@
#include "gtest/gtest.h"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
}

View File

@ -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);
}
}

View File

@ -61,4 +61,4 @@ TEST(strs, format)
TEST(strs, mem)
{
EXPECT_EQ(pikaMemNow(), mem);
}
}

View File

@ -48,4 +48,4 @@ TEST(sysObj, noMethod)
args_deinit(res);
obj_deinit(obj);
EXPECT_EQ(pikaMemNow(), 0);
}
}