mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
format arg_new[]Obj api
This commit is contained in:
parent
bac4c4c90a
commit
ceb8de7c81
@ -49,11 +49,11 @@ void PikaStdLib_SysObj_type(PikaObj* self, Arg* arg) {
|
||||
obj_setSysOut(self, "<class 'buitin_function_or_method'>");
|
||||
return;
|
||||
}
|
||||
if (ARG_TYPE_METHOD_OBJECT== type) {
|
||||
if (ARG_TYPE_METHOD_OBJECT == type) {
|
||||
obj_setSysOut(self, "<class 'method'>");
|
||||
return;
|
||||
}
|
||||
if (ARG_TYPE_METHOD_STATIC== type) {
|
||||
if (ARG_TYPE_METHOD_STATIC == type) {
|
||||
obj_setSysOut(self, "<class 'function'>");
|
||||
return;
|
||||
}
|
||||
@ -113,8 +113,7 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
|
||||
/* a String, return a StringObj */
|
||||
if (ARG_TYPE_STRING == arg_getType(arg)) {
|
||||
obj_setStr(self, "_sobj", arg_getStr(arg));
|
||||
return arg_setMetaObj("", "PikaStdLib_StringObj",
|
||||
New_PikaStdLib_StringObj);
|
||||
return arg_newMetaObj(New_PikaStdLib_StringObj);
|
||||
}
|
||||
/* a MATE object, return itself */
|
||||
if (ARG_TYPE_OBJECT_MATE == arg_getType(arg)) {
|
||||
@ -146,7 +145,7 @@ Arg* PikaStdLib_SysObj_range(PikaObj* self, int a1, int a2) {
|
||||
/* set template arg to create rangeObj */
|
||||
obj_setInt(self, "_r1", a1);
|
||||
obj_setInt(self, "_r2", a2);
|
||||
return arg_setMetaObj("", "PikaStdLib_RangeObj", New_PikaStdLib_RangeObj);
|
||||
return arg_newMetaObj(New_PikaStdLib_RangeObj);
|
||||
}
|
||||
|
||||
Arg* PikaStdLib_SysObj___get__(PikaObj* self, Arg* key, Arg* obj) {
|
||||
|
@ -49,11 +49,11 @@ void PikaStdLib_SysObj_type(PikaObj* self, Arg* arg) {
|
||||
obj_setSysOut(self, "<class 'buitin_function_or_method'>");
|
||||
return;
|
||||
}
|
||||
if (ARG_TYPE_METHOD_OBJECT== type) {
|
||||
if (ARG_TYPE_METHOD_OBJECT == type) {
|
||||
obj_setSysOut(self, "<class 'method'>");
|
||||
return;
|
||||
}
|
||||
if (ARG_TYPE_METHOD_STATIC== type) {
|
||||
if (ARG_TYPE_METHOD_STATIC == type) {
|
||||
obj_setSysOut(self, "<class 'function'>");
|
||||
return;
|
||||
}
|
||||
@ -113,8 +113,7 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
|
||||
/* a String, return a StringObj */
|
||||
if (ARG_TYPE_STRING == arg_getType(arg)) {
|
||||
obj_setStr(self, "_sobj", arg_getStr(arg));
|
||||
return arg_setMetaObj("", "PikaStdLib_StringObj",
|
||||
New_PikaStdLib_StringObj);
|
||||
return arg_newMetaObj(New_PikaStdLib_StringObj);
|
||||
}
|
||||
/* a MATE object, return itself */
|
||||
if (ARG_TYPE_OBJECT_MATE == arg_getType(arg)) {
|
||||
@ -146,7 +145,7 @@ Arg* PikaStdLib_SysObj_range(PikaObj* self, int a1, int a2) {
|
||||
/* set template arg to create rangeObj */
|
||||
obj_setInt(self, "_r1", a1);
|
||||
obj_setInt(self, "_r2", a2);
|
||||
return arg_setMetaObj("", "PikaStdLib_RangeObj", New_PikaStdLib_RangeObj);
|
||||
return arg_newMetaObj(New_PikaStdLib_RangeObj);
|
||||
}
|
||||
|
||||
Arg* PikaStdLib_SysObj___get__(PikaObj* self, Arg* key, Arg* obj) {
|
||||
|
@ -362,7 +362,7 @@ PikaObj* removeMethodInfo(PikaObj* thisClass) {
|
||||
return thisClass;
|
||||
}
|
||||
|
||||
PikaObj* obj_newObjDirect(NewFun newObjFun) {
|
||||
PikaObj* NewObjDirect(NewFun newObjFun) {
|
||||
PikaObj* thisClass = obj_getClassObjByNewFun(NULL, "", newObjFun);
|
||||
obj_refcntInc(thisClass);
|
||||
return removeMethodInfo(thisClass);
|
||||
@ -370,7 +370,7 @@ PikaObj* obj_newObjDirect(NewFun newObjFun) {
|
||||
|
||||
extern PikaObj* __pikaMain;
|
||||
PikaObj* newRootObj(char* name, NewFun newObjFun) {
|
||||
PikaObj* newObj = obj_newObjDirect(newObjFun);
|
||||
PikaObj* newObj = NewObjDirect(newObjFun);
|
||||
__pikaMain = newObj;
|
||||
return newObj;
|
||||
}
|
||||
@ -379,14 +379,25 @@ Arg* obj_getRefArg(PikaObj* self) {
|
||||
return arg_setPtr(NULL, "", ARG_TYPE_OBJECT_FREE, self);
|
||||
}
|
||||
|
||||
Arg* obj_newObjArg(NewFun newObjFun) {
|
||||
PikaObj* newObj = obj_newObjDirect(newObjFun);
|
||||
Arg* arg_newMetaObj(NewFun objPtr) {
|
||||
Arg* argNew = New_arg(NULL);
|
||||
/* m means mate-object */
|
||||
argNew = arg_setPtr(argNew, "", ARG_TYPE_OBJECT_MATE, (void*)objPtr);
|
||||
return argNew;
|
||||
}
|
||||
|
||||
Arg* arg_newDirectObj(NewFun newObjFun) {
|
||||
PikaObj* newObj = NewObjDirect(newObjFun);
|
||||
Arg* objArg = arg_setPtr(NULL, "", ARG_TYPE_OBJECT_FREE, newObj);
|
||||
return objArg;
|
||||
}
|
||||
|
||||
Arg* arg_newObj(NewFun newObjFun) {
|
||||
return arg_newDirectObj(newObjFun);
|
||||
}
|
||||
|
||||
Arg* obj_newObjInPackage(NewFun newObjFun) {
|
||||
return obj_newObjArg(newObjFun);
|
||||
return arg_newObj(newObjFun);
|
||||
}
|
||||
|
||||
static PikaObj* __initObj(PikaObj* obj, char* name) {
|
||||
@ -889,18 +900,11 @@ PikaObj* obj_importModuleWithByteCodeFrame(PikaObj* self,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Arg* arg_setMetaObj(char* objName, char* className, NewFun objPtr) {
|
||||
Arg* argNew = New_arg(NULL);
|
||||
/* m means mate-object */
|
||||
argNew = arg_setPtr(argNew, objName, ARG_TYPE_OBJECT_MATE, (void*)objPtr);
|
||||
return argNew;
|
||||
}
|
||||
|
||||
int32_t obj_newSubObj(PikaObj* self,
|
||||
char* objName,
|
||||
char* className,
|
||||
NewFun newFunPtr) {
|
||||
Arg* new_obj = obj_newObjArg(newFunPtr);
|
||||
Arg* new_obj = arg_newObj(newFunPtr);
|
||||
new_obj = arg_setName(new_obj, objName);
|
||||
new_obj = arg_setType(new_obj, ARG_TYPE_OBJECT);
|
||||
args_setArg(self->list, new_obj);
|
||||
@ -912,7 +916,8 @@ int32_t obj_newSubObjByMate(PikaObj* self,
|
||||
char* className,
|
||||
NewFun newFunPtr) {
|
||||
/* add mate Obj, no inited */
|
||||
Arg* new_obj = arg_setMetaObj(objName, className, newFunPtr);
|
||||
Arg* new_obj = arg_newMetaObj(newFunPtr);
|
||||
new_obj = arg_setName(new_obj, objName);
|
||||
args_setArg(self->list, new_obj);
|
||||
return 0;
|
||||
}
|
||||
|
@ -223,13 +223,13 @@ void obj_shellLineProcess(PikaObj* self,
|
||||
int pikaCompile(char* output_file_name, char* py_lines);
|
||||
Method obj_getNativeMethod(PikaObj* self, char* method_name);
|
||||
void obj_runNativeMethod(PikaObj* self, char* method_name, Args* args);
|
||||
Arg* obj_newObjArg(NewFun newObjFun);
|
||||
Arg* arg_newObj(NewFun newObjFun);
|
||||
Arg* obj_newObjInPackage(NewFun newObjFun);
|
||||
|
||||
void obj_refcntInc(PikaObj* self);
|
||||
void obj_refcntDec(PikaObj* self);
|
||||
int obj_refcntNow(PikaObj* self);
|
||||
PikaObj* obj_newObjDirect(NewFun newObjFun);
|
||||
PikaObj* NewObjDirect(NewFun newObjFun);
|
||||
Arg* arg_setRefObj(Arg* self, char* name, PikaObj* obj);
|
||||
Arg* arg_setWeakRefObj(Arg* self, char* name, PikaObj* obj);
|
||||
|
||||
@ -242,7 +242,7 @@ int32_t obj_newObj(PikaObj* self,
|
||||
char* className,
|
||||
NewFun newFunPtr);
|
||||
|
||||
Arg* arg_setMetaObj(char* objName, char* className, NewFun objPtr);
|
||||
Arg* arg_newMetaObj(NewFun objPtr);
|
||||
|
||||
#define PIKA_PYTHON_BEGIN
|
||||
#define PIKA_PYTHON(x)
|
||||
|
Loading…
x
Reference in New Issue
Block a user