fix '@p' hash conflict with 'AO'

This commit is contained in:
lyon1998 2024-05-06 00:34:30 +08:00
parent 41432d5501
commit 6130b754ea
6 changed files with 23 additions and 9 deletions

View File

@ -24,7 +24,7 @@
// "--gtest_filter=vm.test_cmodule_import_as"
// "--gtest_filter=vm.subsrc_import"
// "--gtest_filter=event.event_thread"
"--gtest_filter=*mqtt*"
// "--gtest_filter=module.while_loop"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View File

@ -30,10 +30,11 @@ TEST(module, while_loop) {
/* run */
obj_run(pikaMain,
"import test_module1\n"
"test_module1.while_loop()\n");
"test_module1.while_loop()\n"
"test_module1");
/* collect */
/* assert */
EXPECT_STREQ("4\r\n", log_buff[0]);
EXPECT_STREQ("4\r\n", log_buff[1]);
/* deinit */
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);

View File

@ -1,2 +1,7 @@
def mytest():
print('test_module_1_hello')
print('test_module_1_hello')
class AO:
def __init__(self):
print('test_module_1_AO')

View File

@ -559,14 +559,23 @@ PikaObj* _pika_dict_new(int num_args, ...) {
}
NativeProperty* obj_getProp(PikaObj* self) {
NativeProperty* prop = obj_getPtr(self, "@p");
Arg* aProp = obj_getArg(self, "@p");
PikaObj* class_obj = NULL;
if (NULL == prop) {
if (NULL == aProp) {
if (NULL != self->constructor) {
class_obj = obj_getClassObj(self);
prop = obj_getPtr(class_obj, "@p");
aProp = obj_getArg(class_obj, "@p");
}
}
NativeProperty* prop = NULL;
if (aProp == NULL) {
goto __exit;
}
if (arg_getType(aProp) != ARG_TYPE_POINTER) {
goto __exit;
}
prop = (NativeProperty*)arg_getPtr(aProp);
__exit:
if (NULL != class_obj) {
obj_deinit_no_del(class_obj);
}

View File

@ -2,4 +2,4 @@
#define PIKA_VERSION_MINOR 13
#define PIKA_VERSION_MICRO 3
#define PIKA_EDIT_TIME "2024/05/05 02:39:07"
#define PIKA_EDIT_TIME "2024/05/06 00:34:23"

View File

@ -58,7 +58,6 @@ void* args_getPtr(Args* self, char* name) {
if (NULL == arg) {
return NULL;
}
pointer = arg_getPtr(arg);
return pointer;
}