diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2005-03-09 04:58:11 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2005-03-09 04:58:11 +0000 |
commit | e854889b99b9e515dc69d237b1031b5705e83b60 (patch) | |
tree | 6b525184d850f15012e316ca51cf0a11563261ea /externals/grill/py/source/pybuffer.h | |
parent | 9ccbbc943fa25426542b4fb6d6bc280c3281001b (diff) |
fixes for detached operation and single-threaded version
use lock count instead of message queuing to avoid py->py messaging deadlock
support for buffer objects (preliminary)
updated build system
little restructuring
fixes for single-threaded compilation
added support for numarray
svn path=/trunk/; revision=2610
Diffstat (limited to 'externals/grill/py/source/pybuffer.h')
-rw-r--r-- | externals/grill/py/source/pybuffer.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/externals/grill/py/source/pybuffer.h b/externals/grill/py/source/pybuffer.h new file mode 100644 index 00000000..1d59dd95 --- /dev/null +++ b/externals/grill/py/source/pybuffer.h @@ -0,0 +1,79 @@ +/*
+
+py/pyext - python script object for PD and Max/MSP
+
+Copyright (c)2002-2005 Thomas Grill (gr@grrrr.org)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
+#ifndef __PYBUFFER_H
+#define __PYBUFFER_H
+
+#include <flext.h>
+
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 500)
+#error You need at least flext version 0.5.0
+#endif
+
+#if FLEXT_OS == FLEXT_OS_MAC
+#include <Python/Python.h>
+#else
+#include <Python.h>
+#endif
+
+
+#ifdef _MSC_VER
+ #ifdef PY_EXPORTS
+ #define PY_EXPORT __declspec(dllexport)
+ #else
+ #define PY_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define PY_EXPORT
+#endif
+
+typedef struct {
+ PyObject_HEAD
+ /* Type-specific fields go here. */
+ const t_symbol *sym;
+ flext::buffer *buf;
+ flext::buffer::lock_t lock;
+ bool dirty;
+} pySamplebuffer;
+
+PY_EXPORT extern PyTypeObject pySamplebuffer_Type;
+
+#define pySamplebuffer_Check(op) PyObject_TypeCheck(op, &pySamplebuffer_Type) +#define pySamplebuffer_CheckExact(op) ((op)->ob_type == &PySamplebuffer_Type) + + +PY_EXPORT PyObject *pySamplebuffer_FromSymbol(const t_symbol *sym); + +inline PyObject *pySamplebuffer_FromString(const char *str) +{ + return pySamplebuffer_FromSymbol(flext::MakeSymbol(str)); +} + +inline PyObject *pySamplebuffer_FromString(PyObject *str) +{ + return pySamplebuffer_FromString(PyString_AsString(str)); +} + +inline const t_symbol *pySamplebuffer_AS_SYMBOL(PyObject *op)
+{
+ return ((pySamplebuffer *)op)->sym;
+}
+
+inline const t_symbol *pySamplebuffer_AsSymbol(PyObject *op)
+{
+ return pySamplebuffer_Check(op)?pySamplebuffer_AS_SYMBOL(op):NULL;
+}
+
+inline const char *pySamplebuffer_AS_STRING(PyObject *op)
+{
+ return flext::GetString(pySamplebuffer_AS_SYMBOL(op));
+}
+
+#endif
|