format stdlib

This commit is contained in:
Lyon 2021-09-22 16:07:26 +08:00
parent 06101b0fc6
commit 1b12eca2a1
8 changed files with 176 additions and 187 deletions

View File

@ -2,79 +2,79 @@
#include "PikaStdDevice_GPIO.h" #include "PikaStdDevice_GPIO.h"
void PikaStdDevice_GPIO_init(PikaObj* self) { void PikaStdDevice_GPIO_init(PikaObj* self) {
obj_setInt(self, "isEnable", 0); obj_setInt(self, "isEnable", 0);
obj_setStr(self, "pin", "PA0"); obj_setStr(self, "pin", "PA0");
obj_setStr(self, "mode", "out"); obj_setStr(self, "mode", "out");
obj_setInt(self, "isOn", 0); obj_setInt(self, "isOn", 0);
} }
void PikaStdDevice_GPIO_disable(PikaObj* self) { void PikaStdDevice_GPIO_disable(PikaObj* self) {
obj_setInt(self, "isEnable", 0); obj_setInt(self, "isEnable", 0);
obj_run(self, "platformDisable()"); obj_run(self, "platformDisable()");
} }
void PikaStdDevice_GPIO_enable(PikaObj* self) { void PikaStdDevice_GPIO_enable(PikaObj* self) {
obj_setInt(self, "isEnable", 1); obj_setInt(self, "isEnable", 1);
obj_run(self, "platformEnable()"); obj_run(self, "platformEnable()");
} }
char* PikaStdDevice_GPIO_getMode(PikaObj* self) { char* PikaStdDevice_GPIO_getMode(PikaObj* self) {
return obj_getStr(self, "mode"); return obj_getStr(self, "mode");
} }
char* PikaStdDevice_GPIO_getPin(PikaObj* self) { char* PikaStdDevice_GPIO_getPin(PikaObj* self) {
return obj_getStr(self, "pin"); return obj_getStr(self, "pin");
} }
void PikaStdDevice_GPIO_low(PikaObj* self) { void PikaStdDevice_GPIO_low(PikaObj* self) {
obj_setInt(self, "isOn", 0); obj_setInt(self, "isOn", 0);
obj_run(self, "platformLow()"); obj_run(self, "platformLow()");
} }
void PikaStdDevice_GPIO_high(PikaObj* self) { void PikaStdDevice_GPIO_high(PikaObj* self) {
obj_setInt(self, "isOn", 1); obj_setInt(self, "isOn", 1);
obj_run(self, "platformHigh()"); obj_run(self, "platformHigh()");
} }
void PikaStdDevice_GPIO_setMode(PikaObj* self, char* mode) { void PikaStdDevice_GPIO_setMode(PikaObj* self, char* mode) {
obj_setStr(self, "mode", mode); obj_setStr(self, "mode", mode);
obj_run(self, "platformSetMode(mode)"); obj_run(self, "platformSetMode(mode)");
} }
void PikaStdDevice_GPIO_setPin(PikaObj* self, char* pinName) { void PikaStdDevice_GPIO_setPin(PikaObj* self, char* pinName) {
obj_setStr(self, "pin", pinName); obj_setStr(self, "pin", pinName);
} }
void PikaStdDevice_GPIO_platformDisable(PikaObj* self) { void PikaStdDevice_GPIO_platformDisable(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_GPIO_platformEnable(PikaObj* self) { void PikaStdDevice_GPIO_platformEnable(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_GPIO_platformLow(PikaObj* self) { void PikaStdDevice_GPIO_platformLow(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_GPIO_platformHigh(PikaObj* self) { void PikaStdDevice_GPIO_platformHigh(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_GPIO_platformSetMode(PikaObj* self, char* mode) { void PikaStdDevice_GPIO_platformSetMode(PikaObj* self, char* mode) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_GPIO_platformOff(PikaObj* self) { void PikaStdDevice_GPIO_platformOff(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_GPIO_platformOn(PikaObj* self) { void PikaStdDevice_GPIO_platformOn(PikaObj* self) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }

View File

@ -2,29 +2,29 @@
#include "BaseObj.h" #include "BaseObj.h"
void PikaStdDevice_ADC_enable(PikaObj* self) { void PikaStdDevice_ADC_enable(PikaObj* self) {
obj_run(self, "platformEnable(pin)"); obj_run(self, "platformEnable(pin)");
} }
void PikaStdDevice_ADC_init(PikaObj* self) { void PikaStdDevice_ADC_init(PikaObj* self) {
obj_setStr(self, "pin", "PA0"); obj_setStr(self, "pin", "PA0");
} }
float PikaStdDevice_ADC_read(PikaObj* self) { float PikaStdDevice_ADC_read(PikaObj* self) {
obj_run(self, "val = platformRead(pin)"); obj_run(self, "val = platformRead(pin)");
return obj_getFloat(self, "val"); return obj_getFloat(self, "val");
} }
void PikaStdDevice_ADC_setPin(PikaObj* self, char* pin) { void PikaStdDevice_ADC_setPin(PikaObj* self, char* pin) {
obj_setStr(self, "pin", pin); obj_setStr(self, "pin", pin);
} }
void PikaStdDevice_ADC_platformEnable(PikaObj* self, char* pin) { void PikaStdDevice_ADC_platformEnable(PikaObj* self, char* pin) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
float PikaStdDevice_ADC_platformRead(PikaObj* self, char* pin) { float PikaStdDevice_ADC_platformRead(PikaObj* self, char* pin) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
return -1; return -1;
} }

View File

@ -1,96 +1,80 @@
#include "BaseObj.h"
#include "PikaStdDevice_GPIO.h" #include "PikaStdDevice_GPIO.h"
#include "BaseObj.h"
void PikaStdDeivce_GPIO_init(PikaObj *self) void PikaStdDeivce_GPIO_init(PikaObj* self) {
{
obj_setInt(self, "isEnable", 0); obj_setInt(self, "isEnable", 0);
obj_setStr(self, "pin", "PA0"); obj_setStr(self, "pin", "PA0");
obj_setStr(self, "mode", "out"); obj_setStr(self, "mode", "out");
obj_setInt(self, "isOn", 0); obj_setInt(self, "isOn", 0);
} }
void PikaStdDeivce_GPIO_disable(PikaObj *self) void PikaStdDeivce_GPIO_disable(PikaObj* self) {
{
obj_setInt(self, "isEnable", 0); obj_setInt(self, "isEnable", 0);
obj_run(self, "platformDisable()"); obj_run(self, "platformDisable()");
} }
void PikaStdDeivce_GPIO_enable(PikaObj *self) void PikaStdDeivce_GPIO_enable(PikaObj* self) {
{
obj_setInt(self, "isEnable", 1); obj_setInt(self, "isEnable", 1);
obj_run(self, "platformEnable()"); obj_run(self, "platformEnable()");
} }
char *PikaStdDeivce_GPIO_getMode(PikaObj *self) char* PikaStdDeivce_GPIO_getMode(PikaObj* self) {
{
return obj_getStr(self, "mode"); return obj_getStr(self, "mode");
} }
char *PikaStdDeivce_GPIO_getPin(PikaObj *self) char* PikaStdDeivce_GPIO_getPin(PikaObj* self) {
{
return obj_getStr(self, "pin"); return obj_getStr(self, "pin");
} }
void PikaStdDeivce_GPIO_low(PikaObj *self) void PikaStdDeivce_GPIO_low(PikaObj* self) {
{
obj_setInt(self, "isOn", 0); obj_setInt(self, "isOn", 0);
obj_run(self, "platformLow()"); obj_run(self, "platformLow()");
} }
void PikaStdDeivce_GPIO_high(PikaObj *self) void PikaStdDeivce_GPIO_high(PikaObj* self) {
{
obj_setInt(self, "isOn", 1); obj_setInt(self, "isOn", 1);
obj_run(self, "platformHigh()"); obj_run(self, "platformHigh()");
} }
void PikaStdDeivce_GPIO_setMode(PikaObj *self, char *mode) void PikaStdDeivce_GPIO_setMode(PikaObj* self, char* mode) {
{
obj_setStr(self, "mode", mode); obj_setStr(self, "mode", mode);
obj_run(self, "platformSetMode(mode)"); obj_run(self, "platformSetMode(mode)");
} }
void PikaStdDeivce_GPIO_setPin(PikaObj *self, char *pinName) void PikaStdDeivce_GPIO_setPin(PikaObj* self, char* pinName) {
{
obj_setStr(self, "pin", pinName); obj_setStr(self, "pin", pinName);
} }
void PikaStdDeivce_GPIO_platformDisable(PikaObj *self) void PikaStdDeivce_GPIO_platformDisable(PikaObj* self) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDeivce_GPIO_platformEnable(PikaObj *self) void PikaStdDeivce_GPIO_platformEnable(PikaObj* self) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDeivce_GPIO_platformLow(PikaObj *self) void PikaStdDeivce_GPIO_platformLow(PikaObj* self) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDeivce_GPIO_platformHigh(PikaObj *self) void PikaStdDeivce_GPIO_platformHigh(PikaObj* self) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDeivce_GPIO_platformSetMode(PikaObj *self, char *mode) void PikaStdDeivce_GPIO_platformSetMode(PikaObj* self, char* mode) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDeivce_GPIO_platformOff(PikaObj *self) void PikaStdDeivce_GPIO_platformOff(PikaObj* self) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDeivce_GPIO_platformOn(PikaObj *self) void PikaStdDeivce_GPIO_platformOn(PikaObj* self) {
{
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }

View File

@ -1,47 +1,52 @@
#include "PikaStdDevice_PWM.h" #include "PikaStdDevice_PWM.h"
#include "BaseObj.h" #include "BaseObj.h"
void PikaStdDevice_PWM_init(PikaObj *self){ void PikaStdDevice_PWM_init(PikaObj* self) {
obj_setStr(self, "pin", "PA8"); obj_setStr(self, "pin", "PA8");
obj_setInt(self, "freq", 1000); obj_setInt(self, "freq", 1000);
obj_setFloat(self, "duty", 0.5f); obj_setFloat(self, "duty", 0.5f);
} }
void PikaStdDevice_PWM_setPin(PikaObj *self, char * pin){ void PikaStdDevice_PWM_setPin(PikaObj* self, char* pin) {
obj_setStr(self, "pin", pin); obj_setStr(self, "pin", pin);
} }
void PikaStdDevice_PWM_setFrequency(PikaObj *self, int freq){ void PikaStdDevice_PWM_setFrequency(PikaObj* self, int freq) {
obj_setInt(self, "freq", freq); obj_setInt(self, "freq", freq);
obj_run(self, "platformSetFrequency(pin, freq)"); obj_run(self, "platformSetFrequency(pin, freq)");
} }
void PikaStdDevice_PWM_setDuty(PikaObj *self, float duty){ void PikaStdDevice_PWM_setDuty(PikaObj* self, float duty) {
obj_setFloat(self, "duty", duty); obj_setFloat(self, "duty", duty);
obj_run(self, "platformSetDuty(pin, duty)"); obj_run(self, "platformSetDuty(pin, duty)");
} }
void PikaStdDevice_PWM_enable(PikaObj *self){ void PikaStdDevice_PWM_enable(PikaObj* self) {
obj_run(self, "platformEnable(pin, freq, duty)"); obj_run(self, "platformEnable(pin, freq, duty)");
} }
float PikaStdDevice_PWM_getDuty(PikaObj *self){ float PikaStdDevice_PWM_getDuty(PikaObj* self) {
return obj_getFloat(self, "duty"); return obj_getFloat(self, "duty");
} }
int PikaStdDevice_PWM_getFrequency(PikaObj *self){ int PikaStdDevice_PWM_getFrequency(PikaObj* self) {
return obj_getInt(self, "freq"); return obj_getInt(self, "freq");
} }
void PikaStdDevice_PWM_platformEnable(PikaObj *self, float dute, int freq, char * pin){ void PikaStdDevice_PWM_platformEnable(PikaObj* self,
float dute,
int freq,
char* pin) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_PWM_platformSetDuty(PikaObj *self, float duty, char * pin){ void PikaStdDevice_PWM_platformSetDuty(PikaObj* self, float duty, char* pin) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_PWM_platformSetFrequency(PikaObj *self, int freq, char * pin){ void PikaStdDevice_PWM_platformSetFrequency(PikaObj* self,
int freq,
char* pin) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }

View File

@ -2,10 +2,10 @@
#include "BaseObj.h" #include "BaseObj.h"
void PikaStdDevice_Time_sleep_ms(PikaObj* self, int ms) { void PikaStdDevice_Time_sleep_ms(PikaObj* self, int ms) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
void PikaStdDevice_Time_sleep_s(PikaObj* self, int s) { void PikaStdDevice_Time_sleep_s(PikaObj* self, int s) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }

View File

@ -2,39 +2,39 @@
#include "BaseObj.h" #include "BaseObj.h"
void PikaStdDevice_UART_enable(PikaObj* self) { void PikaStdDevice_UART_enable(PikaObj* self) {
obj_run(self, "platformEnable(id, baudRate)"); obj_run(self, "platformEnable(id, baudRate)");
} }
void PikaStdDevice_UART_init(PikaObj* self) { void PikaStdDevice_UART_init(PikaObj* self) {
obj_setInt(self, "baudRate", 115200); obj_setInt(self, "baudRate", 115200);
obj_setInt(self, "id", 1); obj_setInt(self, "id", 1);
obj_setStr(self, "readBuff", ""); obj_setStr(self, "readBuff", "");
} }
char* PikaStdDevice_UART_read(PikaObj* self, int length) { char* PikaStdDevice_UART_read(PikaObj* self, int length) {
obj_setInt(self, "length", length); obj_setInt(self, "length", length);
obj_run(self, "readData = platformRead(id, length)"); obj_run(self, "readData = platformRead(id, length)");
return obj_getStr(self, "readData"); return obj_getStr(self, "readData");
} }
void PikaStdDevice_UART_setBaudRate(PikaObj* self, int baudRate) { void PikaStdDevice_UART_setBaudRate(PikaObj* self, int baudRate) {
obj_setInt(self, "baudRate", baudRate); obj_setInt(self, "baudRate", baudRate);
} }
void PikaStdDevice_UART_setId(PikaObj* self, int id) { void PikaStdDevice_UART_setId(PikaObj* self, int id) {
obj_setInt(self, "id", id); obj_setInt(self, "id", id);
} }
void PikaStdDevice_UART_write(PikaObj* self, char* data) { void PikaStdDevice_UART_write(PikaObj* self, char* data) {
obj_setStr(self, "writeData", data); obj_setStr(self, "writeData", data);
obj_run(self, "platformWrite(id, writeData)"); obj_run(self, "platformWrite(id, writeData)");
} }
void PikaStdDevice_UART_platformEnable(PikaObj* self, int baudRate, int id) { void PikaStdDevice_UART_platformEnable(PikaObj* self, int baudRate, int id) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }
char * PikaStdDevice_UART_platformRead(PikaObj *self, int id, int length){ char* PikaStdDevice_UART_platformRead(PikaObj* self, int id, int length) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
return NULL; return NULL;
} }
void PikaStdDevice_UART_platformWrite(PikaObj *self, char * data, int id){ void PikaStdDevice_UART_platformWrite(PikaObj* self, char* data, int id) {
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error] platform method need to be override."); obj_setSysOut(self, "[error] platform method need to be override.");
} }

View File

@ -2,13 +2,13 @@
#include "dataStrs.h" #include "dataStrs.h"
void PikaStdLib_MemChecker_max(PikaObj* self) { void PikaStdLib_MemChecker_max(PikaObj* self) {
obj_sysPrintf(self, "%0.2f kB", pikaMemMax() / 1024.0); obj_sysPrintf(self, "%0.2f kB", pikaMemMax() / 1024.0);
} }
void PikaStdLib_MemChecker_now(PikaObj* self) { void PikaStdLib_MemChecker_now(PikaObj* self) {
obj_sysPrintf(self, "%0.2f kB", pikaMemNow() / 1024.0); obj_sysPrintf(self, "%0.2f kB", pikaMemNow() / 1024.0);
} }
void PikaStdLib_MemChecker_resetMax(PikaObj* self) { void PikaStdLib_MemChecker_resetMax(PikaObj* self) {
pikaMemMaxReset(); pikaMemMaxReset();
} }

View File

@ -2,97 +2,97 @@
#include "dataStrs.h" #include "dataStrs.h"
static int32_t __foreach_listEachArg(Arg* argEach, Args* handleArgs) { static int32_t __foreach_listEachArg(Arg* argEach, Args* handleArgs) {
Args* buffs = handleArgs; Args* buffs = handleArgs;
if (NULL == handleArgs) { if (NULL == handleArgs) {
/* error: not handleArgs input */ /* error: not handleArgs input */
return 1; return 1;
} }
char* argName = strsCopy(buffs, arg_getName(argEach)); char* argName = strsCopy(buffs, arg_getName(argEach));
if (strIsStartWith(argName, "[")) { if (strIsStartWith(argName, "[")) {
/* skip */ /* skip */
return 0;
}
char* stringOut = args_getStr(handleArgs, "stringOut");
if (NULL == stringOut) {
// stringOut no found
return 1;
}
stringOut = strsAppend(buffs, stringOut, argName);
stringOut = strsAppend(buffs, stringOut, " ");
args_setStr(handleArgs, "stringOut", stringOut);
return 0; return 0;
}
char* stringOut = args_getStr(handleArgs, "stringOut");
if (NULL == stringOut) {
// stringOut no found
return 1;
}
stringOut = strsAppend(buffs, stringOut, argName);
stringOut = strsAppend(buffs, stringOut, " ");
args_setStr(handleArgs, "stringOut", stringOut);
return 0;
} }
void PikaStdLib_SysObj_ls(PikaObj* self, char* objPath) { void PikaStdLib_SysObj_ls(PikaObj* self, char* objPath) {
obj_setErrorCode(self, 0); obj_setErrorCode(self, 0);
Args* args = New_args(NULL); Args* args = New_args(NULL);
args_setStr(args, "stringOut", ""); args_setStr(args, "stringOut", "");
obj_setSysOut(self, ""); obj_setSysOut(self, "");
if (NULL == objPath) { if (NULL == objPath) {
/* no input obj path, use current obj */ /* no input obj path, use current obj */
args_foreach(self->attributeList, __foreach_listEachArg, args); args_foreach(self->attributeList, __foreach_listEachArg, args);
obj_setSysOut(self, args_getStr(args, "stringOut"));
goto exit;
}
PikaObj* obj = obj_getObj(self, objPath, 0);
if (NULL == obj) {
/* do not find obj */
obj_setSysOut(self, "[error] list: object no found.");
obj_setErrorCode(self, 1);
goto exit;
}
/* list args */
args_foreach(obj->attributeList, __foreach_listEachArg, args);
obj_setSysOut(self, args_getStr(args, "stringOut")); obj_setSysOut(self, args_getStr(args, "stringOut"));
goto exit;
}
PikaObj* obj = obj_getObj(self, objPath, 0);
if (NULL == obj) {
/* do not find obj */
obj_setSysOut(self, "[error] list: object no found.");
obj_setErrorCode(self, 1);
goto exit;
}
/* list args */
args_foreach(obj->attributeList, __foreach_listEachArg, args);
obj_setSysOut(self, args_getStr(args, "stringOut"));
exit: exit:
args_deinit(args); args_deinit(args);
} }
void PikaStdLib_SysObj_new(PikaObj* self, char* classPath, char* objPath) { void PikaStdLib_SysObj_new(PikaObj* self, char* classPath, char* objPath) {
int32_t res = obj_newObj(self, objPath, classPath); int32_t res = obj_newObj(self, objPath, classPath);
if (1 == res) { if (1 == res) {
obj_setSysOut(self, "[error] new: class not found ."); obj_setSysOut(self, "[error] new: class not found .");
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
return; return;
} }
} }
void PikaStdLib_SysObj_remove(PikaObj* self, char* argPath) { void PikaStdLib_SysObj_remove(PikaObj* self, char* argPath) {
obj_setErrorCode(self, 0); obj_setErrorCode(self, 0);
int32_t res = obj_removeArg(self, argPath); int32_t res = obj_removeArg(self, argPath);
if (1 == res) { if (1 == res) {
obj_setSysOut(self, "[error] del: object no found."); obj_setSysOut(self, "[error] del: object no found.");
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
return; return;
} }
if (2 == res) { if (2 == res) {
obj_setSysOut(self, "[error] del: arg not match."); obj_setSysOut(self, "[error] del: arg not match.");
obj_setErrorCode(self, 2); obj_setErrorCode(self, 2);
return; return;
} }
} }
void PikaStdLib_SysObj_type(PikaObj* self, char* argPath) { void PikaStdLib_SysObj_type(PikaObj* self, char* argPath) {
if (NULL == argPath) { if (NULL == argPath) {
/* no input obj path, use current obj */ /* no input obj path, use current obj */
PikaObj* objHost = obj_getContext(self); PikaObj* objHost = obj_getContext(self);
Arg* objArg = obj_getArg(objHost, obj_getStr(self, "_n")); Arg* objArg = obj_getArg(objHost, obj_getStr(self, "_n"));
if (NULL == objArg) { if (NULL == objArg) {
obj_setSysOut(self, "[error] type: arg no found."); obj_setSysOut(self, "[error] type: arg no found.");
obj_setErrorCode(self, 1); obj_setErrorCode(self, 1);
return; return;
}
obj_setSysOut(self, arg_getType(objArg));
return;
} }
obj_setSysOut(self, arg_getType(objArg)); Arg* arg = obj_getArg(self, argPath);
return; if (NULL == arg) {
} obj_setSysOut(self, "[error] type: arg no found.");
Arg* arg = obj_getArg(self, argPath); obj_setErrorCode(self, 1);
if (NULL == arg) { return;
obj_setSysOut(self, "[error] type: arg no found."); }
obj_setErrorCode(self, 1); obj_setSysOut(self, arg_getType(arg));
return;
}
obj_setSysOut(self, arg_getType(arg));
} }