mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
format stdlib
This commit is contained in:
parent
06101b0fc6
commit
1b12eca2a1
@ -2,79 +2,79 @@
|
||||
#include "PikaStdDevice_GPIO.h"
|
||||
|
||||
void PikaStdDevice_GPIO_init(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
obj_setStr(self, "mode", "out");
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
obj_setStr(self, "mode", "out");
|
||||
obj_setInt(self, "isOn", 0);
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_disable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_run(self, "platformDisable()");
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_enable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 1);
|
||||
obj_run(self, "platformEnable()");
|
||||
obj_setInt(self, "isEnable", 1);
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
char* PikaStdDevice_GPIO_getMode(PikaObj* self) {
|
||||
return obj_getStr(self, "mode");
|
||||
return obj_getStr(self, "mode");
|
||||
}
|
||||
|
||||
char* PikaStdDevice_GPIO_getPin(PikaObj* self) {
|
||||
return obj_getStr(self, "pin");
|
||||
return obj_getStr(self, "pin");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_low(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_run(self, "platformLow()");
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_run(self, "platformLow()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_high(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 1);
|
||||
obj_run(self, "platformHigh()");
|
||||
obj_setInt(self, "isOn", 1);
|
||||
obj_run(self, "platformHigh()");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setMode(PikaObj* self, char* mode) {
|
||||
obj_setStr(self, "mode", mode);
|
||||
obj_run(self, "platformSetMode(mode)");
|
||||
obj_setStr(self, "mode", mode);
|
||||
obj_run(self, "platformSetMode(mode)");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_setPin(PikaObj* self, char* pinName) {
|
||||
obj_setStr(self, "pin", pinName);
|
||||
obj_setStr(self, "pin", pinName);
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformDisable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformEnable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
void PikaStdDevice_GPIO_platformLow(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformHigh(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformSetMode(PikaObj* self, char* mode) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformOff(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
void PikaStdDevice_GPIO_platformOn(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
@ -2,29 +2,29 @@
|
||||
#include "BaseObj.h"
|
||||
|
||||
void PikaStdDevice_ADC_enable(PikaObj* self) {
|
||||
obj_run(self, "platformEnable(pin)");
|
||||
obj_run(self, "platformEnable(pin)");
|
||||
}
|
||||
|
||||
void PikaStdDevice_ADC_init(PikaObj* self) {
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
obj_setStr(self, "pin", "PA0");
|
||||
}
|
||||
|
||||
float PikaStdDevice_ADC_read(PikaObj* self) {
|
||||
obj_run(self, "val = platformRead(pin)");
|
||||
return obj_getFloat(self, "val");
|
||||
obj_run(self, "val = platformRead(pin)");
|
||||
return obj_getFloat(self, "val");
|
||||
}
|
||||
|
||||
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) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
||||
float PikaStdDevice_ADC_platformRead(PikaObj* self, char* pin) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
return -1;
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
return -1;
|
||||
}
|
@ -1,96 +1,80 @@
|
||||
#include "BaseObj.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_setStr(self, "pin", "PA0");
|
||||
obj_setStr(self, "mode", "out");
|
||||
obj_setInt(self, "isOn", 0);
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_disable(PikaObj *self)
|
||||
{
|
||||
void PikaStdDeivce_GPIO_disable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 0);
|
||||
obj_run(self, "platformDisable()");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_enable(PikaObj *self)
|
||||
{
|
||||
void PikaStdDeivce_GPIO_enable(PikaObj* self) {
|
||||
obj_setInt(self, "isEnable", 1);
|
||||
obj_run(self, "platformEnable()");
|
||||
}
|
||||
|
||||
char *PikaStdDeivce_GPIO_getMode(PikaObj *self)
|
||||
{
|
||||
char* PikaStdDeivce_GPIO_getMode(PikaObj* self) {
|
||||
return obj_getStr(self, "mode");
|
||||
}
|
||||
|
||||
char *PikaStdDeivce_GPIO_getPin(PikaObj *self)
|
||||
{
|
||||
char* PikaStdDeivce_GPIO_getPin(PikaObj* self) {
|
||||
return obj_getStr(self, "pin");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_low(PikaObj *self)
|
||||
{
|
||||
void PikaStdDeivce_GPIO_low(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 0);
|
||||
obj_run(self, "platformLow()");
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_high(PikaObj *self)
|
||||
{
|
||||
void PikaStdDeivce_GPIO_high(PikaObj* self) {
|
||||
obj_setInt(self, "isOn", 1);
|
||||
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_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);
|
||||
}
|
||||
|
||||
void PikaStdDeivce_GPIO_platformDisable(PikaObj *self)
|
||||
{
|
||||
void PikaStdDeivce_GPIO_platformDisable(PikaObj* self) {
|
||||
obj_setErrorCode(self, 1);
|
||||
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_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_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_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_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_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_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
@ -1,47 +1,52 @@
|
||||
#include "PikaStdDevice_PWM.h"
|
||||
#include "BaseObj.h"
|
||||
|
||||
void PikaStdDevice_PWM_init(PikaObj *self){
|
||||
void PikaStdDevice_PWM_init(PikaObj* self) {
|
||||
obj_setStr(self, "pin", "PA8");
|
||||
obj_setInt(self, "freq", 1000);
|
||||
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);
|
||||
}
|
||||
|
||||
void PikaStdDevice_PWM_setFrequency(PikaObj *self, int freq){
|
||||
void PikaStdDevice_PWM_setFrequency(PikaObj* self, int freq) {
|
||||
obj_setInt(self, "freq", 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_run(self, "platformSetDuty(pin, duty)");
|
||||
}
|
||||
|
||||
void PikaStdDevice_PWM_enable(PikaObj *self){
|
||||
void PikaStdDevice_PWM_enable(PikaObj* self) {
|
||||
obj_run(self, "platformEnable(pin, freq, duty)");
|
||||
}
|
||||
|
||||
float PikaStdDevice_PWM_getDuty(PikaObj *self){
|
||||
float PikaStdDevice_PWM_getDuty(PikaObj* self) {
|
||||
return obj_getFloat(self, "duty");
|
||||
}
|
||||
|
||||
int PikaStdDevice_PWM_getFrequency(PikaObj *self){
|
||||
int PikaStdDevice_PWM_getFrequency(PikaObj* self) {
|
||||
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_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_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_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
#include "BaseObj.h"
|
||||
|
||||
void PikaStdDevice_Time_sleep_ms(PikaObj* self, int ms) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
void PikaStdDevice_Time_sleep_s(PikaObj* self, int s) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
@ -2,39 +2,39 @@
|
||||
#include "BaseObj.h"
|
||||
|
||||
void PikaStdDevice_UART_enable(PikaObj* self) {
|
||||
obj_run(self, "platformEnable(id, baudRate)");
|
||||
obj_run(self, "platformEnable(id, baudRate)");
|
||||
}
|
||||
void PikaStdDevice_UART_init(PikaObj* self) {
|
||||
obj_setInt(self, "baudRate", 115200);
|
||||
obj_setInt(self, "id", 1);
|
||||
obj_setStr(self, "readBuff", "");
|
||||
obj_setInt(self, "baudRate", 115200);
|
||||
obj_setInt(self, "id", 1);
|
||||
obj_setStr(self, "readBuff", "");
|
||||
}
|
||||
char* PikaStdDevice_UART_read(PikaObj* self, int length) {
|
||||
obj_setInt(self, "length", length);
|
||||
obj_run(self, "readData = platformRead(id, length)");
|
||||
return obj_getStr(self, "readData");
|
||||
obj_setInt(self, "length", length);
|
||||
obj_run(self, "readData = platformRead(id, length)");
|
||||
return obj_getStr(self, "readData");
|
||||
}
|
||||
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) {
|
||||
obj_setInt(self, "id", id);
|
||||
obj_setInt(self, "id", id);
|
||||
}
|
||||
void PikaStdDevice_UART_write(PikaObj* self, char* data) {
|
||||
obj_setStr(self, "writeData", data);
|
||||
obj_run(self, "platformWrite(id, writeData)");
|
||||
obj_setStr(self, "writeData", data);
|
||||
obj_run(self, "platformWrite(id, writeData)");
|
||||
}
|
||||
|
||||
void PikaStdDevice_UART_platformEnable(PikaObj* self, int baudRate, int id) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
||||
char * PikaStdDevice_UART_platformRead(PikaObj *self, int id, int length){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
return NULL;
|
||||
char* PikaStdDevice_UART_platformRead(PikaObj* self, int id, int length) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
return NULL;
|
||||
}
|
||||
void PikaStdDevice_UART_platformWrite(PikaObj *self, char * data, int id){
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
void PikaStdDevice_UART_platformWrite(PikaObj* self, char* data, int id) {
|
||||
obj_setErrorCode(self, 1);
|
||||
obj_setSysOut(self, "[error] platform method need to be override.");
|
||||
}
|
@ -2,13 +2,13 @@
|
||||
#include "dataStrs.h"
|
||||
|
||||
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) {
|
||||
obj_sysPrintf(self, "%0.2f kB", pikaMemNow() / 1024.0);
|
||||
obj_sysPrintf(self, "%0.2f kB", pikaMemNow() / 1024.0);
|
||||
}
|
||||
|
||||
void PikaStdLib_MemChecker_resetMax(PikaObj* self) {
|
||||
pikaMemMaxReset();
|
||||
pikaMemMaxReset();
|
||||
}
|
||||
|
@ -2,97 +2,97 @@
|
||||
#include "dataStrs.h"
|
||||
|
||||
static int32_t __foreach_listEachArg(Arg* argEach, Args* handleArgs) {
|
||||
Args* buffs = handleArgs;
|
||||
if (NULL == handleArgs) {
|
||||
/* error: not handleArgs input */
|
||||
return 1;
|
||||
}
|
||||
Args* buffs = handleArgs;
|
||||
if (NULL == handleArgs) {
|
||||
/* error: not handleArgs input */
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* argName = strsCopy(buffs, arg_getName(argEach));
|
||||
if (strIsStartWith(argName, "[")) {
|
||||
/* skip */
|
||||
char* argName = strsCopy(buffs, arg_getName(argEach));
|
||||
if (strIsStartWith(argName, "[")) {
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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) {
|
||||
obj_setErrorCode(self, 0);
|
||||
Args* args = New_args(NULL);
|
||||
args_setStr(args, "stringOut", "");
|
||||
obj_setSysOut(self, "");
|
||||
if (NULL == objPath) {
|
||||
/* no input obj path, use current obj */
|
||||
args_foreach(self->attributeList, __foreach_listEachArg, args);
|
||||
obj_setErrorCode(self, 0);
|
||||
Args* args = New_args(NULL);
|
||||
args_setStr(args, "stringOut", "");
|
||||
obj_setSysOut(self, "");
|
||||
if (NULL == objPath) {
|
||||
/* no input obj path, use current obj */
|
||||
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"));
|
||||
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:
|
||||
args_deinit(args);
|
||||
args_deinit(args);
|
||||
}
|
||||
|
||||
void PikaStdLib_SysObj_new(PikaObj* self, char* classPath, char* objPath) {
|
||||
int32_t res = obj_newObj(self, objPath, classPath);
|
||||
if (1 == res) {
|
||||
obj_setSysOut(self, "[error] new: class not found .");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
int32_t res = obj_newObj(self, objPath, classPath);
|
||||
if (1 == res) {
|
||||
obj_setSysOut(self, "[error] new: class not found .");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdLib_SysObj_remove(PikaObj* self, char* argPath) {
|
||||
obj_setErrorCode(self, 0);
|
||||
int32_t res = obj_removeArg(self, argPath);
|
||||
if (1 == res) {
|
||||
obj_setSysOut(self, "[error] del: object no found.");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
if (2 == res) {
|
||||
obj_setSysOut(self, "[error] del: arg not match.");
|
||||
obj_setErrorCode(self, 2);
|
||||
return;
|
||||
}
|
||||
obj_setErrorCode(self, 0);
|
||||
int32_t res = obj_removeArg(self, argPath);
|
||||
if (1 == res) {
|
||||
obj_setSysOut(self, "[error] del: object no found.");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
if (2 == res) {
|
||||
obj_setSysOut(self, "[error] del: arg not match.");
|
||||
obj_setErrorCode(self, 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PikaStdLib_SysObj_type(PikaObj* self, char* argPath) {
|
||||
if (NULL == argPath) {
|
||||
/* no input obj path, use current obj */
|
||||
PikaObj* objHost = obj_getContext(self);
|
||||
Arg* objArg = obj_getArg(objHost, obj_getStr(self, "_n"));
|
||||
if (NULL == objArg) {
|
||||
obj_setSysOut(self, "[error] type: arg no found.");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
if (NULL == argPath) {
|
||||
/* no input obj path, use current obj */
|
||||
PikaObj* objHost = obj_getContext(self);
|
||||
Arg* objArg = obj_getArg(objHost, obj_getStr(self, "_n"));
|
||||
if (NULL == objArg) {
|
||||
obj_setSysOut(self, "[error] type: arg no found.");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
obj_setSysOut(self, arg_getType(objArg));
|
||||
return;
|
||||
}
|
||||
obj_setSysOut(self, arg_getType(objArg));
|
||||
return;
|
||||
}
|
||||
Arg* arg = obj_getArg(self, argPath);
|
||||
if (NULL == arg) {
|
||||
obj_setSysOut(self, "[error] type: arg no found.");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
obj_setSysOut(self, arg_getType(arg));
|
||||
Arg* arg = obj_getArg(self, argPath);
|
||||
if (NULL == arg) {
|
||||
obj_setSysOut(self, "[error] type: arg no found.");
|
||||
obj_setErrorCode(self, 1);
|
||||
return;
|
||||
}
|
||||
obj_setSysOut(self, arg_getType(arg));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user