Skip to content

Commit 1850489

Browse files
authored
lib/external/parson: complete the wrapping of parson (OSGeo#6434)
* lib/external/parson: complete the wrapping of parson.[c|h], through re-typedefing objects like JSON_Object, JSON_Array, JSON_Value, to objects renamed with the prefix 'G_', and thus hiding the parson API. * adapt code to use GRASS' wrapping API
1 parent a858662 commit 1850489

File tree

64 files changed

+491
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+491
-431
lines changed

db/db.columns/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ int main(int argc, char **argv)
3838
dbTable *table;
3939
dbString table_name;
4040
int col, ncols;
41-
JSON_Value *root_value = NULL;
42-
JSON_Array *root_array = NULL;
41+
G_JSON_Value *root_value = NULL;
42+
G_JSON_Array *root_array = NULL;
4343

4444
parse_command_line(argc, argv);
4545

db/db.connect/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int main(int argc, char *argv[])
3737
struct Option *driver, *database, *schema, *group, *frmt;
3838
struct GModule *module;
3939
enum OutputFormat format;
40-
JSON_Value *root_value = NULL;
41-
JSON_Object *root_object = NULL;
40+
G_JSON_Value *root_value = NULL;
41+
G_JSON_Object *root_object = NULL;
4242

4343
/* Initialize the GIS calls */
4444
G_gisinit(argv[0]);

db/db.describe/local_proto.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
enum OutputFormat { PLAIN, JSON };
77

8-
int print_priv(char *, int, enum OutputFormat, JSON_Object *);
9-
int print_column_definition(dbColumn *, int, enum OutputFormat, JSON_Array *);
8+
int print_priv(char *, int, enum OutputFormat, G_JSON_Object *);
9+
int print_column_definition(dbColumn *, int, enum OutputFormat, G_JSON_Array *);
1010
int print_table_definition(dbDriver *, dbTable *, enum OutputFormat,
11-
JSON_Object *, JSON_Array *);
11+
G_JSON_Object *, G_JSON_Array *);
1212

1313
#endif /* __LOCAL_PROTO_H__ */

db/db.describe/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ int main(int argc, char **argv)
4242
char buf[1024];
4343
dbString stmt;
4444

45-
JSON_Object *root_object = NULL, *col_object = NULL;
46-
JSON_Value *root_value = NULL, *cols_value = NULL, *col_value = NULL;
47-
JSON_Array *cols_array = NULL;
45+
G_JSON_Object *root_object = NULL, *col_object = NULL;
46+
G_JSON_Value *root_value = NULL, *cols_value = NULL, *col_value = NULL;
47+
G_JSON_Array *cols_array = NULL;
4848

4949
parse_command_line(argc, argv);
5050

db/db.describe/printtab.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <grass/gjson.h>
55

66
int print_table_definition(dbDriver *driver, dbTable *table,
7-
enum OutputFormat format, JSON_Object *root_object,
8-
JSON_Array *cols_array)
7+
enum OutputFormat format, G_JSON_Object *root_object,
8+
G_JSON_Array *cols_array)
99
{
1010
int ncols, col, nrows;
1111
dbColumn *column;
@@ -55,10 +55,10 @@ int print_table_definition(dbDriver *driver, dbTable *table,
5555
}
5656

5757
int print_column_definition(dbColumn *column, int position,
58-
enum OutputFormat format, JSON_Array *cols_array)
58+
enum OutputFormat format, G_JSON_Array *cols_array)
5959
{
60-
JSON_Object *col_object = NULL;
61-
JSON_Value *col_value = NULL;
60+
G_JSON_Object *col_object = NULL;
61+
G_JSON_Value *col_value = NULL;
6262

6363
dbString value_string;
6464

@@ -121,7 +121,7 @@ int print_column_definition(dbColumn *column, int position,
121121
}
122122

123123
int print_priv(char *label, int priv, enum OutputFormat format,
124-
JSON_Object *root_object)
124+
G_JSON_Object *root_object)
125125
{
126126
switch (format) {
127127
case PLAIN:

general/g.findfile/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
enum OutputFormat { SHELL, JSON };
3030

31-
void print_json(JSON_Value *root_value)
31+
void print_json(G_JSON_Value *root_value)
3232
{
3333
char *json_string = G_json_serialize_to_string_pretty(root_value);
3434
if (!json_string) {
@@ -54,8 +54,8 @@ int main(int argc, char *argv[])
5454
struct Flag *n_flag, *l_flag, *t_flag;
5555
size_t len;
5656
enum OutputFormat format;
57-
JSON_Value *root_value = NULL;
58-
JSON_Object *root_object = NULL;
57+
G_JSON_Value *root_value = NULL;
58+
G_JSON_Object *root_object = NULL;
5959

6060
module = G_define_module();
6161
G_add_keyword(_("general"));

general/g.list/list.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ void print_list(FILE *fp, struct elist *el, int count, const char *separator,
7575
{
7676
int i;
7777
char fullname[1024];
78-
JSON_Array *root_array = NULL;
79-
JSON_Value *root_value = NULL;
80-
JSON_Object *map_object = NULL;
81-
JSON_Value *map_value = NULL;
78+
G_JSON_Array *root_array = NULL;
79+
G_JSON_Value *root_value = NULL;
80+
G_JSON_Object *map_object = NULL;
81+
G_JSON_Value *map_value = NULL;
8282

8383
if (!count && format != JSON)
8484
return;

general/g.mapset/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
enum OutputFormat { PLAIN, JSON };
3030

3131
// Function to serialize and print JSON value
32-
static void serialize_and_print_json_object(JSON_Value *root_value)
32+
static void serialize_and_print_json_object(G_JSON_Value *root_value)
3333
{
3434
char *serialized_string = G_json_serialize_to_string_pretty(root_value);
3535
if (!serialized_string) {
@@ -60,8 +60,8 @@ int main(int argc, char *argv[])
6060
const char *shell;
6161
char path[GPATH_MAX];
6262
enum OutputFormat format;
63-
JSON_Object *root_object = NULL;
64-
JSON_Value *root_value = NULL;
63+
G_JSON_Object *root_object = NULL;
64+
G_JSON_Value *root_value = NULL;
6565

6666
G_gisinit(argv[0]);
6767

@@ -160,8 +160,8 @@ int main(int argc, char *argv[])
160160
if (flag.list->answer) {
161161
char **ms;
162162
int nmapsets;
163-
JSON_Array *mapsets_array = NULL;
164-
JSON_Value *mapsets_value = NULL;
163+
G_JSON_Array *mapsets_array = NULL;
164+
G_JSON_Value *mapsets_value = NULL;
165165

166166
G_setenv_nogisrc("LOCATION_NAME", location_new);
167167
G_setenv_nogisrc("GISDBASE", gisdbase_new);

general/g.mapsets/list.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
#include <grass/gjson.h>
77

88
// Function to initialize a JSON object with a mapsets array
9-
static JSON_Object *initialize_json_object(void)
9+
static G_JSON_Object *initialize_json_object(void)
1010
{
11-
JSON_Value *root_value = G_json_value_init_object();
11+
G_JSON_Value *root_value = G_json_value_init_object();
1212
if (!root_value) {
1313
G_fatal_error(_("Failed to initialize JSON object. Out of memory?"));
1414
}
1515

16-
JSON_Object *root_object = G_json_value_get_object(root_value);
16+
G_JSON_Object *root_object = G_json_value_get_object(root_value);
1717
G_json_object_set_value(root_object, "mapsets", G_json_value_init_array());
1818

19-
JSON_Array *mapsets = G_json_object_get_array(root_object, "mapsets");
19+
G_JSON_Array *mapsets = G_json_object_get_array(root_object, "mapsets");
2020
if (!mapsets) {
2121
G_json_value_free(root_value);
2222
G_fatal_error(_("Failed to initialize mapsets array. Out of memory?"));
@@ -26,7 +26,7 @@ static JSON_Object *initialize_json_object(void)
2626
}
2727

2828
// Function to serialize and print JSON object
29-
static void serialize_and_print_json_object(JSON_Value *root_value)
29+
static void serialize_and_print_json_object(G_JSON_Value *root_value)
3030
{
3131
char *serialized_string = G_json_serialize_to_string_pretty(root_value);
3232
if (!serialized_string) {
@@ -73,8 +73,8 @@ void list_accessible_mapsets(const char *fs)
7373
void list_accessible_mapsets_json(void)
7474
{
7575
const char *name;
76-
JSON_Object *root_object = initialize_json_object();
77-
JSON_Array *mapsets = G_json_object_get_array(root_object, "mapsets");
76+
G_JSON_Object *root_object = initialize_json_object();
77+
G_JSON_Array *mapsets = G_json_object_get_array(root_object, "mapsets");
7878

7979
for (int n = 0; (name = G_get_mapset_name(n)); n++) {
8080
G_json_array_append_string(mapsets, name);
@@ -87,8 +87,8 @@ void list_accessible_mapsets_json(void)
8787
// Lists available mapsets from a provided array in JSON format
8888
void list_avaliable_mapsets_json(const char **mapset_names, int nmapsets)
8989
{
90-
JSON_Object *root_object = initialize_json_object();
91-
JSON_Array *mapsets = G_json_object_get_array(root_object, "mapsets");
90+
G_JSON_Object *root_object = initialize_json_object();
91+
G_JSON_Array *mapsets = G_json_object_get_array(root_object, "mapsets");
9292

9393
for (int n = 0; n < nmapsets; n++) {
9494
G_json_array_append_string(mapsets, mapset_names[n]);

general/g.proj/output.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
#include "local_proto.h"
3131

3232
static int check_xy(enum OutputFormat);
33-
static void print_json(JSON_Value *);
33+
static void print_json(G_JSON_Value *);
3434

3535
/* print projection information gathered from one of the possible inputs
3636
* in GRASS format */
3737
void print_projinfo(enum OutputFormat format)
3838
{
3939
int i;
40-
JSON_Value *value = NULL;
41-
JSON_Object *object = NULL;
40+
G_JSON_Value *value = NULL;
41+
G_JSON_Object *object = NULL;
4242

4343
if (check_xy(format))
4444
return;
@@ -342,8 +342,8 @@ void print_wkt(int esristyle, int dontprettify)
342342

343343
static int check_xy(enum OutputFormat format)
344344
{
345-
JSON_Value *value = NULL;
346-
JSON_Object *object = NULL;
345+
G_JSON_Value *value = NULL;
346+
G_JSON_Object *object = NULL;
347347

348348
if (cellhd.proj == PROJECTION_XY) {
349349
switch (format) {
@@ -375,7 +375,7 @@ static int check_xy(enum OutputFormat format)
375375
return 0;
376376
}
377377

378-
void print_json(JSON_Value *value)
378+
void print_json(G_JSON_Value *value)
379379
{
380380
char *serialized_string = G_json_serialize_to_string_pretty(value);
381381
if (serialized_string == NULL) {

0 commit comments

Comments
 (0)