paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/bindings/python python.h,NONE,1.1.2.1 Makefil


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/bindings/python python.h,NONE,1.1.2.1 Makefile.am,1.1.1.1,1.1.1.1.6.1
Date: Fri, 01 Nov 2002 10:01:01 -0500

Update of /cvsroot/paragui/paragui/bindings/python
In directory subversions:/tmp/cvs-serv2475/bindings/python

Modified Files:
      Tag: devel-1-0
        Makefile.am 
Added Files:
      Tag: devel-1-0
        python.h 
Log Message:
added Ruby bindings. Thanks Leon <address@hidden>



--- NEW FILE ---
#ifdef SWIG

%include "paragui.h"

// Grab a Python function object as a Python object.
%typemap(python,in) PyObject *pyfunc {
        if (!PyCallable_Check($input)) {
                PyErr_SetString(PyExc_TypeError, "Need a callable object!");
                return NULL;
        }
        $1 = $input;
}

%module pgmessageobject

%extend PG_MessageObject {

        // This function matches the prototype of the normal C callback
        // function for our widget. However, we use the clientdata pointer
        // for holding a reference to a Python callable object.

        static bool PythonCallBack(int id, PG_Widget *widget, unsigned long 
data, void *clientdata) {
                PyObject *func, *arglist;
                PyObject *result;
                bool     res = 0;

                func = (PyObject *) clientdata;               // Get Python 
function
                arglist = Py_BuildValue("(ill)",id,widget,data);// Build 
argument list
                result = PyEval_CallObject(func,arglist);     // Call Python
                Py_DECREF(arglist);                           // Trash arglist
                if (result) {                                 // If no errors, 
return double
                        res = PyInt_AsLong(result);
                }
                Py_XDECREF(result);
                return res;
        }

        // Attach a new method to our plot widget for adding Python functions
        // Set a Python function object as a callback function
        // Note : PyObject *pyfunc is remapped with a typempap

        void set_pymethod(PG_MSG_TYPE type, PyObject *pyfunc) {
                self->SetEventCallback(type, PG_MessageObject_PythonCallBack, 
(void *) pyfunc);
                Py_INCREF(pyfunc);
        }
}

#endif

Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/bindings/python/Attic/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -C2 -r1.1.1.1 -r1.1.1.1.6.1
*** Makefile.am 15 Apr 2002 13:22:16 -0000      1.1.1.1
--- Makefile.am 1 Nov 2002 15:00:59 -0000       1.1.1.1.6.1
***************
*** 35,40 ****
        python -OO -c "import paragui" 2>/dev/null || echo -n
  
! paraguic_wrap.cpp: $(PGHEADERS)
!       $(SWIGCOMPILE) -o paraguic_wrap.cpp $(top_srcdir)/include/paragui.h
  
  paraguic_wrap.o: paraguic_wrap.cpp
--- 35,40 ----
        python -OO -c "import paragui" 2>/dev/null || echo -n
  
! paraguic_wrap.cpp: $(PGHEADERS) python.h
!       $(SWIGCOMPILE) -I$(top_srcdir)/include -o paraguic_wrap.cpp python.h
  
  paraguic_wrap.o: paraguic_wrap.cpp
***************
*** 57,59 ****
  
  EXTRA_DIST = \
!       swigcommon.h
--- 57,60 ----
  
  EXTRA_DIST = \
!       swigcommon.h \
!       python.h





reply via email to

[Prev in Thread] Current Thread [Next in Thread]