diff options
Diffstat (limited to 'json-glib')
-rw-r--r-- | json-glib/Makefile.am | 47 | ||||
-rwxr-xr-x | json-glib/abicheck.sh | 6 | ||||
-rw-r--r-- | json-glib/json-builder.h | 15 | ||||
-rw-r--r-- | json-glib/json-enum-types.h.in | 2 | ||||
-rw-r--r-- | json-glib/json-generator.h | 13 | ||||
-rw-r--r-- | json-glib/json-glib.h | 1 | ||||
-rw-r--r-- | json-glib/json-glib.symbols | 191 | ||||
-rw-r--r-- | json-glib/json-gobject.h | 26 | ||||
-rw-r--r-- | json-glib/json-gvariant.h | 4 | ||||
-rw-r--r-- | json-glib/json-parser.h | 13 | ||||
-rw-r--r-- | json-glib/json-path.h | 6 | ||||
-rw-r--r-- | json-glib/json-reader.h | 22 | ||||
-rw-r--r-- | json-glib/json-types.h | 103 | ||||
-rw-r--r-- | json-glib/json-version-macros.h | 135 |
14 files changed, 344 insertions, 240 deletions
diff --git a/json-glib/Makefile.am b/json-glib/Makefile.am index 09786cc..f428bab 100644 --- a/json-glib/Makefile.am +++ b/json-glib/Makefile.am @@ -14,23 +14,6 @@ bin_PROGRAMS = SUBDIRS = . tests # main library -AM_CPPFLAGS += \ - -DPREFIX=\""$(prefix)"\" \ - -DLIBDIR=\""$(libdir)"\" \ - -DJSON_LOCALEDIR=\""$(localedir)"\" \ - -DJSON_COMPILATION=1 \ - -DG_LOG_DOMAIN=\"Json\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(JSON_DEBUG_CFLAGS) \ - $(NULL) - -AM_CFLAGS += \ - $(JSON_CFLAGS) \ - $(MAINTAINER_CFLAGS) \ - $(JSON_GCOV_CFLAGS) \ - $(NULL) - source_h = \ $(top_srcdir)/json-glib/json-builder.h \ $(top_srcdir)/json-glib/json-generator.h \ @@ -40,6 +23,7 @@ source_h = \ $(top_srcdir)/json-glib/json-path.h \ $(top_srcdir)/json-glib/json-reader.h \ $(top_srcdir)/json-glib/json-types.h \ + $(top_srcdir)/json-glib/json-version-macros.h \ $(NULL) source_h_private = \ @@ -82,11 +66,20 @@ include $(top_srcdir)/build/autotools/Makefile.am.marshal lib_LTLIBRARIES += libjson-glib-1.0.la +libjson_glib_1_0_la_CPPFLAGS = \ + -DPREFIX=\""$(prefix)"\" \ + -DLIBDIR=\""$(libdir)"\" \ + -DJSON_LOCALEDIR=\""$(localedir)"\" \ + -DJSON_COMPILATION=1 \ + -DG_LOG_DOMAIN=\"Json\" \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(JSON_DEBUG_CFLAGS) \ + $(NULL) +libjson_glib_1_0_la_CFLAGS = $(JSON_CFLAGS) $(JSON_HIDDEN_VISIBILITY_CFLAG) $(MAINTAINER_CFLAGS) $(JSON_GCOV_CFLAGS) libjson_glib_1_0_la_LIBADD = $(JSON_LIBS) libjson_glib_1_0_la_SOURCES = $(source_c) $(source_h) $(source_h_private) $(BUILT_SOURCES) -libjson_glib_1_0_la_LDFLAGS = $(JSON_LT_LDFLAGS) $(JSON_GCOV_LDADD) -export-symbols $(top_srcdir)/json-glib/json-glib.symbols - -EXTRA_DIST += json-glib.symbols +libjson_glib_1_0_la_LDFLAGS = $(JSON_LT_LDFLAGS) $(JSON_GCOV_LDADD) -export-dynamic jsonincludedir = $(includedir)/json-glib-1.0/json-glib jsoninclude_DATA = \ @@ -108,20 +101,16 @@ pkgconfigdir = $(libdir)/pkgconfig CLEANFILES += $(pcfiles) EXTRA_DIST += json-glib.pc.in -TESTS_ENVIRONMENT = srcdir="$(srcdir)" json_all_c_sources="$(source_c)" - -if OS_LINUX -TESTS = abicheck.sh -endif - -EXTRA_DIST += abicheck.sh - # tools bin_PROGRAMS += json-glib-validate +json_glib_validate_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) -DJSON_LOCALEDIR=\""$(localedir)"\" +json_glib_validate_CFLAGS = $(JSON_CFLAGS) $(MAINTAINER_CFLAGS) json_glib_validate_SOURCES = json-glib-validate.c json_glib_validate_LDADD = $(JSON_LIBS) libjson-glib-1.0.la bin_PROGRAMS += json-glib-format +json_glib_format_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) -DJSON_LOCALEDIR=\""$(localedir)"\" +json_glib_format_CFLAGS = $(JSON_CFLAGS) $(MAINTAINER_CFLAGS) json_glib_format_SOURCES = json-glib-format.c json_glib_format_LDADD = $(JSON_LIBS) libjson-glib-1.0.la @@ -137,7 +126,7 @@ Json_1_0_gir_NAMESPACE = Json Json_1_0_gir_VERSION = 1.0 Json_1_0_gir_LIBS = libjson-glib-1.0.la Json_1_0_gir_FILES = $(source_h) $(source_c) -Json_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(JSON_CFLAGS) +Json_1_0_gir_CFLAGS = -DJSON_COMPILATION=1 -I$(top_srcdir) -I$(top_builddir) $(JSON_CFLAGS) Json_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 Json_1_0_gir_SCANNERFLAGS = --warn-all --pkg-export json-glib-1.0 --c-include "json-glib/json-glib.h" diff --git a/json-glib/abicheck.sh b/json-glib/abicheck.sh deleted file mode 100755 index 0cba7f9..0000000 --- a/json-glib/abicheck.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -cpp -P ${cppargs} ${srcdir:-.}/json-glib.symbols | sed -e '/^$/d' -e 's/ G_GNUC.*$//' -e 's/ PRIVATE//' -e 's/ DATA//' | sort > expected-abi - -nm -D -g --defined-only .libs/libjson-glib-1.0.so | cut -d ' ' -f 3 | egrep -v '^(__bss_start|_edata|_end)' | sort > actual-abi -diff -u expected-abi actual-abi && rm -f expected-abi actual-abi diff --git a/json-glib/json-builder.h b/json-glib/json-builder.h index 361c64a..dd0bad8 100644 --- a/json-glib/json-builder.h +++ b/json-glib/json-builder.h @@ -75,29 +75,44 @@ struct _JsonBuilderClass void (* _json_reserved2) (void); }; +JSON_AVAILABLE_IN_1_0 GType json_builder_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_new (void); +JSON_AVAILABLE_IN_1_0 JsonNode *json_builder_get_root (JsonBuilder *builder); +JSON_AVAILABLE_IN_1_0 void json_builder_reset (JsonBuilder *builder); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_begin_array (JsonBuilder *builder); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_end_array (JsonBuilder *builder); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_begin_object (JsonBuilder *builder); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_end_object (JsonBuilder *builder); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_set_member_name (JsonBuilder *builder, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_add_value (JsonBuilder *builder, JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_add_int_value (JsonBuilder *builder, gint64 value); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_add_double_value (JsonBuilder *builder, gdouble value); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_add_boolean_value (JsonBuilder *builder, gboolean value); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_add_string_value (JsonBuilder *builder, const gchar *value); +JSON_AVAILABLE_IN_1_0 JsonBuilder *json_builder_add_null_value (JsonBuilder *builder); G_END_DECLS diff --git a/json-glib/json-enum-types.h.in b/json-glib/json-enum-types.h.in index c36e433..4ce965d 100644 --- a/json-glib/json-enum-types.h.in +++ b/json-glib/json-enum-types.h.in @@ -7,6 +7,7 @@ #endif #include <glib-object.h> +#include <json-glib/json-version-macros.h> G_BEGIN_DECLS @@ -23,6 +24,7 @@ G_END_DECLS /*** END file-tail ***/ /*** BEGIN value-header ***/ +JSON_AVAILABLE_IN_1_0 GType @enum_name@_get_type (void) G_GNUC_CONST; #define JSON_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) diff --git a/json-glib/json-generator.h b/json-glib/json-generator.h index 3ce7d08..99c1b1d 100644 --- a/json-glib/json-generator.h +++ b/json-glib/json-generator.h @@ -75,28 +75,41 @@ struct _JsonGeneratorClass void (* _json_reserved4) (void); }; +JSON_AVAILABLE_IN_1_0 GType json_generator_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonGenerator * json_generator_new (void); +JSON_AVAILABLE_IN_1_0 void json_generator_set_pretty (JsonGenerator *generator, gboolean is_pretty); +JSON_AVAILABLE_IN_1_0 gboolean json_generator_get_pretty (JsonGenerator *generator); +JSON_AVAILABLE_IN_1_0 void json_generator_set_indent (JsonGenerator *generator, guint indent_level); +JSON_AVAILABLE_IN_1_0 guint json_generator_get_indent (JsonGenerator *generator); +JSON_AVAILABLE_IN_1_0 void json_generator_set_indent_char (JsonGenerator *generator, gunichar indent_char); +JSON_AVAILABLE_IN_1_0 gunichar json_generator_get_indent_char (JsonGenerator *generator); +JSON_AVAILABLE_IN_1_0 void json_generator_set_root (JsonGenerator *generator, JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonNode * json_generator_get_root (JsonGenerator *generator); +JSON_AVAILABLE_IN_1_0 gchar * json_generator_to_data (JsonGenerator *generator, gsize *length); +JSON_AVAILABLE_IN_1_0 gboolean json_generator_to_file (JsonGenerator *generator, const gchar *filename, GError **error); +JSON_AVAILABLE_IN_1_0 gboolean json_generator_to_stream (JsonGenerator *generator, GOutputStream *stream, GCancellable *cancellable, diff --git a/json-glib/json-glib.h b/json-glib/json-glib.h index 257bcdf..8a0e7f7 100644 --- a/json-glib/json-glib.h +++ b/json-glib/json-glib.h @@ -34,6 +34,7 @@ #include <json-glib/json-path.h> #include <json-glib/json-reader.h> #include <json-glib/json-version.h> +#include <json-glib/json-version-macros.h> #include <json-glib/json-enum-types.h> diff --git a/json-glib/json-glib.symbols b/json-glib/json-glib.symbols deleted file mode 100644 index 382fbbd..0000000 --- a/json-glib/json-glib.symbols +++ /dev/null @@ -1,191 +0,0 @@ -json_array_add_array_element -json_array_add_boolean_element -json_array_add_double_element -json_array_add_element -json_array_add_int_element -json_array_add_null_element -json_array_add_object_element -json_array_add_string_element -json_array_dup_element -json_array_foreach_element -json_array_get_array_element -json_array_get_boolean_element -json_array_get_double_element -json_array_get_element -json_array_get_elements -json_array_get_int_element -json_array_get_length -json_array_get_null_element -json_array_get_object_element -json_array_get_string_element -json_array_get_type -json_array_new -json_array_ref -json_array_remove_element -json_array_sized_new -json_array_unref -json_boxed_can_deserialize -json_boxed_can_serialize -json_boxed_deserialize -json_boxed_register_deserialize_func -json_boxed_register_serialize_func -json_boxed_serialize -json_builder_add_boolean_value -json_builder_add_double_value -json_builder_add_int_value -json_builder_add_null_value -json_builder_add_string_value -json_builder_add_value -json_builder_begin_array -json_builder_begin_object -json_builder_end_array -json_builder_end_object -json_builder_get_root -json_builder_get_type -json_builder_new -json_builder_reset -json_builder_set_member_name -json_construct_gobject -json_deserialize_pspec -json_generator_get_indent -json_generator_get_indent_char -json_generator_get_pretty -json_generator_get_root -json_generator_get_type -json_generator_new -json_generator_set_indent -json_generator_set_indent_char -json_generator_set_pretty -json_generator_set_root -json_generator_to_data -json_generator_to_file -json_generator_to_stream -json_gobject_deserialize -json_gobject_from_data -json_gobject_serialize -json_gobject_to_data -json_gvariant_deserialize -json_gvariant_deserialize_data -json_gvariant_serialize -json_gvariant_serialize_data -json_node_alloc -json_node_copy -json_node_dup_array -json_node_dup_object -json_node_dup_string -json_node_free -json_node_get_array -json_node_get_boolean -json_node_get_double -json_node_get_int -json_node_get_node_type -json_node_get_object -json_node_get_parent -json_node_get_string -json_node_get_type -json_node_get_value -json_node_get_value_type -json_node_init -json_node_init_array -json_node_init_boolean -json_node_init_double -json_node_init_int -json_node_init_null -json_node_init_object -json_node_init_string -json_node_is_null -json_node_new -json_node_set_array -json_node_set_boolean -json_node_set_double -json_node_set_int -json_node_set_object -json_node_set_parent -json_node_set_string -json_node_set_value -json_node_take_array -json_node_take_object -json_node_type_get_type -json_node_type_name -json_object_add_member -json_object_dup_member -json_object_foreach_member -json_object_get_array_member -json_object_get_boolean_member -json_object_get_double_member -json_object_get_int_member -json_object_get_member -json_object_get_members -json_object_get_null_member -json_object_get_object_member -json_object_get_size -json_object_get_string_member -json_object_get_type -json_object_get_values -json_object_has_member -json_object_new -json_object_ref -json_object_remove_member -json_object_set_array_member -json_object_set_boolean_member -json_object_set_double_member -json_object_set_int_member -json_object_set_member -json_object_set_null_member -json_object_set_object_member -json_object_set_string_member -json_object_unref -json_parser_error_get_type -json_parser_error_quark -json_parser_get_current_line -json_parser_get_current_pos -json_parser_get_root -json_parser_get_type -json_parser_has_assignment -json_parser_load_from_data -json_parser_load_from_file -json_parser_load_from_stream -json_parser_load_from_stream_async -json_parser_load_from_stream_finish -json_parser_new -json_path_compile -json_path_error_get_type -json_path_error_quark -json_path_get_type -json_path_match -json_path_new -json_path_query -json_reader_count_elements -json_reader_count_members -json_reader_end_element -json_reader_end_member -json_reader_error_get_type -json_reader_error_quark -json_reader_get_boolean_value -json_reader_get_double_value -json_reader_get_error -json_reader_get_int_value -json_reader_get_member_name -json_reader_get_null_value -json_reader_get_string_value -json_reader_get_type -json_reader_get_value -json_reader_is_array -json_reader_is_object -json_reader_is_value -json_reader_list_members -json_reader_new -json_reader_read_element -json_reader_read_member -json_reader_set_root -json_serializable_default_deserialize_property -json_serializable_default_serialize_property -json_serializable_deserialize_property -json_serializable_find_property -json_serializable_get_property -json_serializable_get_type -json_serializable_list_properties -json_serializable_serialize_property -json_serializable_set_property -json_serialize_gobject -json_serialize_pspec diff --git a/json-glib/json-gobject.h b/json-glib/json-gobject.h index dc1fac6..17aa2db 100644 --- a/json-glib/json-gobject.h +++ b/json-glib/json-gobject.h @@ -25,7 +25,6 @@ #define __JSON_GOBJECT_H__ #include <json-glib/json-types.h> -#include <glib-object.h> G_BEGIN_DECLS @@ -84,33 +83,42 @@ struct _JsonSerializableIface GValue *value); }; -GType json_serializable_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 +GType json_serializable_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonNode *json_serializable_serialize_property (JsonSerializable *serializable, const gchar *property_name, const GValue *value, GParamSpec *pspec); +JSON_AVAILABLE_IN_1_0 gboolean json_serializable_deserialize_property (JsonSerializable *serializable, const gchar *property_name, GValue *value, GParamSpec *pspec, JsonNode *property_node); +JSON_AVAILABLE_IN_1_0 GParamSpec * json_serializable_find_property (JsonSerializable *serializable, const char *name); +JSON_AVAILABLE_IN_1_0 GParamSpec ** json_serializable_list_properties (JsonSerializable *serializable, guint *n_pspecs); +JSON_AVAILABLE_IN_1_0 void json_serializable_set_property (JsonSerializable *serializable, GParamSpec *pspec, const GValue *value); +JSON_AVAILABLE_IN_1_0 void json_serializable_get_property (JsonSerializable *serializable, GParamSpec *pspec, GValue *value); +JSON_AVAILABLE_IN_1_0 JsonNode *json_serializable_default_serialize_property (JsonSerializable *serializable, const gchar *property_name, const GValue *value, GParamSpec *pspec); +JSON_AVAILABLE_IN_1_0 gboolean json_serializable_default_deserialize_property (JsonSerializable *serializable, const gchar *property_name, GValue *value, @@ -141,38 +149,48 @@ typedef JsonNode *(* JsonBoxedSerializeFunc) (gconstpointer boxed); */ typedef gpointer (* JsonBoxedDeserializeFunc) (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_boxed_register_serialize_func (GType gboxed_type, JsonNodeType node_type, JsonBoxedSerializeFunc serialize_func); +JSON_AVAILABLE_IN_1_0 void json_boxed_register_deserialize_func (GType gboxed_type, JsonNodeType node_type, JsonBoxedDeserializeFunc deserialize_func); +JSON_AVAILABLE_IN_1_0 gboolean json_boxed_can_serialize (GType gboxed_type, JsonNodeType *node_type); +JSON_AVAILABLE_IN_1_0 gboolean json_boxed_can_deserialize (GType gboxed_type, JsonNodeType node_type); +JSON_AVAILABLE_IN_1_0 JsonNode *json_boxed_serialize (GType gboxed_type, gconstpointer boxed); +JSON_AVAILABLE_IN_1_0 gpointer json_boxed_deserialize (GType gboxed_type, JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonNode *json_gobject_serialize (GObject *gobject); +JSON_AVAILABLE_IN_1_0 GObject * json_gobject_deserialize (GType gtype, JsonNode *node); +JSON_AVAILABLE_IN_1_0 GObject * json_gobject_from_data (GType gtype, const gchar *data, gssize length, GError **error); +JSON_AVAILABLE_IN_1_0 gchar * json_gobject_to_data (GObject *gobject, gsize *length); -JSON_DEPRECATED_FOR(json_gobject_from_data) +JSON_DEPRECATED_IN_1_0_FOR(json_gobject_from_data) GObject * json_construct_gobject (GType gtype, const gchar *data, gsize length, GError **error); -JSON_DEPRECATED_FOR(json_gobject_to_data) +JSON_DEPRECATED_IN_1_0_FOR(json_gobject_to_data) gchar * json_serialize_gobject (GObject *gobject, gsize *length) G_GNUC_MALLOC; diff --git a/json-glib/json-gvariant.h b/json-glib/json-gvariant.h index 8fb54e5..38cfc94 100644 --- a/json-glib/json-gvariant.h +++ b/json-glib/json-gvariant.h @@ -32,13 +32,17 @@ G_BEGIN_DECLS +JSON_AVAILABLE_IN_1_0 JsonNode * json_gvariant_serialize (GVariant *variant); +JSON_AVAILABLE_IN_1_0 gchar * json_gvariant_serialize_data (GVariant *variant, gsize *length); +JSON_AVAILABLE_IN_1_0 GVariant * json_gvariant_deserialize (JsonNode *json_node, const gchar *signature, GError **error); +JSON_AVAILABLE_IN_1_0 GVariant * json_gvariant_deserialize_data (const gchar *json, gssize length, const gchar *signature, diff --git a/json-glib/json-parser.h b/json-glib/json-parser.h index 9988915..8666548 100644 --- a/json-glib/json-parser.h +++ b/json-glib/json-parser.h @@ -28,7 +28,6 @@ #error "Only <json-glib/json-glib.h> can be included directly." #endif -#include <glib-object.h> #include <gio/gio.h> #include <json-glib/json-types.h> @@ -141,34 +140,46 @@ struct _JsonParserClass void (* _json_reserved8) (void); }; +JSON_AVAILABLE_IN_1_0 GQuark json_parser_error_quark (void); +JSON_AVAILABLE_IN_1_0 GType json_parser_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonParser *json_parser_new (void); +JSON_AVAILABLE_IN_1_0 gboolean json_parser_load_from_file (JsonParser *parser, const gchar *filename, GError **error); +JSON_AVAILABLE_IN_1_0 gboolean json_parser_load_from_data (JsonParser *parser, const gchar *data, gssize length, GError **error); +JSON_AVAILABLE_IN_1_0 gboolean json_parser_load_from_stream (JsonParser *parser, GInputStream *stream, GCancellable *cancellable, GError **error); +JSON_AVAILABLE_IN_1_0 void json_parser_load_from_stream_async (JsonParser *parser, GInputStream *stream, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); +JSON_AVAILABLE_IN_1_0 gboolean json_parser_load_from_stream_finish (JsonParser *parser, GAsyncResult *result, GError **error); +JSON_AVAILABLE_IN_1_0 JsonNode * json_parser_get_root (JsonParser *parser); +JSON_AVAILABLE_IN_1_0 guint json_parser_get_current_line (JsonParser *parser); +JSON_AVAILABLE_IN_1_0 guint json_parser_get_current_pos (JsonParser *parser); +JSON_AVAILABLE_IN_1_0 gboolean json_parser_has_assignment (JsonParser *parser, gchar **variable_name); diff --git a/json-glib/json-path.h b/json-glib/json-path.h index 272c298..b8ffb91 100644 --- a/json-glib/json-path.h +++ b/json-glib/json-path.h @@ -76,17 +76,23 @@ typedef struct _JsonPath JsonPath; */ typedef struct _JsonPathClass JsonPathClass; +JSON_AVAILABLE_IN_1_0 GType json_path_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 GQuark json_path_error_quark (void); +JSON_AVAILABLE_IN_1_0 JsonPath * json_path_new (void); +JSON_AVAILABLE_IN_1_0 gboolean json_path_compile (JsonPath *path, const char *expression, GError **error); +JSON_AVAILABLE_IN_1_0 JsonNode * json_path_match (JsonPath *path, JsonNode *root); +JSON_AVAILABLE_IN_1_0 JsonNode * json_path_query (const char *expression, JsonNode *root, GError **error); diff --git a/json-glib/json-reader.h b/json-glib/json-reader.h index 37002f0..32e90da 100644 --- a/json-glib/json-reader.h +++ b/json-glib/json-reader.h @@ -112,36 +112,58 @@ struct _JsonReaderClass void (*_json_padding4) (void); }; +JSON_AVAILABLE_IN_1_0 GQuark json_reader_error_quark (void); +JSON_AVAILABLE_IN_1_0 GType json_reader_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonReader * json_reader_new (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_reader_set_root (JsonReader *reader, JsonNode *root); +JSON_AVAILABLE_IN_1_0 const GError * json_reader_get_error (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_is_array (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_read_element (JsonReader *reader, guint index_); +JSON_AVAILABLE_IN_1_0 void json_reader_end_element (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gint json_reader_count_elements (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_is_object (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_read_member (JsonReader *reader, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 void json_reader_end_member (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gint json_reader_count_members (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gchar ** json_reader_list_members (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 const gchar * json_reader_get_member_name (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_is_value (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 JsonNode * json_reader_get_value (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gint64 json_reader_get_int_value (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gdouble json_reader_get_double_value (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 const gchar * json_reader_get_string_value (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_get_boolean_value (JsonReader *reader); +JSON_AVAILABLE_IN_1_0 gboolean json_reader_get_null_value (JsonReader *reader); G_END_DECLS diff --git a/json-glib/json-types.h b/json-glib/json-types.h index 366d0df..9acc23b 100644 --- a/json-glib/json-types.h +++ b/json-glib/json-types.h @@ -29,17 +29,10 @@ #endif #include <glib-object.h> +#include <json-glib/json-version-macros.h> G_BEGIN_DECLS -#ifdef JSON_DISABLE_DEPRECATION_WARNINGS -#define JSON_DEPRECATED -#define JSON_DEPRECATED_FOR(x) -#else -#define JSON_DEPRECATED G_DEPRECATED -#define JSON_DEPRECATED_FOR(x) G_DEPRECATED_FOR(x) -#endif - /** * JSON_NODE_TYPE: * @node: a #JsonNode @@ -183,174 +176,266 @@ typedef void (* JsonArrayForeach) (JsonArray *array, /* * JsonNode */ + +JSON_AVAILABLE_IN_1_0 GType json_node_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_new (JsonNodeType type); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_alloc (void); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init (JsonNode *node, JsonNodeType type); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_object (JsonNode *node, JsonObject *object); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_array (JsonNode *node, JsonArray *array); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_int (JsonNode *node, gint64 value); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_double (JsonNode *node, gdouble value); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_boolean (JsonNode *node, gboolean value); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_string (JsonNode *node, const char *value); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_init_null (JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_copy (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_free (JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonNodeType json_node_get_node_type (JsonNode *node); +JSON_AVAILABLE_IN_1_0 GType json_node_get_value_type (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_parent (JsonNode *node, JsonNode *parent); +JSON_AVAILABLE_IN_1_0 JsonNode * json_node_get_parent (JsonNode *node); +JSON_AVAILABLE_IN_1_0 const gchar * json_node_type_name (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_object (JsonNode *node, JsonObject *object); +JSON_AVAILABLE_IN_1_0 void json_node_take_object (JsonNode *node, JsonObject *object); +JSON_AVAILABLE_IN_1_0 JsonObject * json_node_get_object (JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonObject * json_node_dup_object (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_array (JsonNode *node, JsonArray *array); +JSON_AVAILABLE_IN_1_0 void json_node_take_array (JsonNode *node, JsonArray *array); +JSON_AVAILABLE_IN_1_0 JsonArray * json_node_get_array (JsonNode *node); +JSON_AVAILABLE_IN_1_0 JsonArray * json_node_dup_array (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_value (JsonNode *node, const GValue *value); +JSON_AVAILABLE_IN_1_0 void json_node_get_value (JsonNode *node, GValue *value); +JSON_AVAILABLE_IN_1_0 void json_node_set_string (JsonNode *node, const gchar *value); +JSON_AVAILABLE_IN_1_0 const gchar * json_node_get_string (JsonNode *node); +JSON_AVAILABLE_IN_1_0 gchar * json_node_dup_string (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_int (JsonNode *node, gint64 value); +JSON_AVAILABLE_IN_1_0 gint64 json_node_get_int (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_double (JsonNode *node, gdouble value); +JSON_AVAILABLE_IN_1_0 gdouble json_node_get_double (JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_node_set_boolean (JsonNode *node, gboolean value); +JSON_AVAILABLE_IN_1_0 gboolean json_node_get_boolean (JsonNode *node); +JSON_AVAILABLE_IN_1_0 gboolean json_node_is_null (JsonNode *node); /* * JsonObject */ +JSON_AVAILABLE_IN_1_0 GType json_object_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonObject * json_object_new (void); +JSON_AVAILABLE_IN_1_0 JsonObject * json_object_ref (JsonObject *object); +JSON_AVAILABLE_IN_1_0 void json_object_unref (JsonObject *object); -JSON_DEPRECATED_FOR(json_object_set_member) +JSON_DEPRECATED_IN_1_0_FOR(json_object_set_member) void json_object_add_member (JsonObject *object, const gchar *member_name, JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_object_set_member (JsonObject *object, const gchar *member_name, JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_object_set_int_member (JsonObject *object, const gchar *member_name, gint64 value); +JSON_AVAILABLE_IN_1_0 void json_object_set_double_member (JsonObject *object, const gchar *member_name, gdouble value); +JSON_AVAILABLE_IN_1_0 void json_object_set_boolean_member (JsonObject *object, const gchar *member_name, gboolean value); +JSON_AVAILABLE_IN_1_0 void json_object_set_string_member (JsonObject *object, const gchar *member_name, const gchar *value); +JSON_AVAILABLE_IN_1_0 void json_object_set_null_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 void json_object_set_array_member (JsonObject *object, const gchar *member_name, JsonArray *value); +JSON_AVAILABLE_IN_1_0 void json_object_set_object_member (JsonObject *object, const gchar *member_name, JsonObject *value); +JSON_AVAILABLE_IN_1_0 GList * json_object_get_members (JsonObject *object); +JSON_AVAILABLE_IN_1_0 JsonNode * json_object_get_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 JsonNode * json_object_dup_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 gint64 json_object_get_int_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 gdouble json_object_get_double_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 gboolean json_object_get_boolean_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 const gchar * json_object_get_string_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 gboolean json_object_get_null_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 JsonArray * json_object_get_array_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 JsonObject * json_object_get_object_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 gboolean json_object_has_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 void json_object_remove_member (JsonObject *object, const gchar *member_name); +JSON_AVAILABLE_IN_1_0 GList * json_object_get_values (JsonObject *object); +JSON_AVAILABLE_IN_1_0 guint json_object_get_size (JsonObject *object); +JSON_AVAILABLE_IN_1_0 void json_object_foreach_member (JsonObject *object, JsonObjectForeach func, gpointer data); +JSON_AVAILABLE_IN_1_0 GType json_array_get_type (void) G_GNUC_CONST; +JSON_AVAILABLE_IN_1_0 JsonArray * json_array_new (void); +JSON_AVAILABLE_IN_1_0 JsonArray * json_array_sized_new (guint n_elements); +JSON_AVAILABLE_IN_1_0 JsonArray * json_array_ref (JsonArray *array); +JSON_AVAILABLE_IN_1_0 void json_array_unref (JsonArray *array); +JSON_AVAILABLE_IN_1_0 void json_array_add_element (JsonArray *array, JsonNode *node); +JSON_AVAILABLE_IN_1_0 void json_array_add_int_element (JsonArray *array, gint64 value); +JSON_AVAILABLE_IN_1_0 void json_array_add_double_element (JsonArray *array, gdouble value); +JSON_AVAILABLE_IN_1_0 void json_array_add_boolean_element (JsonArray *array, gboolean value); +JSON_AVAILABLE_IN_1_0 void json_array_add_string_element (JsonArray *array, const gchar *value); +JSON_AVAILABLE_IN_1_0 void json_array_add_null_element (JsonArray *array); +JSON_AVAILABLE_IN_1_0 void json_array_add_array_element (JsonArray *array, JsonArray *value); +JSON_AVAILABLE_IN_1_0 void json_array_add_object_element (JsonArray *array, JsonObject *value); +JSON_AVAILABLE_IN_1_0 GList * json_array_get_elements (JsonArray *array); +JSON_AVAILABLE_IN_1_0 JsonNode * json_array_get_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 gint64 json_array_get_int_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 gdouble json_array_get_double_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 gboolean json_array_get_boolean_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 const gchar * json_array_get_string_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 gboolean json_array_get_null_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 JsonArray * json_array_get_array_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 JsonObject * json_array_get_object_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 JsonNode * json_array_dup_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 void json_array_remove_element (JsonArray *array, guint index_); +JSON_AVAILABLE_IN_1_0 guint json_array_get_length (JsonArray *array); +JSON_AVAILABLE_IN_1_0 void json_array_foreach_element (JsonArray *array, JsonArrayForeach func, gpointer data); diff --git a/json-glib/json-version-macros.h b/json-glib/json-version-macros.h new file mode 100644 index 0000000..dd2ae1c --- /dev/null +++ b/json-glib/json-version-macros.h @@ -0,0 +1,135 @@ +/* json-version-macros.h - JSON-GLib symbol versioning macros + * + * This file is part of JSON-GLib + * Copyright © 2014 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __JSON_VERSION_MACROS_H__ +#define __JSON_VERSION_MACROS_H__ + +#if !defined(__JSON_GLIB_INSIDE__) && !defined(JSON_COMPILATION) +#error "Only <json-glib/json-glib.h> can be included directly." +#endif + +#include "json-version.h" + +#ifndef _JSON_EXTERN +#define _JSON_EXTERN extern +#endif + +#ifdef JSON_DISABLE_DEPRECATION_WARNINGS +#define JSON_DEPRECATED _JSON_EXTERN +#define JSON_DEPRECATED_FOR(f) _JSON_EXTERN +#define JSON_UNAVAILABLE(maj,min) _JSON_EXTERN +#else +#define JSON_DEPRECATED G_DEPRECATED _JSON_EXTERN +#define JSON_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _JSON_EXTERN +#define JSON_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _JSON_EXTERN +#endif + +/* XXX: Each new cycle should add a new version symbol here */ +#define JSON_VERSION_1_0 (G_ENCODE_VERSION (1, 0)) + +/* evaluates to the current stable version; for development cycles, + * this means the next stable target + */ +#if (JSON_MINOR_VERSION == 99) +#define JSON_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION + 1, 0)) +#elif (JSON_MINOR_VERSION % 2) +#define JSON_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION + 1)) +#else +#define JSON_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION)) +#endif + +/* evaluates to the previous stable version */ +#if (JSON_MINOR_VERSION == 99) +#define JSON_VERSION_PREV_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION + 1, 0)) +#elif (JSON_MINOR_VERSION % 2) +#define JSON_VERSION_PREV_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION - 1)) +#else +#define JSON_VERSION_PREV_STABLE (G_ENCODE_VERSION (JSON_MAJOR_VERSION, JSON_MINOR_VERSION - 2)) +#endif + +/** + * JSON_VERSION_MIN_REQUIRED: + * + * A macro that should be defined by the user prior to including + * the gdk.h header. + * The definition should be one of the predefined JSON version + * macros: %JSON_VERSION_1_0, %JSON_VERSION_1_2,... + * + * This macro defines the lower bound for the JSON-GLib API to use. + * + * If a function has been deprecated in a newer version of JSON-GLib, + * it is possible to use this symbol to avoid the compiler warnings + * without disabling warning for every deprecated function. + * + * Since: 1.0 + */ +#ifndef JSON_VERSION_MIN_REQUIRED +# define JSON_VERSION_MIN_REQUIRED (JSON_VERSION_CUR_STABLE) +#endif + +/** + * JSON_VERSION_MAX_ALLOWED: + * + * A macro that should be defined by the user prior to including + * the json-glib.h header. + + * The definition should be one of the predefined JSON-GLib version + * macros: %JSON_VERSION_1_0, %JSON_VERSION_1_2,... + * + * This macro defines the upper bound for the JSON API-GLib to use. + * + * If a function has been introduced in a newer version of JSON-GLib, + * it is possible to use this symbol to get compiler warnings when + * trying to use that function. + * + * Since: 1.0 + */ +#ifndef JSON_VERSION_MAX_ALLOWED +# if JSON_VERSION_MIN_REQUIRED > JSON_VERSION_PREV_STABLE +# define JSON_VERSION_MAX_ALLOWED (JSON_VERSION_MIN_REQUIRED) +# else +# define JSON_VERSION_MAX_ALLOWED (JSON_VERSION_CUR_STABLE) +# endif +#endif + +/* sanity checks */ +#if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_MIN_REQUIRED +#error "JSON_VERSION_MAX_ALLOWED must be >= JSON_VERSION_MIN_REQUIRED" +#endif +#if JSON_VERSION_MIN_REQUIRED < JSON_VERSION_1_0 +#error "JSON_VERSION_MIN_REQUIRED must be >= JSON_VERSION_1_0" +#endif + +/* XXX: Every new stable minor release should add a set of macros here */ + +#if JSON_VERSION_MIN_REQUIRED >= JSON_VERSION_1_0 +# define JSON_DEPRECATED_IN_1_0 JSON_DEPRECATED +# define JSON_DEPRECATED_IN_1_0_FOR(f) JSON_DEPRECATED_FOR(f) +#else +# define JSON_DEPRECATED_IN_1_0 _JSON_EXTERN +# define JSON_DEPRECATED_IN_1_0_FOR(f) _JSON_EXTERN +#endif + +#if JSON_VERSION_MAX_ALLOWED < JSON_VERSION_1_0 +# define JSON_AVAILABLE_IN_1_0 JSON_UNAVAILABLE(1, 0) +#else +# define JSON_AVAILABLE_IN_1_0 _JSON_EXTERN +#endif + +#endif /* __JSON_VERSION_MACROS_H__ */ |