summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-07-29 19:37:09 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-07-29 19:37:09 +0000
commita350048a2574bb603b8a64d210f42e449f8a4dfe (patch)
treebcdc4afd8c9caf42db1852494184ccd24e4929ea
parent2afddc4305325447f91d879af7d5c4c280257867 (diff)
get rid of useless wrapper code in libjson
git-svn-id: http://svn.miranda-ng.org/main/trunk@14755 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--libs/libjson/src/JSONNode.h4
-rw-r--r--libs/libjson/src/JSONNode.inl4
-rw-r--r--libs/libjson/src/libJSON.cpp88
-rw-r--r--libs/libjson/src/libjson.def5
-rw-r--r--libs/libjson/src/libjson64.def5
5 files changed, 54 insertions, 52 deletions
diff --git a/libs/libjson/src/JSONNode.h b/libs/libjson/src/JSONNode.h
index 487509d852..fe32427019 100644
--- a/libs/libjson/src/JSONNode.h
+++ b/libs/libjson/src/JSONNode.h
@@ -424,8 +424,8 @@ public:
#endif
#ifdef JSON_WRITER
- json_string write(void);
- json_string write_formatted(void);
+ json_string write(void) const;
+ json_string write_formatted(void) const;
#endif
#ifdef JSON_DEBUG
diff --git a/libs/libjson/src/JSONNode.inl b/libs/libjson/src/JSONNode.inl
index d895a977f7..b012ffdbb2 100644
--- a/libs/libjson/src/JSONNode.inl
+++ b/libs/libjson/src/JSONNode.inl
@@ -338,12 +338,12 @@ inline void JSONNode::decRef(void){ //decrements internal's counter, deletes it
}
#endif
#ifdef JSON_WRITER
- inline json_string JSONNode::write(void){
+ inline json_string JSONNode::write(void) const {
JSON_CHECK_INTERNAL();
JSON_ASSERT_SAFE(type() == JSON_NODE || type() == JSON_ARRAY, JSON_TEXT("Writing a non-writable node"), return JSON_TEXT(""););
return internal -> Write(0xFFFFFFFF, true);
}
- inline json_string JSONNode::write_formatted(void){
+ inline json_string JSONNode::write_formatted(void) const {
JSON_CHECK_INTERNAL();
JSON_ASSERT_SAFE(type() == JSON_NODE || type() == JSON_ARRAY, JSON_TEXT("Writing a non-writable node"), return JSON_TEXT(""););
return internal -> Write(0, true);
diff --git a/libs/libjson/src/libJSON.cpp b/libs/libjson/src/libJSON.cpp
index ebedb81f97..06a9a3fd7e 100644
--- a/libs/libjson/src/libJSON.cpp
+++ b/libs/libjson/src/libJSON.cpp
@@ -144,17 +144,17 @@ LIBJSON_DLL(TCHAR*) json_strip_white_space(const json_char *json) {
LIBJSON_DLL(void) json_set_mutex(JSONNode *node, void * mutex) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_mutex"), return;);
- ((JSONNode*)node) -> set_mutex(mutex);
+ node->set_mutex(mutex);
}
LIBJSON_DLL(void) json_lock(JSONNode *node, int threadid) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_lock"), return;);
- ((JSONNode*)node) -> lock(threadid);
+ node->lock(threadid);
}
LIBJSON_DLL(void) json_unlock(JSONNode *node, int threadid) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_unlock"), return;);
- ((JSONNode*)node) -> unlock(threadid);
+ node->unlock(threadid);
}
#endif
@@ -210,107 +210,107 @@ LIBJSON_DLL(JSONNode*) json_new(char type) {
LIBJSON_DLL(JSONNode*) json_copy(const JSONNode *orig) {
JSON_ASSERT_SAFE(orig, JSON_TEXT("null orig to json_copy"), return 0;);
#ifdef JSON_MEMORY_CALLBACKS
- return MANAGER_INSERT(new(json_malloc<JSONNode>(1)) JSONNode(*((JSONNode*)orig)));
+ return MANAGER_INSERT(new(json_malloc<JSONNode>(1)) JSONNode(*orig));
#else
- return MANAGER_INSERT(new JSONNode(*((JSONNode*)orig)));
+ return MANAGER_INSERT(new JSONNode(*orig));
#endif
}
LIBJSON_DLL(JSONNode*) json_duplicate(const JSONNode *orig) {
JSON_ASSERT_SAFE(orig, JSON_TEXT("null orig to json_duplicate"), return 0;);
- return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)orig) -> duplicate()));
+ return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(orig->duplicate()));
}
//assignment
LIBJSON_DLL(void) json_set_a(JSONNode *node, const json_char *value) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_a"), return;);
JSON_ASSERT_SAFE(value, JSON_TEXT("null value to json_set_a"), value = EMPTY_CSTRING;);
- *((JSONNode*)node) = json_string(value);
+ *node = json_string(value);
}
LIBJSON_DLL(void) json_set_i(JSONNode *node, long value) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_i"), return;);
- *((JSONNode*)node) = value;
+ *node = value;
}
LIBJSON_DLL(void) json_set_f(JSONNode *node, double value) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_f"), return;);
- *((JSONNode*)node) = value;
+ *node = value;
}
LIBJSON_DLL(void) json_set_b(JSONNode *node, int value) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_b"), return;);
- *((JSONNode*)node) = value != 0;
+ *node = value != 0;
}
LIBJSON_DLL(void) json_set_n(JSONNode *node, const JSONNode *orig) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_n"), return;);
JSON_ASSERT_SAFE(orig, JSON_TEXT("null node to json_set_n"), return;);
- *((JSONNode*)node) = *((JSONNode*)orig);
+ *node = *orig;
}
//inspectors
LIBJSON_DLL(char) json_type(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_type"), return JSON_NULL;);
- return ((JSONNode*)node) -> type();
+ return node->type();
}
LIBJSON_DLL(json_index_t) json_size(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_size"), return 0;);
- return ((JSONNode*)node) -> size();
+ return node->size();
}
LIBJSON_DLL(int) json_empty(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_empty"), return true;);
- return (int)(((JSONNode*)node) -> empty());
+ return (int)(node->empty());
}
LIBJSON_DLL(const json_char*) json_name(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_name"), return EMPTY_CSTRING;);
- return ((JSONNode*)node) -> name();
+ return node->name();
}
#ifdef JSON_COMMENTS
LIBJSON_DLL(json_char*) json_get_comment(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_get_comment"), return toCString(EMPTY_CSTRING););
- return toCString(((JSONNode*)node) -> get_comment());
+ return toCString(node->get_comment());
}
#endif
LIBJSON_DLL(TCHAR*) json_as_string(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_string"), return toCString(EMPTY_CSTRING););
- return toCString(((JSONNode*)node) -> as_string());
+ return toCString(node->as_string());
}
LIBJSON_DLL(long) json_as_int(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_int"), return 0;);
- return ((JSONNode*)node) -> as_int();
+ return node->as_int();
}
LIBJSON_DLL(double) json_as_float(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_float"), return 0.0;);
- return ((JSONNode*)node) -> as_float();
+ return node->as_float();
}
LIBJSON_DLL(int) json_as_bool(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_bool"), return false;);
- return (int)(((JSONNode*)node) -> as_bool());
+ return (int)(node->as_bool());
}
LIBJSON_DLL(JSONNode*) json_as_node(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_node"), return 0;);
- return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)node) -> as_node()));
+ return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(node->as_node()));
}
LIBJSON_DLL(JSONNode*) json_as_array(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_array"), return 0;);
- return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(((JSONNode*)node) -> as_array()));
+ return MANAGER_INSERT(JSONNode::newJSONNode_Shallow(node->as_array()));
}
#ifdef JSON_BINARY
void * json_as_binary(const JSONNode *node, unsigned long * size) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_as_binary"), if (size) {*size = 0;} return 0;);
- const std::string result = ((JSONNode*)node) -> as_binary();
+ const std::string result = node->as_binary();
const size_t len = result.length();
if (size) *size = len;
#ifdef JSON_SAFE
@@ -327,12 +327,12 @@ LIBJSON_DLL(JSONNode*) json_as_array(const JSONNode *node) {
#ifdef JSON_WRITER
LIBJSON_DLL(TCHAR*) json_write(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_write"), return toCString(EMPTY_CSTRING););
- return toCString(((JSONNode*)node) -> write());
+ return toCString(node->write());
}
LIBJSON_DLL(TCHAR*) json_write_formatted(const JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_write_formatted"), return toCString(EMPTY_CSTRING););
- return toCString(((JSONNode*)node) -> write_formatted());
+ return toCString(node->write_formatted());
}
#endif
@@ -340,75 +340,75 @@ LIBJSON_DLL(JSONNode*) json_as_array(const JSONNode *node) {
LIBJSON_DLL(void) json_set_name(JSONNode *node, const json_char *name) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_name"), return;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_set_name"), name = EMPTY_CSTRING;);
- ((JSONNode*)node) -> set_name(name);
+ node->set_name(name);
}
#ifdef JSON_COMMENTS
LIBJSON_DLL(void) json_set_comment(JSONNode *node, const json_char * comment) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_set_comment"), return;);
JSON_ASSERT_SAFE(comment, JSON_TEXT("null name to json_set_comment"), comment = EMPTY_CSTRING;);
- ((JSONNode*)node) -> set_comment(comment);
+ node->set_comment(comment);
}
#endif
LIBJSON_DLL(void) json_clear(JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_clear"), return;);
- ((JSONNode*)node) -> clear();
+ node->clear();
}
LIBJSON_DLL(void) json_nullify(JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_nullify"), return;);
- ((JSONNode*)node) -> nullify();
+ node->nullify();
}
LIBJSON_DLL(void) json_swap(JSONNode *node, JSONNode *node2) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_swap"), return;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node to json_swap"), return;);
- ((JSONNode*)node) -> swap(*(JSONNode*)node2);
+ node->swap(*node2);
}
LIBJSON_DLL(void) json_merge(JSONNode *node, JSONNode *node2) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_merge"), return;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node to json_merge"), return;);
- ((JSONNode*)node) -> merge(*(JSONNode*)node2);
+ node->merge(*node2);
}
#ifndef JSON_PREPARSE
LIBJSON_DLL(void) json_preparse(JSONNode *node) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_preparse"), return;);
- ((JSONNode*)node) -> preparse();
+ node->preparse();
}
#endif
#ifdef JSON_BINARY
LIBJSON_DLL(void) json_set_binary(JSONNode *node, const void * data, unsigned long length) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_swap"), return;);
- JSON_ASSERT_SAFE(data, JSON_TEXT("null data to json_set_binary"), *((JSONNode*)node) = EMPTY_CSTRING; return;);
- ((JSONNode*)node) -> set_binary((unsigned char *)data, length);
+ JSON_ASSERT_SAFE(data, JSON_TEXT("null data to json_set_binary"), *node = EMPTY_CSTRING; return;);
+ node->set_binary((unsigned char *)data, length);
}
#endif
LIBJSON_DLL(void) json_cast(JSONNode *node, char type) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_cast"), return;);
- ((JSONNode*)node) -> cast(type);
+ node->cast(type);
}
//children access
LIBJSON_DLL(void) json_reserve(JSONNode *node, json_index_t siz) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_reserve"), return;);
- ((JSONNode*)node) -> reserve(siz);
+ node->reserve(siz);
}
LIBJSON_DLL(JSONNode*) json_at(JSONNode *node, json_index_t pos) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_at"), return 0;);
- JSONNode &res = ((JSONNode*)node) -> at(pos);
+ JSONNode &res = node->at(pos);
return (&res == &nullNode) ? NULL : &res;
}
LIBJSON_DLL(JSONNode*) json_get(JSONNode *node, const json_char *name) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_get"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null node to json_get. Did you mean to use json_at?"), return 0;);
- JSONNode &res = ((JSONNode*)node)->at(name);
+ JSONNode &res = node->at(name);
return (&res == &nullNode) ? NULL : &res;
}
@@ -417,7 +417,7 @@ LIBJSON_DLL(JSONNode*) json_get(JSONNode *node, const json_char *name) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_at_nocase"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_at_nocase"), return 0;);
try {
- return &((JSONNode*)node) -> at_nocase(name);
+ return &node->at_nocase(name);
} catch (std::out_of_range) {}
return 0;
}
@@ -425,7 +425,7 @@ LIBJSON_DLL(JSONNode*) json_get(JSONNode *node, const json_char *name) {
LIBJSON_DLL(JSONNode*) json_pop_back_nocase(JSONNode *node, const json_char *name) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_pop_back_nocase"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_pop_back_nocase"), return 0;);
- return MANAGER_INSERT(((JSONNode*)node) -> pop_back_nocase(name));
+ return MANAGER_INSERT(node->pop_back_nocase(name));
}
#endif
@@ -435,23 +435,23 @@ LIBJSON_DLL(void) json_push_back(JSONNode *node, JSONNode *node2) {
#ifdef JSON_MEMORY_MANAGE
NodeHandler.remove(node2);
#endif
- ((JSONNode*)node) -> push_back(*(JSONNode*)node2);
+ node->push_back(*node2);
}
LIBJSON_DLL(JSONNode*) json_pop_back_at(JSONNode *node, json_index_t pos) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_pop_back_i"), return 0;);
- return MANAGER_INSERT(&((JSONNode*)node) -> pop_back(pos));
+ return MANAGER_INSERT(&node->pop_back(pos));
}
LIBJSON_DLL(JSONNode*) json_pop_back(JSONNode *node, const json_char *name) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_pop_back"), return 0;);
JSON_ASSERT_SAFE(name, JSON_TEXT("null name to json_pop_back. Did you mean to use json_pop_back_at?"), return 0;);
- return MANAGER_INSERT(&((JSONNode*)node) -> pop_back(name));
+ return MANAGER_INSERT(&node->pop_back(name));
}
//comparison
LIBJSON_DLL(int) json_equal(JSONNode *node, JSONNode *node2) {
JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_equal"), return false;);
JSON_ASSERT_SAFE(node2, JSON_TEXT("null node2 to json_equal"), return false;);
- return (int)(*((JSONNode*)node) == *((JSONNode*)node2));
+ return *node == *node2;
}
diff --git a/libs/libjson/src/libjson.def b/libs/libjson/src/libjson.def
index 9bcfb45af6..0bbdcc81a9 100644
--- a/libs/libjson/src/libjson.def
+++ b/libs/libjson/src/libjson.def
@@ -148,8 +148,8 @@ EXPORTS
?swap@JSONNode@@QAEXAAV1@@Z @145 NONAME
?toUTF8@JSONWorker@@CA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@Z @146 NONAME
?type@JSONNode@@QBEEXZ @147 NONAME
-?write@JSONNode@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @148 NONAME
-?write_formatted@JSONNode@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @149 NONAME
+?write@JSONNode@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @148 NONAME
+?write_formatted@JSONNode@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @149 NONAME
json_as_array @150
json_as_bool @151
json_as_float @152
@@ -193,3 +193,4 @@ json_type @189
json_write @190
json_write_formatted @191
??6JSONNode@@QAEAAV0@ABV0@@Z @192 NONAME
+??4JSONWorker@@QAEAAV0@$$QAV0@@Z @193 NONAME
diff --git a/libs/libjson/src/libjson64.def b/libs/libjson/src/libjson64.def
index add5cbdd7e..29e021f1c6 100644
--- a/libs/libjson/src/libjson64.def
+++ b/libs/libjson/src/libjson64.def
@@ -148,8 +148,8 @@ EXPORTS
?swap@JSONNode@@QEAAXAEAV1@@Z @145 NONAME
?toUTF8@JSONWorker@@CA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@E@Z @146 NONAME
?type@JSONNode@@QEBAEXZ @147 NONAME
-?write@JSONNode@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @148 NONAME
-?write_formatted@JSONNode@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @149 NONAME
+?write@JSONNode@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @148 NONAME
+?write_formatted@JSONNode@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @149 NONAME
json_as_array @150
json_as_bool @151
json_as_float @152
@@ -193,3 +193,4 @@ json_type @189
json_write @190
json_write_formatted @191
??6JSONNode@@QEAAAEAV0@AEBV0@@Z @192 NONAME
+??4JSONWorker@@QEAAAEAV0@$$QEAV0@@Z @193 NONAME