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