/[ascend]/trunk/models/johnpye/extpy/extpy.c
ViewVC logotype

Diff of /trunk/models/johnpye/extpy/extpy.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 875 by johnpye, Sat Oct 7 06:26:34 2006 UTC revision 877 by johnpye, Sat Oct 7 09:31:51 2006 UTC
# Line 98  int extpy_invokemethod(struct Instance * Line 98  int extpy_invokemethod(struct Instance *
98      /*      /*
99          We need to be able to convert C 'struct Instance' pointers to Python 'Instance' objects.          We need to be able to convert C 'struct Instance' pointers to Python 'Instance' objects.
100          This functionality is implemented in 'ascpy' but we're not going to link to that here,          This functionality is implemented in 'ascpy' but we're not going to link to that here,
101          so we will use the importhandler 'getsharedpointer' trick to get hold of the          so we will use the importhandler 'setsharedpointer' trick to pass the object to the
102          casting function, then run it here.          'registry' then write a routine in ascpy that will cast it into the appropriate
103            Python object.
104      */      */
     CONSOLE_DEBUG("ADDING 'context' AS SHARED POINTER");  
105      importhandler_setsharedpointer("context",(void *)context);      importhandler_setsharedpointer("context",(void *)context);
106    
107        /*
108            Eventually we'll work out how to pass the instance object directly into Python. For
109            the moment, just have a placeholder variable instead:
110        */
111      arglist = Py_BuildValue("(i)", 666);      arglist = Py_BuildValue("(i)", 666);
     CONSOLE_DEBUG("BUILDING ARGLIST FOR PYTHON METHOD");  
112    
113      CONSOLE_DEBUG("CALLING PYTHON");      CONSOLE_DEBUG("CALLING PYTHON");
114      result = PyEval_CallObject(fn, arglist);      result = PyEval_CallObject(fn, arglist);
# Line 113  int extpy_invokemethod(struct Instance * Line 116  int extpy_invokemethod(struct Instance *
116      Py_DECREF(arglist);      Py_DECREF(arglist);
117    
118      if(PyErr_Occurred()){      if(PyErr_Occurred()){
119            /** @TODO we really want to capture these error messages and output them to the GUI, instead of outputting them to the console */
120          PyErr_Print();          PyErr_Print();
121          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Failed running python method (see console)");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Failed running python method (see console)");
122          return 1;          return 1;

Legend:
Removed from v.875  
changed lines
  Added in v.877

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22