| 6259 | } |
| 6260 | |
| 6261 | asSNameSpace *asCBuilder::GetNameSpaceByString(const asCString &nsName, asSNameSpace *implicitNs, asCScriptNode *errNode, asCScriptCode *script, asCTypeInfo **scopeType, bool isRequired) |
| 6262 | { |
| 6263 | if( scopeType ) |
| 6264 | *scopeType = 0; |
| 6265 | |
| 6266 | asSNameSpace *ns = implicitNs; |
| 6267 | if( nsName == "::" ) |
| 6268 | ns = engine->nameSpaces[0]; |
| 6269 | else if( nsName != "" ) |
| 6270 | { |
| 6271 | ns = engine->FindNameSpace(nsName.AddressOf()); |
| 6272 | if (ns == 0 && scopeType) |
| 6273 | { |
| 6274 | asCString typeName; |
| 6275 | asCString searchNs; |
| 6276 | |
| 6277 | // Split the scope with at the inner most :: |
| 6278 | int pos = nsName.FindLast("::"); |
| 6279 | bool recursive = false; |
| 6280 | if (pos >= 0) |
| 6281 | { |
| 6282 | // Fully qualified namespace |
| 6283 | typeName = nsName.SubString(pos + 2); |
| 6284 | searchNs = nsName.SubString(0, pos); |
| 6285 | } |
| 6286 | else |
| 6287 | { |
| 6288 | // Partially qualified, use the implicit namespace and then search recursively for the type |
| 6289 | typeName = nsName; |
| 6290 | searchNs = implicitNs->name; |
| 6291 | recursive = true; |
| 6292 | } |
| 6293 | |
| 6294 | asSNameSpace *nsTmp = searchNs == "::" ? engine->nameSpaces[0] : engine->FindNameSpace(searchNs.AddressOf()); |
| 6295 | asCTypeInfo *ti = 0; |
| 6296 | while( !ti && nsTmp ) |
| 6297 | { |
| 6298 | // Check if the typeName is an existing type in the namespace |
| 6299 | ti = GetType(typeName.AddressOf(), nsTmp, 0); |
| 6300 | if (ti) |
| 6301 | { |
| 6302 | // The informed scope is not a namespace, but it does match a type |
| 6303 | *scopeType = ti; |
| 6304 | return 0; |
| 6305 | } |
| 6306 | nsTmp = recursive ? engine->GetParentNameSpace(nsTmp) : 0; |
| 6307 | } |
| 6308 | } |
| 6309 | |
| 6310 | if (ns == 0 && isRequired) |
| 6311 | { |
| 6312 | asCString msg; |
| 6313 | msg.Format(TXT_NAMESPACE_s_DOESNT_EXIST, nsName.AddressOf()); |
| 6314 | WriteError(msg, script, errNode); |
| 6315 | } |
| 6316 | } |
| 6317 | |
| 6318 | return ns; |
nothing calls this directly
no test coverage detected