mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
support classpar for python class
This commit is contained in:
parent
8aaf317689
commit
38e31ae049
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
// "--gtest_filter=builtin.type1"
|
||||
"--gtest_filter=class.classpar1"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
@ -14,3 +14,19 @@ TEST(class, class_par) {
|
||||
obj_deinit(self);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(class, classpar1) {
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
pikaVM_runSingleFile(self, "../../examples/Class/classpar1.py");
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "test\r\n");
|
||||
EXPECT_STREQ(log_buff[1], "1\r\n");
|
||||
EXPECT_STREQ(log_buff[2], "BEGIN\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(self);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -438,7 +438,8 @@ static PikaObj* __obj_getObjDirect(PikaObj* self,
|
||||
return args_getPtr(self->list, name);
|
||||
}
|
||||
/* found class */
|
||||
if (type == ARG_TYPE_METHOD_NATIVE_CONSTRUCTOR) {
|
||||
if (type == ARG_TYPE_METHOD_NATIVE_CONSTRUCTOR ||
|
||||
type == ARG_TYPE_METHOD_CONSTRUCTOR) {
|
||||
*pIsClass = PIKA_TRUE;
|
||||
PikaObj* method_args_obj = New_TinyObj(NULL);
|
||||
Arg* cls_obj_arg = obj_runMethodArg(self, method_args_obj,
|
||||
|
@ -1307,6 +1307,10 @@ exit:
|
||||
VMParameters* pikaVM_runSingleFile(PikaObj* self, char* filename) {
|
||||
Args buffs = {0};
|
||||
Arg* file_arg = arg_loadFile(NULL, filename);
|
||||
assert(NULL != file_arg);
|
||||
if (NULL == file_arg) {
|
||||
return NULL;
|
||||
}
|
||||
char* lines = (char*)arg_getBytes(file_arg);
|
||||
/* replace the "\r\n" to "\n" */
|
||||
lines = strsReplace(&buffs, lines, "\r\n", "\n");
|
||||
|
@ -2,4 +2,4 @@
|
||||
#define PIKA_VERSION_MINOR 8
|
||||
#define PIKA_VERSION_MICRO 8
|
||||
|
||||
#define PIKA_EDIT_TIME "2022/06/30 17:31:01"
|
||||
#define PIKA_EDIT_TIME "2022/07/01 09:12:44"
|
||||
|
Loading…
x
Reference in New Issue
Block a user