Esempio n. 1
0
int
PyGraviTAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    // Create a tuple to contain the arguments since all of the Set
    // functions expect a tuple.
    PyObject *tuple = PyTuple_New(1);
    PyTuple_SET_ITEM(tuple, 0, args);
    Py_INCREF(args);
    PyObject *obj = NULL;

    if(strcmp(name, "DiffColor") == 0)
        obj = GraviTAttributes_SetDiffColor(self, tuple);
    else if(strcmp(name, "SpecColor") == 0)
        obj = GraviTAttributes_SetSpecColor(self, tuple);
    else if(strcmp(name, "MaxReflections") == 0)
        obj = GraviTAttributes_SetMaxReflections(self, tuple);
    else if(strcmp(name, "Material") == 0)
        obj = GraviTAttributes_SetMaterial(self, tuple);
    else if(strcmp(name, "ScheduleType") == 0)
        obj = GraviTAttributes_SetScheduleType(self, tuple);
    else if(strcmp(name, "Samples") == 0)
        obj = GraviTAttributes_SetSamples(self, tuple);
    else if(strcmp(name, "JitterSize") == 0)
        obj = GraviTAttributes_SetJitterSize(self, tuple);
    else if(strcmp(name, "EnableShadows") == 0)
        obj = GraviTAttributes_SetEnableShadows(self, tuple);
    else if(strcmp(name, "LightBoost") == 0)
        obj = GraviTAttributes_SetLightBoost(self, tuple);
    else if(strcmp(name, "LightDistance") == 0)
        obj = GraviTAttributes_SetLightDistance(self, tuple);

    if(obj != NULL)
        Py_DECREF(obj);

    Py_DECREF(tuple);
    if( obj == NULL)
        PyErr_Format(PyExc_RuntimeError, "Unable to set unknown attribute: '%s'", name);
    return (obj != NULL) ? 0 : -1;
}
int
PyGraviTAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    // Create a tuple to contain the arguments since all of the Set
    // functions expect a tuple.
    PyObject *tuple = PyTuple_New(1);
    PyTuple_SET_ITEM(tuple, 0, args);
    Py_INCREF(args);
    PyObject *obj = NULL;

    if(strcmp(name, "Color") == 0)
        obj = GraviTAttributes_SetColor(self, tuple);
    else if(strcmp(name, "MaxReflections") == 0)
        obj = GraviTAttributes_SetMaxReflections(self, tuple);

    if(obj != NULL)
        Py_DECREF(obj);

    Py_DECREF(tuple);
    if( obj == NULL)
        PyErr_Format(PyExc_RuntimeError, "Unable to set unknown attribute: '%s'", name);
    return (obj != NULL) ? 0 : -1;
}