* Fixed bug in BPY_interface.c (exppython):

Found that syntax errors in scripts were giving SIGSEGV, my mistake.
* Added new helper type: rgbTuple.
    This is used to represent and deal with rgb color triplets in modules
    like Material and Lamp.  Updated Lamp module to use it.
This commit is contained in:
2003-05-23 04:34:55 +00:00
parent 0773536829
commit 9edf1c08a6
8 changed files with 513 additions and 33 deletions

View File

@@ -102,16 +102,12 @@ static PyObject *new_const(void)
constant = (C_constant *)PyObject_NEW(C_constant, &constant_Type);
if (constant == NULL)
{
return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create constant object"));
}
if ((constant->dict = PyDict_New()) == NULL)
{
return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create constant object's dictionary"));
}
return (PyObject *)constant;
}
@@ -122,9 +118,7 @@ static PyObject *new_const(void)
void constant_insert(C_constant *self, char *key, PyObject *value)
{
if (self->dict)
{
PyDict_SetItemString(self->dict, key, value);
}
}
/*****************************************************************************/
@@ -144,23 +138,21 @@ static void constantDeAlloc (C_constant *self)
/* the function that accesses C_constant member variables and */
/* methods. */
/*****************************************************************************/
static PyObject* constantGetAttr (C_constant *self, char *name)
static PyObject *constantGetAttr (C_constant *self, char *name)
{
if (self->dict)
{
PyObject *v;
if (!strcmp(name, "__members__"))
{
return PyDict_Keys(self->dict);
}
v = PyDict_GetItemString(self->dict, name);
if (v)
{
if (v) {
Py_INCREF(v); /* was a borrowed ref */
return v;
}
return (PythonReturnErrorObject (PyExc_AttributeError,
"attribute not found"));
}
@@ -180,11 +172,10 @@ static int constantLength(C_constant *self)
static PyObject *constantSubscript(C_constant *self, PyObject *key)
{
if (self->dict)
{
if (self->dict) {
PyObject *v = PyDict_GetItem(self->dict, key);
if (v)
{
if (v) {
Py_INCREF(v);
return v;
}