--- a/gflib/gflib/gf_type.c Sun Oct 11 04:19:48 2009 -0500
+++ b/gflib/gflib/gf_type.c Sun Oct 11 04:37:30 2009 -0500
@@ -19,25 +19,25 @@
#include <gflib/gf_intl.h>
-#define GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), GF_TYPE_TYPE_PARSE_CONTEXT, GfTypeParseContextPrivate))
+#define GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GF_TYPE_TYPE_QUERY_CONTEXT, GfTypeQueryContextPrivate)) /******************************************************************************
*****************************************************************************/
GDestroyNotify destroy_notify;
-} GfTypeParseContextPrivate;
+} GfTypeQueryContextPrivate; /******************************************************************************
*****************************************************************************/
@@ -49,10 +49,10 @@
static GObjectClass *parent_class = NULL;
/******************************************************************************
*****************************************************************************/
-gf_type_parse_context_real_params(GfTypeParseContextPrivate *priv,
+gf_type_query_context_real_params(GfTypeQueryContextPrivate *priv, GParamSpec **pspecs = NULL;
@@ -60,14 +60,14 @@
pspecs = g_object_class_list_properties(klass, &n_pspecs);
for(p = 0; p < n_pspecs; p++)
- if(priv->parser->param)
- priv->parser->param(pspecs[p]);
+ priv->query->param(pspecs[p]); -gf_type_parse_context_real_signals(GfTypeParseContextPrivate *priv,
+gf_type_query_context_real_signals(GfTypeQueryContextPrivate *priv, guint *signal_ids = NULL, n_ids = 0, s = 0;
@@ -78,15 +78,15 @@
g_signal_query(signal_ids[s], &query);
- if(priv->parser->signal)
- priv->parser->signal(&query);
+ if(priv->query->signal) + priv->query->signal(&query); -gf_type_parse_context_real_parse_object(GfTypeParseContextPrivate *priv,
+gf_type_query_context_real_query_object(GfTypeQueryContextPrivate *priv, GObjectClass *klass = NULL;
@@ -99,24 +99,24 @@
g_type_query(type, &query);
- if(priv->parser->start_object)
- priv->parser->start_object(&query);
+ if(priv->query->start_object) + priv->query->start_object(&query); - /* if the parser doesn't have a function for params signals don't bother
+ /* if the query doesn't have a function for params signals don't bother * with digging through them.
- if(priv->parser->param)
- gf_type_parse_context_real_params(priv, klass);
+ gf_type_query_context_real_params(priv, klass); - if(priv->parser->signal)
- gf_type_parse_context_real_signals(priv, type);
+ if(priv->query->signal) + gf_type_query_context_real_signals(priv, type); /* we're done with this object. finish it up before moving to it's
- if(priv->parser->end_object)
- priv->parser->end_object(&query);
+ if(priv->query->end_object) + priv->query->end_object(&query); /* now dig through the children */
types = g_type_children(type, NULL);
@@ -125,7 +125,7 @@
child = g_type_class_ref(types[t]);
- gf_type_parse_context_real_parse_object(priv, types[t]);
+ gf_type_query_context_real_query_object(priv, types[t]); g_type_class_unref(child);
@@ -135,36 +135,36 @@
-gf_type_parse_context_real_parse(GfTypeParseContext *ctx, GType type) {
- GfTypeParseContextPrivate *priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+gf_type_query_context_real_query(GfTypeQueryContext *ctx, GType type) { + GfTypeQueryContextPrivate *priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx); - gf_type_parse_context_real_parse_object(priv, type);
+ gf_type_query_context_real_query_object(priv, type); /******************************************************************************
*****************************************************************************/
-gf_type_parse_context_set_parser(GfTypeParseContext *ctx,
+gf_type_query_context_set_query(GfTypeQueryContext *ctx, - GfTypeParseContextPrivate *priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+ GfTypeQueryContextPrivate *priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx);
-gf_type_parse_context_set_data(GfTypeParseContext *ctx, gpointer data) {
- GfTypeParseContextPrivate *priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+gf_type_query_context_set_data(GfTypeQueryContext *ctx, gpointer data) { + GfTypeQueryContextPrivate *priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx); -gf_type_parse_context_set_destroy_notify(GfTypeParseContext *ctx,
+gf_type_query_context_set_destroy_notify(GfTypeQueryContext *ctx, GDestroyNotify destroy_notify)
- GfTypeParseContextPrivate *priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+ GfTypeQueryContextPrivate *priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx); priv->destroy_notify = destroy_notify;
@@ -173,22 +173,22 @@
*****************************************************************************/
-gf_type_parse_context_get_property(GObject *obj, guint param_id, GValue *value,
+gf_type_query_context_get_property(GObject *obj, guint param_id, GValue *value, - GfTypeParseContext *ctx = GF_TYPE_PARSE_CONTEXT(obj);
+ GfTypeQueryContext *ctx = GF_TYPE_QUERY_CONTEXT(obj);
- g_value_set_pointer(value, gf_type_parse_context_get_parser(ctx));
+ g_value_set_pointer(value, gf_type_query_context_get_query(ctx)); g_value_set_pointer(value,
- gf_type_parse_context_get_user_data(ctx));
+ gf_type_query_context_get_user_data(ctx)); case PROP_DESTROY_NOTIFY:
g_value_set_pointer(value,
- gf_type_parse_context_get_destroy_notify(ctx));
+ gf_type_query_context_get_destroy_notify(ctx)); G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -197,20 +197,20 @@
-gf_type_parse_context_set_property(GObject *obj, guint param_id,
+gf_type_query_context_set_property(GObject *obj, guint param_id, const GValue *value, GParamSpec *pspec)
- GfTypeParseContext *ctx = GF_TYPE_PARSE_CONTEXT(obj);
+ GfTypeQueryContext *ctx = GF_TYPE_QUERY_CONTEXT(obj);
- gf_type_parse_context_set_parser(ctx, g_value_get_pointer(value));
+ gf_type_query_context_set_query(ctx, g_value_get_pointer(value)); - gf_type_parse_context_set_data(ctx, g_value_get_pointer(value));
+ gf_type_query_context_set_data(ctx, g_value_get_pointer(value)); case PROP_DESTROY_NOTIFY:
- gf_type_parse_context_set_destroy_notify(ctx,
+ gf_type_query_context_set_destroy_notify(ctx, (GDestroyNotify)g_value_get_pointer(value));
@@ -220,8 +220,8 @@
-gf_type_parse_context_finalize(GObject *obj) {
- GfTypeParseContextPrivate *priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(obj);
+gf_type_query_context_finalize(GObject *obj) { + GfTypeQueryContextPrivate *priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(obj); priv->destroy_notify(priv->data);
@@ -230,22 +230,22 @@
-gf_type_parse_context_class_init(GfTypeParseContextClass *klass) {
+gf_type_query_context_class_init(GfTypeQueryContextClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
- g_type_class_add_private(klass, sizeof(GfTypeParseContextPrivate));
+ g_type_class_add_private(klass, sizeof(GfTypeQueryContextPrivate)); - obj_class->get_property = gf_type_parse_context_get_property;
- obj_class->set_property = gf_type_parse_context_set_property;
- obj_class->finalize = gf_type_parse_context_finalize;
+ obj_class->get_property = gf_type_query_context_get_property; + obj_class->set_property = gf_type_query_context_set_property; + obj_class->finalize = gf_type_query_context_finalize; - klass->parse = gf_type_parse_context_real_parse;
+ klass->query = gf_type_query_context_real_query; - g_object_class_install_property(obj_class, PROP_PARSER,
- g_param_spec_pointer("parser", P_("parser"),
- P_("The GfTypeParser to use."),
+ g_object_class_install_property(obj_class, PROP_QUERYR, + g_param_spec_pointer("query", P_("query"), + P_("The GfTypeQuery to use."), G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(obj_class, PROP_DATA,
@@ -264,24 +264,24 @@
*****************************************************************************/
-gf_type_parse_context_get_type(void) {
+gf_type_query_context_get_type(void) { if(G_UNLIKELY(type == 0)) {
static const GTypeInfo info = {
- sizeof(GfTypeParseContextClass),
+ sizeof(GfTypeQueryContextClass), - (GClassInitFunc)gf_type_parse_context_class_init,
+ (GClassInitFunc)gf_type_query_context_class_init, - sizeof(GfTypeParseContext),
+ sizeof(GfTypeQueryContext), type = g_type_register_static(G_TYPE_OBJECT,
@@ -289,102 +289,101 @@
- * gf_type_parse_context_new:
- * @parser: A #GfTypeParser.
- * @data: user data to pass to the #GfTypeParser functions.
+ * gf_type_query_context_new: + * @query: A #GfTypeQuery. + * @data: user data to pass to the #GfTypeQuery functions. * @destroy_notify: A function to free @data.
- * Creates a new #GfTypeParseContext using @parser.
+ * Creates a new #GfTypeQueryContext using @query. - * Return Value: The new #GfTypeParseContext.
+ * Return Value: The new #GfTypeQueryContext.
-gf_type_parse_context_new(GfTypeParser *parser, gpointer data,
+gf_type_query_context_new(GfTypeQuery *query, gpointer data, GDestroyNotify destroy_notify)
- g_return_val_if_fail(parser, NULL);
+ g_return_val_if_fail(query, NULL); - return g_object_new(GF_TYPE_TYPE_PARSE_CONTEXT,
+ return g_object_new(GF_TYPE_TYPE_QUERY_CONTEXT, "destroy-notify", destroy_notify,
- * gf_type_parse_context_parse:
- * @ctx: The #GfTypeParseContext instance.
+ * gf_type_query_context_run: + * @ctx: The #GfTypeQueryContext instance. * @type: The #GType to start the parsing at.
- * Parses through all types descending from @type as well as @type itself.
+ * Querys through all types descending from @type as well as @type itself. -gf_type_parse_context_parse(GfTypeParseContext *ctx, GType type)
- GfTypeParseContextClass *klass = NULL;
+gf_type_query_context_run(GfTypeQueryContext *ctx, GType type) { + GfTypeQueryContextClass *klass = NULL; - g_return_if_fail(GF_IS_TYPE_PARSE_CONTEXT(ctx));
+ g_return_if_fail(GF_IS_TYPE_QUERY_CONTEXT(ctx)); g_return_if_fail(type != G_TYPE_INVALID);
- klass = GF_TYPE_PARSE_CONTEXT_GET_CLASS(ctx);
+ klass = GF_TYPE_QUERY_CONTEXT_GET_CLASS(ctx); - if(klass && klass->parse)
- klass->parse(ctx, type);
+ if(klass && klass->query) + klass->query(ctx, type); - * gf_type_parse_context_get_parser:
- * @ctx: The #GfTypeParseContext instance.
+ * gf_type_query_context_get_query: + * @ctx: The #GfTypeQueryContext instance. - * Gets the #GfTypeParser used in @ctx.
+ * Gets the #GfTypeQuery used in @ctx. - * Return Value: The #GfTypeParser used in @ctx.
+ * Return Value: The #GfTypeQuery used in @ctx.
-gf_type_parse_context_get_parser(const GfTypeParseContext *ctx) {
- GfTypeParseContextPrivate *priv = NULL;
+gf_type_query_context_get_query(const GfTypeQueryContext *ctx) { + GfTypeQueryContextPrivate *priv = NULL; - g_return_val_if_fail(GF_IS_TYPE_PARSE_CONTEXT(ctx), NULL);
+ g_return_val_if_fail(GF_IS_TYPE_QUERY_CONTEXT(ctx), NULL); - priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+ priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx);
- * gf_type_parse_context_get_user_data:
- * @ctx: The #GfTypeParseContext instance.
+ * gf_type_query_context_get_user_data: + * @ctx: The #GfTypeQueryContext instance. * Gets the user data from @ctx.
* Return Value: The user data used from @ctx.
-gf_type_parse_context_get_user_data(const GfTypeParseContext *ctx) {
- GfTypeParseContextPrivate *priv = NULL;
+gf_type_query_context_get_user_data(const GfTypeQueryContext *ctx) { + GfTypeQueryContextPrivate *priv = NULL; - g_return_val_if_fail(GF_IS_TYPE_PARSE_CONTEXT(ctx), NULL);
+ g_return_val_if_fail(GF_IS_TYPE_QUERY_CONTEXT(ctx), NULL); - priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+ priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx); - * gf_type_parse_context_get_destroy_notify:
- * @ctx: The #GfTypeParseContext instance.
+ * gf_type_query_context_get_destroy_notify: + * @ctx: The #GfTypeQueryContext instance. * Gets the destroy notify function from @ctx.
* Return Value: The destroy notify function from @ctx.
-gf_type_parse_context_get_destroy_notify(const GfTypeParseContext *ctx) {
- GfTypeParseContextPrivate *priv = NULL;
+gf_type_query_context_get_destroy_notify(const GfTypeQueryContext *ctx) { + GfTypeQueryContextPrivate *priv = NULL; - g_return_val_if_fail(GF_IS_TYPE_PARSE_CONTEXT(ctx), NULL);
+ g_return_val_if_fail(GF_IS_TYPE_QUERY_CONTEXT(ctx), NULL); - priv = GF_TYPE_PARSE_CONTEXT_GET_PRIVATE(ctx);
+ priv = GF_TYPE_QUERY_CONTEXT_GET_PRIVATE(ctx); return priv->destroy_notify;
--- a/gflib/gflib/gf_type.h Sun Oct 11 04:19:48 2009 -0500
+++ b/gflib/gflib/gf_type.h Sun Oct 11 04:37:30 2009 -0500
@@ -21,30 +21,32 @@
-#define GF_TYPE_TYPE_PARSE_CONTEXT (gf_type_parse_context_get_type())
-#define GF_TYPE_PARSE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GF_TYPE_TYPE_PARSE_CONTEXT, GfTypeParseContext))
-#define GF_TYPE_PARSE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GF_TYPE_TYPE_PARSE_CONTEXT, GfTypeParseContextClass))
-#define GF_IS_TYPE_PARSE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GF_TYPE_TYPE_PARSE_CONTEXT))
-#define GF_IS_TYPE_PARSE_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GF_TYPE_TYPE_PARSE_CONTEXT))
-#define GF_TYPE_PARSE_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GF_TYPE_TYPE_PARSE_CONTEXT, GfTypeParseContextClass))
+#define GF_TYPE_TYPE_QUERY_CONTEXT (gf_type_query_context_get_type()) +#define GF_TYPE_QUERY_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GF_TYPE_TYPE_QUERY_CONTEXT, GfTypeQueryContext)) +#define GF_TYPE_QUERY_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GF_TYPE_TYPE_QUERY_CONTEXT, GfTypeQueryContextClass)) +#define GF_IS_TYPE_QUERY_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GF_TYPE_TYPE_QUERY_CONTEXT)) +#define GF_IS_TYPE_QUERY_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GF_TYPE_TYPE_QUERY_CONTEXT)) +#define GF_TYPE_QUERY_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GF_TYPE_TYPE_QUERY_CONTEXT, GfTypeQueryContextClass)) -typedef struct _GfTypeParseContext GfTypeParseContext;
-typedef struct _GfTypeParseContextClass GfTypeParseContextClass;
+typedef struct _GfTypeQueryContext GfTypeQueryContext; +typedef struct _GfTypeQueryContextClass GfTypeQueryContextClass; +typedef struct _GfTypeQuery GfTypeQuery;
* A class that allows digging through the types in the type system.
-struct _GfTypeParseContext {
+struct _GfTypeQueryContext { -struct _GfTypeParseContextClass {
+struct _GfTypeQueryContextClass { - void (*parse)(GfTypeParseContext *ctx, GType type);
+ void (*query)(GfTypeQueryContext *ctx, GType type); void (*_gf_reserved_1)(void);
void (*_gf_reserved_2)(void);
@@ -52,19 +54,17 @@
void (*_gf_reserved_4)(void);
-typedef struct _GfTypeParser GfTypeParser;
* @start_object: A function to call when an object is first reached.
* @end_object: A function to call when finished with an object.
* @param: A function thats called when a param is reached.
* @signal: A function to call when a signal is found.
* A simple structure for functions to call during a call to
- * #gf_type_parse_context_parse.
+ * #gf_type_query_context_query.
void (*start_object)(const GTypeQuery *query);
void (*end_object)(const GTypeQuery *query);
@@ -74,14 +74,14 @@
-GType gf_type_parse_context_get_type(void);
+GType gf_type_query_context_get_type(void); -GfTypeParseContext *gf_type_parse_context_new(GfTypeParser *parser, gpointer data, GDestroyNotify destroy_notify);
-void gf_type_parse_context_parse(GfTypeParseContext *ctx, GType type);
+GfTypeQueryContext *gf_type_query_context_new(GfTypeQuery *query, gpointer data, GDestroyNotify destroy_notify); +void gf_type_query_context_run(GfTypeQueryContext *ctx, GType type); -GfTypeParser *gf_type_parse_context_get_parser(const GfTypeParseContext *ctx);
-gpointer gf_type_parse_context_get_user_data(const GfTypeParseContext *ctx);
-GDestroyNotify gf_type_parse_context_get_destroy_notify(const GfTypeParseContext *ctx);
+GfTypeQuery *gf_type_query_context_get_query(const GfTypeQueryContext *ctx); +gpointer gf_type_query_context_get_user_data(const GfTypeQueryContext *ctx); +GDestroyNotify gf_type_query_context_get_destroy_notify(const GfTypeQueryContext *ctx); GType *gf_type_children(GType type, guint *n_children);
GType *gf_type_concrete_children(GType type, guint *n_children);
--- a/gflib/tests/genobjects.c Sun Oct 11 04:19:48 2009 -0500
+++ b/gflib/tests/genobjects.c Sun Oct 11 04:37:30 2009 -0500
@@ -51,7 +51,7 @@
-static GfTypeParser parser = {
+static GfTypeQuery query = { gf_gen_hierarchy_start_object,
gf_gen_hierarchy_end_object,
@@ -60,7 +60,7 @@
main(gint argc, gchar **argv) {
- GfTypeParseContext *tctx = NULL;
+ GfTypeQueryContext *tctx = NULL; GOptionContext *octx = NULL;
octx = g_option_context_new(NULL);
@@ -69,12 +69,12 @@
gf_lib_init(&argc, &argv);
- tctx = gf_type_parse_context_new(&parser, NULL, NULL);
+ tctx = gf_type_query_context_new(&query, NULL, NULL); printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- gf_type_parse_context_parse(tctx, GF_TYPE_OBJECT);
+ gf_type_query_context_run(tctx, GF_TYPE_OBJECT);