--- a/gplate/gplate-code-tag.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-code-tag.c Tue Feb 12 04:00:11 2008 -0600
@@ -35,11 +35,6 @@
-gplate_code_tag_render(const GPlateTag *tag, GPlateTemplate *tplate) {
/******************************************************************************
*****************************************************************************/
@@ -49,8 +44,6 @@
tag_class->get_prefix = gplate_code_tag_class_get_prefix;
tag_class->get_suffix = gplate_code_tag_class_get_suffix;
- tag_class->render = gplate_code_tag_render;
/******************************************************************************
--- a/gplate/gplate-comment-tag.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-comment-tag.c Tue Feb 12 04:00:11 2008 -0600
@@ -35,11 +35,6 @@
-gplate_comment_tag_render(const GPlateTag *tag, GPlateTemplate *tplate) {
/******************************************************************************
*****************************************************************************/
@@ -49,8 +44,6 @@
tag_class->get_prefix = gplate_comment_tag_class_get_prefix;
tag_class->get_suffix = gplate_comment_tag_class_get_suffix;
- tag_class->render = gplate_comment_tag_render;
/******************************************************************************
--- a/gplate/gplate-function.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-function.c Tue Feb 12 04:00:11 2008 -0600
@@ -53,15 +53,15 @@
* gplate_function_evaluate:
* @function: The #GPlateFunction.
- * @variables: The #GPlateCollection to use as the variable store.
+ * @tplate: The #GPlateTemplate that @function is being evaluated for. * @contents: The contents for the function to use.
- * Evaluates @contents using @function with the @variables collection.
+ * Evaluates @contents using @function for @tplate. * Return Value: The evaluated output.
-gplate_function_evaluate(GPlateFunction *function, GPlateCollection *variables,
+gplate_function_evaluate(GPlateFunction *function, GPlateTemplate *tplate, GPlateFunctionClass *klass = NULL;
@@ -71,7 +71,7 @@
klass = GPLATE_FUNCTION_GET_CLASS(function);
if(klass && klass->evaluate)
- return klass->evaluate(function, variables, contents);
+ return klass->evaluate(function, tplate, contents); --- a/gplate/gplate-function.h Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-function.h Tue Feb 12 04:00:11 2008 -0600
@@ -22,7 +22,7 @@
-#include <gplate/gplate-collection.h>
+#include <gplate/gplate-template.h> #define GPLATE_TYPE_FUNCTION (gplate_function_get_gtype())
#define GPLATE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLATE_TYPE_FUNCTION, GPlateFunction))
@@ -46,7 +46,7 @@
struct _GPlateFunctionClass {
- gchar *(*evaluate)(GPlateFunction *function, GPlateCollection *variables, const gchar *contents);
+ gchar *(*evaluate)(GPlateFunction *function, GPlateTemplate *tplate, const gchar *contents); void (*_gplate_reserved1)(void);
void (*_gplate_reserved2)(void);
@@ -58,7 +58,7 @@
GType gplate_function_get_gtype(void);
-gchar *gplate_function_evaluate(GPlateFunction *function, GPlateCollection *variables, const gchar *contents);
+gchar *gplate_function_evaluate(GPlateFunction *function, GPlateTemplate *tplate, const gchar *contents); --- a/gplate/gplate-noop-function.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-noop-function.c Tue Feb 12 04:00:11 2008 -0600
@@ -22,27 +22,11 @@
#include <gplate/gplate-noop-function.h>
-#define GPLATE_NOOP_FUNCTION_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPLATE_TYPE_NOOP_FUNCTION, GPlateNoopFunctionPrivate))
-/******************************************************************************
- *****************************************************************************/
-/******************************************************************************
- *****************************************************************************/
-/******************************************************************************
- *****************************************************************************/
/******************************************************************************
*****************************************************************************/
-gplate_noop_function_evaluate(GPlateFunction *function,
- GPlateCollection *variables,
+gplate_noop_function_evaluate(GPlateFunction *function, GPlateTemplate *tplate, --- a/gplate/gplate-print-function.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-print-function.c Tue Feb 12 04:00:11 2008 -0600
@@ -27,8 +27,8 @@
*****************************************************************************/
gplate_print_function_evaluate(GPlateFunction *function,
- GPlateCollection *variables,
+ GPlateTemplate *tplate, return (contents) ? g_strdup(contents) : NULL;
--- a/gplate/gplate-tag.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-tag.c Tue Feb 12 04:00:11 2008 -0600
@@ -30,6 +30,7 @@
*****************************************************************************/
@@ -38,6 +39,7 @@
*****************************************************************************/
+ GPlateTemplate *tplate; @@ -49,11 +51,19 @@
/******************************************************************************
*****************************************************************************/
+gplate_tag_real_set_template(GPlateTag *tag, GPlateTemplate *tplate) { + GPlateTagPrivate *priv = GPLATE_TAG_GET_PRIVATE(tag); + if(GPLATE_IS_TEMPLATE(tplate)) + priv->tplate = g_object_ref(tplate); gplate_tag_real_get_contents(const GPlateTag *tag) {
GPlateTagPrivate *priv = GPLATE_TAG_GET_PRIVATE(tag);
+ return (priv->contents) ? g_strdup(priv->contents) : NULL; @@ -75,6 +85,9 @@
GPlateTag *tag = GPLATE_TAG(obj);
+ g_value_set_object(value, gplate_tag_get_template(tag)); g_value_set_string(value, gplate_tag_get_contents(tag));
@@ -91,6 +104,9 @@
GPlateTag *tag = GPLATE_TAG(obj);
+ gplate_tag_real_set_template(tag, g_value_get_object(value)); gplate_tag_real_set_contents(tag, g_value_get_string(value));
@@ -124,6 +140,12 @@
klass->get_contents = gplate_tag_real_get_contents;
+ pspec = g_param_spec_object("template", "template", + "The template this tag belongs to.", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property(obj_class, PROP_TEMPLATE, pspec); pspec = g_param_spec_string("contents", "contents",
"The contents of the tag.",
@@ -160,6 +182,25 @@
+ * gplate_tag_get_template: + * @tag: The #GPlateTag. + * Gets the #GPlateTemplate to which @tag belongs. + * Return Value: The #GPlateTemplate that @tag belongs to. +gplate_tag_get_template(const GPlateTag *tag) { + GPlateTagPrivate *priv = NULL; + g_return_val_if_fail(GPLATE_IS_TAG(tag), NULL); + priv = GPLATE_TAG_GET_PRIVATE(tag); * gplate_tag_get_contents:
* @tag: The #GPlateTag whose contents to get.
@@ -167,7 +208,7 @@
* Return Value: The contents of @tag.
gplate_tag_get_contents(const GPlateTag *tag) {
GPlateTagClass *klass = NULL;
@@ -182,29 +223,6 @@
- * @tag: The #GPlateTag to render.
- * @tplate: The #GPlateTemplate that's rendering @tag.
- * Return Value: The rendered output of @tag.
-gplate_tag_render(const GPlateTag *tag, GPlateTemplate *tplate) {
- GPlateTagClass *klass = NULL;
- g_return_val_if_fail(GPLATE_IS_TAG(tag), NULL);
- klass = GPLATE_TAG_GET_CLASS(tag);
- if(klass && klass->render)
- return klass->render(tag, tplate);
* gplate_tag_class_get_prefix:
* @tag_class: The #GPlateTagClass whose prefix to grab
--- a/gplate/gplate-tag.h Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-tag.h Tue Feb 12 04:00:11 2008 -0600
@@ -22,9 +22,9 @@
-#define GPLATE_TYPE_TAG (gplate_tag_get_gtype())
-#define GPLATE_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLATE_TYPE_TAG, GPlateTag))
-#define GPLATE_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GPLATE_TYPE_TAG, GPlateTagClass))
+#define GPLATE_TYPE_TAG (gplate_tag_get_gtype()) +#define GPLATE_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLATE_TYPE_TAG, GPlateTag)) +#define GPLATE_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GPLATE_TYPE_TAG, GPlateTagClass)) #define GPLATE_IS_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLATE_TYPE_TAG))
#define GPLATE_IS_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GPLATE_TYPE_TAG))
#define GPLATE_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPLATE_TYPE_TAG, GPlateTagClass))
@@ -46,9 +46,7 @@
- const gchar *(*get_contents)(const GPlateTag *tag);
- gchar *(*render)(const GPlateTag *tag, GPlateTemplate *tplate);
+ gchar *(*get_contents)(const GPlateTag *tag); const gchar *(*get_prefix)(const GPlateTagClass *tag_class);
const gchar *(*get_suffix)(const GPlateTagClass *tag_class);
@@ -63,9 +61,8 @@
GType gplate_tag_get_gtype(void);
-const gchar *gplate_tag_get_contents(const GPlateTag *tag);
-gchar *gplate_tag_render(const GPlateTag *tag, GPlateTemplate *tplate);
+GPlateTemplate *gplate_tag_get_template(const GPlateTag *tag); +gchar *gplate_tag_get_contents(const GPlateTag *tag); const gchar *gplate_tag_class_get_prefix(const GPlateTagClass *tag_class);
const gchar *gplate_tag_class_get_suffix(const GPlateTagClass *tag_class);
--- a/gplate/gplate-template.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-template.c Tue Feb 12 04:00:11 2008 -0600
@@ -22,6 +22,7 @@
#include <gplate/gplate-template.h>
+#include <gplate/gplate-collection.h> #include <gplate/gplate-dictionary-variable.h>
#include <gplate/gplate-errors.h>
#include <gplate/gplate-library.h>
--- a/gplate/gplate-text-tag.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-text-tag.c Tue Feb 12 04:00:11 2008 -0600
@@ -23,26 +23,6 @@
#include <gplate/gplate-text-tag.h>
/******************************************************************************
- *****************************************************************************/
-gplate_text_tag_render(const GPlateTag *tag, GPlateTemplate *tplate) {
- const gchar *contents = gplate_tag_get_contents(tag);
- return (contents) ? g_strdup(contents) : NULL;
-/******************************************************************************
- *****************************************************************************/
-gplate_text_tag_class_init(GPlateTextTagClass *klass) {
- GPlateTagClass *tag_class = GPLATE_TAG_CLASS(klass);
- tag_class->render = gplate_text_tag_render;
-/******************************************************************************
*****************************************************************************/
@@ -54,7 +34,7 @@
sizeof(GPlateTextTagClass),
- (GClassInitFunc)gplate_text_tag_class_init,
--- a/gplate/gplate-variable-tag.c Mon Feb 11 05:10:17 2008 -0600
+++ b/gplate/gplate-variable-tag.c Tue Feb 12 04:00:11 2008 -0600
@@ -26,6 +26,11 @@
#include <gplate/gplate-variable.h>
/******************************************************************************
+ *****************************************************************************/ +static GObjectClass *parent_class = NULL; +/****************************************************************************** *****************************************************************************/
@@ -39,11 +44,12 @@
-gplate_variable_tag_render(const GPlateTag *tag, GPlateTemplate *tplate) {
+gplate_variable_tag_get_contents(const GPlateTag *tag) { + GPlateTemplate *tplate = NULL; GPlateVariable *variable = NULL;
+ gchar *name = NULL, *contents = NULL; const gchar *value = NULL;
/* create our regex with available variable characters and ignore
@@ -56,8 +62,12 @@
+ /* grab the contents from the parent */ + contents = GPLATE_TAG_CLASS(parent_class)->get_contents(tag); /* make sure our regex matches */
- if(!g_regex_match(regex, gplate_tag_get_contents(tag), 0, &info)) {
+ if(!g_regex_match(regex, contents, 0, &info)) { @@ -68,6 +78,7 @@
/* make sure we have the correct number of matches */
if(g_match_info_get_match_count(info) < 2) {
@@ -75,6 +86,9 @@
/* get and validate the variable name */
name = g_match_info_fetch(info, 1);
@@ -82,6 +96,7 @@
/* find the variable from the name */
+ tplate = gplate_tag_get_template(tag); variable = gplate_collection_find_variable(GPLATE_COLLECTION(tplate),
@@ -107,10 +122,12 @@
gplate_variable_tag_class_init(GPlateVariableTagClass *klass) {
GPlateTagClass *tag_class = GPLATE_TAG_CLASS(klass);
+ parent_class = g_type_class_peek_parent(klass); tag_class->get_prefix = gplate_variable_tag_class_get_prefix;
tag_class->get_suffix = gplate_variable_tag_class_get_suffix;
- tag_class->render = gplate_variable_tag_render;
+ tag_class->get_contents = gplate_variable_tag_get_contents; /******************************************************************************