[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue docbook/GNUeModuleGuide/chapters/businesso...
From: |
Neil Tiffin |
Subject: |
gnue docbook/GNUeModuleGuide/chapters/businesso... |
Date: |
Sun, 27 May 2001 18:24:07 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/05/27 18:24:07
Modified files:
docbook/GNUeModuleGuide/chapters: businessobjects.sgml
geas/lib/classdefs: classdata.c classdata.h yparser.y
Log message:
Implement EXTEND keyword.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/docbook/GNUeModuleGuide/chapters/businessobjects.sgml.diff?cvsroot=OldCVS&tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.h.diff?cvsroot=OldCVS&tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/yparser.y.diff?cvsroot=OldCVS&tr1=1.29&tr2=1.30&r1=text&r2=text
Patches:
Index: gnue/docbook/GNUeModuleGuide/chapters/businessobjects.sgml
diff -u gnue/docbook/GNUeModuleGuide/chapters/businessobjects.sgml:1.16
gnue/docbook/GNUeModuleGuide/chapters/businessobjects.sgml:1.17
--- gnue/docbook/GNUeModuleGuide/chapters/businessobjects.sgml:1.16 Thu May
24 07:00:40 2001
+++ gnue/docbook/GNUeModuleGuide/chapters/businessobjects.sgml Sun May 27
18:24:06 2001
@@ -7,7 +7,7 @@
Introduction
</title>
<para>
- This chapter is $Id: businessobjects.sgml,v 1.16
2001/05/24 14:00:40 ntiffin Exp $.
+ This chapter is $Id: businessobjects.sgml,v 1.17
2001/05/28 01:24:06 ntiffin Exp $.
</para>
<para>
Quick links to the various sections.
@@ -169,7 +169,7 @@
#
# This file originally written by Neil Tiffin (address@hidden).
#
-# $Revision: 1.16 $ $Date: 2001/05/24 14:00:40 $ $Author: ntiffin $
+# $Revision: 1.17 $ $Date: 2001/05/28 01:24:06 $ $Author: ntiffin $
#
module person
@@ -253,7 +253,7 @@
exactly like a class definition:
</para>
<programlisting>
- EXTEND class_name
+ EXTEND fully_qualified_class_name
{
};
@@ -280,17 +280,14 @@
</para>
<programlisting>
- MODULE supply_chain
- {
- EXTEND base::item
- {
- int quantity_on_hand;
- };
- };
+ EXTEND base::item
+ {
+ int quantity_on_hand;
+ };
</programlisting>
<para>
-This is really produces the same results as if it had been originally defined
as:
+Note that the extend defintion exists outside of any module definition even if
it is defined inside a module definition. This is really produces the same
results as if it had been originally defined as:
</para>
<programlisting>
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.54
gnue/geas/lib/classdefs/classdata.c:1.55
--- gnue/geas/lib/classdefs/classdata.c:1.54 Sun May 27 16:00:26 2001
+++ gnue/geas/lib/classdefs/classdata.c Sun May 27 18:24:06 2001
@@ -22,7 +22,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: classdata.c,v 1.54 2001/05/27 23:00:26 ntiffin Exp $
+ $Id: classdata.c,v 1.55 2001/05/28 01:24:06 ntiffin Exp $
*/
@@ -1746,27 +1746,40 @@
}
/* ------------------------------------------------------------------------- *\
- * Given an item make a fullname with all of the parents.
+ * Given an name and a container (parent) make a fullname
+ * with all of the parents.
\* ------------------------------------------------------------------------- */
char *
-odl_make_fullname( odl_base * base )
+odl_make_fullname( odl_base * parent, char * name )
{
- GString * name = g_string_new(NULL);
- odl_base * b = NULL;
+ GString * name_string = g_string_new(NULL);
char * result;
- g_assert( base );
+ odl_base * b = NULL;
+
+ g_assert( parent != NULL);
+ g_assert( name != NULL);
- name = g_string_append( name, base->name );
- b = base->parent;
+ name_string = g_string_append( name_string, name );
+ b = parent;
while (b)
{
- name = g_string_prepend(name, "::");
- name = g_string_prepend(name, b->name);
+ name_string = g_string_prepend(name_string, "::");
+ name_string = g_string_prepend(name_string, b->name);
b = b->parent;
}
- result = name->str;
- g_string_free( name, FALSE);
+ result = name_string->str;
+ g_string_free( name_string, FALSE);
return result;
+}
+
+/* ------------------------------------------------------------------------- *\
+ * Given an item make a fullname with all of the parents.
+\* ------------------------------------------------------------------------- */
+char *
+odl_make_fullname_base( odl_base * base )
+{
+ g_assert( base );
+ return odl_make_fullname( base->parent, base->name);
}
/* ------------------------------------------------------------------------- *\
Index: gnue/geas/lib/classdefs/classdata.h
diff -u gnue/geas/lib/classdefs/classdata.h:1.29
gnue/geas/lib/classdefs/classdata.h:1.30
--- gnue/geas/lib/classdefs/classdata.h:1.29 Sun May 27 16:00:26 2001
+++ gnue/geas/lib/classdefs/classdata.h Sun May 27 18:24:07 2001
@@ -292,7 +292,8 @@
*
*/
void odl_resolve_implicit_list (odl_item * i );
-char * odl_make_fullname( odl_base * base );
+char * odl_make_fullname( odl_base * parent, char * name );
+char * odl_make_fullname_base( odl_base * base );
odl_tree *odl_load_files(odl_filenamelist * files, odl_tree * tree);
void odl_display_tree(FILE * out, odl_tree * tree, gboolean show_full_name);
Index: gnue/geas/lib/classdefs/yparser.y
diff -u gnue/geas/lib/classdefs/yparser.y:1.29
gnue/geas/lib/classdefs/yparser.y:1.30
--- gnue/geas/lib/classdefs/yparser.y:1.29 Sun May 27 16:00:26 2001
+++ gnue/geas/lib/classdefs/yparser.y Sun May 27 18:24:07 2001
@@ -33,6 +33,7 @@
struct _odl_container *yycurrent_container = NULL;
struct _odl_container *lastpushed = NULL;
+struct _odl_container *beforefind = NULL; /* used with find class to restore
last position */
static gboolean is_a_type = FALSE;
@@ -125,6 +126,45 @@
}
}
;
+
+find_class: /* */ {
+ odl_class * found_class = NULL;
+ found_class = odl_find_class ( yycurrenttree,
$<string>0, NULL);
+ /* TODO fix extend must use fully qualified
name */
+ /* odl_make_fullname_base(
yycurrent_container, $<string>0)); */
+ if ( found_class != NULL)
+ {
+ beforefind = yycurrent_container;
+ yycurrent_container = found_class;
+ }
+ else
+ {
+ yyerror("Could not find class.");
+ }
+ }
+ ;
+
+unfind_class: /* */ {
+ if( current_pass == 1 )
+ {
+ odl_class *c = NULL;
+ c = (odl_class *) yycurrent_container;
+ /* add stuff to class */
+ if ($<list>-1)
+ {
+ if (c->contents)
+ {
+ c->contents = g_list_concat (c->contents,
$<list>-1);
+ }
+ else
+ {
+ c->contents = $<list>-1;
+ }
+ }
+ }
+ yycurrent_container = beforefind;
+ }
+ ;
push_class: /* */ {
if( current_pass == 1 )
@@ -137,7 +177,7 @@
g_assert( newone );
newone->base.parent = (odl_base
*)yycurrent_container;
/* try to find a class with the same name */
- fullname = odl_make_fullname( (odl_base*) newone );
+ fullname = odl_make_fullname_base( (odl_base*)
newone );
check_class = odl_find_class(yycurrenttree,
fullname, NULL);
if (check_class != NULL)
{
@@ -263,6 +303,7 @@
unit: opt_access module ';' { is_a_type = FALSE; }
| opt_access class ';' { is_a_type = FALSE; }
+ | opt_access extend ';' { is_a_type = FALSE; }
| opt_access type ';' { is_a_type = TRUE; }
| opt_access ENUM enum ';' { is_a_type = FALSE; }
;
@@ -274,6 +315,9 @@
;
type: opt_class_type CTYPE dt_off new_class_name push_class opt_parent_list
'{' dt_on class_body '}' pop_class dt_on { lastpushed->istype = TRUE; }
+ ;
+
+extend: EXTEND dt_off existing_class_name find_class '{' dt_on class_body '}'
unfind_class dt_on {}
;
enum: new_container_name '{' enum_body '}' dt_on {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue docbook/GNUeModuleGuide/chapters/businesso...,
Neil Tiffin <=