bool DefaultConverter::toScriptType(const Variant& inVariant, PyScript::ScriptObject& outObject, void* userData) /* override */ { if (inVariant.typeIs<Variant::traits<ObjectHandle>::storage_type>()) { ObjectHandle handle = inVariant.value<ObjectHandle>(); auto contents = handle.getBase<ReflectedPython::DefinedInstance>(); if (contents == nullptr) { return false; } outObject = contents->pythonObject(); return true; } return false; }
Variant Property::Implementation::getValue(const ObjectHandle& handle) { #if defined(_DEBUG) auto pInstance = handle.getBase<DefinedInstance>(); assert(pInstance != nullptr); assert(pInstance->pythonObject().compareTo(pythonObject_, PyScript::ScriptErrorPrint()) == 0); #endif // defined( _DEBUG ) PyScript::ScriptErrorPrint errorHandler; // Get the attribute PyScript::ScriptObject attribute = pythonObject_.getAttribute(key_.c_str(), errorHandler); auto pTypeConverters = get<PythonType::Converters>(); assert(pTypeConverters != nullptr); Variant value; const bool success = pTypeConverters->toVariant(attribute, value, handle, key_); assert(success); return value; }