Exemple #1
0
static int pyShaderConst___init__(pyShaderConst* self, PyObject* args, PyObject* kwds) {
    float sc[4];
    PyObject* init = NULL;

    if (PyArg_ParseTuple(args, "ffff", &sc[0], &sc[1], &sc[2], &sc[3])) {
        self->fThis->fArray[0] = sc[0];
        self->fThis->fArray[1] = sc[1];
        self->fThis->fArray[2] = sc[2];
        self->fThis->fArray[3] = sc[3];
    } else if (PyErr_Clear(), PyArg_ParseTuple(args, "|O", &init)) {
        if (init == NULL)
            return 0;
        if (pyShaderConst_Check(init)) {
            self->fThis->fArray[0] = ((pyShaderConst*)init)->fThis->fArray[0];
            self->fThis->fArray[1] = ((pyShaderConst*)init)->fThis->fArray[1];
            self->fThis->fArray[2] = ((pyShaderConst*)init)->fThis->fArray[2];
            self->fThis->fArray[3] = ((pyShaderConst*)init)->fThis->fArray[3];
        } else {
            return -1;
        }
    } else {
        return -1;
    }

    return 0;
}
Exemple #2
0
static int pyShader_setConsts(pyShader* self, PyObject* value, void*) {
    if (value == NULL || value == Py_None) {
        self->fThis->setConsts(std::vector<plShaderConst>());
        return 0;
    } else if (PyList_Check(value)) {
        size_t count = PyList_Size(value);
        std::vector<plShaderConst> constList(count);
        for (size_t i=0; i<count; i++) {
            if (!pyShaderConst_Check(PyList_GetItem(value, i))) {
                PyErr_SetString(PyExc_TypeError, "consts should be a list of strings");
                return -1;
            }
            constList[i] = *((pyShaderConst*)(PyList_GetItem(value, i)))->fThis;
        }
        self->fThis->setConsts(constList);
        return 0;
    } else {
        PyErr_SetString(PyExc_TypeError, "consts should be a list of strings");
        return -1;
    }
}