static int wrapper_set(pyWrapperObject* self, char* name, PyObject* value) {
int wrapper_set(pyWrapperObject* self, char* name, PyObject* value) {
static int wrapper_set(pyWrapperObject* self, char* name, PyObject* value) {	QObject *wrapped = self->wrapped;	// Error checking for deleted objects	if (!wrapped) {		PyErr_Format(PyExc_AttributeError, "Unable to retrieve attribute %s since the wrapped object has already been deleted.", name);		return 0;	}	// Check if the wrapped object has a property with the given name and return it	const QMetaObject *meta = wrapped->metaObject();	int propertyIndex = meta->indexOfProperty(name);		// Found a property, now return it	if (propertyIndex != -1) {		// Get the property information		QMetaProperty property = meta->property(propertyIndex);		// Check if the property is writeable		if (property.isWritable()) {			QVariant variant;					int type = QMetaType::type(property.typeName());			if (type == QMetaType::Void) {				type = QVariant::nameToType(property.typeName());			}			switch (type) {				case QVariant::String:					variant.setValue<QString>(fromPythonToString(value));					break;				case QVariant::Int:				case QMetaType::Short:				case QMetaType::Char:					variant.setValue<int>(fromPythonToInt(value));					break;				case QVariant::UInt:				case QMetaType::UShort:				case QMetaType::UChar:					variant.setValue<uint>(fromPythonToUInt(value));					break;				case QVariant::Bool:					variant.setValue<bool>(PyObject_IsTrue(value) != 0);					break;				default:					if (type >= QMetaType::User) {						// This kind of handling sucks!						// But there is no other way of handling it other than upcasting to the respective class in this case												if (type == (int)QMetaType::type("cMobile*")) {							variant.setValue<cMobile*>(dynamic_cast<cMobile*>(getWrappedObject(value)));						} else if (type == (int)QMetaType::type("cDynamicItem*")) {							variant.setValue<cDynamicItem*>(dynamic_cast<cDynamicItem*>(getWrappedObject(value)));						} else {							variant.setValue<QObject*>(getWrappedObject(value));						}											} else {						PyErr_Format(PyExc_AttributeError, "Unsupported property type: %d (%s)", (int)property.type(), name);						return -1;					}								}			// Read the property from our wrapped object			if (property.write(wrapped, variant)) {				return 0; // Success			}		}		PyErr_SetString(PyExc_AttributeError, name);		return -1;	}	PyErr_SetString(PyExc_AttributeError, name);	return -1;}