[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src/classdef classdef.c classdef.h gc...
From: |
Reinhard Mueller |
Subject: |
gnue/geas/src/classdef classdef.c classdef.h gc... |
Date: |
Fri, 12 Oct 2001 16:14:18 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Reinhard Mueller <address@hidden> 01/10/12 16:14:18
Modified files:
geas/src/classdef: classdef.c classdef.h gcdinfo.c
Log message:
Create the following automatic fields for every class:
geas::id
geas::cre_user
geas::cre_time
geas::mod_user
geas::mod_time
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/classdef.c.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/classdef.h.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/gcdinfo.c.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: gnue/geas/src/classdef/classdef.c
diff -u gnue/geas/src/classdef/classdef.c:1.17
gnue/geas/src/classdef/classdef.c:1.18
--- gnue/geas/src/classdef/classdef.c:1.17 Mon Oct 1 15:49:36 2001
+++ gnue/geas/src/classdef/classdef.c Fri Oct 12 16:14:18 2001
@@ -19,7 +19,7 @@
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.17 2001/10/01 19:49:36 reinhard Exp $
+ $Id: classdef.c,v 1.18 2001/10/12 20:14:18 reinhard Exp $
*/
#include "config.h"
@@ -95,12 +95,17 @@
* Global variables
\* ========================================================================= */
-/* ------------------------------------------------------------------------- *\
- * All modules are listed here
-\* ------------------------------------------------------------------------- */
-
+/* All modules are listed here */
static GHashTable *_modules = NULL;
+/* The "geas" module that holds automatically created stuff */
+static geas_cd_module *_geas_module = NULL;
+
+/* The types for the automatic fields */
+static geas_cd_type *_id_type = NULL;
+static geas_cd_type *_username_type = NULL;
+static geas_cd_type *_datetime_type = NULL;
+
/* ========================================================================= *\
* Prototypes
\* ========================================================================= */
@@ -147,6 +152,17 @@
NEWTYPE ("int", GEAS_CD_DATATYPE_INT32);
NEWTYPE ("boolean", GEAS_CD_DATATYPE_BOOL);
#undef NEWTYPE
+
+ /* create "geas" module for internal fields */
+ _geas_module = geas_cd_module_new ("geas", GEAS_CD_ACCESS_PUBLIC);
+
+#define NEWTYPE(n,t) \
+ geas_cd_module_type_new(_geas_module,n,GEAS_CD_ACCESS_PRIVATE,t)
+ _id_type = NEWTYPE ("id", GEAS_CD_DATATYPE_ID);
+ _username_type = NEWTYPE ("username", GEAS_CD_DATATYPE_CHAR);
+ _datetime_type = NEWTYPE ("datetime", GEAS_CD_DATATYPE_DATETIME);
+#undef NEWTYPE
+ geas_cd_type_set_format (_username_type, 16);
}
/* ------------------------------------------------------------------------- *\
@@ -158,7 +174,7 @@
g_return_if_fail (_modules);
g_hash_table_foreach_remove (_modules, _hr_free_module, NULL);
- g_assert (g_hash_table_size (_modules) == 1);
+ g_assert (g_hash_table_size (_modules) == 2);
}
/* ========================================================================= *\
@@ -242,6 +258,17 @@
c->fields = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (m->classes, c->name, c);
+
+ /* Create the automatic objectid field */
+ geas_cd_class_field_new (c, _geas_module, "id", _id_type, NULL, NULL);
+ geas_cd_class_field_new (c, _geas_module, "cre_user", _username_type,
+ NULL, NULL);
+ geas_cd_class_field_new (c, _geas_module, "cre_time", _datetime_type,
+ NULL, NULL);
+ geas_cd_class_field_new (c, _geas_module, "mod_user", _username_type,
+ NULL, NULL);
+ geas_cd_class_field_new (c, _geas_module, "mod_time", _datetime_type,
+ NULL, NULL);
}
return (c);
@@ -322,12 +349,13 @@
}
/* ------------------------------------------------------------------------- *\
- * Free a module except "builtin" (called in g_hash_table_foreach_remove)
+ * Free a module except "builtin" and "geas" (called in
+ * g_hash_table_foreach_remove)
\* ------------------------------------------------------------------------- */
static gboolean
_hr_free_module (gpointer key, gpointer value, gpointer user_data)
{
- if (strcmp (key, "builtin"))
+ if (strcmp (key, "builtin") && strcmp (key, "geas"))
{
_free_module ((geas_cd_module *)value);
return (TRUE);
@@ -643,6 +671,18 @@
}
/* ------------------------------------------------------------------------- *\
+ * Set the format for a type (only for char types)
+\* ------------------------------------------------------------------------- */
+void
+geas_cd_type_set_format (geas_cd_type *t, int format)
+{
+ g_return_if_fail (t);
+ g_return_if_fail (t->datatype == GEAS_CD_DATATYPE_CHAR);
+
+ t->format = format;
+}
+
+/* ------------------------------------------------------------------------- *\
* Get the name of a type without the module prefix
\* ------------------------------------------------------------------------- */
const char *
@@ -673,6 +713,17 @@
g_return_val_if_fail (t, NULL);
return (t->filename);
+}
+
+/* ------------------------------------------------------------------------- *\
+ * Get the format of a type (only for char types)
+\* ------------------------------------------------------------------------- */
+int
+geas_cd_type_get_format (const geas_cd_type *t)
+{
+ g_return_val_if_fail (t, 0);
+
+ return (t->format);
}
/* ------------------------------------------------------------------------- *\
Index: gnue/geas/src/classdef/classdef.h
diff -u gnue/geas/src/classdef/classdef.h:1.15
gnue/geas/src/classdef/classdef.h:1.16
--- gnue/geas/src/classdef/classdef.h:1.15 Mon Oct 1 15:49:36 2001
+++ gnue/geas/src/classdef/classdef.h Fri Oct 12 16:14:18 2001
@@ -19,7 +19,7 @@
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.15 2001/10/01 19:49:36 reinhard Exp $
+ $Id: classdef.h,v 1.16 2001/10/12 20:14:18 reinhard Exp $
*/
/* ------------------------------------------------------------------------- *\
@@ -120,9 +120,11 @@
void geas_cd_type_set_filename (geas_cd_type *t,
const char *filename);
+void geas_cd_type_set_format (geas_cd_type *t, int format);
const char *geas_cd_type_get_name (const geas_cd_type *t);
const char *geas_cd_type_get_name_full (const geas_cd_type *t);
const char *geas_cd_type_get_filename (const geas_cd_type *t);
+int geas_cd_type_get_format (const geas_cd_type *t);
geas_cd_field *geas_cd_type_field_new (geas_cd_type *t, const char *name,
geas_cd_type *type,
geas_cd_class *reference,
Index: gnue/geas/src/classdef/gcdinfo.c
diff -u gnue/geas/src/classdef/gcdinfo.c:1.6
gnue/geas/src/classdef/gcdinfo.c:1.7
--- gnue/geas/src/classdef/gcdinfo.c:1.6 Mon Oct 1 11:47:32 2001
+++ gnue/geas/src/classdef/gcdinfo.c Fri Oct 12 16:14:18 2001
@@ -19,7 +19,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: gcdinfo.c,v 1.6 2001/10/01 15:47:32 ntiffin Exp $
+ $Id: gcdinfo.c,v 1.7 2001/10/12 20:14:18 reinhard Exp $
*/
#include <stdio.h>
@@ -56,6 +56,9 @@
printf ("%-32s ", geas_cd_field_get_name_full (f));
switch (geas_cd_field_get_datatype (f))
{
+ case GEAS_CD_DATATYPE_ID:
+ printf ("id ");
+ break;
case GEAS_CD_DATATYPE_CHAR:
printf ("char<%3d> ",
geas_cd_field_get_format (f));
- gnue/geas/src/classdef classdef.c classdef.h gc...,
Reinhard Mueller <=