}
static void
-export_accessors (char *var_name,
- GString *get_cbuf,
+export_accessors (const char *var_name,
+ const char *get_cbuf,
int get_lineno,
- GString *set_cbuf,
+ const char *set_cbuf,
int set_lineno,
Type *type,
+ const char *gtktype,
int lineno)
{
- if (get_cbuf) {
+ if (type == NULL) {
+ char *cast = g_strdup (get_cast (gtktype, FALSE));
+ char *p = strchr (cast, ' ');
+ if (p != NULL) {
+ *p = '\0';
+ p++;
+ }
+ /* leak, but we don't really care any more */
+ type = (Type *)new_type (cast,
+ g_strdup (p),
+ NULL);
+ }
+
+ if (get_cbuf != NULL) {
char *get_id = g_strdup_printf ("get_%s", var_name);
- GString *get_cbuf_copy = g_string_new (get_cbuf->str);
+ GString *get_cbuf_copy = g_string_new (get_cbuf);
char *tmp;
- Node *node1 = new_type (type->name, type->pointer, type->postfix);
- Node *node3 = new_type (class->class.otype, "*", NULL);
+ Node *node1 = new_type (g_strdup (type->name),
+ g_strdup (type->pointer),
+ g_strdup (type->postfix));
+ Node *node3 = new_type (g_strdup (class->class.otype),
+ g_strdup ("*"),
+ NULL);
tmp = g_strdup_printf ("\t%s%s ARG;\n",
type->name,
lineno, FALSE, NULL);
}
- if (set_cbuf) {
+ if (set_cbuf != NULL) {
char *set_id = g_strdup_printf ("set_%s", var_name);
- GString *set_cbuf_copy = g_string_new (set_cbuf->str);
- Node *node1 = new_type (type->name, type->pointer, type->postfix);
- Node *node2 = new_type ("void", NULL, NULL);
- Node *node3 = new_type (class->class.otype, "*", NULL);
+ GString *set_cbuf_copy = g_string_new (set_cbuf);
+ Node *node1 = new_type (g_strdup (type->name),
+ g_strdup (type->pointer),
+ g_strdup (type->postfix));
+ Node *node2 = new_type (g_strdup ("void"),
+ NULL,
+ NULL);
+ Node *node3 = new_type (g_strdup (class->class.otype),
+ g_strdup ("*"),
+ NULL);
typestack = g_list_prepend (typestack, node2);
typestack = g_list_prepend (typestack, node1);
if ($<id>5) {
export_accessors ($<id>4,
- $<cbuf>8, $<line>7,
- $<cbuf>11, $<line>10,
+ ($<cbuf>8)->str, $<line>7,
+ ($<cbuf>11)->str, $<line>10,
type,
+ $<id>3,
$<line>1);
+ g_free ($<id>5);
}
g_string_free ($<cbuf>8, FALSE);
($<cbuf>11)->str,$<line>10,
($<cbuf>8)->str,$<line>7,
$<line>1);
+
+ if ($<id>5) {
+ export_accessors ($<id>4,
+ ($<cbuf>11)->str, $<line>10,
+ ($<cbuf>8)->str, $<line>7,
+ type,
+ $<id>3,
+ $<line>1);
+ g_free ($<id>5);
+ }
+
g_string_free ($<cbuf>11, FALSE);
g_string_free ($<cbuf>8, FALSE);
class_nodes = g_list_append(class_nodes,node);
$<line>1);
if ($<id>5) {
export_accessors ($<id>4,
- $<cbuf>8, $<line>7,
+ ($<cbuf>8)->str, $<line>7,
NULL, 0,
type,
+ $<id>3,
$<line>1);
+ g_free ($<id>5);
}
g_string_free ($<cbuf>8, FALSE);
if ($<id>5) {
export_accessors ($<id>4,
NULL, 0,
- $<cbuf>8, $<line>7,
+ ($<cbuf>8)->str, $<line>7,
type,
+ $<id>3,
$<line>1);
+ g_free ($<id>5);
}
g_string_free ($<cbuf>8, FALSE);
g_assert_not_reached();
}
- if(strcmp ($<id>6, "stringlink")==0) {
+ if (strcmp ($<id>6, "stringlink")==0) {
get = g_strdup_printf("ARG = g_strdup(%s->%s);", root, $<id>4);
- } else
+ } else {
/* For everything else, get is just straight assignment */
get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
+ }
g_free ($<id>6);
$<line>1);
if ($<id>5) {
export_accessors ($<id>4,
- g_string_new (get), $<line>1,
- g_string_new (set), $<line>1,
+ get, $<line>1,
+ set, $<line>1,
type,
+ $<id>3,
$<line>1);
+ g_free ($<id>5);
}
class_nodes = g_list_append(class_nodes,node);