get refarg is ok

This commit is contained in:
lyon 2021-09-05 14:02:36 +08:00
parent 0a0c0fbec8
commit 4f8ab57dc7
3 changed files with 20 additions and 11 deletions

View File

@ -17,18 +17,13 @@ static int32_t loadArgByType(PikaObj *self,
{ {
return 0; return 0;
} }
/* get reference arg */ if (0 == obj_getRefArg(self, argPath, args))
Arg *arg = obj_getArg(self, argPath);
if (arg == NULL)
{ {
/* can not get arg */
return 3;
}
Arg *argCopied = arg_copy(arg);
argCopied = arg_setName(argCopied, argPath);
args_setArg(args, argCopied);
return 0; return 0;
} }
/* solve arg faild */
return 3;
}
if (strEqu(definedType, "str")) if (strEqu(definedType, "str"))
{ {
/* solve the string type */ /* solve the string type */
@ -234,8 +229,6 @@ static void *getMethodPtr(PikaObj *methodHost, char *methodName)
return res; return res;
} }
Args *obj_invoke(PikaObj *self, char *cmd) Args *obj_invoke(PikaObj *self, char *cmd)
{ {
/* the Args returned need to be deinit */ /* the Args returned need to be deinit */

View File

@ -534,6 +534,21 @@ char *getRightCmd(Args *buffs, char *cmd)
return right; return right;
} }
uint8_t obj_getRefArg(PikaObj *self, char *argPath, Args *targetArgs)
{
/* get reference arg */
Arg *arg = obj_getArg(self, argPath);
if (arg == NULL)
{
/* can not get arg */
return 3;
}
Arg *argCopied = arg_copy(arg);
argCopied = arg_setName(argCopied, argPath);
args_setArg(targetArgs, argCopied);
return 0;
}
Args *getRightRes(PikaObj *self, char *cmd) Args *getRightRes(PikaObj *self, char *cmd)
{ {
Args *buffs = New_strBuff(); Args *buffs = New_strBuff();

View File

@ -81,5 +81,6 @@ void args_setSysOut(Args *args, char *str);
char *obj_getSysOut(PikaObj *self); char *obj_getSysOut(PikaObj *self);
void obj_sysPrintf(PikaObj *self, char *fmt, ...); void obj_sysPrintf(PikaObj *self, char *fmt, ...);
PikaObj *obj_getContext(PikaObj *self); PikaObj *obj_getContext(PikaObj *self);
uint8_t obj_getRefArg(PikaObj *self, char *argPath, Args *targetArgs);
#endif #endif