mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
rezise arg to 16 byte in 32bit system
This commit is contained in:
parent
07ff463386
commit
ca29e11268
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*",
|
||||||
|
@ -25,15 +25,15 @@ TEST(content, init) {
|
|||||||
uint16_t size = content_getSize(self);
|
uint16_t size = content_getSize(self);
|
||||||
uint8_t* content = content_getContent(self);
|
uint8_t* content = content_getContent(self);
|
||||||
|
|
||||||
ASSERT_EQ(contentOffset, 15);
|
ASSERT_EQ(contentOffset, 14);
|
||||||
ASSERT_EQ(typeOffset, 19);
|
ASSERT_EQ(typeOffset, 18);
|
||||||
ASSERT_EQ(sizeOffset, 8);
|
ASSERT_EQ(sizeOffset, 8);
|
||||||
ASSERT_EQ(size, 4);
|
ASSERT_EQ(size, 4);
|
||||||
ASSERT_EQ(content[0], 1);
|
ASSERT_EQ(content[0], 1);
|
||||||
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, 24);
|
ASSERT_EQ(totleSize, 23);
|
||||||
|
|
||||||
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
||||||
ASSERT_STREQ((char*)"type", type);
|
ASSERT_STREQ((char*)"type", type);
|
||||||
@ -63,15 +63,15 @@ TEST(content, set) {
|
|||||||
uint16_t size = content_getSize(self);
|
uint16_t size = content_getSize(self);
|
||||||
uint8_t* content = content_getContent(self);
|
uint8_t* content = content_getContent(self);
|
||||||
|
|
||||||
ASSERT_EQ(contentOffset, 15);
|
ASSERT_EQ(contentOffset, 14);
|
||||||
ASSERT_EQ(typeOffset, 19);
|
ASSERT_EQ(typeOffset, 18);
|
||||||
ASSERT_EQ(sizeOffset, 8);
|
ASSERT_EQ(sizeOffset, 8);
|
||||||
ASSERT_EQ(size, 4);
|
ASSERT_EQ(size, 4);
|
||||||
ASSERT_EQ(content[0], 1);
|
ASSERT_EQ(content[0], 1);
|
||||||
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, 24);
|
ASSERT_EQ(totleSize, 23);
|
||||||
|
|
||||||
ASSERT_EQ(hash_time33((char *)"name"), nameHash);
|
ASSERT_EQ(hash_time33((char *)"name"), nameHash);
|
||||||
ASSERT_STREQ("type", type);
|
ASSERT_STREQ("type", type);
|
||||||
|
@ -261,8 +261,8 @@ void* getNewClassObjFunByName(PikaObj* obj, char* name) {
|
|||||||
return newClassObjFun;
|
return newClassObjFun;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t removeEachMethodInfo(Arg* argNow, Args* argList) {
|
int32_t __foreach_removeMethodInfo(Arg* argNow, Args* argList) {
|
||||||
if (strEqu(arg_getType(argNow), "_mtd-")) {
|
if (strEqu(arg_getType(argNow), "M")) {
|
||||||
args_removeArg(argList, argNow);
|
args_removeArg(argList, argNow);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ int32_t removeEachMethodInfo(Arg* argNow, Args* argList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PikaObj* removeMethodInfo(PikaObj* thisClass) {
|
PikaObj* removeMethodInfo(PikaObj* thisClass) {
|
||||||
args_foreach(thisClass->list, removeEachMethodInfo, thisClass->list);
|
args_foreach(thisClass->list, __foreach_removeMethodInfo, thisClass->list);
|
||||||
return thisClass;
|
return thisClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ void obj_saveMethodInfo(PikaObj* self,
|
|||||||
/* +1 to add \0 */
|
/* +1 to add \0 */
|
||||||
memcpy(info + size_ptr, pars, size_pars + 1);
|
memcpy(info + size_ptr, pars, size_pars + 1);
|
||||||
arg = arg_setName(arg, method_name);
|
arg = arg_setName(arg, method_name);
|
||||||
arg = arg_setType(arg, "_mtd-");
|
arg = arg_setType(arg, "M");
|
||||||
arg = arg_setContent(arg, info, size_info);
|
arg = arg_setContent(arg, info, size_info);
|
||||||
|
|
||||||
args_setArg(self->list, arg);
|
args_setArg(self->list, arg);
|
||||||
|
@ -65,17 +65,15 @@ uint8_t* content_init_hash(Hash nameHash,
|
|||||||
uint16_t nameSize = sizeof(Hash); // use hash
|
uint16_t nameSize = sizeof(Hash); // use hash
|
||||||
uint16_t typeSize = strGetSize(type);
|
uint16_t typeSize = strGetSize(type);
|
||||||
uint8_t* self = (uint8_t*)pikaMalloc(nextLength + sizeLength + nameSize +
|
uint8_t* self = (uint8_t*)pikaMalloc(nextLength + sizeLength + nameSize +
|
||||||
1 + size + typeSize + 1);
|
size + typeSize + 1);
|
||||||
|
|
||||||
uint8_t* nextDir = self;
|
uint8_t* nextDir = self;
|
||||||
uint8_t* sizeDir = nextDir + nextLength;
|
uint8_t* sizeDir = nextDir + nextLength;
|
||||||
uint8_t* nameDir = sizeDir + sizeLength;
|
uint8_t* nameDir = sizeDir + sizeLength;
|
||||||
uint8_t* contentDir = nameDir + nameSize + 1;
|
uint8_t* contentDir = nameDir + nameSize;
|
||||||
uint8_t* typeDir = contentDir + size;
|
uint8_t* typeDir = contentDir + size;
|
||||||
|
|
||||||
// memcpy(nameDir, name, nameSize + 1);
|
|
||||||
memcpy(nameDir, &nameHash, nameSize); // use hash
|
memcpy(nameDir, &nameHash, nameSize); // use hash
|
||||||
nameDir[nameSize] = '\0'; // add \0 by hand
|
|
||||||
memcpy(typeDir, type, typeSize + 1);
|
memcpy(typeDir, type, typeSize + 1);
|
||||||
sizeDir[0] = size;
|
sizeDir[0] = size;
|
||||||
sizeDir[1] = size >> 8;
|
sizeDir[1] = size >> 8;
|
||||||
@ -110,8 +108,7 @@ uint16_t content_totleSize(uint8_t* self) {
|
|||||||
const uint8_t sizeLenth = 2;
|
const uint8_t sizeLenth = 2;
|
||||||
const uint8_t nextLength = sizeof(uint8_t*);
|
const uint8_t nextLength = sizeof(uint8_t*);
|
||||||
uint16_t size = content_getSize(self);
|
uint16_t size = content_getSize(self);
|
||||||
return size + sizeof(Hash) + 1 + strGetSize(type) + 1 + sizeLenth +
|
return size + sizeof(Hash) + strGetSize(type) + 1 + sizeLenth + nextLength;
|
||||||
nextLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void arg_freeContent(Arg* self) {
|
void arg_freeContent(Arg* self) {
|
||||||
@ -223,7 +220,7 @@ uint16_t content_contentOffset(uint8_t* self) {
|
|||||||
const uint8_t nextLength = sizeof(uint8_t*);
|
const uint8_t nextLength = sizeof(uint8_t*);
|
||||||
const uint8_t sizeLength = 2;
|
const uint8_t sizeLength = 2;
|
||||||
Hash nameHash = content_getNameHash(self);
|
Hash nameHash = content_getNameHash(self);
|
||||||
return nextLength + sizeLength + sizeof(Hash) + 1;
|
return nextLength + sizeLength + sizeof(Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t content_nextOffset(uint8_t* self) {
|
uint16_t content_nextOffset(uint8_t* self) {
|
||||||
@ -341,9 +338,8 @@ uint16_t content_typeOffset(uint8_t* self) {
|
|||||||
const uint8_t nextLength = sizeof(uint8_t*);
|
const uint8_t nextLength = sizeof(uint8_t*);
|
||||||
const uint8_t sizeLength = 2;
|
const uint8_t sizeLength = 2;
|
||||||
uint16_t size = content_getSize(self);
|
uint16_t size = content_getSize(self);
|
||||||
Hash nameHash = content_getNameHash(self);
|
|
||||||
uint16_t nameSize = sizeof(Hash);
|
uint16_t nameSize = sizeof(Hash);
|
||||||
return nextLength + sizeLength + nameSize + 1 + size;
|
return nextLength + sizeLength + nameSize + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hash arg_getNameHash(Arg* self) {
|
Hash arg_getNameHash(Arg* self) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user