• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

plplot_widgetmodule.c

Go to the documentation of this file.
00001 // C code to create dynamically loaded library to implement plplot_widget module
00002 
00003 #include <Python.h>
00004 // Change this to the recommended
00005 // #include <Numeric/arrayobject.h>
00006 //  once we no longer support python1.5
00007 #include <arrayobject.h>
00008 #include "plplot.h"
00009 #include "plplotP.h"
00010 
00011 #ifdef ENABLE_tk
00012 #include <tcl.h>
00013 #endif
00014 
00015 #define TRY( E )    if ( !( E ) ) return NULL
00016 
00017 #ifdef ENABLE_tk
00018 static char doc_Pltk_init[] = "Initialize the Pltk Tcl extension.";
00019 
00020 //--------------------------------------------------------------------------
00021 // A python module method for initializing the PLtk extension.  This method
00022 // must be called from python with a single argument, which is the address of
00023 // the Tcl interpreter into which the Pltk extension is to be injected.
00024 //--------------------------------------------------------------------------
00025 
00026 static PyObject *pl_Pltk_init( PyObject *self, PyObject *args )
00027 {
00028     printf( "in pl_Pltk_init()\n" );
00029     long x = 0;
00030 
00031     TRY( PyArg_ParseTuple( args, "l", &x ) );
00032 
00033     if ( !x )
00034     {
00035         printf( "Something went wrong...\n" );
00036         Py_INCREF( Py_None );
00037         return Py_None;
00038     }
00039 
00040     Tcl_Interp *interp = (Tcl_Interp *) x;
00041 
00042     printf( "Tcl_Interp * = %ld \n", x );
00043 
00044     if ( Pltk_Init( interp ) == TCL_ERROR )
00045     {
00046         printf( "Initizlization of Pltk Tcl extension failed!\n" );
00047         return NULL;
00048     }
00049 
00050     printf( "plframe has been installed into the Tcl interpreter.\n" );
00051 
00052     Py_INCREF( Py_None );
00053     return Py_None;
00054 }
00055 
00056 #endif
00057 
00058 //--------------------------------------------------------------------------
00059 
00060 static PyMethodDef plplot_widget_methods[] = {
00061 #ifdef ENABLE_tk
00062     { "Pltk_init", pl_Pltk_init, METH_VARARGS, doc_Pltk_init },
00063 #endif
00064 
00065     { NULL,        NULL,                    0, NULL          }
00066 };
00067 
00068 PLDLLIMPEXP_PLPLOT_WIDGETMODULE void initplplot_widget( void )
00069 {
00070     PyObject *m;
00071     PyObject *d;
00072 
00073     import_array();
00074 
00075     // Create the module and add the functions
00076     m = Py_InitModule( "plplot_widget", plplot_widget_methods );
00077     d = PyModule_GetDict( m );
00078 
00079     // Check for errors
00080     if ( PyErr_Occurred() )
00081         Py_FatalError( "plplot_widget module initialization failed" );
00082 }

Generated on Wed Oct 12 2011 20:42:22 for PLplot by  doxygen 1.7.1