gi-json-1.0.2: JSON GObject bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Json.Callbacks

Description

 
Synopsis

Signals

ArrayForeach

type ArrayForeach Source #

Arguments

 = Array

array: the iterated JSON array

-> Word32

index_: the index of the element

-> Node

elementNode: the value of the element at the given index_

-> IO () 

The function to be passed to [methodjson.Array.foreach_element].

You should not add or remove elements to and from array within this function.

It is safe to change the value of elementNode.

Since: 0.8

type ArrayForeach_WithClosures Source #

Arguments

 = Array

array: the iterated JSON array

-> Word32

index_: the index of the element

-> Node

elementNode: the value of the element at the given index_

-> Ptr ()

userData: data passed to the function

-> IO () 

The function to be passed to [methodjson.Array.foreach_element].

You should not add or remove elements to and from array within this function.

It is safe to change the value of elementNode.

Since: 0.8

type C_ArrayForeach = Ptr Array -> Word32 -> Ptr Node -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

drop_closures_ArrayForeach :: ArrayForeach -> ArrayForeach_WithClosures Source #

A simple wrapper that ignores the closure arguments.

dynamic_ArrayForeach Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> FunPtr C_ArrayForeach 
-> Array

array: the iterated JSON array

-> Word32

index_: the index of the element

-> Node

elementNode: the value of the element at the given index_

-> Ptr ()

userData: data passed to the function

-> m () 

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

mk_ArrayForeach :: C_ArrayForeach -> IO (FunPtr C_ArrayForeach) Source #

Generate a function pointer callable from C code, from a C_ArrayForeach.

BoxedDeserializeFunc

type BoxedDeserializeFunc Source #

Arguments

 = Node

node: a node tree representing a boxed data

-> IO (Ptr ())

Returns: the newly created boxed structure

Deserializes the contents of the passed JsonNode into a GBoxed, for instance:

``@c static gpointer my_point_deserialize (JsonNode *node) { double x = 0.0, y = 0.0;

if (JSON_NODE_HOLDS_ARRAY (node)) { JsonArray *array = json_node_get_array (node);

if (json_array_get_length (array) == 2) { x = json_array_get_double_element (array, 0); y = json_array_get_double_element (array, 1); } } else if (JSON_NODE_HOLDS_OBJECT (node)) { JsonObject *obj = json_node_get_object (node);

x = json_object_get_double_member_with_default (obj, "x", 0.0); y = json_object_get_double_member_with_default (obj, "y", 0.0); }

// my_point_new() is defined elsewhere return my_point_new (x, y); } @``

Since: 0.10

type C_BoxedDeserializeFunc = Ptr Node -> IO (Ptr ()) Source #

Type for the callback on the (unwrapped) C side.

dynamic_BoxedDeserializeFunc Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> FunPtr C_BoxedDeserializeFunc 
-> Node

node: a node tree representing a boxed data

-> m (Ptr ())

Returns: the newly created boxed structure

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

mk_BoxedDeserializeFunc :: C_BoxedDeserializeFunc -> IO (FunPtr C_BoxedDeserializeFunc) Source #

Generate a function pointer callable from C code, from a C_BoxedDeserializeFunc.

BoxedSerializeFunc

type BoxedSerializeFunc Source #

Arguments

 = Ptr ()

boxed: a boxed data structure

-> IO Node

Returns: the newly created JSON node tree representing the boxed data

Serializes the passed GBoxed and stores it inside a JsonNode, for instance:

``@c static JsonNode * my_point_serialize (gconstpointer boxed) { const MyPoint *point = boxed;

g_autoptr(JsonBuilder) builder = json_builder_new ();

json_builder_begin_object (builder); json_builder_set_member_name (builder, "x"); json_builder_add_double_value (builder, point->x); json_builder_set_member_name (builder, "y"); json_builder_add_double_value (builder, point->y); json_builder_end_object (builder);

return json_builder_get_root (builder); } @``

Since: 0.10

type C_BoxedSerializeFunc = Ptr () -> IO (Ptr Node) Source #

Type for the callback on the (unwrapped) C side.

dynamic_BoxedSerializeFunc Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> FunPtr C_BoxedSerializeFunc 
-> Ptr ()

boxed: a boxed data structure

-> m Node

Returns: the newly created JSON node tree representing the boxed data

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

mk_BoxedSerializeFunc :: C_BoxedSerializeFunc -> IO (FunPtr C_BoxedSerializeFunc) Source #

Generate a function pointer callable from C code, from a C_BoxedSerializeFunc.

ObjectForeach

type C_ObjectForeach = Ptr Object -> CString -> Ptr Node -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type ObjectForeach Source #

Arguments

 = Object

object: the iterated JSON object

-> Text

memberName: the name of the member

-> Node

memberNode: the value of the member

-> IO () 

The function to be passed to [methodjson.Object.foreach_member].

You should not add or remove members to and from object within this function.

It is safe to change the value of memberNode.

Since: 0.8

type ObjectForeach_WithClosures Source #

Arguments

 = Object

object: the iterated JSON object

-> Text

memberName: the name of the member

-> Node

memberNode: the value of the member

-> Ptr ()

userData: data passed to the function

-> IO () 

The function to be passed to [methodjson.Object.foreach_member].

You should not add or remove members to and from object within this function.

It is safe to change the value of memberNode.

Since: 0.8

drop_closures_ObjectForeach :: ObjectForeach -> ObjectForeach_WithClosures Source #

A simple wrapper that ignores the closure arguments.

dynamic_ObjectForeach Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> FunPtr C_ObjectForeach 
-> Object

object: the iterated JSON object

-> Text

memberName: the name of the member

-> Node

memberNode: the value of the member

-> Ptr ()

userData: data passed to the function

-> m () 

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

mk_ObjectForeach :: C_ObjectForeach -> IO (FunPtr C_ObjectForeach) Source #

Generate a function pointer callable from C code, from a C_ObjectForeach.