MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / makeHandleType

Method makeHandleType

src/ast/ast_module.cpp:1179–1227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1177 }
1178
1179 TypeDeclPtr ModuleLibrary::makeHandleType ( const string & name ) const {
1180 auto t = new TypeDecl(Type::tHandle);
1181 auto handles = findAnnotation(name,nullptr);
1182#if DAS_ALLOW_ANNOTATION_LOOKUP
1183 bool need_require = false;
1184 if ( handles.size()==0 ) {
1185 handles = findStaticAnnotation(name);
1186 need_require = true;
1187 }
1188#endif
1189 if ( handles.size()==1 ) {
1190#if DAS_ALLOW_ANNOTATION_LOOKUP
1191 if ( need_require ) {
1192 ModuleLibrary * THAT = (ModuleLibrary *) this;
1193 THAT->addModule(handles.back()->module);
1194 }
1195#endif
1196 if ( handles.back()->rtti_isHandledTypeAnnotation() ) {
1197 t->annotation = static_cast<TypeAnnotation*>(handles.back());
1198 } else {
1199 DAS_FATAL_ERROR("makeHandleType(%s) failed, not a handle type\n", name.c_str());
1200 return nullptr;
1201 }
1202 } else if ( handles.size()==0 ) {
1203
1204#if DAS_ALLOW_ANNOTATION_LOOKUP
1205 DAS_FATAL_LOG("NEED_MODULE(Module_<name>) with %s needs to be before this module binding.\n", name.c_str());
1206 DAS_FATAL_LOG("Explicit lib.addModule(require(\"<name>\")); would be preferable.\n");
1207#else
1208 DAS_FATAL_LOG("In the bound module missing is lib.addModule(require(\"module-name\")) which contains module-name::%s\n", name.c_str());
1209 Module::foreach([&](Module * mod){
1210 if ( mod->findAnnotation(name) ) {
1211 DAS_FATAL_LOG("\tLikely candidate is lib.addModule(require(\"%s\"));\n", mod->name.c_str());
1212 }
1213 return true;
1214 });
1215#endif
1216 DAS_FATAL_ERROR("makeHandleType(%s) failed, missing annotation\n", name.c_str());
1217 return nullptr;
1218 } else {
1219
1220 for ( auto & h : handles ) {
1221 DAS_FATAL_LOG("\tduplicate annotation%s::%s\n", h->name.c_str(), name.c_str());
1222 }
1223 DAS_FATAL_ERROR("makeHandleType(%s) failed, duplicate annotation\n", name.c_str());
1224 return nullptr;
1225 }
1226 return t;
1227 }
1228
1229 TypeDeclPtr ModuleLibrary::makeEnumType ( const string & name ) const {
1230 auto enums = findEnum(name,nullptr);

Callers 1

makeHandleTypeFunction · 0.80

Calls 6

findAnnotationFunction · 0.85
sizeMethod · 0.45
addModuleMethod · 0.45
c_strMethod · 0.45
findAnnotationMethod · 0.45

Tested by

no test coverage detected