[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/lib/classdefs classdata.c lparser.h l...
From: |
Neil Tiffin |
Subject: |
gnue/geas/lib/classdefs classdata.c lparser.h l... |
Date: |
Sun, 06 May 2001 16:20:43 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/05/06 16:20:43
Modified files:
geas/lib/classdefs: classdata.c lparser.h lparser.l
Log message:
Update classdata.c to GNUe coding standard, add assert()s, and debug
code, add Id to headers for lparser.h and .l, add parser reset to lparser.l
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.41&tr2=1.42&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/lparser.h.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/lparser.l.diff?cvsroot=OldCVS&tr1=1.16&tr2=1.17&r1=text&r2=text
Patches:
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.41
gnue/geas/lib/classdefs/classdata.c:1.42
--- gnue/geas/lib/classdefs/classdata.c:1.41 Thu Apr 19 12:21:12 2001
+++ gnue/geas/lib/classdefs/classdata.c Sun May 6 16:20:42 2001
@@ -23,6 +23,7 @@
#include <glib.h>
#include <string.h>
#include <time.h>
+#include <assert.h>
/* #include "gcdparser.h" */
#include "classdata.h"
@@ -32,994 +33,1542 @@
/* spaces to indent per level */
#define INDENT 2
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
int
-odl_get_error_count()
- {
- return (yyerrorcount);
- }
-
+odl_get_error_count ()
+{
+ return (yyerrorcount);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
int
-odl_get_warn_count()
- {
- return (yywarncount);
- }
-
-const char *
-odl_access_name(unsigned long int access)
- {
- switch (access)
- {
- case ODL_ACCESS_PUBLIC:
+odl_get_warn_count ()
+{
+ return (yywarncount);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_access_name (unsigned long int access)
+{
+ switch (access)
+ {
+ case ODL_ACCESS_PUBLIC:
return ("public");
- case ODL_ACCESS_PRIVATE:
+ case ODL_ACCESS_PRIVATE:
return ("private");
- case ODL_ACCESS_PROTECTED:
+ case ODL_ACCESS_PROTECTED:
return ("protected");
- case ODL_ACCESS_SYSTEM:
+ case ODL_ACCESS_SYSTEM:
return ("system");
- }
- return ("(unknown access)");
- }
-
-const char *
-odl_itemtype_name(enum odl_itemtype type)
- {
- switch (type)
- {
- case IT_unknown:
+ }
+ return ("(unknown access)");
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_itemtype_name (enum odl_itemtype type)
+{
+ switch (type)
+ {
+ case IT_type: /* added this to satisify compiler warnings
neilt */
+ case IT_ignore: /* added this to satisify compiler warnings
neilt */
+ case IT_unknown:
return ("unknown");
- case IT_module:
+ case IT_module:
return ("module");
- case IT_class:
+ case IT_class:
return ("class");
- case IT_field:
+ case IT_field:
return ("field");
- case IT_enum:
+ case IT_enum:
return ("enum");
- }
- return ("unknown");
- }
-
+ }
+ return ("unknown");
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_itemtype
-odl_itemtype_id(const char *name)
- {
- if (g_strcasecmp(name, "module") == 0)
+odl_itemtype_id (const char *name)
+{
+#ifdef DEBUG
+ assert (name != NULL);
+#endif
+ if (g_strcasecmp (name, "module") == 0)
+ {
return (IT_module);
- if (g_strcasecmp(name, "class") == 0)
+ }
+ if (g_strcasecmp (name, "class") == 0)
+ {
return (IT_class);
- if (g_strcasecmp(name, "field") == 0)
+ }
+ if (g_strcasecmp (name, "field") == 0)
+ {
return (IT_field);
- if (g_strcasecmp(name, "enum") == 0)
+ }
+ if (g_strcasecmp (name, "enum") == 0)
+ {
return (IT_enum);
-
- return (IT_unknown);
- }
-
-const char *
-odl_datatype_name(enum odl_datatype type)
- {
- switch (type)
- {
- case DT_unknown:
+ }
+ return (IT_unknown);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_datatype_name (enum odl_datatype type)
+{
+ switch (type)
+ {
+ case DT_unknown:
return ("unknown");
- case DT_char:
+ case DT_char:
return ("char");
- case DT_int:
+ case DT_int:
return ("int");
- case DT_text:
+ case DT_text:
return ("text");
- case DT_date:
+ case DT_date:
return ("date");
- case DT_time:
+ case DT_time:
return ("time");
- case DT_datetime:
+ case DT_datetime:
return ("datetime");
- case DT_bool:
+ case DT_bool:
return ("bool");
- case DT_float:
+ case DT_float:
return ("float");
- case DT_class:
+ case DT_class:
return ("class");
- case DT_enum:
+ case DT_enum:
return ("enum");
- case DT_void:
+ case DT_void:
return ("void");
- case DT_object:
+ case DT_object:
return ("object");
- case DT_unsignedint:
+ case DT_unsignedint:
return ("unsigned int");
-
- case DT_type:
+ case DT_type:
return ("compound datatype");
- }
- return ("unknown");
- }
-
+ }
+ return ("unknown");
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_datatype
-odl_datatype_id(const char *name)
- {
- if (g_strcasecmp(name, "char") == 0)
+odl_datatype_id (const char *name)
+{
+#ifdef DEBUG
+ assert (name != NULL);
+#endif
+ if (g_strcasecmp (name, "char") == 0)
+ {
return (DT_char);
- if (g_strcasecmp(name, "int") == 0)
+ }
+ if (g_strcasecmp (name, "int") == 0)
+ {
return (DT_int);
- if (g_strcasecmp(name, "text") == 0)
+ }
+ if (g_strcasecmp (name, "text") == 0)
+ {
return (DT_text);
- if (g_strcasecmp(name, "float") == 0)
+ }
+ if (g_strcasecmp (name, "float") == 0)
+ {
return (DT_float);
- if (g_strcasecmp(name, "bool") == 0)
+ }
+ if (g_strcasecmp (name, "bool") == 0)
+ {
return (DT_bool);
- if (g_strcasecmp(name, "date") == 0)
+ }
+ if (g_strcasecmp (name, "date") == 0)
+ {
return (DT_date);
- if (g_strcasecmp(name, "time") == 0)
+ }
+ if (g_strcasecmp (name, "time") == 0)
+ {
return (DT_time);
- if (g_strcasecmp(name, "datetime") == 0)
+ }
+ if (g_strcasecmp (name, "datetime") == 0)
+ {
return (DT_datetime);
- if (g_strcasecmp(name, "class") == 0)
+ }
+ if (g_strcasecmp (name, "class") == 0)
+ {
return (DT_class);
- if (g_strcasecmp(name, "void") == 0)
+ }
+ if (g_strcasecmp (name, "void") == 0)
+ {
return (DT_void);
- if (g_strcasecmp(name, "enum") == 0)
+ }
+ if (g_strcasecmp (name, "enum") == 0)
+ {
return (DT_enum);
- if (g_strcasecmp(name, "object") == 0)
+ }
+ if (g_strcasecmp (name, "object") == 0)
+ {
return (DT_object);
- if (g_strcasecmp(name, "unsignedint") == 0)
+ }
+ if (g_strcasecmp (name, "unsignedint") == 0)
+ {
return (DT_unsignedint);
-
- return (DT_unknown);
- }
-
-const char *
-odl_fieldtype_name(enum odl_fieldtype type)
- {
- switch (type)
- {
- case FT_unknown:
+ }
+ return (DT_unknown);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_fieldtype_name (enum odl_fieldtype type)
+{
+ switch (type)
+ {
+ case FT_unknown:
return ("unknown");
- case FT_lookup:
+ case FT_lookup:
return ("lookup");
- case FT_reference:
+ case FT_reference:
return ("reference");
- case FT_list:
+ case FT_list:
return ("list");
- case FT_method:
+ case FT_method:
return ("method");
- case FT_calculated:
+ case FT_calculated:
return ("calculated");
- case FT_readonly:
+ case FT_readonly:
return ("readonly");
- case FT_basic:
+ case FT_basic:
return ("basic");
- }
- return ("unknown");
- }
-
+ }
+ return ("unknown");
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_fieldtype
-odl_fieldtype_id(const char *name)
- {
- if (g_strcasecmp(name, "lookup") == 0)
+odl_fieldtype_id (const char *name)
+{
+#ifdef DEBUG
+ assert (name != NULL);
+#endif
+ if (g_strcasecmp (name, "lookup") == 0)
+ {
return (FT_lookup);
- if (g_strcasecmp(name, "reference") == 0)
+ }
+ if (g_strcasecmp (name, "reference") == 0)
+ {
return (FT_reference);
- if (g_strcasecmp(name, "list") == 0)
+ }
+ if (g_strcasecmp (name, "list") == 0)
+ {
return (FT_list);
- if (g_strcasecmp(name, "method") == 0)
+ }
+ if (g_strcasecmp (name, "method") == 0)
+ {
return (FT_method);
- if (g_strcasecmp(name, "calculated") == 0)
+ }
+ if (g_strcasecmp (name, "calculated") == 0)
+ {
return (FT_calculated);
- if (g_strcasecmp(name, "readonly") == 0)
+ }
+ if (g_strcasecmp (name, "readonly") == 0)
+ {
return (FT_readonly);
- if (g_strcasecmp(name, "basic") == 0)
+ }
+ if (g_strcasecmp (name, "basic") == 0)
+ {
return (FT_basic);
-
- return (FT_unknown);
- }
-
-/**********************/
-
-/* List handling code */
-
+ }
+ return (FT_unknown);
+}
+
+/* ========================================================================= *\
+ * List handling code
+\* ========================================================================= */
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
void
-odl_filenamelist_free(odl_filenamelist * list)
- {
- odl_namelist_free((odl_namelist *) list);
- }
-
+odl_filenamelist_free (odl_filenamelist * list)
+{
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ odl_namelist_free ((odl_namelist *) list);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_filenamelist *
-odl_filenamelist_add(odl_filenamelist * list, const char *filename)
- {
- char *f;
-
- if (filename)
- f = g_strdup(filename);
- if (f)
- list = (odl_filenamelist *) g_list_append((GList *) list, f);
- return (list);
- }
-
+odl_filenamelist_add (odl_filenamelist * list, const char *filename)
+{
+ char *f;
+
+#ifdef DEBUG
+ assert (filename != NULL);
+#endif
+ if (filename)
+ {
+ f = g_strdup (filename);
+ }
+ if (f)
+ {
+ list = (odl_filenamelist *) g_list_append ((GList *) list, f);
+ }
+ return (list);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
void
-odl_namelist_free(odl_namelist * list)
- {
- GList *l = (GList *) list;
-
- /* printf( "----" ); */
- while (l)
- {
- /* printf( "\n***" ); */
+odl_namelist_free (odl_namelist * list)
+{
+ GList *l;
+
+#ifdef DEBUG
+ printf ("---- odl_namelist_free() ----\n");
+ assert (list != NULL);
+#endif
+ l = (GList *) list;
+ while (l)
+ {
if (l->data)
- {
- /* printf( "...... %s" , l->data ); */
- g_free(l->data);
- }
-
- l = g_list_next(l);
- }
- if (list)
- g_list_free((GList *) list);
- /* printf( "----\n" ); */
- }
-
-const char *
-odl_namelist_entry(odl_namelist * list, int index)
- {
- return (g_list_nth_data((GList *) list, index));
- }
+ {
+#ifdef DEBUG
+ printf( "...... %s\n" , l->data );
+#endif
+ g_free (l->data);
+ }
+ l = g_list_next (l);
+ }
+ if (list)
+ {
+ g_list_free ((GList *) list);
+ }
+#ifdef DEBUG
+ printf( "---- end of odl_namelist_free() ----\n" );
+#endif
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_namelist_entry (odl_namelist * list, int index)
+{
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ return (g_list_nth_data ((GList *) list, index));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
gboolean
-odl_namelist_contains(odl_namelist * list, const char *name, gboolean
casesensitive)
- {
- GList *l = list;
-
- while (l)
- {
+odl_namelist_contains (odl_namelist * list, const char *name,
+ gboolean casesensitive)
+{
+ GList *l;
+
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ l = list;
+ while (l)
+ {
if (!casesensitive)
- if (g_strcasecmp(name, l->data) == 0)
- return (TRUE);
- else if (strcmp(name, l->data) == 0)
- return (TRUE);
- l = g_list_next(l);
- }
- return (FALSE);
- }
-
+ {
+ if (g_strcasecmp (name, l->data) == 0)
+ {
+ return (TRUE);
+ }
+ else if (strcmp (name, l->data) == 0)
+ {
+ return (TRUE);
+ }
+ }
+ l = g_list_next (l);
+ }
+ return (FALSE);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
void
-odl_fieldlist_free(odl_fieldlist * list)
- {
- if (list)
- g_list_free((GList *) list);
- }
-
+odl_fieldlist_free (odl_fieldlist * list)
+{
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ if (list)
+ {
+ g_list_free ((GList *) list);
+ }
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_field *
-odl_fieldlist_entry(odl_fieldlist * list, int index)
- {
- return (g_list_nth_data((GList *) list, index));
- }
-
+odl_fieldlist_entry (odl_fieldlist * list, int index)
+{
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ return (g_list_nth_data ((GList *) list, index));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
void
-odl_argumentlist_free(odl_argumentlist * list)
- {
- if (list)
- g_list_free((GList *) list);
- }
-
+odl_argumentlist_free (odl_argumentlist * list)
+{
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ if (list)
+ {
+ g_list_free ((GList *) list);
+ }
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_argument *
-odl_argumentlist_entry(odl_argumentlist * list, int index)
- {
- return (g_list_nth_data((GList *) list, index));
- }
-
-/* locate items based on name */
+odl_argumentlist_entry (odl_argumentlist * list, int index)
+{
+#ifdef DEBUG
+ assert (list != NULL);
+#endif
+ return (g_list_nth_data ((GList *) list, index));
+}
+
+/* ========================================================================= *\
+ * Locate items based on name
+\* ========================================================================= */
+
+/* ------------------------------------------------------------------------- *\
+ * if id = null, use latest version other wise use the specified version
+ * not implemented.
+\* ------------------------------------------------------------------------- */
odl_class *
-odl_find_class(odl_tree * tree, const char *name, const char *id)
- {
- struct _odl_base *item = (struct _odl_base *)odl_find_item(tree, name, id);
+odl_find_class (odl_tree * tree, const char *name, const char *id)
+{
+ struct _odl_base *item;
+
+#ifdef DEBUG
+ assert (name != NULL);
+ assert (tree != NULL);
+#endif
+ item = (struct _odl_base *) odl_find_item (tree, name, id);
- if (!item)
+ if (!item)
+ {
return (NULL);
-
- if (item->type == IT_class)
+ }
+ if (item->type == IT_class)
+ {
return ((odl_class *) item);
- return (NULL);
- }
-
+ }
+ return (NULL);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_module *
-odl_find_module(odl_tree * tree, const char *name, const char *id)
- {
- struct _odl_base *item = (struct _odl_base *)odl_find_item(tree, name, id);
+odl_find_module (odl_tree * tree, const char *name, const char *id)
+{
+ struct _odl_base *item;
+
+#ifdef DEBUG
+ assert (name != NULL);
+ assert (id != NULL);
+#endif
+ item = (struct _odl_base *) odl_find_item (tree, name, id);
- if (!item)
+ if (!item)
+ {
return (NULL);
-
- if (item->type == IT_module)
+ }
+ if (item->type == IT_module)
+ {
return ((odl_module *) item);
- return (NULL);
- }
-
+ }
+ return (NULL);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_field *
-odl_find_field(odl_tree * tree, const char *name, const char *id)
- {
- struct _odl_base *item = (struct _odl_base *)odl_find_item(tree, name, id);
-
- if (!item)
+odl_find_field (odl_tree * tree, const char *name, const char *id)
+{
+ struct _odl_base *item;
+
+#ifdef DEBUG
+ assert (name != NULL);
+ assert (id != NULL);
+#endif
+ item = (struct _odl_base *) odl_find_item (tree, name, id);
+ if (!item)
+ {
return (NULL);
-
- if (item->type == IT_field)
+ }
+ if (item->type == IT_field)
+ {
return ((odl_field *) item);
- return (NULL);
- }
-
+ }
+ return (NULL);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_find_in_container(odl_base * c, const char *name)
- {
- GList *l;
-
- /* if it's not a container, it really can't contain things ;) */
- if (c->type != IT_class && c->type != IT_module)
+odl_find_in_container (odl_base * c, const char *name)
+{
+ GList *l;
+
+#ifdef DEBUG
+ assert (c != NULL);
+ assert (name != NULL);
+#endif
+ /* if it's not a container, it really can't contain things ;) */
+ if (c->type != IT_class && c->type != IT_module)
+ {
return (NULL);
-
- l = ((odl_container *) c)->contents;
- while (l)
- {
- if (g_strcasecmp(((odl_base *) l->data)->name, name) == 0)
- return ((odl_base *) l->data);
- l = g_list_next(l);
- }
- return (NULL);
- }
-
+ }
+ l = ((odl_container *) c)->contents;
+ while (l)
+ {
+ if (g_strcasecmp (((odl_base *) l->data)->name, name) == 0)
+ {
+ return ((odl_base *) l->data);
+ }
+ l = g_list_next (l);
+ }
+ return (NULL);
+}
+
+/* ------------------------------------------------------------------------- *\
+ * :ocate a named item in the class tree
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_find_item(odl_tree * tree, const char *name, const char *id)
- {
- /* locate a named item in the class tree */
- odl_namelist *nl;
- GList *l;
- odl_base *retval = NULL;
- char *tmp;
-
- /* cos it's a const input, make a temp. duplicate */
- tmp = g_strdup(name);
- if (!tmp)
+odl_find_item (odl_tree * tree, const char *name, const char *id)
+{
+ odl_namelist *nl;
+ GList *l;
+ odl_base *retval = NULL;
+ char *tmp;
+
+#ifdef DEBUG
+ assert (name != NULL);
+ /* assert (id != NULL); id not used? */
+ assert (tree != NULL);
+#endif
+ /* cos it's a const input, make a temp. duplicate */
+ tmp = g_strdup (name);
+ if (!tmp)
+ {
return (NULL);
- nl = odl_split_qualified_name(tmp);
- g_free(tmp);
- if (!nl)
+ }
+ nl = odl_split_qualified_name (tmp);
+ g_free (tmp);
+ if (!nl)
+ {
return (NULL);
-
- /* make everything look like an 'absolute' name */
- if (nl && nl->data && strcmp(nl->data, "root") != 0)
- nl = g_list_prepend(nl, g_strdup("root"));
-
- /* handle special case: 'root'. */
- retval = (odl_base *) odl_tree_get_root(tree);
- if (!retval)
- {
- odl_namelist_free(nl);
+ }
+ /* make everything look like an 'absolute' name */
+ if (nl && nl->data && strcmp (nl->data, "root") != 0)
+ {
+ nl = g_list_prepend (nl, g_strdup ("root"));
+ }
+ /* handle special case: 'root'. */
+ retval = (odl_base *) odl_tree_get_root (tree);
+ if (!retval)
+ {
+ odl_namelist_free (nl);
return (NULL);
- }
- if (g_strcasecmp(retval->name, nl->data) != 0)
- {
+ }
+ if (g_strcasecmp (retval->name, nl->data) != 0)
+ {
/* really shouldn't happen.. */
- odl_namelist_free(nl);
+ odl_namelist_free (nl);
return (NULL);
- }
+ }
- l = nl->next;
+ l = nl->next;
- /* for each item, look for it inside 'retval' then make that the */
- /* new 'retval' - once last item is found, we have it */
- while (l)
- {
- retval = (odl_base *) odl_find_in_container(retval, l->data);
+ /* for each item, look for it inside 'retval' then make that the */
+ /* new 'retval' - once last item is found, we have it */
+ while (l)
+ {
+ retval = (odl_base *) odl_find_in_container (retval, l->data);
if (!retval)
- {
- /* not found, name doesn't exist */
- odl_namelist_free(nl);
- return (NULL);
- }
+ {
+ /* not found, name doesn't exist */
+ odl_namelist_free (nl);
+ return (NULL);
+ }
/* found it, start on next one */
l = l->next;
- }
- odl_namelist_free(nl);
- return (retval);
- }
-
+ }
+ odl_namelist_free (nl);
+ return (retval);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_container_get_parent(odl_container * container)
- {
- return (container->base.parent);
- }
-
+odl_container_get_parent (odl_container * container)
+{
+#ifdef DEBUG
+ assert (container != NULL);
+#endif
+ return (container->base.parent);
+}
+
+/* ------------------------------------------------------------------------- *\
+ * Locate a named item in the class tree
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_find_relative(odl_base * start, const char *name)
- {
- /* locate a named item in the class tree */
- odl_namelist *nl;
- GList *l;
- odl_base *retval = start;
- char *tmp;
-
- /* cos it's a const input, make a temp. duplicate */
- tmp = g_strdup(name);
- if (!tmp)
+odl_find_relative (odl_base * start, const char *name)
+{
+ odl_namelist *nl;
+ GList *l;
+ odl_base *retval;
+ char *tmp;
+
+#ifdef DEBUG
+ assert (start != NULL);
+ assert (name != NULL);
+#endif
+ retval = start;
+ /* cos it's a const input, make a temp. duplicate */
+ tmp = g_strdup (name);
+ if (!tmp)
+ {
return (NULL);
- nl = odl_split_qualified_name(tmp);
- g_free(tmp);
-
- l = nl;
-
- /* for each item, look for it inside 'retval' then make that the */
- /* new 'retval' - once last item is found, we have it */
- while (l)
- {
- retval = (odl_base *) odl_find_in_container(retval, l->data);
+ }
+ nl = odl_split_qualified_name (tmp);
+ g_free (tmp);
+
+ l = nl;
+
+ /* for each item, look for it inside 'retval' then make that the */
+ /* new 'retval' - once last item is found, we have it */
+ while (l)
+ {
+ retval = (odl_base *) odl_find_in_container (retval, l->data);
if (!retval)
- {
- /* not found, name doesn't exist */
- odl_namelist_free(nl);
- return (NULL);
- }
+ {
+ /* not found, name doesn't exist */
+ odl_namelist_free (nl);
+ return (NULL);
+ }
/* found it, start on next one */
l = l->next;
- }
- odl_namelist_free(nl);
- return (retval);
- }
-
+ }
+ odl_namelist_free (nl);
+ return (retval);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_itemtype
-odl_find_named_item_type(odl_tree * tree, const char *name)
- {
- odl_base *i = (odl_base *) odl_find_item(tree, name, NULL);
-
- if (!i)
+odl_find_named_item_type (odl_tree * tree, const char *name)
+{
+ odl_base *i;
+
+#ifdef DEBUG
+ assert (tree != NULL);
+ assert (name != NULL);
+#endif
+ i = (odl_base *) odl_find_item (tree, name, NULL);
+ if (!i)
+ {
return (IT_unknown);
- return (i->type);
- }
-
-const char *
-odl_item_get_full_name(odl_base * item)
- {
- return (odl_get_base_full_name((odl_base *) item));
- }
-
+ }
+ return (i->type);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_item_get_full_name (odl_base * item)
+{
+#ifdef DEBUG
+ assert (item != NULL);
+#endif
+ return (odl_get_base_full_name ((odl_base *) item));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_class *
-odl_field_defined_in(odl_class * startclass, const char *name)
- {
- odl_class *c;
- odl_namelist *parents;
- GList *l;
-
- /* look in initial class */
- if (odl_find_in_container((odl_base *) startclass, name))
+odl_field_defined_in (odl_class * startclass, const char *name)
+{
+ odl_class *c;
+ odl_namelist *parents;
+ GList *l;
+
+#ifdef DEBUG
+ assert (startclass != NULL);
+ assert (name != NULL);
+#endif
+ /* look in initial class */
+ if (odl_find_in_container ((odl_base *) startclass, name))
+ {
return (startclass);
-
- /* search parents */
- parents = odl_class_get_parentnames(startclass);
- l = parents;
- while (l)
- {
- c = odl_find_class(startclass->base.tree, l->data, NULL);
+ }
+ /* search parents */
+ parents = odl_class_get_parentnames (startclass);
+ l = parents;
+ while (l)
+ {
+ c = odl_find_class (startclass->base.tree, l->data, NULL);
if (c)
- {
- if (odl_find_in_container((odl_base *) c, name))
+ {
+ if (odl_find_in_container ((odl_base *) c, name))
{
- odl_namelist_free(parents);
- return (c);
+ odl_namelist_free (parents);
+ return (c);
}
- }
- l = g_list_next(l);
- }
-
- /* not found */
- odl_namelist_free(parents);
- return (NULL);
- }
+ }
+ l = g_list_next (l);
+ }
-static odl_namelist *
-real_odl_tree_list_classes(odl_base * item)
- {
- odl_namelist *nl = NULL;
- GList *l;
+ /* not found */
+ odl_namelist_free (parents);
+ return (NULL);
+}
- if (!item)
+static odl_namelist *
+real_odl_tree_list_classes (odl_base * item)
+{
+ odl_namelist *nl = NULL;
+ GList *l;
+
+#ifdef DEBUG
+ assert (item != NULL);
+#endif
+ if (!item)
+ {
return (NULL);
- if (item->type == IT_class && ((odl_class *) item)->istype == FALSE)
- {
- nl = g_list_append(nl, g_strdup(odl_item_get_full_name(item)));
- }
-
- l = ((odl_container *) item)->contents;
- while (l)
- {
+ }
+ if (item->type == IT_class && ((odl_class *) item)->istype == FALSE)
+ {
+ nl = g_list_append (nl, g_strdup (odl_item_get_full_name (item)));
+ }
+ l = ((odl_container *) item)->contents;
+ while (l)
+ {
odl_base *i = (odl_base *) l->data;
-
if (i->type == IT_module || i->type == IT_class)
- {
- odl_namelist *t = real_odl_tree_list_classes(i);
-
- if (t)
+ {
+ odl_namelist *t = real_odl_tree_list_classes (i);
+ if (t)
{
- if (nl != NULL)
- nl = g_list_concat(nl, t);
- else
- nl = t;
- }
- }
- l = g_list_next(l);
- }
-
- return (nl);
- }
-
+ if (nl != NULL)
+ {
+ nl = g_list_concat (nl, t);
+ }
+ else
+ {
+ nl = t;
+ }
+ }
+ }
+ l = g_list_next (l);
+ }
+ return (nl);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_namelist *
-odl_tree_list_classes(odl_tree * tree)
- {
- if (tree == NULL)
+odl_tree_list_classes (odl_tree * tree)
+{
+#ifdef DEBUG
+ assert (tree != NULL);
+#endif
+ if (tree == NULL)
+ {
return (NULL);
- return (real_odl_tree_list_classes((odl_base *) tree->root));
- }
-
-const char *
-odl_module_get_name(odl_module * module)
- {
- return (module->base.name);
- }
-
-const char *
-odl_enum_get_full_name(odl_enum * e)
- {
- return (odl_get_base_full_name((odl_base *) e));
- }
-
-const char *
-odl_module_get_full_name(odl_module * module)
- {
- return (odl_get_base_full_name((odl_base *) module));
- }
-
+ }
+ return (real_odl_tree_list_classes ((odl_base *) tree->root));
+}
+
+const char *
+odl_module_get_name (odl_module * module)
+{
+#ifdef DEBUG
+ assert (module != NULL);
+#endif
+ return (module->base.name);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_enum_get_full_name (odl_enum * e)
+{
+#ifdef DEBUG
+ assert (e != NULL);
+#endif
+ return (odl_get_base_full_name ((odl_base *) e));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_module_get_full_name (odl_module * module)
+{
+#ifdef DEBUG
+ assert (module != NULL);
+#endif
+ return (odl_get_base_full_name ((odl_base *) module));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
unsigned long int
-odl_module_get_access(odl_module * module)
- {
- return (module->base.access);
- }
-
+odl_module_get_access (odl_module * module)
+{
+#ifdef DEBUG
+ assert (module != NULL);
+#endif
+ return (module->base.access);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_module_get_parent(odl_module * module)
- {
- return (module->base.parent);
- }
-
-/* read data from: class */
-const char *
-odl_class_get_name(odl_class * classd)
- {
- return (classd->base.name);
- }
-
-const char *
-odl_class_get_full_name(odl_class * classd)
- {
- return (odl_get_base_full_name((odl_base *) classd));
- }
-
-const char *
-odl_class_get_mangled_name(odl_class * classd)
- {
- if (classd->base.mangledname == NULL)
- {
-
- /* printf( "mangling name %s\n" , classd->base.name ); */
- classd->base.mangledname =
odl_mangle_qualified_name(odl_class_get_full_name(classd));
- }
-
- /* printf( "mangled name: %s\n" , classd->base.mangledname ); */
- return (classd->base.mangledname);
- }
-
+odl_module_get_parent (odl_module * module)
+{
+#ifdef DEBUG
+ assert (module != NULL);
+#endif
+ return (module->base.parent);
+}
+
+/* ========================================================================= *\
+ * Read data from: class
+\* ========================================================================= */
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_class_get_name (odl_class * classd)
+{
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ return (classd->base.name);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_class_get_full_name (odl_class * classd)
+{
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ return (odl_get_base_full_name ((odl_base *) classd));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_class_get_mangled_name (odl_class * classd)
+{
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ if (classd->base.mangledname == NULL)
+ {
+#ifdef DEBUG
+ printf( "mangling name %s\n" , classd->base.name );
+#endif
+ classd->base.mangledname =
+ odl_mangle_qualified_name (odl_class_get_full_name (classd));
+ }
+#ifdef DEBUG
+ printf( "mangled name: %s\n" , classd->base.mangledname );
+#endif
+ return (classd->base.mangledname);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
unsigned long int
-odl_class_get_access(odl_class * classd)
- {
- return (classd->base.access);
- }
-
+odl_class_get_access (odl_class * classd)
+{
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ return (classd->base.access);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
unsigned long int
-odl_class_get_triggers(odl_class * classd)
- {
- return (classd->base.triggers);
- }
-
+odl_class_get_triggers (odl_class * classd)
+{
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ return (classd->base.triggers);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_class_get_parent(odl_class * classd)
- {
- return (classd->base.parent);
- }
-
+odl_class_get_parent (odl_class * classd)
+{
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ return (classd->base.parent);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_namelist *
-odl_class_get_parentnames(odl_class * classd)
- {
- odl_namelist *nl = NULL;
- GList *l;
-
- l = classd->parents;
- while (l)
- {
- nl = g_list_append(nl, g_strdup(l->data));
- l = g_list_next(l);
- }
- return (nl);
- }
-
+odl_class_get_parentnames (odl_class * classd)
+{
+ odl_namelist *nl = NULL;
+ GList *l;
+
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ l = classd->parents;
+ while (l)
+ {
+ nl = g_list_append (nl, g_strdup (l->data));
+ l = g_list_next (l);
+ }
+ return (nl);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_field *
-odl_class_get_field(odl_class * classd, const char *fieldname)
- {
- odl_class *c = odl_field_defined_in(classd, fieldname);
-
- if (c)
- {
- return ((odl_field *) odl_find_relative((odl_base *) c, fieldname));
- }
- return (NULL);
- }
-
+odl_class_get_field (odl_class * classd, const char *fieldname)
+{
+ odl_class *c;
+
+#ifdef DEBUG
+ assert (classd != NULL);
+ assert (fieldname != NULL);
+#endif
+ c = odl_field_defined_in (classd, fieldname);
+ if (c)
+ {
+ return ((odl_field *) odl_find_relative ((odl_base *) c, fieldname));
+ }
+ return (NULL);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_fieldlist *
-odl_class_get_fields(odl_class * classd, enum odl_fieldtype type)
- {
- /* list of pointers to odl_field with indicated type */
- /* excludes inherited fields */
- odl_fieldlist *fl = NULL;
- GList *l;
-
- l = classd->contents;
- while (l)
- {
+odl_class_get_fields (odl_class * classd, enum odl_fieldtype type)
+{
+ /* list of pointers to odl_field with indicated type */
+ /* excludes inherited fields */
+ odl_fieldlist *fl = NULL;
+ GList *l;
+
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ l = classd->contents;
+ while (l)
+ {
odl_base *b = l->data;
if (b->type == IT_field)
- {
- odl_field *f = (odl_field *) b;
-
- if (f->fieldtype == type)
- fl = g_list_append(fl, f);
- }
- l = g_list_next(l);
- }
- return (fl);
- }
+ {
+ odl_field *f = (odl_field *) b;
+ if (f->fieldtype == type)
+ fl = g_list_append (fl, f);
+ }
+ l = g_list_next (l);
+ }
+ return (fl);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_fieldlist *
-odl_class_get_all_fields(odl_class * classd, enum odl_fieldtype type)
- {
- /* list of pointers to odl_field with indicated type */
- /* includes inherited fields */
- odl_fieldlist *fl = NULL;
- odl_namelist *parents = odl_class_get_parentnames(classd);
- GList *l;
-
- fl = odl_class_get_fields(classd, type);
- l = parents;
- while (l)
- {
+odl_class_get_all_fields (odl_class * classd, enum odl_fieldtype type)
+{
+ /* list of pointers to odl_field with indicated type */
+ /* includes inherited fields */
+ odl_fieldlist *fl = NULL;
+ odl_namelist *parents;
+ GList *l;
+
+#ifdef DEBUG
+ assert (classd != NULL);
+#endif
+ parents = odl_class_get_parentnames (classd);
+ fl = odl_class_get_fields (classd, type);
+ l = parents;
+ while (l)
+ {
odl_fieldlist *tmp;
- odl_class *c = odl_find_class(classd->base.tree, l->data, NULL);
-
+ odl_class *c = odl_find_class (classd->base.tree, l->data, NULL);
if (c)
- {
- tmp = odl_class_get_fields(c, type);
- if (tmp)
- {
- if (fl)
- fl = g_list_concat(fl, tmp);
- else
- fl = tmp;
- }
- }
- l = g_list_next(l);
- }
- if (parents)
- odl_namelist_free(parents);
-
- return (fl);
- }
-
+ {
+ tmp = odl_class_get_fields (c, type);
+ if (tmp)
+ {
+ if (fl)
+ {
+ fl = g_list_concat (fl, tmp);
+ }
+ else
+ {
+ fl = tmp;
+ }
+ }
+ }
+ l = g_list_next (l);
+ }
+ if (parents)
+ {
+ odl_namelist_free (parents);
+ }
+ return (fl);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
gboolean
-odl_class_is_instanceof(odl_class * classd, const char *classname)
- {
- odl_namelist *parents;
- char *n1, *n2;
-
- /* account for "root::" being in the full class name */
- n1 = (char *)odl_class_get_full_name(classd);
- n2 = (char *)classname;
- if (strncmp(n2, "root::", 6) != 0)
- {
- if (strncmp(n1, "root::", 6) == 0)
- n1 += 6;
- }
-
- if (g_strcasecmp(n1, n2) == 0)
+odl_class_is_instanceof (odl_class * classd, const char *classname)
+{
+ odl_namelist *parents;
+ char *n1, *n2;
+
+#ifdef DEBUG
+ assert (classd != NULL);
+ assert (classname != NULL);
+#endif
+ /* account for "root::" being in the full class name */
+ n1 = (char *) odl_class_get_full_name (classd);
+ n2 = (char *) classname;
+ if (strncmp (n2, "root::", 6) != 0)
+ {
+ if (strncmp (n1, "root::", 6) == 0)
+ {
+ n1 += 6;
+ }
+ }
+ if (g_strcasecmp (n1, n2) == 0)
+ {
return (TRUE);
-
- parents = odl_class_get_parentnames(classd);
- if (odl_namelist_contains(parents, classname, FALSE))
- {
- odl_namelist_free(parents);
+ }
+ parents = odl_class_get_parentnames (classd);
+ if (odl_namelist_contains (parents, classname, FALSE))
+ {
+ odl_namelist_free (parents);
return (TRUE);
- }
- odl_namelist_free(parents);
- return (FALSE);
- }
-
+ }
+ odl_namelist_free (parents);
+ return (FALSE);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_fieldtype
-odl_field_get_type(odl_field * field)
- {
- return (field->fieldtype);
- }
-
+odl_field_get_type (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->fieldtype);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_datatype
-odl_field_get_datatype(odl_field * field)
- {
- return (field->datatype);
- }
-
-const char *
-odl_field_get_datatype_classname(odl_field * field)
- {
- return (field->datatypeclass);
- }
-
+odl_field_get_datatype (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->datatype);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_datatype_classname (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->datatypeclass);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
gboolean
-odl_field_has_property(odl_field * field, unsigned long int property)
- {
- return (field->properties & property ? TRUE : FALSE);
- }
-
-/* read data from: field */
-const char *
-odl_field_get_name(odl_field * field)
- {
- return (field->base.name);
- }
-
-const char *
-odl_field_get_full_name(odl_field * field)
- {
- return (odl_get_base_full_name((odl_base *) field));
- }
-
+odl_field_has_property (odl_field * field, unsigned long int property)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->properties & property ? TRUE : FALSE);
+}
+
+/* ========================================================================= *\
+ * Read data from: field
+\* ========================================================================= */
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_name (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->base.name);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_full_name (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (odl_get_base_full_name ((odl_base *) field));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
unsigned long int
-odl_field_get_access(odl_field * field)
- {
- return (field->base.access);
- }
-
+odl_field_get_access (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->base.access);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
unsigned long int
-odl_field_get_triggers(odl_field * field)
- {
- return (field->base.triggers);
- }
-
+odl_field_get_triggers (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->base.triggers);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_base *
-odl_field_get_class(odl_field * field)
- {
- return (field->base.parent);
- }
-
-const char *
-odl_field_get_format(odl_field * field)
- {
- return (field->format);
- }
-
-const char *
-odl_field_get_default(odl_field * field)
- {
- int len;
- time_t timep;
- struct tm *tm;
-
- if (field->tmpdefault)
- g_free(field->tmpdefault);
- field->tmpdefault = NULL;
-
- switch (field->datatype)
- {
- case DT_date:
- if( !field->defaultval ) {
- field->tmpdefault = g_strdup( "" );
- return (field->tmpdefault);
- }
- if (g_strcasecmp(field->defaultval, "today") == 0)
- {
- len = strlen("0000-00-00 AD");
- field->tmpdefault = g_malloc(len + 2);
- timep = time(NULL);
- tm = localtime(&timep);
- strftime(field->tmpdefault, len, "%G-%m-%d", tm);
- field->tmpdefault[len + 1] = '\0';
- return (field->tmpdefault);
- }
+odl_field_get_class (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->base.parent);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_format (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->format);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_default (odl_field * field)
+{
+ int len;
+ time_t timep;
+ struct tm *tm;
+
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ if (field->tmpdefault)
+ g_free (field->tmpdefault);
+ field->tmpdefault = NULL;
+ switch (field->datatype)
+ {
+ case DT_date:
+ if (!field->defaultval)
+ {
+ field->tmpdefault = g_strdup ("");
+ return (field->tmpdefault);
+ }
+ if (g_strcasecmp (field->defaultval, "today") == 0)
+ {
+ len = strlen ("0000-00-00 AD");
+ field->tmpdefault = g_malloc (len + 2);
+ timep = time (NULL);
+ tm = localtime (&timep);
+ strftime (field->tmpdefault, len, "%G-%m-%d", tm);
+ field->tmpdefault[len + 1] = '\0';
+ return (field->tmpdefault);
+ }
break;
- case DT_time:
- if( !field->defaultval ) {
- field->tmpdefault = g_strdup( "" );
- return (field->tmpdefault);
- }
- if (g_strcasecmp(field->defaultval, "now") == 0)
- {
- len = strlen("HH:MM:SS AM");
- field->tmpdefault = g_malloc(len + 2);
- timep = time(NULL);
- tm = localtime(&timep);
- strftime(field->tmpdefault, len, "%H:%M:%S", tm);
- field->tmpdefault[len + 1] = '\0';
- return (field->tmpdefault);
- }
+ case DT_time:
+ if (!field->defaultval)
+ {
+ field->tmpdefault = g_strdup ("");
+ return (field->tmpdefault);
+ }
+ if (g_strcasecmp (field->defaultval, "now") == 0)
+ {
+ len = strlen ("HH:MM:SS AM");
+ field->tmpdefault = g_malloc (len + 2);
+ timep = time (NULL);
+ tm = localtime (&timep);
+ strftime (field->tmpdefault, len, "%H:%M:%S", tm);
+ field->tmpdefault[len + 1] = '\0';
+ return (field->tmpdefault);
+ }
break;
- case DT_datetime:
- if( !field->defaultval ) {
- field->tmpdefault = g_strdup( "" );
- return (field->tmpdefault);
- }
- if (g_strcasecmp(field->defaultval, "now") == 0)
- {
- len = strlen("0000-00-00 AD HH:MM:SS AM");
- field->tmpdefault = g_malloc(len + 2);
- timep = time(NULL);
- tm = localtime(&timep);
- strftime(field->tmpdefault, len, "%G-%m-%d %H:%M:%S", tm);
- field->tmpdefault[len + 1] = '\0';
- return (field->tmpdefault);
- }
+ case DT_datetime:
+ if (!field->defaultval)
+ {
+ field->tmpdefault = g_strdup ("");
+ return (field->tmpdefault);
+ }
+ if (g_strcasecmp (field->defaultval, "now") == 0)
+ {
+ len = strlen ("0000-00-00 AD HH:MM:SS AM");
+ field->tmpdefault = g_malloc (len + 2);
+ timep = time (NULL);
+ tm = localtime (&timep);
+ strftime (field->tmpdefault, len, "%G-%m-%d %H:%M:%S", tm);
+ field->tmpdefault[len + 1] = '\0';
+ return (field->tmpdefault);
+ }
break;
- default:
+ default:
break;
- }
-
- return (field->defaultval);
- }
-
-const char *
-odl_field_get_sourcefield(odl_field * field)
- {
- return (field->sourcefield);
- }
+ }
-const char *
-odl_field_get_sourceclass(odl_field * field)
- {
- return (field->sourceclass);
- }
+ return (field->defaultval);
+}
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_sourcefield (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->sourcefield);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_sourceclass (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->sourceclass);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_fieldlist *
-odl_field_get_this_fields(odl_field * field)
- {
- return (field->this_fields);
- }
-
+odl_field_get_this_fields (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->this_fields);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_fieldlist *
-odl_field_get_source_fields(odl_field * field)
- {
- return (field->source_fields);
- }
-
+odl_field_get_source_fields (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->source_fields);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_argumentlist *
-odl_field_get_arguments(odl_field * field)
- {
- return (field->arguments);
- }
-
+odl_field_get_arguments (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (field->arguments);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
unsigned long int
-odl_method_argument_count(odl_field * field)
- {
- return (g_list_length(field->arguments));
- }
-
-const char *
-odl_field_get_calculation(odl_field * field)
- {
- return ("idiot! not done yet :)");
- }
-
-/* read data from: method argument */
-const char *
-odl_argument_get_name(odl_argument * arg)
- {
- return (arg->name);
- }
-
+odl_method_argument_count (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return (g_list_length (field->arguments));
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_field_get_calculation (odl_field * field)
+{
+#ifdef DEBUG
+ assert (field != NULL);
+#endif
+ return ("Not done yet :)");
+}
+
+
+/* ========================================================================= *\
+ * read data from: method argument
+\* ========================================================================= */
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_argument_get_name (odl_argument * arg)
+{
+#ifdef DEBUG
+ assert (arg != NULL);
+#endif
+ return (arg->name);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
enum odl_datatype
-odl_argument_get_datatype(odl_argument * arg)
- {
- return (arg->datatype);
- }
-
-const char *
-odl_argument_get_classdatatype(odl_argument * arg)
- {
- return (arg->classdatatype);
- }
-
-/* Utility functions */
+odl_argument_get_datatype (odl_argument * arg)
+{
+#ifdef DEBUG
+ assert (arg != NULL);
+#endif
+ return (arg->datatype);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+const char *
+odl_argument_get_classdatatype (odl_argument * arg)
+{
+#ifdef DEBUG
+ assert (arg != NULL);
+#endif
+ return (arg->classdatatype);
+}
+
+/* ========================================================================= *\
+ * Utility functions
+\* ========================================================================= */
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_namelist *
-odl_split_qualified_name(char *qualifiedname)
- {
- GList *names = NULL;
- char *p, *q;
- char *tmp;
- gboolean done = FALSE;
+odl_split_qualified_name (char *qualifiedname)
+{
+ GList *names = NULL;
+ char *p, *q;
+
+#ifdef DEBUG
+ assert (qualifiedname != NULL);
+ printf( "---- odl_split_qualified_name() is splitting: '%s'\n" ,
qualifiedname );
+#endif
+ /* char *tmp; */
+ /* gboolean done = FALSE; */
- /* printf( "splitting: '%s'\n" , qualifiedname ); */
- if (!qualifiedname)
+ if (!qualifiedname)
+ {
return (NULL);
- if (strlen(qualifiedname) == 0)
+ }
+ if (strlen (qualifiedname) == 0)
+ {
return (NULL);
-
- /* if the name starts with :: ignore it, all other 0 length */
- /* names are errors */
- if (qualifiedname[0] == ':' && qualifiedname[1] == ':')
- {
- names = g_list_append(NULL, g_strdup("root"));
- /* printf( " <root>\n" ); */
+ }
+ /* if the name starts with :: ignore it, all other 0 length */
+ /* names are errors */
+ if (qualifiedname[0] == ':' && qualifiedname[1] == ':')
+ {
+ names = g_list_append (NULL, g_strdup ("root"));
+#ifdef DEBUG
+ printf( " <root>\n" );
+#endif
p = &qualifiedname[2];
- }
- else
- {
+ }
+ else
+ {
p = qualifiedname;
names = NULL;
- }
+ }
- while (*p != '\0')
- {
- q = strstr(p, "::");
+ while (*p != '\0')
+ {
+ q = strstr (p, "::");
if (q)
- *q = '\0';
+ {
+ *q = '\0';
+ }
else
- {
- names = g_list_append(names, g_strdup(p));
- break; /*
done last name */
- }
-
- if (strlen(p) == 0)
- {
- /* error: "::::" is illegal */
- odl_namelist_free(names);
- return (NULL);
- }
+ {
+ names = g_list_append (names, g_strdup (p));
+ break; /* done last name */
+ }
+
+ if (strlen (p) == 0)
+ {
+ /* error: "::::" is illegal */
+#ifdef DEBUG
+ assert( strlen (p) != 0);
+#endif
+ odl_namelist_free (names);
+ return (NULL);
+ }
else
- {
- names = g_list_append(names, g_strdup(p));
- /* printf( " :%s:\n" , p ); */
- p = q + 2;
- }
+ {
+ names = g_list_append (names, g_strdup (p));
+#ifdef DEBUG
+ printf( " :%s:\n" , p );
+#endif
+ p = q + 2;
+ }
if (q)
- *q = ':';
- }
- return (names);
- }
-
+ {
+ *q = ':';
+ }
+ }
+ return (names);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
char *
-odl_mangle_qualified_name(const char *qualifiedname)
- {
- char *name, *p;
- void *dest, *src;
- size_t size;
-
- if (!qualifiedname)
+odl_mangle_qualified_name (const char *qualifiedname)
+{
+ char *name, *p;
+ void *dest, *src;
+ size_t size;
+
+#ifdef DEBUG
+ assert (qualifiedname != NULL);
+#endif
+ if (!qualifiedname)
+ {
return (NULL);
-
- name = g_strdup(qualifiedname);
- /* printf( "> '%s' (%d)\n" , name , strlen(name) ); */
- if (strncmp(name, "root::", 6) == 0)
- {
+ }
+ name = g_strdup (qualifiedname);
+#ifdef DEBUG
+ printf( "---- odl_mangle_qualified_name()\n" , name , strlen(name) );
+ printf( " > '%s' (%d)\n" , name , strlen(name) );
+#endif
+ if (strncmp (name, "root::", 6) == 0)
+ {
dest = name;
src = &name[6];
- size = strlen(name) - 5;
- memmove(dest, (const void *)src, size);
- }
- p = strstr(name, "::");
+ size = strlen (name) - 5;
+ memmove (dest, (const void *) src, size);
+ }
+ p = strstr (name, "::");
- while (p)
- {
+ while (p)
+ {
/* replace :: with __ */
*p = '_';
p++;
@@ -1027,515 +1576,655 @@
p++;
/* next, if any */
- /* printf( ": '%s' (%d)\n" , name , strlen(name) ); */
- p = strstr(p, "::");
- }
- return (name);
- }
-
+#ifdef DEBUG
+ printf( ": '%s' (%d)\n" , name , strlen(name) );
+#endif
+ p = strstr (p, "::");
+ }
+ return (name);
+}
+
+/* ------------------------------------------------------------------------- *\
+ * Scan the data base and replace all fields that are TYPES with the
+ * resultant exploded fields.
+\* ------------------------------------------------------------------------- */
static void
-odl_process_coumpound_types(odl_container * c)
- {
- odl_field *f;
- odl_class *cl;
- GList *l, *newlist;
-
- l = c->contents;
- while (l)
- {
+odl_process_coumpound_types (odl_container * c)
+{
+ odl_field *f;
+ odl_class *cl;
+ GList *l, *newlist;
+
+#ifdef DEBUG
+ assert (c != NULL);
+#endif
+ l = c->contents;
+ while (l)
+ {
odl_base *b = l->data;
/* process sub items */
if (b->type == IT_class || b->type == IT_module)
- odl_process_coumpound_types((odl_container *) b);
-
+ {
+ odl_process_coumpound_types ((odl_container *) b);
+ }
if (b->type == IT_field)
- {
- f = (odl_field *) b;
- if (f->datatype == DT_type)
- {
- /* it's a compound type - make new fields */
- b->type = IT_ignore;
-
- /* printf( "look for type '%s'\n" , f->datatypeclass ); */
- cl = odl_find_class(b->tree, f->datatypeclass, NULL);
- if (!cl)
- {
- /* printf( "Couldn't find it!\n" ); */
- }
- else
- {
- if (!cl->istype)
- {
- /* printf( "Not a 'type'\n" ); */
- }
- else
- {
- GList *l;
-
- /* printf( "Got it\n" ); */
- /* printf( "make field '%s.*'\n" , b->name ); */
-
- l = cl->contents;
- newlist = NULL;
- while (l)
- {
- odl_field *fld = l->data;
- odl_field *n;
-
- if (fld->base.type == IT_field && strcmp(fld->base.name,
"objectid") != 0)
+ {
+ f = (odl_field *) b;
+ if (f->datatype == DT_type)
+ {
+ /* it's a compound type - make new fields */
+ b->type = IT_ignore;
+#ifdef DEBUG
+ printf( "---- odl_process_coumpound_types()\n look for type
'%s'\n" , f->datatypeclass );
+#endif
+ cl = odl_find_class (b->tree, f->datatypeclass, NULL);
+ if (!cl)
+ {
+#ifdef DEBUG
+ printf( " Couldn't find it!\n" );
+#endif
+ }
+ else
+ {
+ if (!cl->istype)
+ {
+#ifdef DEBUG
+ printf( " Not a 'type'\n" );
+#endif
+ }
+ else
+ {
+ GList *l;
+#ifdef DEBUG
+ printf( " Got it\n" );
+ printf( " Make field '%s.*'\n" , b->name );
+#endif
+ l = cl->contents;
+ newlist = NULL;
+ while (l)
{
- n = alloc_odl_item();
- if (n)
- {
- n->base.type = IT_field;
- n->base.parent = (odl_base *) c;
- n->base.name = g_strdup_printf("%s.%s", b->name,
fld->base.name);
- n->base.access = b->access;
- n->fieldtype = FT_basic;
- n->datatype = fld->datatype;
- if (fld->datatypeclass)
- n->datatypeclass = g_strdup(fld->datatypeclass);
- else
- n->datatypeclass = NULL;
- n->properties = fld->properties;
-
- c->contents = g_list_append(c->contents, n);
- /* printf( "made '%s'\n" , n->base.name ); */
- }
- else
- yyerror("Out of memory");
- }
+ odl_field *fld = l->data;
+ odl_field *n;
- l = g_list_next(l);
- }
- }
- }
- }
- }
-
- l = g_list_next(l);
- }
- }
+ if (fld->base.type == IT_field
+ && strcmp (fld->base.name, "objectid") != 0)
+ {
+ n = alloc_odl_item ();
+ if (n)
+ {
+ n->base.type = IT_field;
+ n->base.parent = (odl_base *) c;
+ n->base.name =
+ g_strdup_printf ("%s.%s", b->name,
+ fld->base.name);
+ n->base.access = b->access;
+ n->fieldtype = FT_basic;
+ n->datatype = fld->datatype;
+ if (fld->datatypeclass)
+ {
+ n->datatypeclass =
+ g_strdup (fld->datatypeclass);
+ }
+ else
+ {
+ n->datatypeclass = NULL;
+ }
+ n->properties = fld->properties;
+
+ c->contents =
+ g_list_append (c->contents, n);
+#ifdef DEBUG
+ printf( " Made '%s'\n" , n->base.name );
+#endif
+ }
+ else
+ {
+ yyerror ("Out of memory");
+ }
+ }
-static void
-odl_link_all_to_tree(odl_base * b, odl_tree * tree)
- {
- GList *l;
+ l = g_list_next (l);
+ }
+ }
+ }
+ }
+ }
- b->tree = tree;
+ l = g_list_next (l);
+ }
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
+static void
+odl_link_all_to_tree (odl_base * b, odl_tree * tree)
+{
+ GList *l;
+
+#ifdef DEBUG
+ assert (tree != NULL);
+ assert (b != NULL);
+#endif
+ b->tree = tree;
- if (b->type == IT_field)
- {
+ if (b->type == IT_field)
+ {
odl_field *f = (odl_field *) b;
if (f->fieldtype == FT_lookup)
- {
- odl_class *c;
+ {
+ odl_class *c;
+
+ f->properties = ODL_PROP_READONLY | f->properties;
+ c = odl_find_class (tree, f->sourceclass, NULL);
+ if (c)
+ {
+ odl_field *fd;
- f->properties = ODL_PROP_READONLY | f->properties;
- c = odl_find_class(tree, f->sourceclass, NULL);
- if (c)
- {
- odl_field *fd;
-
- fd = odl_class_get_field(c, f->sourcefield);
- if (fd)
- {
- f->datatype = fd->datatype;
- if (fd->datatypeclass)
- f->datatypeclass = g_strdup(fd->datatypeclass);
- if (fd->format)
- f->format = g_strdup(fd->format);
- if (fd->defaultval)
- f->defaultval = g_strdup(fd->defaultval);
- }
+ fd = odl_class_get_field (c, f->sourcefield);
+ if (fd)
+ {
+ f->datatype = fd->datatype;
+ if (fd->datatypeclass)
+ {
+ f->datatypeclass = g_strdup (fd->datatypeclass);
+ }
+ if (fd->format)
+ {
+ f->format = g_strdup (fd->format);
+ }
+ if (fd->defaultval)
+ {
+ f->defaultval = g_strdup (fd->defaultval);
+ }
+ }
}
- }
- }
+ }
+ }
- if (b->type == IT_class || b->type == IT_module)
- {
+ if (b->type == IT_class || b->type == IT_module)
+ {
l = ((odl_container *) b)->contents;
while (l)
- {
- odl_link_all_to_tree((odl_base *) l->data, tree);
- l = g_list_next(l);
- }
- }
- }
+ {
+ odl_link_all_to_tree ((odl_base *) l->data, tree);
+ l = g_list_next (l);
+ }
+ }
+}
odl_tree *yycurrenttree = NULL;
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_tree *
-odl_load_files(odl_filenamelist * files, odl_tree * tree)
- {
- GList *l;
- odl_tree *newtree;
- int max_errors = 0;
-
- /* use old tree, or allocate a new one */
- if (tree)
+odl_load_files (odl_filenamelist * files, odl_tree * tree)
+{
+ GList *l;
+ odl_tree *newtree;
+ int max_errors = 0;
+
+ /* use old tree, or allocate a new one */
+ if (tree)
+ {
newtree = tree;
- else
- newtree = alloc_odl_tree();
- if (!newtree)
+ }
+ else
+ {
+ newtree = alloc_odl_tree ();
+ }
+#ifdef DEBUG
+ assert (newtree != NULL);
+ assert (files != NULL);
+#endif
+ if (!newtree)
+ {
return (NULL);
+ }
- yycurrenttree = newtree;
+ yycurrenttree = newtree;
- /* setup */
- yyerrorcount = 0;
- yywarncount = 0;
-
- /* pass 1 */
- current_access = ODL_ACCESS_DEFAULT;
- current_pass = 1;
- expecting_datatype = 1;
- expecting_fieldprop = 0;
- expect_triggertype = 0;
- yycurrent_container = odl_tree_get_root(newtree);
- l = (GList *) files;
- while (l)
- {
- switch (yystartfile(l->data))
- {
- case 0:
- /* already processed */
- break;
- case 1:
- /* process now */
- errors_show_file(1);
- yyparse();
- break;
- case ( -1):
- /* error */
- yyerror("Error opening file %s", (char *)l->data);
- break;
- }
-
- l = g_list_next(l);
- }
-
- /* end of pass 1 */
- errors_show_file(0);
- clear_file_history();
-
- if (yyerrorcount > max_errors)
- {
- yymessage("Too many errors. File load failed.");
- return (NULL);
- }
+ /* setup */
+ yyerrorcount = 0;
+ yywarncount = 0;
+
+ /* pass 1 */
+ current_access = ODL_ACCESS_DEFAULT;
+ current_pass = 1;
+ expecting_datatype = 1;
+ expecting_fieldprop = 0;
+ expect_triggertype = 0;
+ yycurrent_container = odl_tree_get_root (newtree);
+ l = (GList *) files;
+ while (l)
+ {
+#ifdef DEBUG
+ printf( "++++ Pass 1 Start processing file: %s\n", l->data);
+#endif
+ switch (yystartfile (l->data))
+ {
+ case 0:
+ /* already processed */
+ break;
+ case 1:
+ /* process now */
+ errors_show_file (1);
+ yyparse ();
+ break;
+ case (-1):
+ /* error */
+ yyerror ("Error opening file %s", (char *) l->data);
+ break;
+ }
+
+ l = g_list_next (l);
+ }
- /* pass 2 */
- current_access = ODL_ACCESS_DEFAULT;
- current_pass = 2;
- expecting_datatype = 1;
- expecting_fieldprop = 0;
- expect_triggertype = 0;
- l = (GList *) files;
- while (l)
- {
- switch (yystartfile(l->data))
- {
- case 0:
- /* already processed */
- break;
- case 1:
- /* process now */
- errors_show_file(1);
- yyparse();
- break;
- case ( -1):
- /* error */
- yyerror("Error opening file %s", (char *)l->data);
- break;
- }
-
- l = g_list_next(l);
- }
-
- /* end of pass 2 */
- errors_show_file(0);
- clear_file_history();
-
- if (yyerrorcount > max_errors)
- {
- yymessage("Too many errors. File load failed.");
+ /* end of pass 1 */
+ errors_show_file (0);
+ clear_file_history ();
+
+ if (yyerrorcount > max_errors)
+ {
+ yymessage ("Too many errors. File load failed.");
return (NULL);
- }
+ }
- /* done */
- odl_link_all_to_tree((odl_base *) newtree->root, newtree);
- odl_process_coumpound_types((odl_container *) newtree->root);
- return (newtree);
- }
+ /* pass 2 */
+ current_access = ODL_ACCESS_DEFAULT;
+ current_pass = 2;
+ expecting_datatype = 1;
+ expecting_fieldprop = 0;
+ expect_triggertype = 0;
+ l = (GList *) files;
+ while (l)
+ {
+#ifdef DEBUG
+ printf( "++++ Pass 2 Start processing file: %s\n", l->data);
+#endif
+ switch (yystartfile (l->data))
+ {
+ case 0:
+ /* already processed */
+ break;
+ case 1:
+ /* process now */
+ errors_show_file (1);
+ yyparse ();
+ break;
+ case (-1):
+ /* error */
+ yyerror ("Error opening file %s", (char *) l->data);
+ break;
+ }
+
+ l = g_list_next (l);
+ }
+ /* end of pass 2 */
+ errors_show_file (0);
+ clear_file_history ();
+
+ if (yyerrorcount > max_errors)
+ {
+ yymessage ("Too many errors. File load failed.");
+ return (NULL);
+ }
+
+ /* done */
+ odl_link_all_to_tree ((odl_base *) newtree->root, newtree);
+ odl_process_coumpound_types ((odl_container *) newtree->root);
+ return (newtree);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
static void
-real_odl_display_tree(FILE * out, odl_base * item, int indent, gboolean
show_full_name)
- {
- int i;
- GList *l, *s, *t;
- GList *lst;
- odl_item *it;
- char *buf;
-
- if (item->type == IT_ignore)
- return ;
-
- /* indent this item */
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
-
- /* print type and name */
- if (item->type == IT_class)
- {
+real_odl_display_tree (FILE * out, odl_base * item, int indent,
+ gboolean show_full_name)
+{
+ int i;
+ GList *l, *s, *t;
+ GList *lst;
+ odl_item *it;
+ char *buf;
+
+#ifdef DEBUG
+ assert (item != NULL);
+ assert (out != NULL);
+#endif
+ if (item->type == IT_ignore)
+ return;
+
+ /* indent this item */
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ /* print type and name */
+ if (item->type == IT_class)
+ {
if (((odl_class *) item)->istype)
- {
- fprintf(out, "%s %s (%s)", odl_access_name(item->access), item->name,
"type");
- }
+ {
+ fprintf (out, "%s %s (%s)", odl_access_name (item->access),
+ item->name, "type");
+ }
else
- {
- fprintf(out, "%s %s (%s)", odl_access_name(item->access), item->name,
"class");
- }
- }
- else
- {
- fprintf(out, "%s %s (%s)", odl_access_name(item->access), item->name,
odl_itemtype_name(item->type));
- }
-
- switch (item->type)
- {
- case IT_module:
- buf = (char *)odl_module_get_full_name((odl_module *) item);
+ {
+ fprintf (out, "%s %s (%s)", odl_access_name (item->access),
+ item->name, "class");
+ }
+ }
+ else
+ {
+ fprintf (out, "%s %s (%s)", odl_access_name (item->access), item->name,
+ odl_itemtype_name (item->type));
+ }
+
+ switch (item->type)
+ {
+ case IT_module:
+ buf = (char *) odl_module_get_full_name ((odl_module *) item);
break;
- case IT_class:
- buf = (char *)odl_class_get_full_name((odl_class *) item);
+ case IT_class:
+ buf = (char *) odl_class_get_full_name ((odl_class *) item);
break;
- case IT_field:
- buf = (char *)odl_field_get_full_name((odl_field *) item);
+ case IT_field:
+ buf = (char *) odl_field_get_full_name ((odl_field *) item);
break;
- case IT_enum:
- buf = (char *)odl_enum_get_full_name((odl_enum *) item);
+ case IT_enum:
+ buf = (char *) odl_enum_get_full_name ((odl_enum *) item);
break;
- default:
- buf = g_strdup("<unknown>");
- }
- if (buf && show_full_name)
- {
- if (strncmp(buf, "root::", 6) == 0)
- fprintf(out, " [full name: %s]", (&buf[6]));
+ default:
+ buf = g_strdup ("<unknown>");
+ }
+ if (buf && show_full_name)
+ {
+ if (strncmp (buf, "root::", 6) == 0)
+ fprintf (out, " [full name: %s]", (&buf[6]));
else
- fprintf(out, " [full name: %s]", buf);
- }
+ fprintf (out, " [full name: %s]", buf);
+ }
- /* print children of a module or class */
- switch (item->type)
- {
- case IT_class:
+ /* print children of a module or class */
+ switch (item->type)
+ {
+ case IT_class:
l = ((odl_container *) item)->parents;
if (l)
- {
- fprintf(out, "\n");
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, "Parents:");
- while (l)
- {
- fprintf(out, " %s", l->data);
- if (l->next)
- fprintf(out, ",");
- l = g_list_next(l);
+ {
+ fprintf (out, "\n");
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, "Parents:");
+ while (l)
+ {
+ fprintf (out, " %s", l->data);
+ if (l->next)
+ {
+ fprintf (out, ",");
+ }
+ l = g_list_next (l);
}
- }
+ }
l = ((odl_container *) item)->indexes;
if (l)
- {
- fprintf(out, "\n");
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, "Indexes:\n");
- while (l)
- {
- _odl_index *idx = l->data;
- GList *l2 = idx->fields;
-
- if ((idx->primary) || (idx->unique) || (l2))
- {
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- }
- if (idx->primary)
- fprintf(out, "PRIMARY KEY: ");
- else if (idx->unique)
- fprintf(out, "UNIQUE: ");
- else
- fprintf(out, "INDEX: ");
- while (l2)
- {
- fprintf(out, "%s", l2->data);
- if (l2->next)
- fprintf(out, ", ");
- l2 = g_list_next(l2);
- }
- fprintf(out, "\n");
- l = g_list_next(l);
+ {
+ fprintf (out, "\n");
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, "Indexes:\n");
+ while (l)
+ {
+ _odl_index *idx = l->data;
+ GList *l2 = idx->fields;
+
+ if ((idx->primary) || (idx->unique) || (l2))
+ {
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ }
+ if (idx->primary)
+ {
+ fprintf (out, "PRIMARY KEY: ");
+ }
+ else if (idx->unique)
+ {
+ fprintf (out, "UNIQUE: ");
+ }
+ else
+ {
+ fprintf (out, "INDEX: ");
+ }
+ while (l2)
+ {
+ fprintf (out, "%s", l2->data);
+ if (l2->next)
+ fprintf (out, ", ");
+ l2 = g_list_next (l2);
+ }
+ fprintf (out, "\n");
+ l = g_list_next (l);
}
- }
+ }
if (((odl_container *) item)->orderby)
- {
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, "ORDER BY %s", ((odl_container *) item)->orderby);
- fprintf(out, "\n");
+ {
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, "ORDER BY %s", ((odl_container *) item)->orderby);
+ fprintf (out, "\n");
}
l = ((odl_container *) item)->contents;
while (l)
- {
- real_odl_display_tree(out, l->data, indent + INDENT, show_full_name);
- l = g_list_next(l);
- }
- fprintf(out, "\n");
+ {
+ real_odl_display_tree (out, l->data, indent + INDENT,
+ show_full_name);
+ l = g_list_next (l);
+ }
+ fprintf (out, "\n");
break;
- case IT_module:
- fprintf(out, "\n");
- l = ((odl_container *) item)->contents;
+ case IT_module:
+ fprintf (out, "\n");
+ l = ((odl_container *) item)->contents;
while (l)
- {
- real_odl_display_tree(out, l->data, indent + INDENT, show_full_name);
- l = g_list_next(l);
- }
- fprintf(out, "\n");
+ {
+ real_odl_display_tree (out, l->data, indent + INDENT,
+ show_full_name);
+ l = g_list_next (l);
+ }
+ fprintf (out, "\n");
break;
- case IT_enum:
+ case IT_enum:
/* indent this item */
- fprintf(out, "\n");
+ fprintf (out, "\n");
for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, "Values: ");
- lst = ((struct _odl_item *)item)->elements;
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, "Values: ");
+ lst = ((struct _odl_item *) item)->elements;
while (lst)
- {
- fprintf(out, " %s", lst->data);
- lst = g_list_next(lst);
- }
- fprintf(out, "\n");
+ {
+ fprintf (out, " %s", lst->data);
+ lst = g_list_next (lst);
+ }
+ fprintf (out, "\n");
break;
- case IT_field:
+ case IT_field:
it = (odl_item *) item;
switch (it->fieldtype)
- {
- case FT_basic:
- fprintf(out, " Basic: %s", odl_datatype_name(it->datatype));
- if (it->properties & ODL_PROP_NOTNULL)
- fprintf(out, " NOT NULL");
- if (it->properties & ODL_PROP_READONLY)
- fprintf(out, " READONLY");
- if (it->properties & ODL_PROP_SERVER)
- fprintf(out, " SERVER");
- if (it->properties & ODL_PROP_HIDDEN)
- fprintf(out, " HIDDEN");
- fprintf(out, "\n");
- break;
- case FT_lookup:
- fprintf(out, " Lookup: load field %s from class %s where\n",
it->sourcefield, it->sourceclass);
- s = it->source_fields;
- t = it->this_fields;
- while (s && t)
- {
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, " %s.%s = this.%s\n", it->sourceclass, s->data,
t->data);
- s = g_list_next(s);
- t = g_list_next(t);
- }
- break;
- case FT_list:
- fprintf(out, " List: load class %s where\n", it->sourceclass);
- s = it->source_fields;
- t = it->this_fields;
- while (s && t)
- {
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, " %s.%s = this.%s\n", it->sourceclass, s->data,
t->data);
- s = g_list_next(s);
- t = g_list_next(t);
- }
- break;
- case FT_reference:
- fprintf(out, " Reference: load class %s where\n", it->sourceclass);
- s = it->source_fields;
- t = it->this_fields;
- while (s && t)
- {
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, " %s.%s = this.%s\n", it->sourceclass, s->data,
t->data);
- s = g_list_next(s);
- t = g_list_next(t);
- }
- break;
- case FT_method:
- fprintf(out, " Method: returns: %s\n",
odl_datatype_name(it->datatype));
- for (i = 0; i < indent; i++)
- fprintf(out, " ");
- fprintf(out, " arguments:");
- s = it->arguments;
- if (!s)
- fprintf(out, " <none>");
- while (s)
- {
- fprintf(out, " %s %s",
- odl_datatype_name(((odl_argument *) s->
- data)->datatype), ((odl_argument *)
s->data)->name);
- s = g_list_next(s);
- if (s)
- fprintf(out, ",");
- }
- fprintf(out, "\n");
- break;
- case FT_calculated:
- fprintf(out, " Calculated:");
- fprintf(out, "\n");
- break;
- case FT_readonly:
- fprintf(out, " Readonly:");
- fprintf(out, "\n");
- break;
- case FT_unknown:
- fprintf(out, " Unknown field type");
- fprintf(out, "\n");
- break;
- }
+ {
+ case FT_basic:
+ fprintf (out, " Basic: %s", odl_datatype_name (it->datatype));
+ if (it->properties & ODL_PROP_NOTNULL)
+ {
+ fprintf (out, " NOT NULL");
+ }
+ if (it->properties & ODL_PROP_READONLY)
+ {
+ fprintf (out, " READONLY");
+ }
+ if (it->properties & ODL_PROP_SERVER)
+ {
+ fprintf (out, " SERVER");
+ }
+ if (it->properties & ODL_PROP_HIDDEN)
+ {
+ fprintf (out, " HIDDEN");
+ }
+ fprintf (out, "\n");
+ break;
+ case FT_lookup:
+ fprintf (out, " Lookup: load field %s from class %s where\n",
+ it->sourcefield, it->sourceclass);
+ s = it->source_fields;
+ t = it->this_fields;
+ while (s && t)
+ {
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, " %s.%s = this.%s\n", it->sourceclass, s->data,
+ t->data);
+ s = g_list_next (s);
+ t = g_list_next (t);
+ }
+ break;
+ case FT_list:
+ fprintf (out, " List: load class %s where\n", it->sourceclass);
+ s = it->source_fields;
+ t = it->this_fields;
+ while (s && t)
+ {
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, " %s.%s = this.%s\n", it->sourceclass, s->data,
+ t->data);
+ s = g_list_next (s);
+ t = g_list_next (t);
+ }
+ break;
+ case FT_reference:
+ fprintf (out, " Reference: load class %s where\n", it->sourceclass);
+ s = it->source_fields;
+ t = it->this_fields;
+ while (s && t)
+ {
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, " %s.%s = this.%s\n", it->sourceclass, s->data,
+ t->data);
+ s = g_list_next (s);
+ t = g_list_next (t);
+ }
+ break;
+ case FT_method:
+ fprintf (out, " Method: returns: %s\n",
+ odl_datatype_name (it->datatype));
+ for (i = 0; i < indent; i++)
+ {
+ fprintf (out, " ");
+ }
+ fprintf (out, " arguments:");
+ s = it->arguments;
+ if (!s)
+ {
+ fprintf (out, " <none>");
+ }
+ while (s)
+ {
+ fprintf (out, " %s %s",
+ odl_datatype_name (((odl_argument *) s->
+ data)->datatype),
+ ((odl_argument *) s->data)->name);
+ s = g_list_next (s);
+ if (s)
+ {
+ fprintf (out, ",");
+ }
+ }
+ fprintf (out, "\n");
+ break;
+ case FT_calculated:
+ fprintf (out, " Calculated:");
+ fprintf (out, "\n");
+ break;
+ case FT_readonly:
+ fprintf (out, " Readonly:");
+ fprintf (out, "\n");
+ break;
+ case FT_unknown:
+ fprintf (out, " Unknown field type");
+ fprintf (out, "\n");
+ break;
+ }
break;
- case IT_unknown:
+ case IT_unknown:
/* indent this item */
- fprintf(out, "Unknown item (%s)\n", it->base.name);
- fprintf(out, "\n");
+ fprintf (out, "Unknown item (%s)\n", it->base.name);
+ fprintf (out, "\n");
break;
- }
- }
-
+ case IT_type:
+ case IT_ignore:
+ break; /* added to satisfy compiler warning neilt */
+ }
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
void
-odl_display_tree(FILE * out, odl_tree * tree, gboolean show_full_name)
- {
- fprintf(out, "\nCurrent Class Tree\n\n");
- if (tree)
- real_odl_display_tree(out, (odl_base *) tree->root, 0, show_full_name);
- else
- fprintf(out, "No clases found\n");
- fprintf(out, "\n");
- }
-
+odl_display_tree (FILE * out, odl_tree * tree, gboolean show_full_name)
+{
+#ifdef DEBUG
+ assert (out != NULL);
+#endif
+ fprintf (out, "\nCurrent Class Tree\n\n");
+ if (tree)
+ {
+ real_odl_display_tree (out, (odl_base *) tree->root, 0, show_full_name);
+ }
+ else
+ {
+ fprintf (out, "No clases found\n");
+ }
+ fprintf (out, "\n");
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
void
-odl_free_tree(odl_tree * tree)
- {
- free_odl_tree(tree);
- }
-
+odl_free_tree (odl_tree * tree)
+{
+#ifdef DEBUG
+ assert (tree != NULL);
+#endif
+ free_odl_tree (tree);
+}
+
+/* ------------------------------------------------------------------------- *\
+ *
+\* ------------------------------------------------------------------------- */
odl_tree *
-odl_create_empty_tree()
- {
- return (alloc_odl_tree());
- }
+odl_create_empty_tree ()
+{
+ return (alloc_odl_tree ());
+}
Index: gnue/geas/lib/classdefs/lparser.h
diff -u gnue/geas/lib/classdefs/lparser.h:1.2
gnue/geas/lib/classdefs/lparser.h:1.3
--- gnue/geas/lib/classdefs/lparser.h:1.2 Sun Mar 4 17:02:49 2001
+++ gnue/geas/lib/classdefs/lparser.h Sun May 6 16:20:42 2001
@@ -1,5 +1,7 @@
/*
- geas - GNU Enterprise Application Server
+ lparser.h
+
+ Part of GNU Enterprise Application Server (GEAS)
Copyright (C) 2001 Free Software Foundation
@@ -17,6 +19,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ $Id: lparser.h,v 1.3 2001/05/06 23:20:42 ntiffin Exp $
*/
#ifndef LPARSER_Y
Index: gnue/geas/lib/classdefs/lparser.l
diff -u gnue/geas/lib/classdefs/lparser.l:1.16
gnue/geas/lib/classdefs/lparser.l:1.17
--- gnue/geas/lib/classdefs/lparser.l:1.16 Mon Apr 2 20:51:23 2001
+++ gnue/geas/lib/classdefs/lparser.l Sun May 6 16:20:42 2001
@@ -4,7 +4,9 @@
%{
/*
- geas - GNU Enterprise Application Server
+ Source file: lparser.l
+
+ Part of GNU Enterprise Application Server (GEAS)
Copyright (C) 2001 Free Software Foundation
@@ -20,7 +22,9 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ $Id: lparser.l,v 1.17 2001/05/06 23:20:42 ntiffin Exp $
*/
@@ -80,7 +84,7 @@
static struct FileData *file_stack = NULL;
static int push_file( char *filename );
-static int pop_file(); /* return 0 if nothing to pop else return 1 */
+static int pop_file(); /* return 0 if nothing to pop else return 1 */
static char **processed_files = NULL;
static unsigned int processed_count = 0;
@@ -90,6 +94,11 @@
%}
+/*
+ * set up exclusive start conditions
+ * exclusive = rules with no start conditions are not
+ * active when these conditions are active
+ */
%x incl
%x endincl
%x failinclude
@@ -164,9 +173,9 @@
{qstring} { ST;
while( yytext[strlen(yytext)-1] == '"' )
- yytext[strlen(yytext)-1] = '\0';
- yylval.string = g_strdup(&yytext[1]);
- return(STRING); }
+ yytext[strlen(yytext)-1] = '\0';
+ yylval.string = g_strdup(&yytext[1]);
+ return(STRING); }
[+-]?[0-9]+ { ST; yylval.integer = atol(yytext); return(INTEGER); }
[+-]?[0-9]+.[0-9]+ { ST; yylval.floating = atof(yytext); return(DOUBLE); }
@@ -426,6 +435,11 @@
/* printf( "fopen : %08lx\n" , fp ); */
+ /* ntiffin */ /* reset lexer state */
+ expecting_datatype = 1;
+ expecting_fieldprop = 0;
+ expect_triggertype = 0;
+
/* setup lexer */
yyrestart( fp );
yy_setfirstfilename( filename );
@@ -436,7 +450,7 @@
strcpy( currentfile.modulename , "" );
strcpy( currentfile.moduleprefix , "" );
currentfile.next = NULL;
-
+
/* done */
return(1);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/lib/classdefs classdata.c lparser.h l...,
Neil Tiffin <=