[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src/classdef classdef.c classdef.h pa...
From: |
Reinhard Mueller |
Subject: |
gnue/geas/src/classdef classdef.c classdef.h pa... |
Date: |
Sat, 26 Jan 2002 17:16:43 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Reinhard Mueller <address@hidden> 02/01/26 17:16:42
Modified files:
geas/src/classdef: classdef.c classdef.h parse.y
Log message:
Implemented indexes.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/classdef.c.diff?tr1=1.30&tr2=1.31&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/classdef.h.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/parse.y.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
Patches:
Index: gnue/geas/src/classdef/classdef.c
diff -c gnue/geas/src/classdef/classdef.c:1.30
gnue/geas/src/classdef/classdef.c:1.31
*** gnue/geas/src/classdef/classdef.c:1.30 Tue Dec 18 16:29:12 2001
--- gnue/geas/src/classdef/classdef.c Sat Jan 26 17:16:42 2002
***************
*** 19,25 ****
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
! $Id: classdef.c,v 1.30 2001/12/18 21:29:12 reinhard Exp $
*/
#include "config.h"
--- 19,25 ----
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
! $Id: classdef.c,v 1.31 2002/01/26 22:16:42 reinhard Exp $
*/
#include "config.h"
***************
*** 54,59 ****
--- 54,60 ----
char *filename;
GList *fields;
GList *methods;
+ GList *indexes;
};
struct _geas_cd_type
***************
*** 93,98 ****
--- 94,100 ----
GList *fields; /* only for compound types */
char *default_val; /* not for ref., list and compound */
int property;
+ GList *indexes;
};
struct _geas_cd_method
***************
*** 109,114 ****
--- 111,129 ----
int argcount;
};
+ struct _geas_cd_indexlist
+ {
+ GList *list;
+ GList *current;
+ };
+
+ struct _geas_cd_index
+ {
+ geas_cd_class *parent;
+ int unique;
+ GList *fields;
+ };
+
/* =========================================================================
*\
* Global variables
\* =========================================================================
*/
***************
*** 922,927 ****
--- 937,955 ----
}
/* -------------------------------------------------------------------------
*\
+ * Create the fieldlist for the class
+ \* -------------------------------------------------------------------------
*/
+ geas_cd_fieldlist *
+ geas_cd_class_fieldlist_new (const geas_cd_class *c)
+ {
+ geas_cd_fieldlist *fl;
+
+ fl = g_new0 (geas_cd_fieldlist, 1);
+ fl->root = c->fields;
+ return (fl);
+ }
+
+ /* -------------------------------------------------------------------------
*\
* Allocate a new method as a member of a class, giving the type of the
* return value
\* -------------------------------------------------------------------------
*/
***************
*** 978,983 ****
--- 1006,1024 ----
}
/* -------------------------------------------------------------------------
*\
+ * Create the indexlist for the class
+ \* -------------------------------------------------------------------------
*/
+ geas_cd_indexlist *
+ geas_cd_class_indexlist_new (const geas_cd_class *c)
+ {
+ geas_cd_indexlist *il;
+
+ il = g_new0 (geas_cd_indexlist, 1);
+ il->list = c->indexes;
+ return (il);
+ }
+
+ /* -------------------------------------------------------------------------
*\
* Free the memory allocated for a class
\* -------------------------------------------------------------------------
*/
static void
***************
*** 1001,1006 ****
--- 1042,1066 ----
}
/* -------------------------------------------------------------------------
*\
+ * Allocate a new index as a member of a class
+ \* -------------------------------------------------------------------------
*/
+ geas_cd_index *
+ geas_cd_class_index_new (geas_cd_class *c, int unique)
+ {
+ geas_cd_index *i;
+
+ g_return_val_if_fail (c, NULL);
+
+ i = g_new0 (geas_cd_index, 1);
+ i->unique = unique;
+ i->parent = c;
+
+ c->indexes = g_list_append (c->indexes, i);
+
+ return (i);
+ }
+
+ /* -------------------------------------------------------------------------
*\
* Free a class (called in g_hash_table_foreach_remove)
\* -------------------------------------------------------------------------
*/
static gboolean
***************
*** 1312,1330 ****
\* =========================================================================
*/
/* -------------------------------------------------------------------------
*\
- * Create the fieldlist for the class
- \* -------------------------------------------------------------------------
*/
- geas_cd_fieldlist *
- geas_cd_class_fieldlist_new (const geas_cd_class *c)
- {
- geas_cd_fieldlist *fl;
-
- fl = g_new0 (geas_cd_fieldlist, 1);
- fl->root = c->fields;
- return (fl);
- }
-
- /* -------------------------------------------------------------------------
*\
* Get the next item of the fieldlist
\* -------------------------------------------------------------------------
*/
geas_cd_field *
--- 1372,1377 ----
***************
*** 1561,1566 ****
--- 1608,1626 ----
}
/* -------------------------------------------------------------------------
*\
+ * Create the indexlist for the field
+ \* -------------------------------------------------------------------------
*/
+ geas_cd_indexlist *
+ geas_cd_field_indexlist_new (const geas_cd_field *f)
+ {
+ geas_cd_indexlist *il;
+
+ il = g_new0 (geas_cd_indexlist, 1);
+ il->list = f->indexes;
+ return (il);
+ }
+
+ /* -------------------------------------------------------------------------
*\
* Free the memory allocated for a field
\* -------------------------------------------------------------------------
*/
static void
***************
*** 1627,1630 ****
--- 1687,1746 ----
/* TODO: Remove the member "argcount" and return the number of items in the
argument list here */
return (m->argcount);
+ }
+
+ /* =========================================================================
*\
+ * Indexlists
+ \* =========================================================================
*/
+
+ /* -------------------------------------------------------------------------
*\
+ * Get the next item of the indexlist
+ \* -------------------------------------------------------------------------
*/
+ geas_cd_index *
+ geas_cd_indexlist_next (geas_cd_indexlist *il)
+ {
+ g_return_val_if_fail (il, NULL);
+
+ if (!il->current)
+ {
+ il->current = il->list;
+ }
+ else
+ {
+ il->current = il->current->next;
+ }
+ if (il->current)
+ {
+ return (geas_cd_index *)(il->current->data);
+ }
+ else
+ {
+ return (NULL);
+ }
+ }
+
+ /* -------------------------------------------------------------------------
*\
+ * Free a indexlist
+ \* -------------------------------------------------------------------------
*/
+ void
+ geas_cd_indexlist_free (geas_cd_indexlist *il)
+ {
+ g_free (il);
+ }
+
+ /* =========================================================================
*\
+ * Indexes
+ \* =========================================================================
*/
+
+ /* -------------------------------------------------------------------------
*\
+ * Add a new field to an index
+ \* -------------------------------------------------------------------------
*/
+ void
+ geas_cd_index_add_field (geas_cd_index *i, geas_cd_field *f)
+ {
+ g_return_if_fail (i);
+ g_return_if_fail (f);
+
+ i->fields = g_list_append (i->fields, f);
+ f->indexes = g_list_append (f->indexes, i);
}
Index: gnue/geas/src/classdef/classdef.h
diff -c gnue/geas/src/classdef/classdef.h:1.27
gnue/geas/src/classdef/classdef.h:1.28
*** gnue/geas/src/classdef/classdef.h:1.27 Tue Dec 18 16:29:12 2001
--- gnue/geas/src/classdef/classdef.h Sat Jan 26 17:16:42 2002
***************
*** 19,25 ****
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
! $Id: classdef.h,v 1.27 2001/12/18 21:29:12 reinhard Exp $
*/
#ifndef _CLASSDEF_H
--- 19,25 ----
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
! $Id: classdef.h,v 1.28 2002/01/26 22:16:42 reinhard Exp $
*/
#ifndef _CLASSDEF_H
***************
*** 55,60 ****
--- 55,62 ----
typedef struct _geas_cd_fieldlist geas_cd_fieldlist;
typedef struct _geas_cd_field geas_cd_field;
typedef struct _geas_cd_method geas_cd_method;
+ typedef struct _geas_cd_indexlist geas_cd_indexlist;
+ typedef struct _geas_cd_index geas_cd_index;
/* -------------------------------------------------------------------------
*\
* General functions
***************
*** 131,136 ****
--- 133,140 ----
const geas_cd_module *m,
const char *name);
void geas_cd_class_free (geas_cd_class *c);
+ geas_cd_index *geas_cd_class_index_new (geas_cd_class *c, int unique);
+ geas_cd_indexlist *geas_cd_class_indexlist_new (const geas_cd_class *c);
/* -------------------------------------------------------------------------
*\
* Types (can be plain type or structured type)
***************
*** 173,195 ****
#define GEAS_CD_FPROP_NOTNULL 0x0001 /* may not contain NULL value */
#define GEAS_CD_FPROP_INTERNAL 0x0002 /* only for internal use of GEAS */
! void geas_cd_field_set_format (geas_cd_field *f, int format);
! void geas_cd_field_set_default (geas_cd_field *f,
! const char *default_val);
! const char *geas_cd_field_get_name (const geas_cd_field *f);
! const char *geas_cd_field_get_name_full (const geas_cd_field *f);
! const char *geas_cd_field_get_name_db (const geas_cd_field *f);
! geas_cd_datatype geas_cd_field_get_datatype (const geas_cd_field *f);
! int geas_cd_field_get_format (const geas_cd_field *f);
! geas_cd_class *geas_cd_field_get_thisclass (const geas_cd_field *f);
! geas_cd_field *geas_cd_field_get_thisfield (const geas_cd_field *f);
! geas_cd_class *geas_cd_field_get_otherclass (const geas_cd_field *f);
! geas_cd_field *geas_cd_field_get_otherfield (const geas_cd_field *f);
! const char *geas_cd_field_get_default (const geas_cd_field *f);
! void geas_cd_field_prop_set (geas_cd_field *f, int property);
! void geas_cd_field_prop_clr (geas_cd_field *f, int property);
! int geas_cd_field_prop_get (geas_cd_field *f, int property);
! void geas_cd_field_free (geas_cd_field *f);
/* -------------------------------------------------------------------------
*\
* Methodlists
--- 177,200 ----
#define GEAS_CD_FPROP_NOTNULL 0x0001 /* may not contain NULL value */
#define GEAS_CD_FPROP_INTERNAL 0x0002 /* only for internal use of GEAS */
! void geas_cd_field_set_format (geas_cd_field *f, int format);
! void geas_cd_field_set_default (geas_cd_field *f,
! const char *default_val);
! const char *geas_cd_field_get_name (const geas_cd_field *f);
! const char *geas_cd_field_get_name_full (const geas_cd_field *f);
! const char *geas_cd_field_get_name_db (const geas_cd_field *f);
! geas_cd_datatype geas_cd_field_get_datatype (const geas_cd_field *f);
! int geas_cd_field_get_format (const geas_cd_field *f);
! geas_cd_class *geas_cd_field_get_thisclass (const geas_cd_field *f);
! geas_cd_field *geas_cd_field_get_thisfield (const geas_cd_field *f);
! geas_cd_class *geas_cd_field_get_otherclass (const geas_cd_field *f);
! geas_cd_field *geas_cd_field_get_otherfield (const geas_cd_field *f);
! const char *geas_cd_field_get_default (const geas_cd_field *f);
! void geas_cd_field_prop_set (geas_cd_field *f, int property);
! void geas_cd_field_prop_clr (geas_cd_field *f, int property);
! int geas_cd_field_prop_get (geas_cd_field *f, int property);
! geas_cd_indexlist *geas_cd_field_indexlist_new (const geas_cd_field *f);
! void geas_cd_field_free (geas_cd_field *f);
/* -------------------------------------------------------------------------
*\
* Methodlists
***************
*** 212,215 ****
--- 217,233 ----
/* TODO */
+ /* -------------------------------------------------------------------------
*\
+ * Indexlists
+ \* -------------------------------------------------------------------------
*/
+
+ geas_cd_index *geas_cd_indexlist_next (geas_cd_indexlist *il);
+ void geas_cd_indexlist_free (geas_cd_indexlist *il);
+
#endif /* _CLASSDEF_H */
+ /* -------------------------------------------------------------------------
*\
+ * Indexes
+ \* -------------------------------------------------------------------------
*/
+
+ void geas_cd_index_add_field (geas_cd_index *i, geas_cd_field *f);
+
Index: gnue/geas/src/classdef/parse.y
diff -c gnue/geas/src/classdef/parse.y:1.28 gnue/geas/src/classdef/parse.y:1.29
*** gnue/geas/src/classdef/parse.y:1.28 Thu Nov 29 15:56:56 2001
--- gnue/geas/src/classdef/parse.y Sat Jan 26 17:16:42 2002
***************
*** 19,25 ****
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
! $Id: parse.y,v 1.28 2001/11/29 20:56:56 reinhard Exp $
*/
%{
--- 19,25 ----
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
! $Id: parse.y,v 1.29 2002/01/26 22:16:42 reinhard Exp $
*/
%{
***************
*** 96,101 ****
--- 96,104 ----
static gboolean _new_method (const gchar *name);
static gboolean _new_argument (const gchar *name);
+ static void _new_index (gboolean unique);
+ static gboolean _new_indexfield (geas_cd_field *field);
+
%}
/* =========================================================================
*\
***************
*** 407,426 ****
* Index and order
\* -------------------------------------------------------------------------
*/
! index: unique INDEX '(' ixfields ')'
! { /* TODO */ }
;
unique: /* */ { $$ = FALSE; }
| UNIQUE { $$ = TRUE; }
;
! ixfields: SYMBOL { g_free ($1); /* TODO */ }
! | ixfields ',' SYMBOL { g_free ($3); /* TODO */ }
;
! orderby: ORDER BY SYMBOL desc { g_free ($3); /* TODO */ }
;
desc: /* */ { $$ = FALSE; }
--- 410,429 ----
* Index and order
\* -------------------------------------------------------------------------
*/
! index: unique INDEX { _new_index ($1); }
! /* continued */ '(' ixfields ')'
;
unique: /* */ { $$ = FALSE; }
| UNIQUE { $$ = TRUE; }
;
! ixfields: thisfield { _new_indexfield ($1); }
! | ixfields ',' thisfield { _new_indexfield ($3); }
;
! orderby: ORDER BY thisfield desc { /* TODO */ }
;
desc: /* */ { $$ = FALSE; }
***************
*** 449,454 ****
--- 452,458 ----
static geas_cd_field *_current_field;
static geas_cd_method *_current_method;
+ static geas_cd_index *_current_index;
/* -------------------------------------------------------------------------
*\
* Run the parser on a specific file for a specific pass
***************
*** 1446,1451 ****
--- 1450,1498 ----
{
g_assert_not_reached ();
}
+ return (TRUE);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ return (FALSE);
+ }
+ }
+
+ /* -------------------------------------------------------------------------
*\
+ * Found a new index
+ \* -------------------------------------------------------------------------
*/
+ static void
+ _new_index (gboolean unique)
+ {
+ switch (_current_pass)
+ {
+ case 1:
+ break;
+
+ case 2:
+ _current_index = geas_cd_class_index_new (_current_class, unique);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+ }
+
+ /* -------------------------------------------------------------------------
*\
+ * Add a new field to the current index
+ \* -------------------------------------------------------------------------
*/
+ static gboolean
+ _new_indexfield (geas_cd_field *field)
+ {
+ switch (_current_pass)
+ {
+ case 1:
+ return (TRUE);
+ break;
+
+ case 2:
+ geas_cd_index_add_field (_current_index, field);
return (TRUE);
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/src/classdef classdef.c classdef.h pa...,
Reinhard Mueller <=