Пример #1
0
	bool next()
	{
		if (iterator_.get() == nullptr)
		{
			current_.reset();
			return false;
		}

		while (PyScript::ScriptObject key = iterator_.next())
		{
			PyScript::ScriptString str = key.str(PyScript::ScriptErrorPrint());
			const char* name = str.c_str();

			// Some properties from dir are not accessible as attributes
			// e.g. __abstractmethods__ is a descriptor
			if (!object_.hasAttribute(name))
			{
				continue;
			}

			auto meta = extractMetaData(name, metaDataDict_);
			if (current_ == nullptr)
			{
				current_ = std::make_shared<ReflectedPython::Property>(context_, name, object_, meta);
			}
			else
			{
				auto property = static_cast<ReflectedPython::Property*>(current_.get());
				property->updatePropertyData(name, object_, meta);
			}
			return true;
		}
		current_.reset();
		return false;
	}
Пример #2
0
	bool next()
	{
		current_.reset();

		if (iterator_.get() == nullptr)
		{
			return false;
		}

		while (PyScript::ScriptObject key = iterator_.next())
		{
			PyScript::ScriptString str = key.str( PyScript::ScriptErrorPrint() );
			const char * name = str.c_str();

			// Some properties from dir are not accessible as attributes
			// e.g. __abstractmethods__ is a descriptor
			if (!object_.hasAttribute( name ))
			{
				continue;
			}

			auto meta = extractMetaData( name, metaDataDict_ );
			IBasePropertyPtr property = std::make_shared< ReflectedPython::Property >(
				context_, name, object_ );

			current_ = meta != nullptr ?
				std::make_shared< BasePropertyWithMetaData >( property, meta ) : property;
			return true;
		}

		return false;
	}