File: plplot_widgetmodule.c

package info (click to toggle)
plplot 5.10.0%2Bdfsg2-0.4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 25,792 kB
  • ctags: 13,517
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,208; makefile: 210; lisp: 75; sed: 25; fortran: 7
file content (83 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (2)
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
83
// C code to create dynamically loaded library to implement plplot_widget module

#define NPY_NO_DEPRECATED_API    NPY_1_7_API_VERSION
#include <Python.h>
#include <arrayobject.h>
#include "plplot.h"
#include "plplotP.h"

#ifdef ENABLE_tkX
#include <tcl.h>
#include "pltk.h"
#endif

void initplplot_widget( void );

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

#ifdef ENABLE_tkX
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 * PL_UNUSED( 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( "Initialization 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_tkX
    { "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 );
    PyModule_GetDict( m );

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