mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
rename cJSON to pika_cjson
This commit is contained in:
parent
87090181f5
commit
60389c541d
@ -1,9 +0,0 @@
|
||||
#include "cJSON_Utils.h"
|
||||
|
||||
PikaObj* cJSON_Utils_parse(PikaObj* self) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PikaObj* cJSON_Utils_createObject(PikaObj *self){
|
||||
return NULL;
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
#include "cJSON_cJSON.h"
|
||||
#include "pika_cjson_cJSON.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
void cJSON_cJSON_parse(PikaObj* self, char* value) {
|
||||
void pika_cjson_cJSON_parse(PikaObj* self, char* value) {
|
||||
cJSON* item = cJSON_Parse(value);
|
||||
obj_setPtr(self, "item", item);
|
||||
obj_setInt(self, "needfree", 1);
|
||||
}
|
||||
|
||||
char* cJSON_cJSON_print(PikaObj* self) {
|
||||
char* pika_cjson_cJSON_print(PikaObj* self) {
|
||||
cJSON* item = obj_getPtr(self, "item");
|
||||
char* res = cJSON_Print(item);
|
||||
obj_setStr(self, "_buf", res);
|
||||
@ -15,19 +15,19 @@ char* cJSON_cJSON_print(PikaObj* self) {
|
||||
return obj_getStr(self, "_buf");
|
||||
}
|
||||
|
||||
void cJSON_cJSON___del__(PikaObj* self) {
|
||||
void pika_cjson_cJSON___del__(PikaObj* self) {
|
||||
cJSON* item = obj_getPtr(self, "item");
|
||||
if (obj_getInt(self, "needfree") == 1) {
|
||||
cJSON_Delete(item);
|
||||
}
|
||||
}
|
||||
|
||||
Arg* cJSON_cJSON_getObjectItem(PikaObj* self, char* string) {
|
||||
Arg* pika_cjson_cJSON_getObjectItem(PikaObj* self, char* string) {
|
||||
cJSON* item = obj_getPtr(self, "item");
|
||||
cJSON* subItem = cJSON_GetObjectItem(item, string);
|
||||
|
||||
/* create subCJSON */
|
||||
Arg* subCJSON_arg = obj_newObjInPackage(New_cJSON_cJSON);
|
||||
Arg* subCJSON_arg = obj_newObjInPackage(New_pika_cjson_cJSON);
|
||||
|
||||
/* init the subCJSON */
|
||||
PikaObj* subCJSON = arg_getPtr(subCJSON_arg);
|
@ -1,6 +1,4 @@
|
||||
import imp
|
||||
from PikaObj import *
|
||||
import json
|
||||
|
||||
|
||||
class cJSON(TinyObj):
|
@ -9,7 +9,7 @@ import test_module1
|
||||
import test_cmodule
|
||||
import TempDevTest as dev
|
||||
import TemplateDevice
|
||||
import cJSON
|
||||
import pika_cjson
|
||||
from PikaStdData import String as S
|
||||
|
||||
mem = PikaStdLib.MemChecker()
|
||||
|
@ -1,6 +1,4 @@
|
||||
import imp
|
||||
from PikaObj import *
|
||||
import json
|
||||
|
||||
|
||||
class cJSON(TinyObj):
|
@ -1,13 +1,13 @@
|
||||
#include "cJSON_cJSON.h"
|
||||
#include "pika_cjson_cJSON.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
void cJSON_cJSON_parse(PikaObj* self, char* value) {
|
||||
void pika_cjson_cJSON_parse(PikaObj* self, char* value) {
|
||||
cJSON* item = cJSON_Parse(value);
|
||||
obj_setPtr(self, "item", item);
|
||||
obj_setInt(self, "needfree", 1);
|
||||
}
|
||||
|
||||
char* cJSON_cJSON_print(PikaObj* self) {
|
||||
char* pika_cjson_cJSON_print(PikaObj* self) {
|
||||
cJSON* item = obj_getPtr(self, "item");
|
||||
char* res = cJSON_Print(item);
|
||||
obj_setStr(self, "_buf", res);
|
||||
@ -15,19 +15,19 @@ char* cJSON_cJSON_print(PikaObj* self) {
|
||||
return obj_getStr(self, "_buf");
|
||||
}
|
||||
|
||||
void cJSON_cJSON___del__(PikaObj* self) {
|
||||
void pika_cjson_cJSON___del__(PikaObj* self) {
|
||||
cJSON* item = obj_getPtr(self, "item");
|
||||
if (obj_getInt(self, "needfree") == 1) {
|
||||
cJSON_Delete(item);
|
||||
}
|
||||
}
|
||||
|
||||
Arg* cJSON_cJSON_getObjectItem(PikaObj* self, char* string) {
|
||||
Arg* pika_cjson_cJSON_getObjectItem(PikaObj* self, char* string) {
|
||||
cJSON* item = obj_getPtr(self, "item");
|
||||
cJSON* subItem = cJSON_GetObjectItem(item, string);
|
||||
|
||||
/* create subCJSON */
|
||||
Arg* subCJSON_arg = obj_newObjInPackage(New_cJSON_cJSON);
|
||||
Arg* subCJSON_arg = obj_newObjInPackage(New_pika_cjson_cJSON);
|
||||
|
||||
/* init the subCJSON */
|
||||
PikaObj* subCJSON = arg_getPtr(subCJSON_arg);
|
@ -36,7 +36,7 @@ TEST(cJSON, parse_print) {
|
||||
/* run */
|
||||
obj_setStr(pikaMain, "testjson", testjson);
|
||||
obj_run(pikaMain,
|
||||
"a = cJSON.cJSON()\n"
|
||||
"a = pika_cjson.cJSON()\n"
|
||||
"a.parse(testjson)\n"
|
||||
"a.print()\n");
|
||||
/* collect */
|
||||
@ -67,7 +67,7 @@ TEST(cJSON, getItem) {
|
||||
obj_setStr(pikaMain, "testjson", testjson);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
obj_run(pikaMain,
|
||||
"a = cJSON.cJSON()\n"
|
||||
"a = pika_cjson.cJSON()\n"
|
||||
"a.parse(testjson)\n"
|
||||
"age = a.getObjectItem('age')\n"
|
||||
"age.print()\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user