[lasem/mml-attrs] [Mathml] Migration to lsm_attribute_manager WIP.



commit 9acb7d2f88e67a8e0931b2430e754356858a97a7
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sun Dec 13 21:50:21 2009 +0100

    [Mathml] Migration to lsm_attribute_manager WIP.
    
    lsm_mathml_string_attribute

 src/lsmmathmlattributes.c        |   18 ++++++++++++-
 src/lsmmathmlattributes.h        |   14 ++++++---
 src/lsmmathmlfencedelement.c     |   53 +++++++++++++++++++++++++++++++------
 src/lsmmathmlpresentationtoken.c |   32 +++++++++++++++++++---
 src/lsmmathmlpresentationtoken.h |    6 ++--
 src/lsmmathmlstringelement.c     |   53 ++++++++++++++++++++++++++++---------
 src/lsmmathmlstyleelement.c      |   25 ++++++++++++++---
 src/lsmmathmltraits.c            |   33 +++++++++++++++++++++++
 src/lsmmathmltraits.h            |    1 +
 9 files changed, 194 insertions(+), 41 deletions(-)
---
diff --git a/src/lsmmathmlattributes.c b/src/lsmmathmlattributes.c
index 578387a..dcf832f 100644
--- a/src/lsmmathmlattributes.c
+++ b/src/lsmmathmlattributes.c
@@ -48,6 +48,17 @@ lsm_mathml_double_attribute_inherit (LsmMathmlDoubleAttribute *attribute, double
 	return attribute->value;
 }
 
+const char *
+lsm_mathml_string_attribute_inherit (LsmMathmlStringAttribute *attribute, const char *string)
+{
+	if (attribute->base.value == NULL) {
+		g_free (attribute->value);
+		attribute->value = g_strdup (string);
+	}
+
+	return attribute->value;
+}
+
 /**************************/
 
 typedef struct {
@@ -424,7 +435,6 @@ lsm_mathml_double_attribute_parse (LsmMathmlDoubleAttribute *attribute,
 	*style_value = attribute->value;
 }
 
-#endif
 
 void
 lsm_mathml_string_attribute_parse (LsmMathmlStringAttribute *attribute,
@@ -448,6 +458,8 @@ lsm_mathml_string_attribute_parse (LsmMathmlStringAttribute *attribute,
 	}
 }
 
+#endif
+
 void
 lsm_mathml_enum_attribute_parse (LsmMathmlEnumAttribute *attribute,
 			      unsigned int *style_value,
@@ -506,6 +518,7 @@ lsm_mathml_enum_list_attribute_parse (LsmMathmlEnumListAttribute *attribute,
 	g_strfreev (items);
 }
 
+#if 0
 void
 lsm_mathml_string_attribute_finalize (void *abstract)
 {
@@ -516,6 +529,7 @@ lsm_mathml_string_attribute_finalize (void *abstract)
 	g_free (attribute->value);
 	attribute->value = NULL;
 }
+#endif
 
 void
 lsm_mathml_enum_list_attribute_finalize (void *abstract)
@@ -533,6 +547,7 @@ static const LsmMathmlAttributeClass string_attribute_class = {
 	.finalize = lsm_mathml_string_attribute_finalize
 };
 
+#if 0
 void
 lsm_mathml_attribute_map_add_string (LsmMathmlAttributeMap *map,
 				     char const *name,
@@ -540,6 +555,7 @@ lsm_mathml_attribute_map_add_string (LsmMathmlAttributeMap *map,
 {
 	lsm_mathml_attribute_map_add_attribute_full (map, name, offset, &string_attribute_class);
 }
+#endif
 
 static const LsmMathmlAttributeClass enum_list_attribute_class = {
 	.finalize = lsm_mathml_enum_list_attribute_finalize
diff --git a/src/lsmmathmlattributes.h b/src/lsmmathmlattributes.h
index 2332c07..e605900 100644
--- a/src/lsmmathmlattributes.h
+++ b/src/lsmmathmlattributes.h
@@ -46,8 +46,14 @@ typedef struct {
 	double value;
 } LsmMathmlDoubleAttribute;
 
+typedef struct {
+	LsmAttribute base;
+	char *value;
+} LsmMathmlStringAttribute;
+
 gboolean	lsm_mathml_boolean_attribute_inherit 	(LsmMathmlBooleanAttribute *attribute, gboolean value);
 double 		lsm_mathml_double_attribute_inherit 	(LsmMathmlDoubleAttribute *attribute, double value);
+const char *	lsm_mathml_string_attribute_inherit	(LsmMathmlStringAttribute *attribute, const char *string);
 
 /*******************************/
 
@@ -143,10 +149,6 @@ typedef struct {
 } LsmMathmlDoubleAttribute;
 
 #endif
-typedef struct {
-	LsmMathmlAttribute attr;
-	char *value;
-} LsmMathmlStringAttribute;
 
 typedef struct {
 	LsmMathmlAttribute attr;
@@ -239,9 +241,9 @@ void 		lsm_mathml_unsigned_attribute_parse	(LsmMathmlUnsignedAttribute *attribut
 							 unsigned *default_value);
 void 		lsm_mathml_double_attribute_parse	(LsmMathmlDoubleAttribute *attribute,
 							 double *default_value);
-#endif
 void		lsm_mathml_string_attribute_parse	(LsmMathmlStringAttribute *attribute,
 							 char **default_value);
+#endif
 void 		lsm_mathml_enum_attribute_parse 	(LsmMathmlEnumAttribute *attribute,
 							 unsigned int *default_value,
 							 LsmDomNamedConvert convert);
@@ -253,9 +255,11 @@ void		lsm_mathml_string_attribute_finalize	(void *abstract);
 void 		lsm_mathml_enum_list_attribute_finalize	(void *abstract);
 
 
+#if 0
 void 		lsm_mathml_attribute_map_add_string 	(LsmMathmlAttributeMap *map,
 							 char const *name,
 							 ptrdiff_t offset);
+#endif
 void 		lsm_mathml_attribute_map_add_enum_list 	(LsmMathmlAttributeMap *map,
 							 char const *name,
 							 ptrdiff_t offset);
diff --git a/src/lsmmathmlfencedelement.c b/src/lsmmathmlfencedelement.c
index a12eb8b..4f3dd19 100644
--- a/src/lsmmathmlfencedelement.c
+++ b/src/lsmmathmlfencedelement.c
@@ -35,6 +35,7 @@ lsm_mathml_fenced_element_get_node_name (LsmDomNode *node)
 
 /* LsmMathmlElement implementation */
 
+#if 0
 static void
 lsm_mathml_fenced_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
 {
@@ -53,6 +54,7 @@ lsm_mathml_fenced_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
 	lsm_mathml_string_attribute_parse (&fenced->separators, &default_string);
 	g_free (default_string);
 }
+#endif
 
 static const LsmMathmlBbox *
 lsm_mathml_fenced_element_measure (LsmMathmlElement *self, LsmMathmlView *view, const LsmMathmlBbox *bbox)
@@ -131,6 +133,10 @@ lsm_mathml_fenced_element_render (LsmMathmlElement *self, LsmMathmlView *view)
 
 /* LsmMathmlFencedElement implementation */
 
+static const char *open_default = "(";
+static const char *close_default = ")";
+static const char *separators_default = ",";
+
 LsmDomNode *
 lsm_mathml_fenced_element_new (void)
 {
@@ -138,12 +144,36 @@ lsm_mathml_fenced_element_new (void)
 }
 
 static void
-lsm_mathml_fenced_element_init (LsmMathmlFencedElement *element)
+lsm_mathml_fenced_element_init (LsmMathmlFencedElement *self)
 {
+	self->open.value = g_strdup (open_default);
+	self->close.value = g_strdup (close_default);
+	self->separators.value = g_strdup (separators_default);
 }
 
 /* LsmMathmlFencedElement class */
 
+static const LsmAttributeInfos _attribute_infos[] = {
+	{
+		.name = "open",
+		.attribute_offset = offsetof (LsmMathmlFencedElement, open),
+		.trait_class = &lsm_mathml_string_trait_class,
+		.trait_default = &open_default
+	},
+	{
+		.name = "close",
+		.attribute_offset = offsetof (LsmMathmlFencedElement, close),
+		.trait_class = &lsm_mathml_string_trait_class,
+		.trait_default = &close_default
+	},
+	{
+		.name = "separators",
+		.attribute_offset = offsetof (LsmMathmlFencedElement, separators),
+		.trait_class = &lsm_mathml_string_trait_class,
+		.trait_default = &separators_default
+	}
+};
+
 static void
 lsm_mathml_fenced_element_class_init (LsmMathmlFencedElementClass *m_fenced_element_class)
 {
@@ -154,19 +184,24 @@ lsm_mathml_fenced_element_class_init (LsmMathmlFencedElementClass *m_fenced_elem
 
 	d_node_class->get_node_name = lsm_mathml_fenced_element_get_node_name;
 
-	m_element_class->update =  lsm_mathml_fenced_element_update;
+/*        m_element_class->update =  lsm_mathml_fenced_element_update;*/
 	m_element_class->measure = lsm_mathml_fenced_element_measure;
 	m_element_class->layout =  lsm_mathml_fenced_element_layout;
 	m_element_class->render =  lsm_mathml_fenced_element_render;
+	m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+	lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+					      G_N_ELEMENTS (_attribute_infos),
+					      _attribute_infos);
 
-	m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
+/*        m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);*/
 
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "open",
-				       offsetof (LsmMathmlFencedElement, open));
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "close",
-				       offsetof (LsmMathmlFencedElement, close));
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "separators",
-				       offsetof (LsmMathmlFencedElement, separators));
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "open",*/
+/*                                       offsetof (LsmMathmlFencedElement, open));*/
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "close",*/
+/*                                       offsetof (LsmMathmlFencedElement, close));*/
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "separators",*/
+/*                                       offsetof (LsmMathmlFencedElement, separators));*/
 }
 
 G_DEFINE_TYPE (LsmMathmlFencedElement, lsm_mathml_fenced_element, LSM_TYPE_MATHML_PRESENTATION_CONTAINER)
diff --git a/src/lsmmathmlpresentationtoken.c b/src/lsmmathmlpresentationtoken.c
index c74bdf1..f3dc6c2 100644
--- a/src/lsmmathmlpresentationtoken.c
+++ b/src/lsmmathmlpresentationtoken.c
@@ -112,7 +112,10 @@ lsm_mathml_presentation_token_update (LsmMathmlElement *self, LsmMathmlStyle *st
 	lsm_mathml_variant_set_font_style (&style->math_variant, font_style);
 	lsm_mathml_variant_set_font_weight (&style->math_variant, font_weight);
 
-	lsm_mathml_string_attribute_parse (&token->math_family, &style->math_family);
+	lsm_mathml_style_set_math_family (style,
+					  lsm_mathml_string_attribute_inherit (&token->math_family,
+									       style->math_family));
+/*        lsm_mathml_string_attribute_parse (&token->math_family, &style->math_family);*/
 	lsm_mathml_variant_attribute_parse (&token->math_variant, &style->math_variant);
 	lsm_mathml_length_attribute_parse (&token->math_size, &style->math_size, style->math_size_value);
 	lsm_mathml_color_attribute_parse (&token->math_color, &style->math_color);
@@ -203,6 +206,20 @@ lsm_mathml_presentation_token_init (LsmMathmlPresentationToken *token)
 
 /* LsmMathmlPresentationToken class */
 
+static const LsmAttributeInfos _attribute_infos[] = {
+	{
+		.name = "mathfamily",
+		.attribute_offset = offsetof (LsmMathmlPresentationToken, math_family),
+		.trait_class = &lsm_mathml_string_trait_class
+	},
+	/* Deprecated attributes */
+	{
+		.name = "fontfamily",
+		.attribute_offset = offsetof (LsmMathmlPresentationToken, math_family),
+		.trait_class = &lsm_mathml_string_trait_class
+	}
+};
+
 static void
 lsm_mathml_presentation_token_class_init (LsmMathmlPresentationTokenClass *m_token_class)
 {
@@ -218,6 +235,11 @@ lsm_mathml_presentation_token_class_init (LsmMathmlPresentationTokenClass *m_tok
 	m_element_class->measure = lsm_mathml_presentation_token_measure;
 	m_element_class->render = lsm_mathml_presentation_token_render;
 	m_element_class->is_inferred_row = NULL;
+	m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+	lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+					      G_N_ELEMENTS (_attribute_infos),
+					      _attribute_infos);
 
 	m_element_class->update = lsm_mathml_presentation_token_update;
 
@@ -225,8 +247,8 @@ lsm_mathml_presentation_token_class_init (LsmMathmlPresentationTokenClass *m_tok
 
 	m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
 
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "mathfamily",
-					  offsetof (LsmMathmlPresentationToken, math_family));
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "mathfamily",*/
+/*                                          offsetof (LsmMathmlPresentationToken, math_family));*/
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "mathvariant",
 					     offsetof (LsmMathmlPresentationToken, math_variant));
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "mathsize",
@@ -238,8 +260,8 @@ lsm_mathml_presentation_token_class_init (LsmMathmlPresentationTokenClass *m_tok
 
 	/* Deprecated attributes */
 
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "fontfamily",
-					  offsetof (LsmMathmlPresentationToken, math_family));
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "fontfamily",*/
+/*                                          offsetof (LsmMathmlPresentationToken, math_family));*/
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "fontsize",
 					     offsetof (LsmMathmlPresentationToken, math_size));
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "color",
diff --git a/src/lsmmathmlpresentationtoken.h b/src/lsmmathmlpresentationtoken.h
index cbb1521..68f600f 100644
--- a/src/lsmmathmlpresentationtoken.h
+++ b/src/lsmmathmlpresentationtoken.h
@@ -49,10 +49,10 @@ struct _LsmMathmlPresentationToken {
 	LsmMathmlPresentationTokenType type;
 
 	LsmMathmlStringAttribute	math_family;
-	LsmMathmlEnumAttribute	math_variant;
+	LsmMathmlEnumAttribute		math_variant;
 	LsmMathmlLengthAttribute	math_size;
-	LsmMathmlColorAttribute	math_color;
-	LsmMathmlColorAttribute	math_background;
+	LsmMathmlColorAttribute		math_color;
+	LsmMathmlColorAttribute		math_background;
 
 	/* Deprecated style attributes */
 
diff --git a/src/lsmmathmlstringelement.c b/src/lsmmathmlstringelement.c
index ba54652..dd429ba 100644
--- a/src/lsmmathmlstringelement.c
+++ b/src/lsmmathmlstringelement.c
@@ -38,18 +38,21 @@ lsm_mathml_string_element_get_node_name (LsmDomNode *node)
 static void
 lsm_mathml_string_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
 {
-	LsmMathmlStringElement *string_element = LSM_MATHML_STRING_ELEMENT (self);
-	char *default_quote;
+/*        LsmMathmlStringElement *string_element = LSM_MATHML_STRING_ELEMENT (self);*/
+/*        char *default_quote;*/
 
 	LSM_MATHML_ELEMENT_CLASS (parent_class)->update (self, style);
 
-	default_quote = g_strdup ("\"");
-	lsm_mathml_string_attribute_parse (&string_element->left_quote, &default_quote);
-	g_free (default_quote);
+/*        default_quote = g_strdup ("\"");*/
+/*        lsm_mathml_string_attribute_parse (&string_element->left_quote, &default_quote);*/
+/*        g_free (default_quote);*/
 
-	default_quote = g_strdup ("\"");
-	lsm_mathml_string_attribute_parse (&string_element->right_quote, &default_quote);
-	g_free (default_quote);
+/*        default_quote = g_strdup ("\"");*/
+/*        lsm_mathml_string_attribute_parse (&string_element->right_quote, &default_quote);*/
+/*        g_free (default_quote);*/
+
+/*        lsm_mathml_string_attribute_inherit (&string_element->left_quote, "\"");*/
+/*        lsm_mathml_string_attribute_inherit (&string_element->right_quote, "\"");*/
 }
 
 /* LsmMathmlPresentationToken implementation */
@@ -75,6 +78,8 @@ lsm_mathml_string_element_get_text (LsmMathmlPresentationToken *token)
 
 /* LsmMathmlStringElement implementation */
 
+static const char *quote_default = "\"";
+
 LsmDomNode *
 lsm_mathml_string_element_new (void)
 {
@@ -84,10 +89,27 @@ lsm_mathml_string_element_new (void)
 static void
 lsm_mathml_string_element_init (LsmMathmlStringElement *self)
 {
+	self->left_quote.value = g_strdup (quote_default);
+	self->right_quote.value = g_strdup (quote_default);
 }
 
 /* LsmMathmlStringElement class */
 
+static const LsmAttributeInfos _attribute_infos[] = {
+	{
+		.name = "lquote",
+		.attribute_offset = offsetof (LsmMathmlStringElement, left_quote),
+		.trait_class = &lsm_mathml_string_trait_class,
+		.trait_default = &quote_default
+	},
+	{
+		.name = "rquote",
+		.attribute_offset = offsetof (LsmMathmlStringElement, right_quote),
+		.trait_class = &lsm_mathml_string_trait_class,
+		.trait_default = &quote_default
+	}
+};
+
 static void
 lsm_mathml_string_element_class_init (LsmMathmlStringElementClass *string_class)
 {
@@ -100,15 +122,20 @@ lsm_mathml_string_element_class_init (LsmMathmlStringElementClass *string_class)
 	d_node_class->get_node_name = lsm_mathml_string_element_get_node_name;
 
 	m_element_class->update = lsm_mathml_string_element_update;
+	m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+	lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+					      G_N_ELEMENTS (_attribute_infos),
+					      _attribute_infos);
 
 	m_token_class->get_text = lsm_mathml_string_element_get_text;
 
-	m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
+/*        m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);*/
 
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "lquote",
-				       offsetof (LsmMathmlStringElement, left_quote));
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "rquote",
-				       offsetof (LsmMathmlStringElement, right_quote));
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "lquote",*/
+/*                                       offsetof (LsmMathmlStringElement, left_quote));*/
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "rquote",*/
+/*                                       offsetof (LsmMathmlStringElement, right_quote));*/
 }
 
 G_DEFINE_TYPE (LsmMathmlStringElement, lsm_mathml_string_element, LSM_TYPE_MATHML_PRESENTATION_TOKEN)
diff --git a/src/lsmmathmlstyleelement.c b/src/lsmmathmlstyleelement.c
index b59a44f..9d0dd38 100644
--- a/src/lsmmathmlstyleelement.c
+++ b/src/lsmmathmlstyleelement.c
@@ -71,7 +71,11 @@ lsm_mathml_style_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
 	lsm_mathml_variant_set_font_style (&style->math_variant, font_style);
 	lsm_mathml_variant_set_font_weight (&style->math_variant, font_weight);
 
-	lsm_mathml_string_attribute_parse (&style_element->math_family, &style->math_family);
+
+	lsm_mathml_style_set_math_family (style,
+					  lsm_mathml_string_attribute_inherit (&style_element->math_family,
+									       style->math_family));
+/*        lsm_mathml_string_attribute_parse (&style_element->math_family, &style->math_family);*/
 	lsm_mathml_length_attribute_parse (&style_element->math_size, &style->math_size, style->math_size_value);
 	lsm_mathml_color_attribute_parse (&style_element->math_color, &style->math_color);
 	lsm_mathml_color_attribute_parse (&style_element->math_background, &style->math_background);
@@ -136,6 +140,17 @@ static const LsmAttributeInfos _attribute_infos[] = {
 		.name = "scriptsizemultiplier",
 		.attribute_offset = offsetof (LsmMathmlStyleElement, script_size_multiplier),
 		.trait_class = &lsm_mathml_double_trait_class
+	},
+	{
+		.name = "mathfamily",
+		.attribute_offset = offsetof (LsmMathmlStyleElement, math_family),
+		.trait_class = &lsm_mathml_string_trait_class
+	},
+	/* Deprecated attributes */
+	{
+		.name = "fontfamily",
+		.attribute_offset = offsetof (LsmMathmlStyleElement, math_family),
+		.trait_class = &lsm_mathml_string_trait_class
 	}
 };
 
@@ -183,8 +198,8 @@ lsm_mathml_style_element_class_init (LsmMathmlStyleElementClass *style_class)
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "veryverythickmathspace",
 					  offsetof (LsmMathmlStyleElement, very_very_thick_math_space));
 
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "mathfamily",
-				       offsetof (LsmMathmlStyleElement, math_family));
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "mathfamily",*/
+/*                                       offsetof (LsmMathmlStyleElement, math_family));*/
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "mathvariant",
 					  offsetof (LsmMathmlStyleElement, math_variant));
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "mathsize",
@@ -199,8 +214,8 @@ lsm_mathml_style_element_class_init (LsmMathmlStyleElementClass *style_class)
 
 	/* Deprecated attributes */
 
-	lsm_mathml_attribute_map_add_string (m_element_class->attributes, "fontfamily",
-				       offsetof (LsmMathmlStyleElement, math_family));
+/*        lsm_mathml_attribute_map_add_string (m_element_class->attributes, "fontfamily",*/
+/*                                       offsetof (LsmMathmlStyleElement, math_family));*/
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "fontsize",
 					  offsetof (LsmMathmlStyleElement, math_size));
 	lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "color",
diff --git a/src/lsmmathmltraits.c b/src/lsmmathmltraits.c
index 2de4614..afbf09c 100644
--- a/src/lsmmathmltraits.c
+++ b/src/lsmmathmltraits.c
@@ -89,3 +89,36 @@ const LsmTraitClass lsm_mathml_double_trait_class = {
 	.from_string = lsm_mathml_double_trait_from_string,
 	.to_string = lsm_mathml_double_trait_to_string
 };
+
+static void
+lsm_mathml_string_trait_from_string (LsmTrait *abstract_trait, char *string)
+{
+	char **value = (char **) abstract_trait;
+
+	g_free (*value);
+	*value = g_strdup (string);
+}
+
+static char *
+lsm_mathml_string_trait_to_string (LsmTrait *abstract_trait)
+{
+	char **value = (char **) abstract_trait;
+
+	return g_strdup (*value);
+}
+
+static void
+lsm_mathml_string_trait_finalize (LsmTrait *abstract_trait)
+{
+	char **value = (char **) abstract_trait;
+
+	g_free (*value);
+	*value = NULL;
+}
+
+const LsmTraitClass lsm_mathml_string_trait_class = {
+	.size = sizeof (char *),
+	.from_string = lsm_mathml_string_trait_from_string,
+	.to_string = lsm_mathml_string_trait_to_string,
+	.finalize = lsm_mathml_string_trait_finalize
+};
diff --git a/src/lsmmathmltraits.h b/src/lsmmathmltraits.h
index a8f73aa..9d0f7ff 100644
--- a/src/lsmmathmltraits.h
+++ b/src/lsmmathmltraits.h
@@ -29,6 +29,7 @@ G_BEGIN_DECLS
 extern const LsmTraitClass lsm_mathml_boolean_trait_class;
 extern const LsmTraitClass lsm_mathml_unsigned_trait_class;
 extern const LsmTraitClass lsm_mathml_double_trait_class;
+extern const LsmTraitClass lsm_mathml_string_trait_class;
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]