From 53c16e06983f9b03464f41b8c0ed3206382c5538 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sun, 9 Jan 2005 04:59:30 +0000 Subject: support for Python threads, at last small fixes merged in 20041229-newdetach branch. renamed locking functions svn path=/trunk/; revision=2483 --- externals/grill/py/source/register.cpp | 37 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'externals/grill/py/source/register.cpp') diff --git a/externals/grill/py/source/register.cpp b/externals/grill/py/source/register.cpp index c0ca4675..ae273955 100644 --- a/externals/grill/py/source/register.cpp +++ b/externals/grill/py/source/register.cpp @@ -2,7 +2,7 @@ py/pyext - python external object for PD and MaxMSP -Copyright (c) 2002-2004 Thomas Grill (gr@grrrr.org) +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. @@ -11,39 +11,37 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "main.h" -V py::Register(const C *regnm) +void py::Register(const char *regnm) { if(module) { // add this to module registry - PyObject *reg = PyDict_GetItemString(dict,(C *)regnm); // borrowed!!! + PyObject *reg = PyDict_GetItemString(dict,(char *)regnm); // borrowed!!! PyObject *add = Py_BuildValue("[i]",(long)this); if(!reg || !PyList_Check(reg)) { - if(PyDict_SetItemString(dict,(C *)regnm,add)) { + if(PyDict_SetItemString(dict,(char *)regnm,add)) { post("%s - Could not set registry",thisName()); } - // Py_XDECREF(reg); } else { PySequence_InPlaceConcat(reg,add); } } - } -V py::Unregister(const C *regnm) +void py::Unregister(const char *regnm) { if(module) { // remove this from module registry - PyObject *reg = PyDict_GetItemString(dict,(C *)regnm); // borrowed!!! + PyObject *reg = PyDict_GetItemString(dict,(char *)regnm); // borrowed!!! PyObject *add = Py_BuildValue("i",(int)this); if(!reg || !PySequence_Check(reg)) - post("%s - Registry not found!?",thisName()); + post("%s - Internal error: Registry not found!?",thisName()); else { - I ix = PySequence_Index(reg,add); + int ix = PySequence_Index(reg,add); if(ix < 0) { - post("%s - This object not found in registry?!",thisName()); + post("%s - Internal error: object not found in registry?!",thisName()); } else { PySequence_DelItem(reg,ix); @@ -51,24 +49,23 @@ V py::Unregister(const C *regnm) } Py_DECREF(add); } - } -V py::Reregister(const C *regnm) +void py::Reregister(const char *regnm) { if(module) { // remove this from module registry - PyObject *reg = PyDict_GetItemString(dict,(C *)regnm); // borrowed!!! + PyObject *reg = PyDict_GetItemString(dict,(char *)regnm); // borrowed!!! if(!reg || !PySequence_Check(reg)) - post("%s - Registry not found!?",thisName()); + post("%s - Internal error: Registry not found!?",thisName()); else { - I cnt = PySequence_Size(reg); - for(I i = 0; i < cnt; ++i) { + int cnt = PySequence_Size(reg); + for(int i = 0; i < cnt; ++i) { PyObject *it = PySequence_GetItem(reg,i); // new reference if(!it || !PyInt_Check(it)) { - post("%s - Corrupt registry?!",thisName()); + post("%s - Internal error: Corrupt registry?!",thisName()); } else { py *th = (py *)PyInt_AsLong(it); @@ -81,8 +78,4 @@ V py::Reregister(const C *regnm) } } } - } - - - -- cgit v1.2.1