示例#1
0
void Loader::onAnnotationData( const location& loc, const std::string& fieldName, const Any& value )
{
	IAnnotation* annotation = _annotations.back().annotations.back().get();
	try
	{
		IInterface* itf = annotation->getInterface();
		IMember* m = itf->getMember( fieldName );
		if( !m || m->getKind() != MK_FIELD )
		{
			PUSH_ERROR( loc, "annotation type '" << itf->getFullName() <<
							"' has no field named '" << fieldName << "'" );
			return;
		}

		ICompositeType* ct = m->getOwner();
		IReflector* reflector = ct->getReflector();
		if( !reflector )
		{
			PUSH_ERROR( loc, "annotation type '" << ct->getFullName() << "' has no reflector" );
			return;
		}

		reflector->setField( annotation, static_cast<IField*>( m ), value );
	}
	catch( Exception& e )
	{
		pushError( loc, e.getMessage() );
		PUSH_ERROR( loc, "error setting annotation field '" << fieldName << "'" );
	}
}