aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pyext.h
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-10-22 23:16:30 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-10-22 23:16:30 +0000
commitc2645dc4003b1391aba9b387a79a66cff1e63d3e (patch)
tree1ea6dccb8011a8ff64efb7c2ecf9a22caad860b3 /externals/grill/py/source/pyext.h
parentd62e56f4df9594f72ce501f5e19c974fd18e7295 (diff)
This commit was generated by cvs2svn to compensate for changes in r189,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=190
Diffstat (limited to 'externals/grill/py/source/pyext.h')
-rw-r--r--externals/grill/py/source/pyext.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/externals/grill/py/source/pyext.h b/externals/grill/py/source/pyext.h
new file mode 100644
index 00000000..2aba0e8e
--- /dev/null
+++ b/externals/grill/py/source/pyext.h
@@ -0,0 +1,127 @@
+/*
+
+py/pyext - python external object for PD and MaxMSP
+
+Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
+#ifndef __PYEXT_H
+#define __PYEXT_H
+
+#include "main.h"
+
+class pyext:
+ public py
+{
+ FLEXT_HEADER_S(pyext,py,setup)
+
+public:
+ pyext(I argc,t_atom *argv);
+ ~pyext();
+
+ static PyObject *pyext__doc__(PyObject *,PyObject *args);
+ static PyObject *pyext__init__(PyObject *,PyObject *args);
+ static PyObject *pyext__del__(PyObject *,PyObject *args);
+
+ static PyObject *pyext_outlet(PyObject *,PyObject *args);
+ static PyObject *pyext_tocanvas(PyObject *,PyObject *args);
+
+ static PyObject *pyext_setattr(PyObject *,PyObject *args);
+ static PyObject *pyext_getattr(PyObject *,PyObject *args);
+
+ static PyObject *pyext_detach(PyObject *,PyObject *args);
+ static PyObject *pyext_stop(PyObject *,PyObject *args);
+
+ I Inlets() const { return inlets; }
+ I Outlets() const { return outlets; }
+
+protected:
+ BL m_method_(I n,const t_symbol *s,I argc,t_atom *argv);
+
+ BL work(I n,const t_symbol *s,I argc,t_atom *argv);
+
+ V m_reload();
+ V m_reload_(I argc,t_atom *argv);
+ V m_doc_();
+ virtual V m_help();
+
+ const t_symbol *methname;
+ PyObject *pyobj;
+ I inlets,outlets;
+
+private:
+ static V setup(t_class *);
+
+ static pyext *GetThis(PyObject *self);
+ V ClearBinding();
+ BL SetClssMeth(); //I argc,t_atom *argv);
+
+ AtomList args;
+
+ virtual V Reload();
+
+ static I pyextref;
+ static PyObject *class_obj,*class_dict;
+ static PyMethodDef attr_tbl[],meth_tbl[];
+ static const C *pyext_doc;
+
+ // -------- bound stuff ------------------
+
+ static t_class *px_class;
+
+ friend class py_proxy;
+
+ class py_proxy // no virtual table!
+ {
+ public:
+ t_object obj; // MUST reside at memory offset 0
+ PyObject *self,*func;
+ t_symbol *name;
+
+ py_proxy *nxt;
+
+ void init(t_symbol *n,PyObject *s,PyObject *f) { name = n,self = s,func = f,nxt = NULL; }
+// bool cmp(PyObject *s,PyObject *f) const { return self == s && func == f; }
+// void init(PyObject *s,char *f) { self = s,func = f,nxt = NULL; }
+// bool cmp(PyObject *s,char *f) const { return self == s && func == f; }
+ static void px_method(py_proxy *c,const t_symbol *s,int argc,t_atom *argv);
+ };
+ static py_proxy *px_head,*px_tail;
+
+ static PyObject *pyext_bind(PyObject *,PyObject *args);
+ static PyObject *pyext_unbind(PyObject *,PyObject *args);
+
+ // ---------------------------
+
+ PyObject *call(const C *meth,I inlet,const t_symbol *s,I argc,t_atom *argv);
+
+ V work_wrapper(void *data);
+ BL callwork(I n,const t_symbol *s,I argc,t_atom *argv);
+
+ class work_data:
+ public flext::AtomAnything
+ {
+ public:
+ work_data(I _n,const t_symbol *_s,I _argc,t_atom *_argv): n(_n),AtomAnything(_s,_argc,_argv) {}
+ I n;
+ };
+
+#ifdef FLEXT_THREADS
+ FLEXT_THREAD_X(work_wrapper)
+#else
+ FLEXT_CALLBACK_X(work_wrapper)
+#endif
+
+ PyThreadState *pythr;
+
+private:
+ FLEXT_CALLBACK(m_reload)
+ FLEXT_CALLBACK_V(m_reload_)
+ FLEXT_CALLBACK(m_doc_)
+};
+
+
+#endif \ No newline at end of file