[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue geas/src/dataobject.c geas/src/mac/geas-ma...
From: |
Neil Tiffin |
Subject: |
gnue geas/src/dataobject.c geas/src/mac/geas-ma... |
Date: |
Tue, 18 Sep 2001 20:45:59 -0400 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/09/18 20:45:59
Modified files:
geas/src : dataobject.c
geas/src/mac/geas-mac.pbproj: project.pbxproj
geas/src/methods: methods_python.c
Added files:
geas/examples/python: neil_methods_test.py
gnue-config : neil_test.gcd neil_test.py
Log message:
Python methods appear to work with one test example. Be aware this
is really early code. To test start geas pointed to gnue-config and
then execute geas/examples/python/neil_methods_test.py.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/neil_methods_test.py?cvsroot=OldCVS&rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/dataobject.c.diff?cvsroot=OldCVS&tr1=1.61&tr2=1.62&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/mac/geas-mac.pbproj/project.pbxproj.diff?cvsroot=OldCVS&tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/methods/methods_python.c.diff?cvsroot=OldCVS&tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-config/neil_test.gcd?cvsroot=OldCVS&rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-config/neil_test.py?cvsroot=OldCVS&rev=1.1
Patches:
Index: gnue/geas/src/dataobject.c
diff -u gnue/geas/src/dataobject.c:1.61 gnue/geas/src/dataobject.c:1.62
--- gnue/geas/src/dataobject.c:1.61 Sun Sep 2 02:49:16 2001
+++ gnue/geas/src/dataobject.c Tue Sep 18 20:45:59 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: dataobject.c,v 1.61 2001/09/02 06:49:16 reinhard Exp $
+ $Id: dataobject.c,v 1.62 2001/09/19 00:45:59 ntiffin Exp $
*/
@@ -1133,7 +1133,7 @@
odl_class *cl = NULL;
odl_field *f = NULL;
- /* validate class/object/method */
+ /* validate class/object/method */
cl = odl_find_class (all_classes, id->classname, NULL);
if (!cl)
{
@@ -1152,9 +1152,7 @@
methodname, id->classname);
return (NULL);
}
- /* done */
-
- /* validate arguments */
+ /* validate arguments */
if (args->_length != odl_method_argument_count (f))
{
make_ArgumentCount_exception (ev, odl_method_argument_count (f),
@@ -1176,6 +1174,6 @@
debug_output (DEBUGLEVEL_ALWAYS, "Arg %2d: %s", i, args->_buffer[i]);
}
#endif
-
+ /* call method */
return (execute_method (id, methodname, args, ev));
}
Index: gnue/geas/src/mac/geas-mac.pbproj/project.pbxproj
diff -u gnue/geas/src/mac/geas-mac.pbproj/project.pbxproj:1.5
gnue/geas/src/mac/geas-mac.pbproj/project.pbxproj:1.6
--- gnue/geas/src/mac/geas-mac.pbproj/project.pbxproj:1.5 Sat Sep 15
18:29:32 2001
+++ gnue/geas/src/mac/geas-mac.pbproj/project.pbxproj Tue Sep 18 20:45:59 2001
@@ -675,7 +675,7 @@
HEADER_SEARCH_PATHS =
"/Volumes/AnagadaII/gnue/geas/src/oql
/Volumes/AnagadaII/gnue/geas/src/objectcache
/Volumes/AnagadaII/gnue/geas/src/objectstore
/Volumes/AnagadaII/gnue/geas/src/lib /Volumes/AnagadaII/gnue/geas/src/config
/Volumes/AnagadaII/gnue/geas/src/methods /Volumes/AnagadaII/gnue/geas/src
/Volumes/AnagadaII/sw/include";
INSTALL_PATH = /Volumes/AnagadaII/gnue/geas/src;
LIBRARY_SEARCH_PATHS =
"/Volumes/AnagadaII/sw/lib /Volumes/AnagadaII/sw/lib/mysql
/Volumes/AnagadaII/sw/lib/python2.1/config /usr/X11R6/lib";
- OPTIMIZATION_CFLAGS = "";
+ OPTIMIZATION_CFLAGS = "-O0";
OTHER_CFLAGS = "-traditional-cpp -g
-DHAVE_GETOPT_H -DHAVE_CONFIG_H -DUSE_SERVANT_MANAGER
-DGEAS_DATA_DIR=\\\\\\\"../../\\\\\\\"
-DGEAS_SYSRC=\\\\\\\"../../geas.conf\\\\\\\" -DGEAS_PID_DIR=\\\\\\\"../\\\\\\\"
-DGEAS_IOR_DIR=\\\\\\\"../\\\\\\\"";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
Index: gnue/geas/src/methods/methods_python.c
diff -u gnue/geas/src/methods/methods_python.c:1.8
gnue/geas/src/methods/methods_python.c:1.9
--- gnue/geas/src/methods/methods_python.c:1.8 Sun Sep 16 14:42:23 2001
+++ gnue/geas/src/methods/methods_python.c Tue Sep 18 20:45:59 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: methods_python.c,v 1.8 2001/09/16 18:42:23 ntiffin Exp $
+ $Id: methods_python.c,v 1.9 2001/09/19 00:45:59 ntiffin Exp $
*/
/*
@@ -76,7 +76,8 @@
\* ========================================================================= */
/* ------------------------------------------------------------------------- *\
- * methods_register_python
+ * methods_register_python - this C function is called through python
+ * to get register the python stuff needed to call a method later.
\* ------------------------------------------------------------------------- */
static PyObject *
@@ -91,19 +92,21 @@
if (!PyArg_ParseTuple
(args, "sO:methods_register_python", &methodname, &function))
{
- return (NULL);
+ errormsg("Failed to parse tuple when registering method\n");
+ return Py_BuildValue ("i", 0);
}
Py_XINCREF (function);
- /* PyObject_Print(function, stdout, 0); */
+ PyObject_Print(function, stdout, 0);
if (!PyCallable_Check (function))
{
Py_XDECREF (function);
+ errormsg("Attempt to register Python function that is not callable:
%s\n", methodname);
return Py_BuildValue ("i", 0);
}
-
if (current_provider)
- current_provider->extra = (void *) function;
-
+ { /* save pointer to function for later use */
+ current_provider->extra = (void *) function;
+ }
return Py_BuildValue ("i", 1); /* succeed */
}
@@ -216,7 +219,8 @@
FILE *fp;
GList *l, *l2;
odl_class *c;
-
+ char *full_classname;
+
g_return_val_if_fail (config, FALSE);
PyEval_AcquireLock ();
@@ -235,7 +239,6 @@
dirname[strlen (dirname) - 1] = '\0';
message( "method dir name: '%s'" , dirname );
- /* execute each .py file */
dir = opendir (dirname);
if (!dir)
{
@@ -243,6 +246,10 @@
g_free (dirname);
return (FALSE);
}
+ /* load all .py files into embedded python
+ note that this executes the file and any
+ non function code will be executed.
+ */
while ((entry = readdir (dir)) != NULL)
{
if (!strcmp (&entry->d_name[strlen (entry->d_name) - 3], ".py"))
@@ -255,63 +262,59 @@
g_free (dirname);
return (FALSE);
}
-
- /* run file 'name' */
+ /* make sure it can be opened */
+ /* TODO make sure this matches a gcd function */
fp = fopen (name, "r");
if (!name)
{
errormsg ("Could not open file '%s'", name);
closedir (dir);
g_free (dirname);
- g_free (name);
+ g_free (name); /* TODO continue on with other names */
return (FALSE);
}
+ /* run file 'name' */
message ("Loading file %s", name);
PyRun_SimpleFile (fp, name);
-
- /* done this file */
+ /* done this file */
fclose (fp);
g_free (name);
}
}
closedir (dir);
g_free (dirname);
-
- /* done loading, now register */
-
+ /* done loading, now register */
lst = l = odl_tree_list_classes (all_classes);
while (l)
{
c = odl_find_class (all_classes, l->data, NULL);
debug_output (DEBUGLEVEL_2, " class %s", odl_class_get_name (c));
-
l2 = list = odl_class_get_fields (c, FT_method);
while (l2)
{
char *buf;
f = l2->data;
debug_output (DEBUGLEVEL_2, " method: %s",
- odl_field_get_name (f));
-
+ odl_field_get_name(f));
+ full_classname =
+ g_strdup_printf("%s__%s", (odl_class_get_parent(c))->name,
odl_class_get_name (c));
current_provider =
- alloc_provider_data (odl_class_get_name (c), NULL,
- odl_field_get_name (f), NULL);
+ alloc_provider_data (full_classname, NULL,
+ odl_field_get_name(f), NULL);
provider_list = g_list_append (provider_list, current_provider);
- buf =
- g_strdup_printf
+ buf = g_strdup_printf
("method_system.register_method( \"%s_%s\" , %s_%s )",
- odl_class_get_name (c), odl_field_get_name (f),
- odl_class_get_name (c), odl_field_get_name (f));
+ full_classname, odl_field_get_name(f),
+ full_classname, odl_field_get_name(f));
g_strdown (buf);
+ warnmsg("Attempt to register method: %s_%s\n", full_classname,
odl_field_get_name (f) );
PyRun_SimpleString (buf);
g_free (buf);
current_provider = NULL;
-
l2 = l2->next;
}
odl_fieldlist_free (list);
-
l = g_list_next (l);
}
odl_namelist_free (l);
@@ -375,10 +378,10 @@
list = provider_list;
while (list)
{
- g_message ("%s = %s", ((provider_t *) list->data)->classname,
obj->classname);
- g_message ("%s = %s", ((provider_t *) list->data)->methodname,
methodname);
+ g_message ("classname: %s = %s", ((provider_t *) list->data)->classname,
obj->classname);
+ g_message ("fieldname: %s = %s", ((provider_t *)
list->data)->methodname, methodname);
if (!g_strcasecmp
- (((provider_t *) list->data)->classname, obj->classname)
+ (((provider_t *) list->data)->classname,
g_strdelimit(obj->classname,":", '_'))
&& !g_strcasecmp (((provider_t *) list->data)->methodname,
methodname))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue geas/src/dataobject.c geas/src/mac/geas-ma...,
Neil Tiffin <=