mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
introduce base class __arg
This commit is contained in:
parent
a3b6f032b0
commit
75ca440724
@ -71,6 +71,10 @@ extern "C" {
|
||||
#define MIN(a, b) ((b)>(a)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(__type, __member) (uintptr_t)(&(((__type *)0)->__member))
|
||||
#endif
|
||||
|
||||
#if !defined(__IS_COMPILER_ARM_COMPILER_6__)
|
||||
/**
|
||||
* Execute a breakpoint instruction
|
||||
|
@ -31,6 +31,9 @@
|
||||
#include "dataString.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void arg_deinit(Arg* self) {
|
||||
arg_freeContent(self);
|
||||
}
|
||||
@ -39,10 +42,12 @@ uint16_t arg_getTotleSize(Arg* self) {
|
||||
return content_totleSize(self);
|
||||
}
|
||||
|
||||
#if 0
|
||||
uint16_t content_sizeOffset(uint8_t* self) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
return nextLength;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t content_getSize(uint8_t* self) {
|
||||
uint32_t* p_size =
|
||||
@ -125,11 +130,13 @@ void arg_freeContent(Arg* self) {
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
uint8_t content_nameOffset(uint8_t* self) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
const uint8_t sizeLength = sizeof(uint32_t);
|
||||
return nextLength + sizeLength;
|
||||
}
|
||||
#endif
|
||||
|
||||
Hash content_getNameHash(uint8_t* self) {
|
||||
return *(Hash*)((uintptr_t)self + (uintptr_t)content_nameOffset(self));
|
||||
@ -224,16 +231,18 @@ ArgType content_getType(uint8_t* self) {
|
||||
return type;
|
||||
}
|
||||
|
||||
#if 0
|
||||
uint16_t content_contentOffset(uint8_t* self) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
const uint8_t sizeLength = sizeof(uint32_t);
|
||||
return nextLength + sizeLength + sizeof(Hash);
|
||||
}
|
||||
|
||||
|
||||
uint16_t content_nextOffset(uint8_t* self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
uint8_t* content_getNext(uint8_t* self) {
|
||||
uintptr_t* nextDir =
|
||||
(uintptr_t*)((uintptr_t)self + (uintptr_t)content_nextOffset(self));
|
||||
|
@ -43,12 +43,26 @@ typedef enum {
|
||||
TYPE_NULL,
|
||||
} ArgType;
|
||||
|
||||
typedef struct __arg __arg;
|
||||
|
||||
struct __arg {
|
||||
__arg *next;
|
||||
uint32_t size;
|
||||
Hash name_hash;
|
||||
uint8_t content[];
|
||||
};
|
||||
|
||||
|
||||
uint16_t content_typeOffset(uint8_t* content);
|
||||
uint16_t content_contentOffset(uint8_t* content);
|
||||
uint16_t content_sizeOffset(uint8_t* self);
|
||||
uint16_t content_contentOffset(uint8_t* self);
|
||||
uint16_t content_nextOffset(uint8_t* self);
|
||||
uint8_t content_nameOffset(uint8_t* self);
|
||||
//uint16_t content_contentOffset(uint8_t* content);
|
||||
//uint16_t content_sizeOffset(uint8_t* self);
|
||||
//uint16_t content_nextOffset(uint8_t* self);
|
||||
//uint8_t content_nameOffset(uint8_t* self);
|
||||
|
||||
#define content_contentOffset(...) offsetof(__arg, content)
|
||||
#define content_sizeOffset(...) offsetof(__arg, size)
|
||||
#define content_nextOffset(...) offsetof(__arg, next)
|
||||
#define content_nameOffset(...) offsetof(__arg, name_hash)
|
||||
|
||||
uint32_t content_getNameHash(uint8_t* content);
|
||||
ArgType content_getType(uint8_t* self);
|
||||
|
Loading…
x
Reference in New Issue
Block a user