Vuo 2.4.2
Loading...
Searching...
No Matches
Functions

Description

Functions to serialize, unserialize, and summarize values of the type.

Replace "MyType" with the name of your type.

Functions

MyType MyType_makeFromJson (json_object *js)
 Creates a new MyType value by unserializing a JSON-C object. More...
 
json_objectMyType_getJson (const MyType value)
 Serializes a MyType value to a JSON-C object. More...
 
struct json_objectMyType_getInterprocessJson (const MyType value)
 Serializes a MyType value to a JSON-formatted string, in a format that will allow another process to unserialize it. More...
 
VuoList_MyType MyType_getAllowedValues (void)
 Returns a list of values that instances of this type can have. More...
 
char * MyType_getSummary (const MyType value)
 Returns a brief description of a value. More...
 
char * MyType_getString (const MyType value)
 Serializes a MyType value to a JSON-formatted string. More...
 
char * MyType_getInterprocessString (const MyType value)
 Serializes a MyType value to a JSON-formatted string, in a format that will allow another process to unserialize it. More...
 
void MyType_retain (const MyType value)
 Increments the reference count of a value or its fields, if needed. More...
 
void MyType_release (const MyType value)
 Decrements the reference count of a value or its fields, if needed. More...
 

Function Documentation

◆ MyType_getAllowedValues()

VuoList_MyType MyType_getAllowedValues ( void  )

Returns a list of values that instances of this type can have.

The values returned by this function are shown in input editor menus, in the order specified.

The type may have other values not returned by this function (for example, if the values were allowed in older versions of the type, but are not allowed now).

This function is required for enum types, and should only be defined for types whose sizeof() = 4 (enum, int64_t, void *, char *, etc).

◆ MyType_getInterprocessJson()

struct json_object * MyType_getInterprocessJson ( const MyType  value)

Serializes a MyType value to a JSON-formatted string, in a format that will allow another process to unserialize it.

If this function is implemented, then MyType_makeFromJson() needs to handle both the format returned by this function and the format returned by MyType_getJson().

This function is optional.

Parameters
valueThe value to serialize. May be null.
Returns
A JSON-C object. It should have a format accepted by MyType_makeFromJson(). The caller is responsible for releasing it with json_object_put().
See also
VuoImage

◆ MyType_getInterprocessString()

char * MyType_getInterprocessString ( const MyType  value)

Serializes a MyType value to a JSON-formatted string, in a format that will allow another process to unserialize it.

Calls MyType_getInterprocessJson().

This function is automatically generated by the Vuo compiler (but only if MyType_getInterprocessJson() exists). Do not implement it. If this function needs to be called by MyType or other code, then declare it in MyType.

Parameters
valueThe value to serialize.
Returns
A JSON-formatted string representation of the value. The caller is responsible for freeing the string.

◆ MyType_getJson()

json_object * MyType_getJson ( const MyType  value)

Serializes a MyType value to a JSON-C object.

This function is required.

If this function serializes the value in a format that won't allow another process to unserialize it (for example, if the serialization contains a memory address), then MyType_getInterprocessJson() needs to be implemented, too.

When implementing this function — If value is being serialized in a format that can only be used within the same process, then you should retain value with MyType_retain().

Parameters
valueThe value to serialize. May be null.
Returns
A JSON-C object. It should have a format accepted by MyType_makeFromJson(). The caller is responsible for releasing it with json_object_put().

◆ MyType_getString()

char * MyType_getString ( const MyType  value)

Serializes a MyType value to a JSON-formatted string.

Calls MyType_getJson().

This function is automatically generated by the Vuo compiler. Do not implement it. If this function needs to be called by MyType or other code, then declare it in MyType.

Parameters
valueThe value to serialize.
Returns
A JSON-formatted string representation of the value. The caller is responsible for freeing the string.

◆ MyType_getSummary()

char * MyType_getSummary ( const MyType  value)

Returns a brief description of a value.

This function is required.

For enum types, the string returned by this function is shown in input editor menus.

Parameters
valueThe value to summarize. May be null.
Returns
The summary. It should be heap-allocated; the caller is responsible for freeing it.

◆ MyType_makeFromJson()

MyType MyType_makeFromJson ( json_object js)

Creates a new MyType value by unserializing a JSON-C object.

This function is required.

When implementing this function — For heap-allocated types, you should register the value with VuoRegister(). In addition, if the value was serialized by MyType_getJson() to a format that can only be used within the same process, you should call json_object_set_userdata() and pass a callback that releases the unserialized value with MyType_release().

When calling this function — You should subsequently retain the return value with MyType_retain() and then release js with json_object_put(), in that order. This is important when working with values serialized for use within the same process because json_object_put() decrements the reference count of the value (thanks to the json_object_set_userdata() callback mentioned above).

Example:
MyType value = MyType_makeFromJson(js);
json_object_put(js);
// … use value …
Parameters
jsA JSON-C object from MyType_getJson() (or MyType_getInterprocessJson() if it exists).
Returns
The unserialized value. For heap-allocated types, this value has been registered. The caller is responsible for retaining and releasing it.

◆ MyType_release()

void MyType_release ( const MyType  value)

Decrements the reference count of a value or its fields, if needed.

  • If MyType is a pointer, this function calls VuoRelease() on value.
  • If MyType is a struct, this function calls VuoRelease() on each field of value that is a pointer.
  • Otherwise, this function does nothing.

This function is automatically generated by the Vuo compiler. Do not implement it. If this function needs to be called by MyType or other code, then declare it in MyType.

◆ MyType_retain()

void MyType_retain ( const MyType  value)

Increments the reference count of a value or its fields, if needed.

  • If MyType is a pointer, this function calls VuoRetain() on value.
  • If MyType is a struct, this function calls VuoRetain() on each field of value that is a pointer.
  • Otherwise, this function does nothing.

This function is automatically generated by the Vuo compiler. Do not implement it. If this function needs to be called by MyType or other code, then declare it in MyType.