commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/geas examples/python/schema.py idl/schema....


From: Neil Tiffin
Subject: gnue/geas examples/python/schema.py idl/schema....
Date: Fri, 07 Sep 2001 12:25:31 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Neil Tiffin <address@hidden>    01/09/07 12:25:31

Modified files:
        geas/examples/python: schema.py 
        geas/idl       : schema.idl 
        geas/lib/classdefs: classdata.c classdata.h 
        geas/src       : schema.c schema.h 
        geas/src/mac/geas-mac.pbproj: ntiffin.pbxuser 

Log message:
        Add gcd filename to introspection properties and revise python program 
to display gcd filename.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/schema.py.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/idl/schema.idl.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.66&tr2=1.67&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.h.diff?cvsroot=OldCVS&tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/schema.c.diff?cvsroot=OldCVS&tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/schema.h.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/mac/geas-mac.pbproj/ntiffin.pbxuser.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: gnue/geas/examples/python/schema.py
diff -u gnue/geas/examples/python/schema.py:1.7 
gnue/geas/examples/python/schema.py:1.8
--- gnue/geas/examples/python/schema.py:1.7     Fri Sep  7 08:12:43 2001
+++ gnue/geas/examples/python/schema.py Fri Sep  7 12:25:31 2001
@@ -7,12 +7,144 @@
 # a test file: relies on GEAS being run from gnue/geas/src
 # and this from gnue/geas/examples/python
 #
-# $Id: schema.py,v 1.7 2001/09/07 15:12:43 ntiffin Exp $
+# $Id: schema.py,v 1.8 2001/09/07 19:25:31 ntiffin Exp $
 
 import sys
 import md5
-from string import * 
+from string import *
 
+def get_numeric_input(a_string, min_value, max_value):
+   idx = max_value + 1
+   while idx < min_value or idx > max_value:
+      print a_string + " [" + str(min_value) + "-" + str(max_value) + "]",
+      cmd = raw_input(" ")
+      if cmd == "Q" or cmd == "q":
+         print ""
+         print "Thank you for playing.."
+         print ""
+         sys.exit(0)
+      if cmd == "":
+         idx = 0
+      else:
+         idx = atoi( cmd )
+   print ""
+   return idx
+   
+def show_classnames( classes ):
+   i = 1
+   data = 0
+   for name in classnames:
+      if i % 2 == 0:
+         print rjust(str(i),4) + " " + ljust(name,32)
+         if i % 24 == 0:
+            data = get_numeric_input( "Select a class number to display 
[q,return]", 0, len(classnames) )
+            if data != 0:
+               return data
+      else:
+         print rjust(str(i),4) + " " + ljust(name,32) + "    ",
+      i = i + 1
+      
+   return data
+
+def show_fields( class_definition ):
+   if len(class_definition.fields) == 0: print " (None)"
+   else: print ""
+   for f in class_definition.fields:
+      print "Field Name: " + f.name
+      print "      Defined in:  " + f.classname
+      print "      Type      : ",
+      if f.type   == GEAS.basic :
+         print "Basic"
+      elif f.type == GEAS.lookup :
+         print "Lookup"
+         d = con.getReferenceDefinition( classnames[idx-1] , f.name )
+         if d != None:
+            if d.type == GEAS.lookup:
+               print "                   Type 'Lookup'"
+            else:
+               print "Wrong Type!"
+            print 
+            print "                   Field '" + d.loadfield +"'"
+            print "                   Fields (",
+            for x in d.srcfields: print x,
+            print ") match (",
+            for x in d.thisfields: print x,
+            print ")"
+      elif f.type == GEAS.reference :
+         print "Reference"
+         d = con.getReferenceDefinition( classnames[idx-1] , f.name )
+         if d != None:
+            if d.type == GEAS.reference:
+               print "                   Type 'Reference'"
+            else:
+               print "Wrong Type!"
+            print "                   Load '" + d.classname +"'"
+            print "                   Fields (",
+            for x in d.srcfields: print x,
+            print ") match (",
+            for x in d.thisfields: print x,
+            print ")"
+      elif f.type == GEAS.list :
+         print "List"
+         d = con.getReferenceDefinition( classnames[idx-1] , f.name )
+         if d != None:
+            if d.type == GEAS.list:
+               print "                   Type 'List'"
+            else:
+               print "Wrong Type!"
+            print "                   Load '" + d.classname +"'"
+            print "                   Fields (",
+            for x in d.srcfields: print x,
+            print ") match (",
+            for x in d.thisfields: print x,
+            print ")"
+      elif f.type == GEAS.method : print "Method"
+      elif f.type == GEAS.calculated : print "Calculated"
+      elif f.type == GEAS.nowrite : print "Read Only"
+      else: print "Unknown"
+      print "      Datatype  : ",
+      if f.datatype   == GEAS.Char: print "char",
+      elif f.datatype == GEAS.Int: print "int",
+      elif f.datatype == GEAS.Text: print "text",
+      elif f.datatype == GEAS.Class: print "class ("+f.datatypeclass+")",
+      elif f.datatype == GEAS.Date: print "date",
+      elif f.datatype == GEAS.Bool: print "bool",
+      elif f.datatype == GEAS.FloatValue: print "float",
+      elif f.datatype == GEAS.Void: print "void",
+      elif f.datatype == GEAS.ObjectRef: print "object",
+      elif f.datatype == GEAS.Enum: print "enum",
+      elif f.datatype  == GEAS.UnsignedInt: print "unsigned",
+      else: print "Unknown",
+      if len(f.format) > 0: print "<"+ f.format +">",
+      if f.defaultvalue != None and len(f.defaultvalue) > 0:
+         print " = " + f.defaultvalue,
+      print ""
+
+      print "      Flags     : ",
+      needcomma = 0
+      if f.notnull:
+         print "Not Null",
+         needcomma = 1;
+      if f.isreadonly:
+         if needcomma == 1: print ", "
+         print "Read Only",
+         needcomma =  1
+      if needcomma == 0: print "<None set>", # only happens if no flags are 
printed
+      print ""
+      print ""
+
+   return
+
+def show_classname( class_definition ):
+   print ""
+   print "Class Name: " + class_definition.name + ",  Parents: ",
+   for p in class_definition.parents:
+      print p + " ",
+   if len(class_definition.parents) == 0: print "(None)",
+   print ""
+   print "Defined in file: " + class_definition.gcdfilename
+   return
+
 try:
    import CORBA
    CORBA._load_idl("../../idl/geas.idl")
@@ -48,122 +180,11 @@
    try:
       print ""
       classnames = con.classes
-      i = 1;
-      for name in classnames:
-         if i < 10: print "   ",
-         elif i < 100: print " ",
-         print str(i) + " ... " + name
-         i = i + 1
-      print ""
-      print "    Q ... Quit program"
-      print ""
-      idx = 0;
-      while idx < 1 or idx > len(classnames):
-         print "Select a class to display: [1-"+str(len(classnames))+"]",
-         cmd = raw_input(" ")
-         if cmd == "Q" or cmd == "q":
-            print ""
-            print "Thank you for playing.."
-            print ""
-            sys.exit(0)
-         idx = atoi( cmd )
-         print ""
-      print ""
-      print "Displaying class " + classnames[idx-1]
-      print ""
+      idx = show_classnames( classnames )
+      
       c = con.getFullClassDefinition( classnames[idx-1] )
-      print "Name   : " + c.name
-      print "Parents: ",
-      for p in c.parents:
-         print p + " ",
-      if len(c.parents) == 0: print "(None)",
-      print ""
-      print "Fields:",
-      if len(c.fields) == 0: print " (None)"
-      else: print ""
-      for f in c.fields:
-         print "  Name: " + f.name
-         print "      Defined in:  " + f.classname
-         print "      Type      : ",
-         if f.type   == GEAS.basic :
-            print "Basic"
-         elif f.type == GEAS.lookup :
-            print "Lookup"
-            d = con.getReferenceDefinition( classnames[idx-1] , f.name )
-            if d != None:
-               if d.type == GEAS.lookup:
-                  print "                   Type 'Lookup'"
-               else:
-                  print "Wrong Type!"
-               print 
-               print "                   Field '" + d.loadfield +"'"
-               print "                   Fields (",
-               for x in d.srcfields: print x,
-               print ") match (",
-               for x in d.thisfields: print x,
-               print ")"
-         elif f.type == GEAS.reference :
-            print "Reference"
-            d = con.getReferenceDefinition( classnames[idx-1] , f.name )
-            if d != None:
-               if d.type == GEAS.reference:
-                  print "                   Type 'Reference'"
-               else:
-                  print "Wrong Type!"
-               print "                   Load '" + d.classname +"'"
-               print "                   Fields (",
-               for x in d.srcfields: print x,
-               print ") match (",
-               for x in d.thisfields: print x,
-               print ")"
-         elif f.type == GEAS.list :
-            print "List"
-            d = con.getReferenceDefinition( classnames[idx-1] , f.name )
-            if d != None:
-               if d.type == GEAS.list:
-                  print "                   Type 'List'"
-               else:
-                  print "Wrong Type!"
-               print "                   Load '" + d.classname +"'"
-               print "                   Fields (",
-               for x in d.srcfields: print x,
-               print ") match (",
-               for x in d.thisfields: print x,
-               print ")"
-         elif f.type == GEAS.method : print "Method"
-         elif f.type == GEAS.calculated : print "Calculated"
-         elif f.type == GEAS.nowrite : print "Read Only"
-         else: print "Unknown"
-         print "      Datatype  : ",
-         if f.datatype   == GEAS.Char: print "char",
-         elif f.datatype == GEAS.Int: print "int",
-         elif f.datatype == GEAS.Text: print "text",
-         elif f.datatype == GEAS.Class: print "class ("+f.datatypeclass+")",
-         elif f.datatype == GEAS.Date: print "date",
-         elif f.datatype == GEAS.Bool: print "bool",
-         elif f.datatype == GEAS.FloatValue: print "float",
-         elif f.datatype == GEAS.Void: print "void",
-         elif f.datatype == GEAS.ObjectRef: print "object",
-         elif f.datatype == GEAS.Enum: print "enum",
-         elif f.datatype  == GEAS.UnsignedInt: print "unsigned",
-         else: print "Unknown",
-         if len(f.format) > 0: print "<"+ f.format +">",
-         if f.defaultvalue != None and len(f.defaultvalue) > 0:
-            print " = " + f.defaultvalue,
-         print ""
-   
-         print "      Flags     : ",
-         needcomma = 0
-         if f.notnull:
-            print "Not Null",
-            needcomma = 1;
-         if f.isreadonly:
-            if needcomma == 1: print ", "
-            print "Read Only",
-            needcomma =  1
-         if needcomma == 0: print "<None set>", # only happens if no flags are 
printed
-         print ""
-         print ""
+      show_classname( c )
+      show_fields( c )
       raw_input( "Press 'enter' to continue" )
 
    except ServerError,ex:
Index: gnue/geas/idl/schema.idl
diff -u gnue/geas/idl/schema.idl:1.7 gnue/geas/idl/schema.idl:1.8
--- gnue/geas/idl/schema.idl:1.7        Mon Mar 26 15:40:31 2001
+++ gnue/geas/idl/schema.idl    Fri Sep  7 12:25:31 2001
@@ -25,6 +25,7 @@
 struct ClassDefinition
 {
     string     name;
+    string     gcdfilename;  // filename defining this class
     classnames parents;   // list of immediate parents
     fieldlist  fields;    // fields in this class
     boolean    allfields; // TRUE if inherited fields are included
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.66 
gnue/geas/lib/classdefs/classdata.c:1.67
--- gnue/geas/lib/classdefs/classdata.c:1.66    Sat Sep  1 23:49:15 2001
+++ gnue/geas/lib/classdefs/classdata.c Fri Sep  7 12:25:31 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.66 2001/09/02 06:49:15 reinhard Exp $
+   $Id: classdata.c,v 1.67 2001/09/07 19:25:31 ntiffin Exp $
    
 */
 
@@ -1137,6 +1137,18 @@
   assert (classd != NULL);
 #endif
   return (classd->base.triggers);
+}
+
+/* ------------------------------------------------------------------------- *\
+ * get gcd filename that defined the class
+\* ------------------------------------------------------------------------- */
+char *
+odl_class_get_gcd_filename (odl_class * classd)
+{
+#ifdef DEBUG
+  assert (classd != NULL);
+#endif
+  return (classd->filename);
 }
 
 /* ------------------------------------------------------------------------- *\
Index: gnue/geas/lib/classdefs/classdata.h
diff -u gnue/geas/lib/classdefs/classdata.h:1.33 
gnue/geas/lib/classdefs/classdata.h:1.34
--- gnue/geas/lib/classdefs/classdata.h:1.33    Tue Jul 24 14:19:38 2001
+++ gnue/geas/lib/classdefs/classdata.h Fri Sep  7 12:25:31 2001
@@ -227,6 +227,7 @@
 unsigned long int odl_class_get_access(odl_class * classd);
 unsigned long int odl_class_get_triggers(odl_class * classd);
 odl_base *odl_class_get_parent(odl_class * classd);
+char *odl_class_get_gcd_filename (odl_class * classd);
 odl_namelist *odl_class_get_parentnames(odl_class * classd);
 odl_field *odl_class_get_field(odl_class * classd, const char *fieldname);
 odl_fieldlist *odl_class_get_fields(odl_class * classd,
Index: gnue/geas/src/mac/geas-mac.pbproj/ntiffin.pbxuser
diff -u gnue/geas/src/mac/geas-mac.pbproj/ntiffin.pbxuser:1.6 
gnue/geas/src/mac/geas-mac.pbproj/ntiffin.pbxuser:1.7
--- gnue/geas/src/mac/geas-mac.pbproj/ntiffin.pbxuser:1.6       Sun Sep  2 
09:56:32 2001
+++ gnue/geas/src/mac/geas-mac.pbproj/ntiffin.pbxuser   Fri Sep  7 12:25:31 2001
@@ -110,9 +110,9 @@
                                                        };
                                                };
                                                Tab2 = {
-                                                       BuildMessageFrame = 
"{{0, 0}, {610, 133}}";
-                                                       BuildTranscriptFrame = 
"{{0, 142}, {610, 122}}";
-                                                       Frame = "{{0, 0}, {608, 
262}}";
+                                                       BuildMessageFrame = 
"{{0, 0}, {579, 133}}";
+                                                       BuildTranscriptFrame = 
"{{0, 142}, {579, 122}}";
+                                                       Frame = "{{0, 0}, {577, 
262}}";
                                                };
                                                Tab3 = {
                                                        Frame = "{{0, 0}, {577, 
298}}";
@@ -141,7 +141,7 @@
                                        };
                                        TabCount = 4;
                                };
-                               WindowLocation = "{104, 27}";
+                               WindowLocation = "{106, 30}";
                        };
                };
        };
Index: gnue/geas/src/schema.c
diff -u gnue/geas/src/schema.c:1.15 gnue/geas/src/schema.c:1.16
--- gnue/geas/src/schema.c:1.15 Tue Jun 19 13:48:10 2001
+++ gnue/geas/src/schema.c      Fri Sep  7 12:25:31 2001
@@ -19,7 +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: schema.c,v 1.15 2001/06/19 20:48:10 reinhard Exp $
+   $Id: schema.c,v 1.16 2001/09/07 19:25:31 ntiffin Exp $
  
 */
 
@@ -128,7 +128,8 @@
 
   /* class name */
   retval->name = CORBA_string_dup (odl_class_get_full_name (c));
-
+  retval->gcdfilename = CORBA_string_dup 
(g_basename(odl_class_get_gcd_filename (c)));
+  
   /* parents */
   l = c->parents;
   count = g_list_length (l);
Index: gnue/geas/src/schema.h
diff -u gnue/geas/src/schema.h:1.4 gnue/geas/src/schema.h:1.5
--- gnue/geas/src/schema.h:1.4  Sun Jun 10 05:56:12 2001
+++ gnue/geas/src/schema.h      Fri Sep  7 12:25:31 2001
@@ -19,7 +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$
+   $Id: schema.h,v 1.5 2001/09/07 19:25:31 ntiffin Exp $
 
 */
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]