[Opensrf-commits] r1095 - in trunk: include/opensrf src/libopensrf
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Sep 30 14:04:49 EDT 2007
Author: miker
Date: 2007-09-30 13:54:25 -0400 (Sun, 30 Sep 2007)
New Revision: 1095
Modified:
trunk/include/opensrf/osrf_json.h
trunk/src/libopensrf/osrf_json_tools.c
Log:
Continued const-correctness improvement from Scott McKellar:
1. I changed the signature of jsonObjectDecodeClass so that it accepts
a non-const pointer parameter. Since it doesn't change the contents
of the jsonObject, there's no need to confine it to non-const
jsonObjects.
2. I replaced jsonObjectGetKey() with jsonObjectGetKeyConst().
3. In one spot I captured the return value of jsonObjectGetIndex()
with a const pointer instead of a non-const pointer.
Modified: trunk/include/opensrf/osrf_json.h
===================================================================
--- trunk/include/opensrf/osrf_json.h 2007-09-30 17:48:32 UTC (rev 1094)
+++ trunk/include/opensrf/osrf_json.h 2007-09-30 17:54:25 UTC (rev 1095)
@@ -355,7 +355,7 @@
* classname set
* Caller must free the returned object
*/
-jsonObject* jsonObjectDecodeClass( jsonObject* obj );
+jsonObject* jsonObjectDecodeClass( const jsonObject* obj );
/** Converts an object with a classname into a
Modified: trunk/src/libopensrf/osrf_json_tools.c
===================================================================
--- trunk/src/libopensrf/osrf_json_tools.c 2007-09-30 17:48:32 UTC (rev 1094)
+++ trunk/src/libopensrf/osrf_json_tools.c 2007-09-30 17:54:25 UTC (rev 1095)
@@ -75,21 +75,21 @@
-jsonObject* jsonObjectDecodeClass( jsonObject* obj ) {
+jsonObject* jsonObjectDecodeClass( const jsonObject* obj ) {
if(!obj) return jsonNewObject(NULL);
- jsonObject* newObj = NULL;
- jsonObject* classObj = NULL;
- jsonObject* payloadObj = NULL;
+ jsonObject* newObj = NULL;
+ const jsonObject* classObj = NULL;
+ const jsonObject* payloadObj = NULL;
int i;
if( obj->type == JSON_HASH ) {
/* are we a special class object? */
- if( (classObj = jsonObjectGetKey( obj, JSON_CLASS_KEY )) ) {
+ if( (classObj = jsonObjectGetKeyConst( obj, JSON_CLASS_KEY )) ) {
/* do we have a payload */
- if( (payloadObj = jsonObjectGetKey( obj, JSON_DATA_KEY )) ) {
+ if( (payloadObj = jsonObjectGetKeyConst( obj, JSON_DATA_KEY )) ) {
newObj = jsonObjectDecodeClass( payloadObj );
jsonObjectSetClass( newObj, jsonObjectGetString(classObj) );
@@ -239,7 +239,7 @@
/* gather all of the sub-objects that match the full path */
for( i = 0; i < arr->size; i++ ) {
- jsonObject* a = jsonObjectGetIndex(arr, i);
+ const jsonObject* a = jsonObjectGetIndex(arr, i);
jsonObject* thing = jsonObjectFindPath(a , path + strlen(root) + 1);
if(thing) { //jsonObjectPush(newarr, thing);
More information about the opensrf-commits
mailing list