mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-07 08:28:43 +02:00
Add copy and free function annotations for POD types
Plain Old Data (POD) types with or without a representation in the GType type system can still have a copy and/or a free function. We should allow annotating these types with their corresponding functions for copying their data into a new instance, and freeing their data. From a language bindings perspective, POD types should have a boxed GType wrapper around them, so they can use the generic GBoxed API to copy and free instances; from a documentation perspective, though, it'd be good to have a way to match a structured type, like a struct or a union, with its copy and free functions. In order to do that, we add two new header block annotations: - (copy-func function_name) - (free-func function_name) These annotations work exactly like ref-func and unref-func for typed instances: /** * GdkRGBA: (copy-func gdk_rgba_copy) * (free-func gdk_rgba_free) * @red: ... * @green: ... * @blue: ... * @alpha: ... * * ... */ The function is stored in the GIR data as two new attributes for the `<record>` and `<union>` elements: <record name="RGBA" c:type="GdkRGBA" copy-function="gdk_rgba_copy" free-function="gdk_rgba_free" glib:type-name="GdkRGBA" glib:get-type="gdk_rgba_get_type" c:symbol-prefix="gdk_rgba"> The annotations are not mandatory. See: #14
This commit is contained in:
@@ -77,6 +77,12 @@ gsize g_union_info_get_size (GIUnionInfo *info);
|
||||
GI_AVAILABLE_IN_ALL
|
||||
gsize g_union_info_get_alignment (GIUnionInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_1_76
|
||||
const char * g_union_info_get_copy_function (GIUnionInfo *info);
|
||||
|
||||
GI_AVAILABLE_IN_1_76
|
||||
const char * g_union_info_get_free_function (GIUnionInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user