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 << "'" ); } }
int CstBufferRepository::gatherFromAnnotation(ICstBuffer** &pp, const char *annotationName, const char* str, int *ival, float *fval) { memset(cbArray, 0, 100*sizeof(ICstBuffer*)); pp = (ICstBuffer**)cbArray; int n = 0; if(!annotationName) return 0; ItemMap::iterator i2 = m_Items.begin(); while(i2 != m_Items.end()) { if(i2->second.p) { IAnnotation* pAnnot = i2->second.p->annotations(); if((str && findMatchingAnnotation(pAnnot, annotationName, str)) ||(ival && (pAnnot->getAnnotationInt(annotationName)==ival[0])) ||(fval && (pAnnot->getAnnotationFloat(annotationName)==fval[0]))) { if(n >= 100) { nvFX::printf(">>Error : gathering of uniforms exceeded 100 !"); return n; } cbArray[n++] = i2->second.p; } } ++i2; } return n; }
int ShaderModuleRepository::gatherFromAnnotation(IShader** &ppShaders, const char *annotationName, const char* str, int *ival, float *fval) { memset(shdArray, 0, 100*sizeof(IShader*)); ppShaders = (IShader**)shdArray; int nshaders = 0; if(!annotationName) return 0; ShdMap::iterator i2 = m_shaders.begin(); while(i2 != m_shaders.end()) { Shader* pShd = static_cast<Shader*>(i2->second.p); if(pShd) { IAnnotation* pAnnot = pShd->annotations(); if((str && findMatchingAnnotation(pAnnot, annotationName, str)) ||(ival && (pAnnot->getAnnotationInt(annotationName)==ival[0])) ||(fval && (pAnnot->getAnnotationFloat(annotationName)==fval[0]))) { if(nshaders >= 100) { nvFX::printf(">>Error : gathering of shader exceeded 100 !"); return nshaders; } shdArray[nshaders++] = pShd; } } ++i2; } // warning : means that we cannot put in the same list some global shaders from here with // local shader previously found in this method... if(nshaders == 0) { // Try in the global repository return static_cast<ShaderModuleRepository*>(getShaderModuleRepositorySingleton())->gatherFromAnnotation(ppShaders, annotationName, str, ival, fval); } return nshaders; }
int ResourceRepository::gatherFromAnnotation(IResource** &pp, const char *annotationName, const char* str, int *ival, float *fval) { memset(resArray, 0, 100*sizeof(IShader*)); pp = (IResource**)resArray; int n = 0; if(!annotationName) return 0; ResourceMap::iterator i2 = m_resources.begin(); while(i2 != m_resources.end()) { if(i2->second.p) { IAnnotation* pAnnot = i2->second.p->annotations(); if((str && findMatchingAnnotation(pAnnot, annotationName, str)) ||(ival && (pAnnot->getAnnotationInt(annotationName)==ival[0])) ||(fval && (pAnnot->getAnnotationFloat(annotationName)==fval[0]))) { if(n >= 100) { nvFX::printf(">>Error : gathering of resources exceeded 100 !"); return n; } resArray[n++] = i2->second.p; } } ++i2; } // warning : means that we cannot put in the same list some global shaders from here with // local shader previously found in this method... if(n == 0) { // Try in the global repository return static_cast<ResourceRepository*>(getResourceRepositorySingleton())->gatherFromAnnotation(pp, annotationName, str, ival, fval); } return n; }