mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix New_Pika<Struct> API
This commit is contained in:
parent
5bc6061386
commit
09a667e1a3
@ -68,7 +68,7 @@ void PikaStdData_List_reverse(PikaObj* self) {
|
||||
}
|
||||
|
||||
PikaObj* PikaStdData_List___add__(PikaObj* self, PikaObj* others) {
|
||||
PikaObj* res = New_pikaList();
|
||||
PikaObj* res = New_PikaList();
|
||||
for (size_t i = 0; i < pikaList_getSize(self); i++) {
|
||||
Arg* arg = pikaList_get(self, i);
|
||||
pikaList_append(res, arg_copy(arg));
|
||||
|
@ -68,7 +68,7 @@ void PikaStdData_List_reverse(PikaObj* self) {
|
||||
}
|
||||
|
||||
PikaObj* PikaStdData_List___add__(PikaObj* self, PikaObj* others) {
|
||||
PikaObj* res = New_pikaList();
|
||||
PikaObj* res = New_PikaList();
|
||||
for (size_t i = 0; i < pikaList_getSize(self); i++) {
|
||||
Arg* arg = pikaList_get(self, i);
|
||||
pikaList_append(res, arg_copy(arg));
|
||||
|
@ -91,7 +91,7 @@ Arg* json_encode_jsmn(jsmntok_t* t,
|
||||
break;
|
||||
}
|
||||
case JSMN_OBJECT: {
|
||||
PikaObj* ret = New_pikaDict();
|
||||
PikaObj* ret = New_PikaDict();
|
||||
int num_keys = t[*index].size;
|
||||
for (int i = 0; i < num_keys; i++) {
|
||||
(*index)++;
|
||||
|
@ -51,10 +51,10 @@ Arg* _lua_val_to_arg(lua_State* L) {
|
||||
// 'key' is at index -2 and 'value' at index -1
|
||||
if (!get_list && !get_dict) {
|
||||
if (lua_isinteger(L, -2)) {
|
||||
ret = New_pikaList();
|
||||
ret = New_PikaList();
|
||||
get_list = PIKA_TRUE;
|
||||
} else {
|
||||
ret = New_pikaDict();
|
||||
ret = New_PikaDict();
|
||||
get_dict = PIKA_TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -769,10 +769,10 @@ PikaObj* __findall(void* pattern__or__re,
|
||||
if (!vcs) {
|
||||
if (m_n < 0)
|
||||
return NULL;
|
||||
Any list = New_pikaList();
|
||||
Any list = New_PikaList();
|
||||
return list;
|
||||
}
|
||||
Any list = New_pikaList();
|
||||
Any list = New_PikaList();
|
||||
PikaTuple* tu;
|
||||
if (brackets == 1) {
|
||||
for (int i = 0; i < m_n; i++) {
|
||||
|
@ -3325,7 +3325,7 @@ Arg* builtins_list(PikaObj* self, PikaTuple* val) {
|
||||
|
||||
Arg* builtins_dict(PikaObj* self, PikaTuple* val) {
|
||||
#if PIKA_BUILTIN_STRUCT_ENABLE
|
||||
return arg_newObj(New_pikaDict());
|
||||
return arg_newObj(New_PikaDict());
|
||||
#else
|
||||
obj_setErrorCode(self, 1);
|
||||
__platform_printf("[Error] built-in dist is not enabled.\r\n");
|
||||
@ -3516,7 +3516,7 @@ PikaObj* builtins_dir(PikaObj* self, Arg* arg) {
|
||||
}
|
||||
PikaObj* obj = arg_getPtr(arg);
|
||||
PikaObj* New_PikaStdData_List(Args * args);
|
||||
PikaObj* list = New_pikaList();
|
||||
PikaObj* list = New_PikaList();
|
||||
Args* context = New_args(NULL);
|
||||
args_setPtr(context, "_list", list);
|
||||
args_foreach(obj->list, __dir_each, context);
|
||||
@ -4069,7 +4069,7 @@ PikaObj* _New_pikaListOrTuple(int isTuple) {
|
||||
return self;
|
||||
}
|
||||
|
||||
PikaList* New_pikaList(void) {
|
||||
PikaList* New_PikaList(void) {
|
||||
return _New_pikaListOrTuple(0);
|
||||
}
|
||||
|
||||
@ -4084,7 +4084,7 @@ void pikaDict_init(PikaObj* self) {
|
||||
obj_setPtr(self, "_keys", keys);
|
||||
}
|
||||
|
||||
PikaDict* New_pikaDict(void) {
|
||||
PikaDict* New_PikaDict(void) {
|
||||
PikaDict* self = newNormalObj(New_PikaStdData_Dict);
|
||||
pikaDict_init(self);
|
||||
return self;
|
||||
|
@ -441,25 +441,25 @@ PikaObj* _pika_dict_new(int num_args, ...);
|
||||
|
||||
/* Macro to create a new tuple PikaObj with the given arguments (of type Arg*).
|
||||
*/
|
||||
#define New_pikaTupleFromVarArgs(...) \
|
||||
#define New_PikaTupleFromVarArgs(...) \
|
||||
_pika_tuple_new(sizeof((Arg*[]){__VA_ARGS__}) / sizeof(Arg*), __VA_ARGS__)
|
||||
|
||||
/* Macro to create a new list PikaObj with the given arguments (of type Arg*).
|
||||
*/
|
||||
#define New_pikaListFromVarArgs(...) \
|
||||
#define New_PikaListFromVarArgs(...) \
|
||||
_pika_list_new(sizeof((Arg*[]){__VA_ARGS__}) / sizeof(Arg*), __VA_ARGS__)
|
||||
|
||||
/* Macro to create a new dict PikaObj with the given arguments (of type
|
||||
* Arg*).
|
||||
*/
|
||||
|
||||
#define New_pikaDictFromVarArgs(...) \
|
||||
#define New_PikaDictFromVarArgs(...) \
|
||||
_pika_dict_new(sizeof((Arg*[]){__VA_ARGS__, NULL}) / sizeof(Arg*) - 1, \
|
||||
__VA_ARGS__)
|
||||
|
||||
#define New_pikaDictFrom New_pikaDictFromVarArgs
|
||||
#define New_pikaListFrom New_pikaListFromVarArgs
|
||||
#define New_pikaTupleFrom New_pikaTupleFromVarArgs
|
||||
#define New_PikaDictFrom New_PikaDictFromVarArgs
|
||||
#define New_PikaListFrom New_PikaListFromVarArgs
|
||||
#define New_PikaTupleFrom New_PikaTupleFromVarArgs
|
||||
|
||||
PikaObj* newNormalObj(NewFun newObjFun);
|
||||
Arg* arg_setRef(Arg* self, char* name, PikaObj* obj);
|
||||
@ -933,10 +933,9 @@ static inline ArgType pikaTuple_getType(PikaTuple* self, int index) {
|
||||
}
|
||||
|
||||
/* dict api */
|
||||
PikaDict* New_pikaDict(void);
|
||||
|
||||
PikaList* New_pikaList(void);
|
||||
PikaTuple* New_pikaTuple(void);
|
||||
PikaDict* New_PikaDict(void);
|
||||
PikaList* New_PikaList(void);
|
||||
PikaTuple* New_PikaTuple(void);
|
||||
PikaTuple* args_getTuple(Args* self, char* name);
|
||||
PikaDict* args_getDict(Args* self, char* name);
|
||||
|
||||
|
@ -1291,7 +1291,7 @@ static void _type_list_parse(FunctionArgsInfo* f) {
|
||||
|
||||
static void _kw_push(FunctionArgsInfo* f, Arg* call_arg, int i) {
|
||||
if (NULL == f->kw) {
|
||||
f->kw = New_pikaDict();
|
||||
f->kw = New_PikaDict();
|
||||
}
|
||||
arg_setIsKeyword(call_arg, pika_false);
|
||||
Hash kw_hash = call_arg->name_hash;
|
||||
@ -1565,7 +1565,7 @@ static int VMState_loadArgsFromMethodArg(VMState* vm,
|
||||
if (arg_def[0] == '*' && arg_def[1] == '*') {
|
||||
/* get kw dict name */
|
||||
f.kw_dict_name = arg_def + 2;
|
||||
f.kw = New_pikaDict();
|
||||
f.kw = New_PikaDict();
|
||||
/* remove the format arg */
|
||||
strPopLastToken(f.type_list, ',');
|
||||
continue;
|
||||
@ -1709,7 +1709,7 @@ static Arg* VM_instruction_handler_DCT(PikaObj* self,
|
||||
Arg* arg_ret_reg) {
|
||||
#if PIKA_BUILTIN_STRUCT_ENABLE
|
||||
uint32_t n_arg = VMState_getInputArgNum(vm);
|
||||
PikaObj* dict = New_pikaDict();
|
||||
PikaObj* dict = New_PikaDict();
|
||||
Stack stack = {0};
|
||||
stack_init(&stack);
|
||||
/* load to local stack to change sort */
|
||||
|
@ -2,4 +2,4 @@
|
||||
#define PIKA_VERSION_MINOR 12
|
||||
#define PIKA_VERSION_MICRO 5
|
||||
|
||||
#define PIKA_EDIT_TIME "2023/08/08 21:01:20"
|
||||
#define PIKA_EDIT_TIME "2023/08/08 22:10:05"
|
||||
|
@ -106,6 +106,19 @@ extern "C" {
|
||||
#define PIKA_FALSE pika_false
|
||||
#define pikaScriptInit pikaPythonInit
|
||||
#define pikaScriptShell pikaPythonShell
|
||||
|
||||
#define New_pikaList New_PikaList
|
||||
#define New_pikaDict New_PikaDict
|
||||
#define New_pikaTuple New_PikaTuple
|
||||
|
||||
#define New_pikaTupleFrom New_PikaTupleFrom
|
||||
#define New_pikaListFrom New_PikaListFrom
|
||||
#define New_pikaDictFrom New_PikaDictFrom
|
||||
|
||||
#define New_pikaTupleFromVarArgs New_PikaTupleFromVarArgs
|
||||
#define New_pikaListFromVarArgs New_PikaListFromVarArgs
|
||||
#define New_pikaDictFromVarArgs New_PikaDictFromVarArgs
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user