static int pyAgeInfoStruct_setAgeInstanceName(pyAgeInfoStruct* self, PyObject* value, void*) { if (value == NULL || !PyAnyStr_Check(value)) { PyErr_SetString(PyExc_TypeError, "ageInstanceName should be a string"); return -1; } self->fThis->setAgeInstanceName(PyStr_To_PlStr(value)); return -1; }
static int pyAGChannel_setName(pyAGChannel* self, PyObject* value, void*) { if (value == NULL || !PyAnyStr_Check(value)) { PyErr_SetString(PyExc_TypeError, "name should be a string"); return -1; } self->fThis->setName(PyStr_To_PlStr(value)); return 0; }
static PyObject* pyDynamicCamMap_addVisRegionName(pyDynamicCamMap* self, PyObject* args) { PyObject* name; if (!(PyArg_ParseTuple(args, "O", &name) && PyAnyStr_Check(name))) { PyErr_SetString(PyExc_TypeError, "addVisRegionName expects a string"); return NULL; } self->fThis->addVisRegionName(PyStr_To_PlStr(name)); Py_INCREF(Py_None); return Py_None; }
static int pyClothingItem_setItemName(pyClothingItem* self, PyObject* value, void* closure) { if (value == NULL) { self->fThis->setItemName(""); } else { if (!PyAnyStr_Check(value)) { PyErr_SetString(PyExc_TypeError, "itemName must be a string"); return -1; } self->fThis->setItemName(PyStr_To_PlStr(value)); } return 0; }
static int pyOneShotMod_setAnimName(pyOneShotMod* self, PyObject* value, void*) { if (value == NULL) { self->fThis->setAnimName(""); return 0; } if (!PyAnyStr_Check(value)) { PyErr_SetString(PyExc_TypeError, "animName should be a string"); return -1; } self->fThis->setAnimName(PyStr_To_PlStr(value)); return 0; }
static int pyPageInfo_setPage(pyPageInfo* self, PyObject* value, void*) { if (value == NULL) { self->fThis->setPage(""); } else { if (!PyAnyStr_Check(value)) { PyErr_SetString(PyExc_TypeError, "page must be a string"); return -1; } self->fThis->setPage(PyStr_To_PlStr(value)); } return 0; }
static PyObject* pyBitVector_Subscript(pyBitVector* self, PyObject* key) { if (PyAnyStr_Check(key)) { Py_INCREF(key); plString name = PyStr_To_PlStr(key); int idx = (int)self->fThis->getValue(name); Py_DECREF(key); bool v = self->fThis->get(idx); return PyBool_FromLong(v ? 1 : 0); } else if (PyInt_Check(key)) { int idx = PyInt_AsLong(key); bool v = self->fThis->get(idx); return PyBool_FromLong(v ? 1 : 0); } else { PyErr_SetString(PyExc_TypeError, "Invalid subscript"); return NULL; } }
static int pyDynamicEnvMap_setVisRegionNames(pyDynamicEnvMap* self, PyObject* value, void*) { if (value == NULL || !PySequence_Check(value)) { PyErr_SetString(PyExc_TypeError, "visRegionNames should be a sequence of strings"); return -1; } std::vector<plString> names; names.resize(PySequence_Size(value)); for (Py_ssize_t i=0; i<PySequence_Size(value); i++) { PyObject* name = PySequence_GetItem(value, i); if (PyAnyStr_Check(name)) { names[i] = PyString_To_PlasmaString(name); } else { PyErr_SetString(PyExc_TypeError, "visRegionNames should be a sequence of strings"); return -1; } } self->fThis->setVisRegionNames(names); return 0; }
static int pySynchedObject_setExcludes(pySynchedObject* self, PyObject* value, void*) { if (value == NULL) { plSynchedObject::Convert(IConvert((pyCreatable*)self))->clearExcludes(); return 0; } else if (PyList_Check(value)) { size_t count = PyList_Size(value); for (size_t i=0; i<count; i++) { if (!PyAnyStr_Check(PyList_GetItem(value, i))) { PyErr_SetString(PyExc_TypeError, "excludes should be a list of strings"); return -1; } plSynchedObject::Convert(IConvert((pyCreatable*)self))->setExclude(PyStr_To_PlStr(PyList_GetItem(value, i))); } return 0; } else { PyErr_SetString(PyExc_TypeError, "excludes should be a list of strings"); return -1; } }
static int pyBitVector_AssSubscript(pyBitVector* self, PyObject* key, PyObject* value) { if (!PyInt_Check(value)) { PyErr_SetString(PyExc_TypeError, "BitVector bits should be bools"); return -1; } bool b = (PyInt_AsLong(value) != 0); if (PyAnyStr_Check(key)) { Py_INCREF(key); plString name = PyStr_To_PlStr(key); int idx = (int)self->fThis->getValue(name); Py_DECREF(key); self->fThis->set(idx, b); return 0; } else if (PyInt_Check(key)) { int idx = PyInt_AsLong(key); self->fThis->set(idx, b); return 0; } else { PyErr_SetString(PyExc_TypeError, "Invalid subscript"); return -1; } }