File: plplot_widgetmodule.c

package info (click to toggle)
plplot 5.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 84,772 kB
  • sloc: ansic: 86,290; xml: 26,754; ada: 17,685; cpp: 15,530; php: 11,938; tcl: 11,125; ml: 6,825; perl: 6,736; f90: 6,709; python: 6,237; java: 6,215; sh: 2,042; makefile: 192; lisp: 75; fortran: 64; sed: 52
file content (82 lines) | stat: -rw-r--r-- 2,164 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// C code to create dynamically loaded library to implement plplot_widget module

#include <Python.h>
// Change this to the recommended
// #include <Numeric/arrayobject.h>
//  once we no longer support python1.5
#include <arrayobject.h>
#include "plplot.h"
#include "plplotP.h"

#ifdef ENABLE_tk
#include <tcl.h>
#endif

#define TRY( E )    if ( !( E ) ) return NULL

#ifdef ENABLE_tk
static char doc_Pltk_init[] = "Initialize the Pltk Tcl extension.";

//--------------------------------------------------------------------------
// A python module method for initializing the PLtk extension.  This method
// must be called from python with a single argument, which is the address of
// the Tcl interpreter into which the Pltk extension is to be injected.
//--------------------------------------------------------------------------

static PyObject *pl_Pltk_init( PyObject *self, PyObject *args )
{
    printf( "in pl_Pltk_init()\n" );
    long x = 0;

    TRY( PyArg_ParseTuple( args, "l", &x ) );

    if ( !x )
    {
        printf( "Something went wrong...\n" );
        Py_INCREF( Py_None );
        return Py_None;
    }

    Tcl_Interp *interp = (Tcl_Interp *) x;

    printf( "Tcl_Interp * = %ld \n", x );

    if ( Pltk_Init( interp ) == TCL_ERROR )
    {
        printf( "Initizlization of Pltk Tcl extension failed!\n" );
        return NULL;
    }

    printf( "plframe has been installed into the Tcl interpreter.\n" );

    Py_INCREF( Py_None );
    return Py_None;
}

#endif

//--------------------------------------------------------------------------

static PyMethodDef plplot_widget_methods[] = {
#ifdef ENABLE_tk
    { "Pltk_init", pl_Pltk_init, METH_VARARGS, doc_Pltk_init },
#endif

    { NULL,        NULL,                    0, NULL          }
};

PLDLLIMPEXP_PLPLOT_WIDGETMODULE void initplplot_widget( void )
{
    PyObject *m;
    PyObject *d;

    import_array();

    // Create the module and add the functions
    m = Py_InitModule( "plplot_widget", plplot_widget_methods );
    d = PyModule_GetDict( m );

    // Check for errors
    if ( PyErr_Occurred() )
        Py_FatalError( "plplot_widget module initialization failed" );
}