mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
use NEUM to save type instead of char *
This commit is contained in:
parent
e71429e26d
commit
3ab412f219
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -14,7 +14,7 @@
|
|||||||
// "--gtest_filter=queue*"
|
// "--gtest_filter=queue*"
|
||||||
// "--gtest_filter=parser*"
|
// "--gtest_filter=parser*"
|
||||||
// "--gtest_filter=args*",
|
// "--gtest_filter=args*",
|
||||||
// "--gtest_filter=content*",
|
"--gtest_filter=content*",
|
||||||
// "--gtest_filter=object_test.printa",
|
// "--gtest_filter=object_test.printa",
|
||||||
// "--gtest_filter=object_test*",
|
// "--gtest_filter=object_test*",
|
||||||
// "--gtest_filter=stack*",
|
// "--gtest_filter=stack*",
|
||||||
|
3
port/linux/.vscode/settings.json
vendored
3
port/linux/.vscode/settings.json
vendored
@ -10,7 +10,8 @@
|
|||||||
"istream": "c",
|
"istream": "c",
|
||||||
"cstring": "cpp",
|
"cstring": "cpp",
|
||||||
"variant": "cpp",
|
"variant": "cpp",
|
||||||
"pikaplatform.h": "c"
|
"pikaplatform.h": "c",
|
||||||
|
"dataarg.h": "c"
|
||||||
},
|
},
|
||||||
"python.formatting.provider": "yapf"
|
"python.formatting.provider": "yapf"
|
||||||
}
|
}
|
@ -6,16 +6,16 @@ project(pikascript VERSION 0.1.0)
|
|||||||
include_directories(package/pikascript/pikascript-core)
|
include_directories(package/pikascript/pikascript-core)
|
||||||
include_directories(package/pikascript/pikascript-api)
|
include_directories(package/pikascript/pikascript-api)
|
||||||
include_directories(package/pikascript/pikascript-lib/PikaRunExternControl)
|
include_directories(package/pikascript/pikascript-lib/PikaRunExternControl)
|
||||||
include_directories(boot/demo01-led)
|
# include_directories(boot/demo01-led)
|
||||||
|
|
||||||
add_subdirectory(package/googletest)
|
add_subdirectory(package/googletest)
|
||||||
add_subdirectory(package/pikascript)
|
add_subdirectory(package/pikascript)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
add_subdirectory(boot/demo01-led)
|
# add_subdirectory(boot/demo01-led)
|
||||||
add_subdirectory(boot/demo02-add)
|
# add_subdirectory(boot/demo02-add)
|
||||||
add_subdirectory(boot/demo03-usart)
|
# add_subdirectory(boot/demo03-usart)
|
||||||
add_subdirectory(boot/demo04-usarts)
|
# add_subdirectory(boot/demo04-usarts)
|
||||||
add_subdirectory(boot/demo05-sysobject)
|
# add_subdirectory(boot/demo05-sysobject)
|
||||||
add_subdirectory(boot/demo06-pikamain)
|
# add_subdirectory(boot/demo06-pikamain)
|
||||||
add_subdirectory(boot/banchmark)
|
add_subdirectory(boot/banchmark)
|
||||||
|
|
||||||
|
@ -23,5 +23,29 @@ void PikaStdLib_SysObj_type(PikaObj* self, char* argPath) {
|
|||||||
obj_setErrorCode(self, 1);
|
obj_setErrorCode(self, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
obj_setSysOut(self, arg_getType(arg));
|
ArgType type = arg_getType(arg);
|
||||||
|
if (TYPE_INT == type) {
|
||||||
|
obj_setSysOut(self, "int");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TYPE_FLOAT == type) {
|
||||||
|
obj_setSysOut(self, "float");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TYPE_STRING == type) {
|
||||||
|
obj_setSysOut(self, "string");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TYPE_POINTER == type) {
|
||||||
|
obj_setSysOut(self, "pointer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TYPE_MATE_OBJECT == type) {
|
||||||
|
obj_setSysOut(self, "mate_object");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (TYPE_METHOD == type) {
|
||||||
|
obj_setSysOut(self, "method");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ TEST(arg_test, str_) {
|
|||||||
TEST(arg_test, ptr) {
|
TEST(arg_test, ptr) {
|
||||||
Arg* arg = New_arg(NULL);
|
Arg* arg = New_arg(NULL);
|
||||||
int a = 1;
|
int a = 1;
|
||||||
arg = arg_setPtr(arg, (char*)"test", (char*)"p", &a);
|
arg = arg_setPtr(arg, (char*)"test", TYPE_POINTER, &a);
|
||||||
int* pa = (int*)arg_getPtr(arg);
|
int* pa = (int*)arg_getPtr(arg);
|
||||||
EXPECT_EQ(*pa, 1);
|
EXPECT_EQ(*pa, 1);
|
||||||
arg_deinit(arg);
|
arg_deinit(arg);
|
||||||
@ -52,9 +52,9 @@ TEST(arg_test, name) {
|
|||||||
|
|
||||||
TEST(arg_test, type) {
|
TEST(arg_test, type) {
|
||||||
Arg* arg = New_arg(NULL);
|
Arg* arg = New_arg(NULL);
|
||||||
arg = arg_setType(arg, (char*)"test");
|
arg = arg_setType(arg, TYPE_NONE);
|
||||||
char* type = arg_getType(arg);
|
ArgType type = arg_getType(arg);
|
||||||
EXPECT_EQ(1, strEqu((char*)"test", type));
|
EXPECT_EQ(TYPE_NONE, type);
|
||||||
arg_deinit(arg);
|
arg_deinit(arg);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ TEST(args, test2) {
|
|||||||
EXPECT_EQ(int64Out, 22221);
|
EXPECT_EQ(int64Out, 22221);
|
||||||
EXPECT_EQ((uint64_t)pointer, 2222322);
|
EXPECT_EQ((uint64_t)pointer, 2222322);
|
||||||
EXPECT_EQ(1, strEqu((char*)"teeeds", strOut));
|
EXPECT_EQ(1, strEqu((char*)"teeeds", strOut));
|
||||||
EXPECT_EQ(0, strcmp("i", args_getType(args, (char*)"int64Test")));
|
EXPECT_EQ(args_getType(args, (char*)"int64Test"), TYPE_INT);
|
||||||
EXPECT_EQ(0, strcmp("p", args_getType(args, (char*)"pointerTest")));
|
EXPECT_EQ(args_getType(args, (char*)"pointerTest"), TYPE_POINTER);
|
||||||
EXPECT_EQ(0, strcmp("s", args_getType(args, (char*)"strTest")));
|
EXPECT_EQ(args_getType(args, (char*)"strTest"), TYPE_STRING);
|
||||||
args_deinit(args);
|
args_deinit(args);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
@ -86,14 +86,14 @@ TEST(args, print_int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TEST(args, test5) {
|
// TEST(args, test5) {
|
||||||
// int32_t testInt = 124;
|
// int32_t testInt = 124;
|
||||||
// Args* args = New_args(NULL);
|
// Args* args = New_args(NULL);
|
||||||
// args_bind(args, (char*)"i", (char*)"testInt", &testInt);
|
// args_bind(args, (char*)"i", (char*)"testInt", &testInt);
|
||||||
// char* type = args_getType(args, (char*)"testInt");
|
// char* type = args_getType(args, (char*)"testInt");
|
||||||
// args_print(args, (char*)"testInt");
|
// args_print(args, (char*)"testInt");
|
||||||
// EXPECT_STREQ((char*)"124", args_print(args, (char*)"testInt"));
|
// EXPECT_STREQ((char*)"124", args_print(args, (char*)"testInt"));
|
||||||
// args_deinit(args);
|
// args_deinit(args);
|
||||||
// EXPECT_EQ(pikaMemNow(), 0);
|
// EXPECT_EQ(pikaMemNow(), 0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TEST(args, test6) {
|
TEST(args, test6) {
|
||||||
@ -105,12 +105,12 @@ TEST(args, test6) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TEST(args, test7) {
|
// TEST(args, test7) {
|
||||||
// Args* args = New_args(NULL);
|
// Args* args = New_args(NULL);
|
||||||
// float floatBindTest = 2.314;
|
// float floatBindTest = 2.314;
|
||||||
// args_bind(args, (char*)"f", (char*)"floatBind", &floatBindTest);
|
// args_bind(args, (char*)"f", (char*)"floatBind", &floatBindTest);
|
||||||
// EXPECT_STREQ((char*)"2.314000", args_print(args, (char*)"floatBind"));
|
// EXPECT_STREQ((char*)"2.314000", args_print(args, (char*)"floatBind"));
|
||||||
// args_deinit(args);
|
// args_deinit(args);
|
||||||
// EXPECT_EQ(pikaMemNow(), 0);
|
// EXPECT_EQ(pikaMemNow(), 0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TEST(args, test8) {
|
TEST(args, test8) {
|
||||||
@ -123,13 +123,13 @@ TEST(args, test8) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TEST(args, test9) {
|
// TEST(args, test9) {
|
||||||
// Args* args = New_args(NULL);
|
// Args* args = New_args(NULL);
|
||||||
// char strBindTest[] = "test string bind";
|
// char strBindTest[] = "test string bind";
|
||||||
// args_bindStr(args, (char*)"testStringBind", (char**)&strBindTest);
|
// args_bindStr(args, (char*)"testStringBind", (char**)&strBindTest);
|
||||||
// EXPECT_STREQ((char*)"test string bind",
|
// EXPECT_STREQ((char*)"test string bind",
|
||||||
// args_print(args, (char*)"testStringBind"));
|
// args_print(args, (char*)"testStringBind"));
|
||||||
// args_deinit(args);
|
// args_deinit(args);
|
||||||
// EXPECT_EQ(pikaMemNow(), 0);
|
// EXPECT_EQ(pikaMemNow(), 0);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TEST(args, test12) {
|
TEST(args, test12) {
|
||||||
|
@ -10,8 +10,7 @@ TEST(content, init) {
|
|||||||
contentIn[1] = 2;
|
contentIn[1] = 2;
|
||||||
contentIn[2] = 3;
|
contentIn[2] = 3;
|
||||||
contentIn[3] = 4;
|
contentIn[3] = 4;
|
||||||
uint8_t* self =
|
uint8_t* self = content_init((char*)"name", TYPE_NONE, contentIn, 4, NULL);
|
||||||
content_init((char*)"name", (char*)"type", contentIn, 4, NULL);
|
|
||||||
|
|
||||||
uint16_t typeOffset = content_typeOffset(self);
|
uint16_t typeOffset = content_typeOffset(self);
|
||||||
uint16_t sizeOffset = content_sizeOffset(self);
|
uint16_t sizeOffset = content_sizeOffset(self);
|
||||||
@ -19,7 +18,7 @@ TEST(content, init) {
|
|||||||
uint16_t totleSize = content_totleSize(self);
|
uint16_t totleSize = content_totleSize(self);
|
||||||
|
|
||||||
Hash nameHash = content_getNameHash(self);
|
Hash nameHash = content_getNameHash(self);
|
||||||
char* type = content_getType(self);
|
ArgType type = content_getType(self);
|
||||||
uint16_t size = content_getSize(self);
|
uint16_t size = content_getSize(self);
|
||||||
uint8_t* content = content_getContent(self);
|
uint8_t* content = content_getContent(self);
|
||||||
|
|
||||||
@ -31,10 +30,10 @@ TEST(content, init) {
|
|||||||
ASSERT_EQ(content[1], 2);
|
ASSERT_EQ(content[1], 2);
|
||||||
ASSERT_EQ(content[2], 3);
|
ASSERT_EQ(content[2], 3);
|
||||||
ASSERT_EQ(content[3], 4);
|
ASSERT_EQ(content[3], 4);
|
||||||
ASSERT_EQ(totleSize, 23);
|
ASSERT_EQ(totleSize, 22);
|
||||||
|
|
||||||
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
||||||
ASSERT_STREQ((char*)"type", type);
|
ASSERT_EQ(TYPE_NONE, type);
|
||||||
|
|
||||||
content_deinit(self);
|
content_deinit(self);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
@ -46,9 +45,9 @@ TEST(content, set) {
|
|||||||
contentIn[1] = 2;
|
contentIn[1] = 2;
|
||||||
contentIn[2] = 3;
|
contentIn[2] = 3;
|
||||||
contentIn[3] = 4;
|
contentIn[3] = 4;
|
||||||
uint8_t* self = content_init((char*)"", (char*)"", NULL, 0, NULL);
|
uint8_t* self = content_init((char*)"", TYPE_NONE, NULL, 0, NULL);
|
||||||
self = content_setName(self, (char*)"name");
|
self = content_setName(self, (char*)"name");
|
||||||
self = content_setType(self, (char*)"type");
|
self = content_setType(self, TYPE_NONE);
|
||||||
self = content_setContent(self, contentIn, 4);
|
self = content_setContent(self, contentIn, 4);
|
||||||
|
|
||||||
uint16_t typeOffset = content_typeOffset(self);
|
uint16_t typeOffset = content_typeOffset(self);
|
||||||
@ -57,7 +56,7 @@ TEST(content, set) {
|
|||||||
uint16_t totleSize = content_totleSize(self);
|
uint16_t totleSize = content_totleSize(self);
|
||||||
|
|
||||||
Hash nameHash = content_getNameHash(self);
|
Hash nameHash = content_getNameHash(self);
|
||||||
char* type = content_getType(self);
|
ArgType type = content_getType(self);
|
||||||
uint16_t size = content_getSize(self);
|
uint16_t size = content_getSize(self);
|
||||||
uint8_t* content = content_getContent(self);
|
uint8_t* content = content_getContent(self);
|
||||||
|
|
||||||
@ -69,18 +68,18 @@ TEST(content, set) {
|
|||||||
ASSERT_EQ(content[1], 2);
|
ASSERT_EQ(content[1], 2);
|
||||||
ASSERT_EQ(content[2], 3);
|
ASSERT_EQ(content[2], 3);
|
||||||
ASSERT_EQ(content[3], 4);
|
ASSERT_EQ(content[3], 4);
|
||||||
ASSERT_EQ(totleSize, 23);
|
ASSERT_EQ(totleSize, 22);
|
||||||
|
|
||||||
ASSERT_EQ(hash_time33((char *)"name"), nameHash);
|
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
||||||
ASSERT_STREQ("type", type);
|
ASSERT_EQ(TYPE_NONE, type);
|
||||||
|
|
||||||
content_deinit(self);
|
content_deinit(self);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(content, next) {
|
TEST(content, next) {
|
||||||
uint8_t* c1 = content_init((char*)"c1", (char*)"type", NULL, 0, NULL);
|
uint8_t* c1 = content_init((char*)"c1", TYPE_NONE, NULL, 0, NULL);
|
||||||
uint8_t* c2 = content_init((char*)"c2", (char*)"type", NULL, 0, c1);
|
uint8_t* c2 = content_init((char*)"c2", TYPE_NONE, NULL, 0, c1);
|
||||||
uint8_t* c3 = content_getNext(c2);
|
uint8_t* c3 = content_getNext(c2);
|
||||||
|
|
||||||
ASSERT_EQ(c3, c1);
|
ASSERT_EQ(c3, c1);
|
||||||
@ -90,9 +89,9 @@ TEST(content, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(content, setNext) {
|
TEST(content, setNext) {
|
||||||
uint8_t* c1 = content_init((char*)"c1", (char*)"type", NULL, 0, NULL);
|
uint8_t* c1 = content_init((char*)"c1", TYPE_NONE, NULL, 0, NULL);
|
||||||
content_setNext(c1,
|
content_setNext(c1,
|
||||||
content_init((char*)"c2", (char*)"type", NULL, 0, NULL));
|
content_init((char*)"c2", TYPE_NONE, NULL, 0, NULL));
|
||||||
uint8_t* c2 = content_getNext(c1);
|
uint8_t* c2 = content_getNext(c1);
|
||||||
Hash c2NameHash = content_getNameHash(c2);
|
Hash c2NameHash = content_getNameHash(c2);
|
||||||
EXPECT_EQ(c2NameHash, hash_time33((char*)"c2"));
|
EXPECT_EQ(c2NameHash, hash_time33((char*)"c2"));
|
||||||
|
@ -12,7 +12,7 @@ TEST(queue, NEW) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queue, INT) {
|
TEST(queue, TYPE_INT) {
|
||||||
Queue* q = New_queue();
|
Queue* q = New_queue();
|
||||||
queue_pushInt(q, 1);
|
queue_pushInt(q, 1);
|
||||||
queue_pushInt(q, 2);
|
queue_pushInt(q, 2);
|
||||||
@ -39,7 +39,7 @@ TEST(queue, arg) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queue, FLOAT) {
|
TEST(queue, TYPE_FLOAT) {
|
||||||
Queue* q = New_queue();
|
Queue* q = New_queue();
|
||||||
queue_pushFloat(q, 1.1f);
|
queue_pushFloat(q, 1.1f);
|
||||||
queue_pushFloat(q, 2.2f);
|
queue_pushFloat(q, 2.2f);
|
||||||
@ -70,7 +70,7 @@ TEST(queueObj, init) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queueObj, INT) {
|
TEST(queueObj, TYPE_INT) {
|
||||||
QueueObj* q = New_TinyObj(NULL);
|
QueueObj* q = New_TinyObj(NULL);
|
||||||
queueObj_init(q);
|
queueObj_init(q);
|
||||||
queueObj_pushInt(q, 1);
|
queueObj_pushInt(q, 1);
|
||||||
@ -83,7 +83,7 @@ TEST(queueObj, INT) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queueObj, FLOAT) {
|
TEST(queueObj, TYPE_FLOAT) {
|
||||||
QueueObj* q = New_TinyObj(NULL);
|
QueueObj* q = New_TinyObj(NULL);
|
||||||
queueObj_init(q);
|
queueObj_init(q);
|
||||||
queueObj_pushFloat(q, 1.1f);
|
queueObj_pushFloat(q, 1.1f);
|
||||||
@ -134,8 +134,8 @@ TEST(queueObj, currentObj) {
|
|||||||
queueObj_pushObj(q, (char*)"type1");
|
queueObj_pushObj(q, (char*)"type1");
|
||||||
PikaObj* currentObj = queueObj_getCurrentObj(q);
|
PikaObj* currentObj = queueObj_getCurrentObj(q);
|
||||||
EXPECT_TRUE(currentObj != NULL);
|
EXPECT_TRUE(currentObj != NULL);
|
||||||
char* type = args_getType(q->list, (char*)"0");
|
ArgType type = args_getType(q->list, (char*)"0");
|
||||||
EXPECT_STREQ((char*)"c", type);
|
EXPECT_EQ(TYPE_OBJECT, type);
|
||||||
obj_setInt(queueObj_getCurrentObj(q), (char*)"test", 1);
|
obj_setInt(queueObj_getCurrentObj(q), (char*)"test", 1);
|
||||||
|
|
||||||
queueObj_pushObj(q, (char*)"type2");
|
queueObj_pushObj(q, (char*)"type2");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user