Skip to content

Commit 1fc474f

Browse files
author
lyon
committed
add demo06 main.py
1 parent f04e068 commit 1fc474f

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ add_subdirectory(src/boot/demo02-add)
1313
add_subdirectory(src/boot/demo03-usart)
1414
add_subdirectory(src/boot/demo04-usarts)
1515
add_subdirectory(src/boot/demo05-sysobject)
16+
add_subdirectory(src/boot/demo06-pikamain)
1617
add_subdirectory(src/boot/banchmark)
1718

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(BINARY ${CMAKE_PROJECT_NAME}_demo06-pikamain)
2+
file(GLOB_RECURSE THIS_SOURCES LIST_DIRECTORIES false *.h *.cpp *.c)
3+
set(SOURCES ${THIS_SOURCES})
4+
add_executable(${BINARY} ${THIS_SOURCES})
5+
# 链接src生成的lib库和gtest库
6+
target_link_libraries(${BINARY} PUBLIC
7+
${CMAKE_PROJECT_NAME}-core
8+
)

src/boot/demo06-pikamain/main.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* this demo shows the usage of method */
2+
#include "pikaScript.h"
3+
#include <stdio.h>
4+
5+
void obj_runWithInfo(PikaObj *self, char *cmd)
6+
{
7+
printf(">>> %s\r\n", cmd);
8+
obj_run(self, cmd);
9+
}
10+
11+
int main()
12+
{
13+
PikaObj *pikaMain = pikaScriptInit();
14+
/* user input buff */
15+
char inputBuff[256] = {0};
16+
/* run the script with check*/
17+
printf(">>> ");
18+
while (1)
19+
{
20+
/* get user input */
21+
fgets(inputBuff, sizeof(inputBuff), stdin);
22+
23+
/* run PikaScript and get res */
24+
Args *resArgs = obj_runDirect(pikaMain, inputBuff);
25+
26+
/* get system output of PikaScript*/
27+
char *sysOut = args_getSysOut(resArgs);
28+
29+
if (!strEqu("", sysOut))
30+
{
31+
/* print out the system output */
32+
printf("%s\r\n", sysOut);
33+
}
34+
printf(">>> ");
35+
36+
/* deinit the res */
37+
args_deinit(resArgs);
38+
}
39+
}

src/package/pikascript/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import PikaStdLib
22

33
print('hello world')
4-
mem = PikaStdLib.MemChecker()
4+
mem = PikaStdLib.MemChecker()
5+
print('mem.max :')
6+
mem.max()
7+
print('mem.now :')
8+
mem.now()
38.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)