diff options
author | Jens Georg <mail@jensge.org> | 2021-05-20 12:50:11 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2021-05-24 08:03:44 +0000 |
commit | b430fd94fe71957fca76b7d01523f905e7fa7612 (patch) | |
tree | b0684aaba417b0812a1167e119c436dc4cf4a402 | |
parent | 0cedf004b4730da8d8533ae6a38efa97553430f1 (diff) | |
download | gupnp-b430fd94fe71957fca76b7d01523f905e7fa7612.tar.gz |
service-introspection: Make GI introspectable
-rw-r--r-- | libgupnp/gupnp-service-introspection.c | 56 | ||||
-rw-r--r-- | libgupnp/gupnp-service-introspection.h | 11 |
2 files changed, 58 insertions, 9 deletions
diff --git a/libgupnp/gupnp-service-introspection.c b/libgupnp/gupnp-service-introspection.c index 9463b34..21b9f8e 100644 --- a/libgupnp/gupnp-service-introspection.c +++ b/libgupnp/gupnp-service-introspection.c @@ -103,10 +103,23 @@ gupnp_service_state_variable_info_free } g_list_free_full (variable->allowed_values, g_free); +} + +static void +gupnp_service_state_variable_info_free ( + GUPnPServiceStateVariableInfo *variable); - g_slice_free (GUPnPServiceStateVariableInfo, variable); +static void +gupnp_service_state_variable_info_relase (GUPnPServiceStateVariableInfo *info) +{ + g_rc_box_release_full (info, (GDestroyNotify)gupnp_service_state_variable_info_free); } +G_DEFINE_BOXED_TYPE(GUPnPServiceStateVariableInfo, + gupnp_service_state_variable_info, + g_rc_box_acquire, + gupnp_service_state_variable_info_relase) + static void gupnp_service_introspection_init (GUPnPServiceIntrospection *introspection) { @@ -147,10 +160,22 @@ gupnp_service_action_arg_info_free (GUPnPServiceActionArgInfo *argument) { g_free (argument->name); g_free (argument->related_state_variable); +} - g_slice_free (GUPnPServiceActionArgInfo, argument); +static void +gupnp_service_action_arg_info_unref (GUPnPServiceActionArgInfo *argument) +{ + g_rc_box_release_full ( + argument, + (GDestroyNotify) gupnp_service_action_arg_info_free); } +G_DEFINE_BOXED_TYPE (GUPnPServiceActionArgInfo, + gupnp_service_action_arg_info, + g_rc_box_acquire, + gupnp_service_action_arg_info_unref) + + /** * gupnp_service_action_info_free: * @argument: A #GUPnPServiceActionInfo @@ -163,10 +188,23 @@ gupnp_service_action_info_free (GUPnPServiceActionInfo *action_info) { g_free (action_info->name); g_list_free_full (action_info->arguments, - (GDestroyNotify) gupnp_service_action_arg_info_free); - g_slice_free (GUPnPServiceActionInfo, action_info); + (GDestroyNotify) gupnp_service_action_arg_info_unref); +} + + +static void +gupnp_service_action_info_unref (GUPnPServiceActionInfo *argument) +{ + g_rc_box_release_full ( + argument, + (GDestroyNotify) gupnp_service_action_info_free); } +G_DEFINE_BOXED_TYPE (GUPnPServiceActionInfo, + gupnp_service_action_info, + g_rc_box_acquire, + gupnp_service_action_info_unref) + static void gupnp_service_introspection_finalize (GObject *object) { @@ -177,10 +215,10 @@ gupnp_service_introspection_finalize (GObject *object) priv = gupnp_service_introspection_get_instance_private (introspection); g_list_free_full (priv->variables, - (GDestroyNotify) gupnp_service_state_variable_info_free); + (GDestroyNotify) gupnp_service_state_variable_info_relase); g_list_free_full (priv->actions, - (GDestroyNotify) gupnp_service_action_info_free); + (GDestroyNotify) gupnp_service_action_info_unref); /* Contents don't need to be freed, they were owned by priv->variables */ @@ -466,7 +504,7 @@ get_state_variable (xmlNodePtr variable_node) return NULL; } - variable = g_slice_new0 (GUPnPServiceStateVariableInfo); + variable = g_rc_box_new0(GUPnPServiceStateVariableInfo); success = set_variable_type (variable, data_type); g_free (data_type); @@ -522,7 +560,7 @@ get_action_argument (xmlNodePtr argument_node) return NULL; } - argument = g_slice_new0 (GUPnPServiceActionArgInfo); + argument = g_rc_box_new0 (GUPnPServiceActionArgInfo); argument->name = name; argument->related_state_variable = state_var; @@ -604,7 +642,7 @@ get_actions (xmlNode *list_element) if (!name) continue; - action_info = g_slice_new0 (GUPnPServiceActionInfo); + action_info = g_rc_box_new0 (GUPnPServiceActionInfo); action_info->name = name; action_info->arguments = get_action_arguments (action_node); diff --git a/libgupnp/gupnp-service-introspection.h b/libgupnp/gupnp-service-introspection.h index a13ea84..1ee8e06 100644 --- a/libgupnp/gupnp-service-introspection.h +++ b/libgupnp/gupnp-service-introspection.h @@ -31,6 +31,10 @@ G_BEGIN_DECLS #define GUPNP_TYPE_SERVICE_INTROSPECTION \ (gupnp_service_introspection_get_type ()) +#define GUPNP_TYPE_SERVICE_ACTION_INFO (gupnp_service_action_info_get_type()) +#define GUPNP_TYPE_SERVICE_ACTION_ARG_INFO (gupnp_service_action_arg_info_get_type()) + + G_DECLARE_FINAL_TYPE (GUPnPServiceIntrospection, gupnp_service_introspection, GUPNP, @@ -66,6 +70,8 @@ typedef struct { char *related_state_variable; gboolean retval; } GUPnPServiceActionArgInfo; +GType +gupnp_service_action_arg_info_get_type (void); /** * GUPnPServiceActionInfo: @@ -80,6 +86,9 @@ typedef struct { GList *arguments; /* list of #GUPnPServiceActionArgInfo */ } GUPnPServiceActionInfo; +GType +gupnp_service_action_info_get_type (void); + /** * GUPnPServiceStateVariableInfo: * @name: The name of the state variable. @@ -112,6 +121,8 @@ typedef struct { GList *allowed_values; } GUPnPServiceStateVariableInfo; +GType +gupnp_service_state_variable_info_get_type (void); const GList * gupnp_service_introspection_list_action_names |