X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/7231d76fbf4ae0b501af648e1216b88714aa7353..38fac18bf81df672821ebbac4130ce41f0a6c61f:/src/treefuncs.c diff --git a/src/treefuncs.c b/src/treefuncs.c index 486a599..6f77f47 100644 --- a/src/treefuncs.c +++ b/src/treefuncs.c @@ -15,6 +15,14 @@ static Check * copy_check (Check * self); static Class * copy_class (Class * self); +static EnumDef * +copy_enumdef (EnumDef * self); +static EnumValue * +copy_enumvalue (EnumValue * self); +static Error * +copy_error (Error * self); +static Flags * +copy_flags (Flags * self); static FuncArg * copy_funcarg (FuncArg * self); static Method * @@ -35,6 +43,14 @@ free_check (Check * self); void free_class (Class * self); void +free_enumdef (EnumDef * self); +void +free_enumvalue (EnumValue * self); +void +free_error (Error * self); +void +free_flags (Flags * self); +void free_funcarg (FuncArg * self); void free_method (Method * self); @@ -54,6 +70,14 @@ setv_check (Check * self, va_list __ap); static void setv_class (Class * self, va_list __ap); static void +setv_enumdef (EnumDef * self, va_list __ap); +static void +setv_enumvalue (EnumValue * self, va_list __ap); +static void +setv_error (Error * self, va_list __ap); +static void +setv_flags (Flags * self, va_list __ap); +static void setv_funcarg (FuncArg * self, va_list __ap); static void setv_method (Method * self, va_list __ap); @@ -72,10 +96,12 @@ enum { QUARK_otype_STEAL, QUARK_ptype, QUARK_ptype_STEAL, - QUARK_bonobo_x_class, - QUARK_bonobo_x_class_STEAL, + QUARK_bonobo_object_class, + QUARK_bonobo_object_class_STEAL, QUARK_chunk_size, QUARK_chunk_size_STEAL, + QUARK_interfaces, + QUARK_interfaces_STEAL, QUARK_nodes, QUARK_nodes_STEAL, QUARK_name, @@ -136,7 +162,9 @@ enum { QUARK_ccode_line, QUARK_vararg, QUARK_unique_id, - QUARK_bonobo_x_func, + QUARK_bonobo_object_func, + QUARK_interface, + QUARK_interface_STEAL, QUARK_vtype, QUARK_vtype_STEAL, QUARK_destructor_unref, @@ -147,6 +175,16 @@ enum { QUARK_initializer, QUARK_initializer_STEAL, QUARK_initializer_line, + QUARK_etype, + QUARK_etype_STEAL, + QUARK_prefix, + QUARK_prefix_STEAL, + QUARK_values, + QUARK_values_STEAL, + QUARK_value, + QUARK_value_STEAL, + QUARK_ftype, + QUARK_ftype_STEAL, QUARK_LAST }; @@ -161,10 +199,12 @@ ensure_quarks (void) g_hash_table_insert (quark_ht, "otype:steal", GINT_TO_POINTER (QUARK_otype_STEAL)); g_hash_table_insert (quark_ht, "ptype", GINT_TO_POINTER (QUARK_ptype)); g_hash_table_insert (quark_ht, "ptype:steal", GINT_TO_POINTER (QUARK_ptype_STEAL)); - g_hash_table_insert (quark_ht, "bonobo_x_class", GINT_TO_POINTER (QUARK_bonobo_x_class)); - g_hash_table_insert (quark_ht, "bonobo_x_class:steal", GINT_TO_POINTER (QUARK_bonobo_x_class_STEAL)); + g_hash_table_insert (quark_ht, "bonobo_object_class", GINT_TO_POINTER (QUARK_bonobo_object_class)); + g_hash_table_insert (quark_ht, "bonobo_object_class:steal", GINT_TO_POINTER (QUARK_bonobo_object_class_STEAL)); g_hash_table_insert (quark_ht, "chunk_size", GINT_TO_POINTER (QUARK_chunk_size)); g_hash_table_insert (quark_ht, "chunk_size:steal", GINT_TO_POINTER (QUARK_chunk_size_STEAL)); + g_hash_table_insert (quark_ht, "interfaces", GINT_TO_POINTER (QUARK_interfaces)); + g_hash_table_insert (quark_ht, "interfaces:steal", GINT_TO_POINTER (QUARK_interfaces_STEAL)); g_hash_table_insert (quark_ht, "nodes", GINT_TO_POINTER (QUARK_nodes)); g_hash_table_insert (quark_ht, "nodes:steal", GINT_TO_POINTER (QUARK_nodes_STEAL)); g_hash_table_insert (quark_ht, "name", GINT_TO_POINTER (QUARK_name)); @@ -225,7 +265,9 @@ ensure_quarks (void) g_hash_table_insert (quark_ht, "ccode_line", GINT_TO_POINTER (QUARK_ccode_line)); g_hash_table_insert (quark_ht, "vararg", GINT_TO_POINTER (QUARK_vararg)); g_hash_table_insert (quark_ht, "unique_id", GINT_TO_POINTER (QUARK_unique_id)); - g_hash_table_insert (quark_ht, "bonobo_x_func", GINT_TO_POINTER (QUARK_bonobo_x_func)); + g_hash_table_insert (quark_ht, "bonobo_object_func", GINT_TO_POINTER (QUARK_bonobo_object_func)); + g_hash_table_insert (quark_ht, "interface", GINT_TO_POINTER (QUARK_interface)); + g_hash_table_insert (quark_ht, "interface:steal", GINT_TO_POINTER (QUARK_interface_STEAL)); g_hash_table_insert (quark_ht, "vtype", GINT_TO_POINTER (QUARK_vtype)); g_hash_table_insert (quark_ht, "vtype:steal", GINT_TO_POINTER (QUARK_vtype_STEAL)); g_hash_table_insert (quark_ht, "destructor_unref", GINT_TO_POINTER (QUARK_destructor_unref)); @@ -236,6 +278,16 @@ ensure_quarks (void) g_hash_table_insert (quark_ht, "initializer", GINT_TO_POINTER (QUARK_initializer)); g_hash_table_insert (quark_ht, "initializer:steal", GINT_TO_POINTER (QUARK_initializer_STEAL)); g_hash_table_insert (quark_ht, "initializer_line", GINT_TO_POINTER (QUARK_initializer_line)); + g_hash_table_insert (quark_ht, "etype", GINT_TO_POINTER (QUARK_etype)); + g_hash_table_insert (quark_ht, "etype:steal", GINT_TO_POINTER (QUARK_etype_STEAL)); + g_hash_table_insert (quark_ht, "prefix", GINT_TO_POINTER (QUARK_prefix)); + g_hash_table_insert (quark_ht, "prefix:steal", GINT_TO_POINTER (QUARK_prefix_STEAL)); + g_hash_table_insert (quark_ht, "values", GINT_TO_POINTER (QUARK_values)); + g_hash_table_insert (quark_ht, "values:steal", GINT_TO_POINTER (QUARK_values_STEAL)); + g_hash_table_insert (quark_ht, "value", GINT_TO_POINTER (QUARK_value)); + g_hash_table_insert (quark_ht, "value:steal", GINT_TO_POINTER (QUARK_value_STEAL)); + g_hash_table_insert (quark_ht, "ftype", GINT_TO_POINTER (QUARK_ftype)); + g_hash_table_insert (quark_ht, "ftype:steal", GINT_TO_POINTER (QUARK_ftype_STEAL)); } static Argument * @@ -295,12 +347,68 @@ copy_class (Class * self) new->type = CLASS_NODE; new->otype = g_strdup (self->otype); new->ptype = g_strdup (self->ptype); - new->bonobo_x_class = g_strdup (self->bonobo_x_class); + new->bonobo_object_class = g_strdup (self->bonobo_object_class); new->chunk_size = g_strdup (self->chunk_size); + new->interfaces = g_list_copy (self->interfaces); COPY_LIST_VALS(new->interfaces, g_strdup); new->nodes = node_list_copy (self->nodes); return new; } +static EnumDef * +copy_enumdef (EnumDef * self) +{ + EnumDef * new; + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (self->type == ENUMDEF_NODE, NULL); + new = g_new0(EnumDef, 1); + new->type = ENUMDEF_NODE; + new->etype = g_strdup (self->etype); + new->prefix = g_strdup (self->prefix); + new->values = node_list_copy (self->values); + return new; +} + +static EnumValue * +copy_enumvalue (EnumValue * self) +{ + EnumValue * new; + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (self->type == ENUMVALUE_NODE, NULL); + new = g_new0(EnumValue, 1); + new->type = ENUMVALUE_NODE; + new->name = g_strdup (self->name); + new->value = g_strdup (self->value); + return new; +} + +static Error * +copy_error (Error * self) +{ + Error * new; + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (self->type == ERROR_NODE, NULL); + new = g_new0(Error, 1); + new->type = ERROR_NODE; + new->etype = g_strdup (self->etype); + new->prefix = g_strdup (self->prefix); + new->values = g_list_copy (self->values); COPY_LIST_VALS(new->values, g_strdup); + return new; +} + +static Flags * +copy_flags (Flags * self) +{ + Flags * new; + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (self->type == FLAGS_NODE, NULL); + new = g_new0(Flags, 1); + new->type = FLAGS_NODE; + new->ftype = g_strdup (self->ftype); + new->prefix = g_strdup (self->prefix); + new->values = g_list_copy (self->values); COPY_LIST_VALS(new->values, g_strdup); + return new; +} + static FuncArg * copy_funcarg (FuncArg * self) { @@ -338,7 +446,8 @@ copy_method (Method * self) new->ccode_line = self->ccode_line; new->vararg = self->vararg; new->unique_id = self->unique_id; - new->bonobo_x_func = self->bonobo_x_func; + new->bonobo_object_func = self->bonobo_object_func; + new->interface = g_strdup (self->interface); return new; } @@ -444,12 +553,56 @@ free_class (Class * self) g_return_if_fail (self->type == CLASS_NODE); g_free (self->otype); g_free (self->ptype); - g_free (self->bonobo_x_class); + g_free (self->bonobo_object_class); g_free (self->chunk_size); + g_list_foreach (self->interfaces, (GFunc)g_free, NULL); g_list_free (self->interfaces); node_list_free (self->nodes); g_free (self); } +void +free_enumdef (EnumDef * self) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (self->type == ENUMDEF_NODE); + g_free (self->etype); + g_free (self->prefix); + node_list_free (self->values); + g_free (self); +} + +void +free_enumvalue (EnumValue * self) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (self->type == ENUMVALUE_NODE); + g_free (self->name); + g_free (self->value); + g_free (self); +} + +void +free_error (Error * self) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (self->type == ERROR_NODE); + g_free (self->etype); + g_free (self->prefix); + g_list_foreach (self->values, (GFunc)g_free, NULL); g_list_free (self->values); + g_free (self); +} + +void +free_flags (Flags * self) +{ + g_return_if_fail (self != NULL); + g_return_if_fail (self->type == FLAGS_NODE); + g_free (self->ftype); + g_free (self->prefix); + g_list_foreach (self->values, (GFunc)g_free, NULL); g_list_free (self->values); + g_free (self); +} + void free_funcarg (FuncArg * self) { @@ -475,6 +628,7 @@ free_method (Method * self) g_free (self->onerror); g_free (self->defreturn); g_free (self->cbuf); + g_free (self->interface); g_free (self); } @@ -728,16 +882,16 @@ setv_class (Class * self, va_list __ap) self->ptype = ptype; break; } - case QUARK_bonobo_x_class: { - char * bonobo_x_class = va_arg (__ap, char *); - char * __old_value = self->bonobo_x_class; - self->bonobo_x_class = g_strdup (bonobo_x_class); + case QUARK_bonobo_object_class: { + char * bonobo_object_class = va_arg (__ap, char *); + char * __old_value = self->bonobo_object_class; + self->bonobo_object_class = g_strdup (bonobo_object_class); g_free (__old_value); break; } - case QUARK_bonobo_x_class_STEAL: { - char * bonobo_x_class = va_arg (__ap, char *); - self->bonobo_x_class = bonobo_x_class; + case QUARK_bonobo_object_class_STEAL: { + char * bonobo_object_class = va_arg (__ap, char *); + self->bonobo_object_class = bonobo_object_class; break; } case QUARK_chunk_size: { @@ -752,6 +906,18 @@ setv_class (Class * self, va_list __ap) self->chunk_size = chunk_size; break; } + case QUARK_interfaces: { + GList * interfaces = va_arg (__ap, GList *); + GList * __old_value = self->interfaces; + self->interfaces = g_list_copy (interfaces); COPY_LIST_VALS(self->interfaces, g_strdup); + g_list_foreach (__old_value, (GFunc)g_free, NULL); g_list_free (__old_value); + break; + } + case QUARK_interfaces_STEAL: { + GList * interfaces = va_arg (__ap, GList *); + self->interfaces = interfaces; + break; + } case QUARK_nodes: { GList * nodes = va_arg (__ap, GList *); GList * __old_value = self->nodes; @@ -771,6 +937,202 @@ setv_class (Class * self, va_list __ap) } } +static void +setv_enumdef (EnumDef * self, va_list __ap) +{ + int quark; + const char *arg; + ensure_quarks (); + while ((arg = va_arg (__ap, char *)) != NULL) { + quark = GPOINTER_TO_INT (g_hash_table_lookup (quark_ht, arg)); + switch (quark) { + case QUARK_etype: { + char * etype = va_arg (__ap, char *); + char * __old_value = self->etype; + self->etype = g_strdup (etype); + g_free (__old_value); + break; + } + case QUARK_etype_STEAL: { + char * etype = va_arg (__ap, char *); + self->etype = etype; + break; + } + case QUARK_prefix: { + char * prefix = va_arg (__ap, char *); + char * __old_value = self->prefix; + self->prefix = g_strdup (prefix); + g_free (__old_value); + break; + } + case QUARK_prefix_STEAL: { + char * prefix = va_arg (__ap, char *); + self->prefix = prefix; + break; + } + case QUARK_values: { + GList * values = va_arg (__ap, GList *); + GList * __old_value = self->values; + self->values = node_list_copy (values); + node_list_free (__old_value); + break; + } + case QUARK_values_STEAL: { + GList * values = va_arg (__ap, GList *); + self->values = values; + break; + } + default: + g_warning ("Argument named 'EnumDef::%s' does not exist", arg); + break; + } + } +} + +static void +setv_enumvalue (EnumValue * self, va_list __ap) +{ + int quark; + const char *arg; + ensure_quarks (); + while ((arg = va_arg (__ap, char *)) != NULL) { + quark = GPOINTER_TO_INT (g_hash_table_lookup (quark_ht, arg)); + switch (quark) { + case QUARK_name: { + char * name = va_arg (__ap, char *); + char * __old_value = self->name; + self->name = g_strdup (name); + g_free (__old_value); + break; + } + case QUARK_name_STEAL: { + char * name = va_arg (__ap, char *); + self->name = name; + break; + } + case QUARK_value: { + char * value = va_arg (__ap, char *); + char * __old_value = self->value; + self->value = g_strdup (value); + g_free (__old_value); + break; + } + case QUARK_value_STEAL: { + char * value = va_arg (__ap, char *); + self->value = value; + break; + } + default: + g_warning ("Argument named 'EnumValue::%s' does not exist", arg); + break; + } + } +} + +static void +setv_error (Error * self, va_list __ap) +{ + int quark; + const char *arg; + ensure_quarks (); + while ((arg = va_arg (__ap, char *)) != NULL) { + quark = GPOINTER_TO_INT (g_hash_table_lookup (quark_ht, arg)); + switch (quark) { + case QUARK_etype: { + char * etype = va_arg (__ap, char *); + char * __old_value = self->etype; + self->etype = g_strdup (etype); + g_free (__old_value); + break; + } + case QUARK_etype_STEAL: { + char * etype = va_arg (__ap, char *); + self->etype = etype; + break; + } + case QUARK_prefix: { + char * prefix = va_arg (__ap, char *); + char * __old_value = self->prefix; + self->prefix = g_strdup (prefix); + g_free (__old_value); + break; + } + case QUARK_prefix_STEAL: { + char * prefix = va_arg (__ap, char *); + self->prefix = prefix; + break; + } + case QUARK_values: { + GList * values = va_arg (__ap, GList *); + GList * __old_value = self->values; + self->values = g_list_copy (values); COPY_LIST_VALS(self->values, g_strdup); + g_list_foreach (__old_value, (GFunc)g_free, NULL); g_list_free (__old_value); + break; + } + case QUARK_values_STEAL: { + GList * values = va_arg (__ap, GList *); + self->values = values; + break; + } + default: + g_warning ("Argument named 'Error::%s' does not exist", arg); + break; + } + } +} + +static void +setv_flags (Flags * self, va_list __ap) +{ + int quark; + const char *arg; + ensure_quarks (); + while ((arg = va_arg (__ap, char *)) != NULL) { + quark = GPOINTER_TO_INT (g_hash_table_lookup (quark_ht, arg)); + switch (quark) { + case QUARK_ftype: { + char * ftype = va_arg (__ap, char *); + char * __old_value = self->ftype; + self->ftype = g_strdup (ftype); + g_free (__old_value); + break; + } + case QUARK_ftype_STEAL: { + char * ftype = va_arg (__ap, char *); + self->ftype = ftype; + break; + } + case QUARK_prefix: { + char * prefix = va_arg (__ap, char *); + char * __old_value = self->prefix; + self->prefix = g_strdup (prefix); + g_free (__old_value); + break; + } + case QUARK_prefix_STEAL: { + char * prefix = va_arg (__ap, char *); + self->prefix = prefix; + break; + } + case QUARK_values: { + GList * values = va_arg (__ap, GList *); + GList * __old_value = self->values; + self->values = g_list_copy (values); COPY_LIST_VALS(self->values, g_strdup); + g_list_foreach (__old_value, (GFunc)g_free, NULL); g_list_free (__old_value); + break; + } + case QUARK_values_STEAL: { + GList * values = va_arg (__ap, GList *); + self->values = values; + break; + } + default: + g_warning ("Argument named 'Flags::%s' does not exist", arg); + break; + } + } +} + static void setv_funcarg (FuncArg * self, va_list __ap) { @@ -970,9 +1332,21 @@ setv_method (Method * self, va_list __ap) self->unique_id = unique_id; break; } - case QUARK_bonobo_x_func: { - gboolean bonobo_x_func = va_arg (__ap, gboolean); - self->bonobo_x_func = bonobo_x_func; + case QUARK_bonobo_object_func: { + gboolean bonobo_object_func = va_arg (__ap, gboolean); + self->bonobo_object_func = bonobo_object_func; + break; + } + case QUARK_interface: { + char * interface = va_arg (__ap, char *); + char * __old_value = self->interface; + self->interface = g_strdup (interface); + g_free (__old_value); + break; + } + case QUARK_interface_STEAL: { + char * interface = va_arg (__ap, char *); + self->interface = interface; break; } default: @@ -1323,6 +1697,10 @@ node_copy (Node *node) case CCODE_NODE: return (Node *)copy_ccode ((CCode *)node); case CHECK_NODE: return (Node *)copy_check ((Check *)node); case CLASS_NODE: return (Node *)copy_class ((Class *)node); + case ENUMDEF_NODE: return (Node *)copy_enumdef ((EnumDef *)node); + case ENUMVALUE_NODE: return (Node *)copy_enumvalue ((EnumValue *)node); + case ERROR_NODE: return (Node *)copy_error ((Error *)node); + case FLAGS_NODE: return (Node *)copy_flags ((Flags *)node); case FUNCARG_NODE: return (Node *)copy_funcarg ((FuncArg *)node); case METHOD_NODE: return (Node *)copy_method ((Method *)node); case PROPERTY_NODE: return (Node *)copy_property ((Property *)node); @@ -1342,6 +1720,10 @@ node_setv (Node *node, va_list __ap) case CCODE_NODE: setv_ccode ((CCode *)node, __ap); break; case CHECK_NODE: setv_check ((Check *)node, __ap); break; case CLASS_NODE: setv_class ((Class *)node, __ap); break; + case ENUMDEF_NODE: setv_enumdef ((EnumDef *)node, __ap); break; + case ENUMVALUE_NODE: setv_enumvalue ((EnumValue *)node, __ap); break; + case ERROR_NODE: setv_error ((Error *)node, __ap); break; + case FLAGS_NODE: setv_flags ((Flags *)node, __ap); break; case FUNCARG_NODE: setv_funcarg ((FuncArg *)node, __ap); break; case METHOD_NODE: setv_method ((Method *)node, __ap); break; case PROPERTY_NODE: setv_property ((Property *)node, __ap); break; @@ -1388,6 +1770,26 @@ node_new (NodeType type, ...) node->type = type; setv_class ((Class *)node, __ap); break; + case ENUMDEF_NODE: + node = (Node *)g_new0 (EnumDef, 1); + node->type = type; + setv_enumdef ((EnumDef *)node, __ap); + break; + case ENUMVALUE_NODE: + node = (Node *)g_new0 (EnumValue, 1); + node->type = type; + setv_enumvalue ((EnumValue *)node, __ap); + break; + case ERROR_NODE: + node = (Node *)g_new0 (Error, 1); + node->type = type; + setv_error ((Error *)node, __ap); + break; + case FLAGS_NODE: + node = (Node *)g_new0 (Flags, 1); + node->type = type; + setv_flags ((Flags *)node, __ap); + break; case FUNCARG_NODE: node = (Node *)g_new0 (FuncArg, 1); node->type = type; @@ -1429,6 +1831,10 @@ node_free (Node *node) case CCODE_NODE: free_ccode ((CCode *)node); return; case CHECK_NODE: free_check ((Check *)node); return; case CLASS_NODE: free_class ((Class *)node); return; + case ENUMDEF_NODE: free_enumdef ((EnumDef *)node); return; + case ENUMVALUE_NODE: free_enumvalue ((EnumValue *)node); return; + case ERROR_NODE: free_error ((Error *)node); return; + case FLAGS_NODE: free_flags ((Flags *)node); return; case FUNCARG_NODE: free_funcarg ((FuncArg *)node); return; case METHOD_NODE: free_method ((Method *)node); return; case PROPERTY_NODE: free_property ((Property *)node); return;