| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add a dependencies file, so that valac can simply use the json-glib-1.0
package and correcly chain up all the dependencies needed (at the moment,
only glib-2.0).
Update the vapi file to match with the GLib bindings with regards to the
out length parameters and some weak pointers. The only way to properly
solve the weak assignments issue would be to make JsonNode, JsonObject
and JsonArray proper GObjects, or at least add reference counting to
JsonNode. Not going to happend in 0.6, but it's worth adding it to the
1.0 roadmap.
|
|
|
|
|
| |
Rules starting with '%' are a make-isms, and automake 1.10 complains a
lot about them.
|
|
|
|
|
| |
The json_parser_peek_root() function has been removed, and so we do not
its symbol in the json-glib-sections.txt file anymore.
|
|
|
|
|
| |
Do not free the root node returned by the get_root() method in the
JSON-GObject API and in the JsonParser tests.
|
|
|
|
|
|
|
|
|
| |
The get_root() method should not return a copy of the parsed node: it is
up to the developer copying it, if it needs to be kept around across multiple
parsing runs.
This commit reverts the 0b6b09c0 commit, by removing the peek_root() method
and restoring the previous get_root() method behaviour.
|
|
|
|
|
| |
The json_object_has_member() used the passed in member name, instead of
the correctly normalized one.
|
|
|
|
|
|
|
|
| |
The JsonParser object clears its state upon starting the parsing sequence
or during the instance destruction process. It's worth moving the free
and unref calls into their own function to be called by the load_from_data()
and dispose methods. As further optimisation, inlining them should be
worth as well.
|
|
|
|
|
| |
Including the autotools generated config.h should always be conditional
on the HAVE_CONFIG_H definitions.
|
|
|
|
| |
Use an intermediary pointer to avoid a lot of pointer dereferences
|
|
|
|
|
|
|
|
| |
Expose the properties as members and remove the accessor methods in case
it's obvious that they are just function proxies.
Also, start binding the basic GObject API, even though no serializable
support is ready, yet.
|
|
|
|
|
|
|
|
| |
The JsonSerializable interface can provide a default implementation, using
the powers of GTypeInterface. This means that classes implementing the
interface can opt to implement both, either or none of the JsonSerializable
methods, and still be able to retain some basic functionality for the methods
they decide not to implement.
|
|
|
|
|
|
| |
When the same JsonParser loads a different buffer it needs to clear out the
current state; this means clearing the variable_name string it saves when
the passed JSON stream is a JavaScript assignment.
|
|
|
|
|
|
|
| |
Since we allow a negative value, meaning "take the whole string", for the
length parameter, when need a signed size_t. This also fixes the bug where
we implicitly always computed the buffer length and discarded the passed
length parameter.
|
|
|
|
| |
Avoid feeding garbage to the callers by using g_slice_new0().
|
|
|
|
| |
Found this very dumb leak while using Valgrind.
|
|
|
|
|
|
| |
The pointer returned by g_value_get_boxed() is just a pointer to the internal
copy inside GValue, and it's not ours to free, as Valgrind gently pointed
out.
|
|
|
|
|
|
| |
We don't provide the Serializable interface at the moment, because it
is too much C-oriented. This example shows how to serialize a class in
Vala to a JSON string.
|
| |
|
|
|
|
|
|
|
|
|
| |
Miscellaneous fixes for the Vala bindings of JSON-GLib:
* add missing return values for a couple of methods
* decorate the Object and Array constructors with their C names
* correctly transfer the ownership when adding members/elements
* add the non-null value marker for strings
* provide default values for the length argument in from_data()/to_data()
|
|
|
|
|
|
| |
If Vala is not available then there's no point in getting into the
contrib directory. This might change in the future, so we already
have the HAVE_VALA conditional for the Makefiles.
|
| |
|
|
|
|
|
| |
Add the Json.Object.dup_member() and Json.Array.dup_element() functions.
Also, export the JSON_NODE_TYPE() macro as Json.Node.type() method.
|
| |
|
|
|
|
|
|
| |
Getting copies of the nodes might work better for high level languages
binding the JSON-GLib API, because they can manage the lifetime of the
returned values using their own rules.
|
|
|
|
|
| |
Dispose the root node when using the JsonParser and JsonGenerator
objects after the change in sematics for their accessors.
|
|
|
|
|
| |
Update json_construct_gobject() to the change of behaviour in the
root node getter function of JsonParser.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The json_parser_get_root() returns a pointer to the root node. This does
not conform to the API naming convention inherited from GLib, where
functions returning an internal pointer are called "peek" and function
returning a copy are called "get".
Thus, json_parser_get_root() will now return a copy of the root node and
it is left to the developer to free the returned JsonNode.
A function returning the pointer has also been added, and it's called
json_parser_peek_root().
|
|
|
|
| |
Add bindings for the basic JSON-GLib API. GObject API will arrive later.
|
|
|
|
|
| |
The indent character should be any Unicode character available instead
of a generic char.
|
|
|
|
|
| |
The JsonGenerator:indent-char can be used to control the character that
indents the lines when pretty printing.
|
|
|
|
|
| |
JsonNode of type value for floating point numbers is G_TYPE_DOUBLE
and not G_TYPE_FLOAT anymore.
|
|
|
|
|
| |
Update the GObject deserialization test suite to check for the correct
deserialization of the enum/flags values.
|
|
|
|
|
|
|
|
| |
If the target value is a G_TYPE_ENUM or a G_TYPE_FLAGS we can effectively
deserialize a string into the corresponding value (or bit mask) using
the introspection API for the GEnum and GFlags types.
This code is taken from ClutterScript and it was adapted from GtkBuilder.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
We provide fallbacks in case a JsonSerializable object does not translate
a property into a JSON object member and vice versa.
|
| |
|
|\ |
|
| |
| |
| |
| |
| |
| |
| | |
To avoid reimplementing the same code all over again, if the implementation
of the serialize_property virtual function of JsonSerializable returns NULL
we will fall back to the simple value-to-node generator we provide for
non-serializable classes.
|
| | |
|
| |
| |
| |
| |
| |
| | |
We need to skip if the CONSTRUCT_ONLY flag is set, not unset. We also need
to copy the value from the JSON node into the target GValue, not the other
way around.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The fallback parser for json_construct_gobject() is invoked if the GType
does not implement the JsonSerializable interface, or if the interface
was not handling the property.
It will natively convert integers, booleans, strings and double precision
floating point values; it also handles string vectors in form of arrays.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
JsonGenerator now has a :root property, so it can be constructed using
just g_object_new():
generator = g_object_new (JSON_TYPE_GENERATOR,
"pretty", TRUE,
"indent", 4,
"root", node,
NULL);
This means that the root node is copied inside the generator, instead of
just taking ownership (it was quite confusing). The documentation now
clearly states what happens, and that you can safely free the node after
feeding it to the JsonGenerator.
|
| |
| |
| |
| | |
JsonNode payload is inside a union.
|
| |
| |
| |
| |
| |
| | |
We need a GType for nodes if we want to add JsonNode properties or signal
marshallers to a GObject class. We could use pointers, but we'd loose type
safety, so it's a no-no.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The json_construct_gobject() function takes a GType and a JSON data stream
and constructs a new instance for the given type. If the type is a
JsonSerializable, it will use the JsonSerializable interface for parsing
the JsonNodes of each object member.
This is the initial implementation of the function: the JsonNode-to-GValue
fallback parser is just a stub.
|
| |
| |
| |
| |
| |
| | |
There's no end to web developers insanity when they can twist and turn a
perfectly simple and elegant notation into something that allows lazyness
and breakage.
|