Check-in [e40e79b7ab]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:e40e79b7ab7b9f0fa6f85f95f97d5ae514c142de
Date: 2012-07-05 19:24:25
User: stephan
Comment:Minor interal json refactoring made possible by recent cson changes.
Tags And Properties
Changes

Changes to src/json.c

870 ** for consistency with how json_err() works. 870 ** for consistency with how json_err() works. 871 */ 871 */ 872 void json_warn( int code, char const * fmt, ... ){ 872 void json_warn( int code, char const * fmt, ... ){ 873 cson_object * obj = NULL; 873 cson_object * obj = NULL; 874 assert( (code>FSL_JSON_W_START) 874 assert( (code>FSL_JSON_W_START) 875 && (code<FSL_JSON_W_END) 875 && (code<FSL_JSON_W_END) 876 && "Invalid warning code."); 876 && "Invalid warning code."); 877 if(!g.json.warnings.v){ | 877 if(!g.json.warnings){ 878 g.json.warnings.v = cson_value_new_array(); | 878 g.json.warnings = cson_new_array(); 879 assert((NULL != g.json.warnings.v) && "Alloc error."); | 879 assert((NULL != g.json.warnings) && "Alloc error."); 880 g.json.warnings.a = cson_value_get_array(g.json.warnings.v); < 881 json_gc_add("$WARNINGS",g.json.warnings.v); | 880 json_gc_add("$WARNINGS",cson_array_value(g.json.warnings)); 882 } 881 } 883 obj = cson_new_object(); 882 obj = cson_new_object(); 884 cson_array_append(g.json.warnings.a, cson_object_value(obj)); | 883 cson_array_append(g.json.warnings, cson_object_value(obj)); 885 cson_object_set(obj,"code",cson_value_new_integer(code)); 884 cson_object_set(obj,"code",cson_value_new_integer(code)); 886 if(fmt && *fmt){ 885 if(fmt && *fmt){ 887 /* FIXME: treat NULL fmt as standard warning message for 886 /* FIXME: treat NULL fmt as standard warning message for 888 the code, but we don't have those yet. 887 the code, but we don't have those yet. 889 */ 888 */ 890 va_list vargs; 889 va_list vargs; 891 char * msg; 890 char * msg; ................................................................................................................................................................................ 1443 INT(g.json, dispatchDepth); 1442 INT(g.json, dispatchDepth); 1444 VAL(authToken, g.json.authToken); 1443 VAL(authToken, g.json.authToken); 1445 CSTR(g.json, jsonp); 1444 CSTR(g.json, jsonp); 1446 VAL(gc, g.json.gc.v); 1445 VAL(gc, g.json.gc.v); 1447 VAL(cmd, g.json.cmd.v); 1446 VAL(cmd, g.json.cmd.v); 1448 VAL(param, g.json.param.v); 1447 VAL(param, g.json.param.v); 1449 VAL(POST, g.json.post.v); 1448 VAL(POST, g.json.post.v); 1450 VAL(warnings, g.json.warnings.v); | 1449 VAL(warnings, cson_array_value(g.json.warnings)); 1451 /*cson_output_opt outOpt;*/ 1450 /*cson_output_opt outOpt;*/ 1452 1451 1453 1452 1454 #undef INT 1453 #undef INT 1455 #undef CSTR 1454 #undef CSTR 1456 #undef VAL 1455 #undef VAL 1457 return cson_object_value(pay); 1456 return cson_object_value(pay); ................................................................................................................................................................................ 1556 double span; 1555 double span; 1557 span = END_TIMER; 1556 span = END_TIMER; 1558 /* i'm actually seeing sub-ms runtimes in some tests, but a time of 1557 /* i'm actually seeing sub-ms runtimes in some tests, but a time of 1559 0 is "just wrong", so we'll bump that up to 1ms. 1558 0 is "just wrong", so we'll bump that up to 1ms. 1560 */ 1559 */ 1561 cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)((span>1. 1560 cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)((span>1. 1562 } 1561 } 1563 if(g.json.warnings.v){ | 1562 if(g.json.warnings){ 1564 tmp = g.json.warnings.v; | 1563 tmp = cson_array_value(g.json.warnings); 1565 SET("warnings"); 1564 SET("warnings"); 1566 } 1565 } 1567 1566 1568 /* Only add the payload to SUCCESS responses. Else delete it. */ 1567 /* Only add the payload to SUCCESS responses. Else delete it. */ 1569 if( NULL != payload ){ 1568 if( NULL != payload ){ 1570 if( resultCode ){ 1569 if( resultCode ){ 1571 cson_value_free(payload); 1570 cson_value_free(payload);

Changes to src/main.c

243 cson_value * v; 243 cson_value * v; 244 cson_object * o; 244 cson_object * o; 245 } param; 245 } param; 246 struct { 246 struct { 247 cson_value * v; 247 cson_value * v; 248 cson_object * o; 248 cson_object * o; 249 } reqPayload; /* request payload object (if any) */ 249 } reqPayload; /* request payload object (if any) */ 250 struct { /* response warnings */ | 250 cson_array * warnings; /* response warnings */ 251 cson_value * v; < 252 cson_array * a; < 253 } warnings; < 254 } json; 251 } json; 255 #endif /* FOSSIL_ENABLE_JSON */ 252 #endif /* FOSSIL_ENABLE_JSON */ 256 }; 253 }; 257 254 258 /* 255 /* 259 ** Macro for debugging: 256 ** Macro for debugging: 260 */ 257 */