IObject* newInstance( const std::string& fullName ) { IType* type = getType( fullName ); assert( type ); IReflector* reflector = type->getReflector(); assert( reflector ); return reflector->newInstance(); }
void Loader::onAnnotation( const location& loc, const std::string& name, bool hasData ) { std::string componentName; componentName.reserve( name.size() + 10 ); componentName.append( name ); componentName.append( "Annotation" ); IType* type = resolveType( loc, componentName ); if( !type ) { PUSH_ERROR( loc, "error loading annotation type '" << componentName << "'" ); return; } if( type->getKind() != TK_COMPONENT ) { PUSH_ERROR( loc, "annotation type '" << componentName << "' is not a component" ); return; } try { RefPtr<IAnnotation> annotation; if( hasData ) { RefPtr<IObject> object( type->getReflector()->newInstance() ); annotation = getAnnotationFrom( object.get() ); } else { annotation = getDefaultAnnotationInstance( type ); } if( _annotations.empty() ) _annotations.push_back( AnnotationRecord() ); _annotations.back().annotations.push_back( annotation.get() ); } catch( Exception& e ) { pushError( loc, e.getMessage() ); } }