internal
| 6437 | |
| 6438 | // internal |
| 6439 | int asCScriptEngine::DetermineNameAndNamespace(const char *in_name, asSNameSpace *implicitNs, asCString &out_name, asSNameSpace *&out_ns) const |
| 6440 | { |
| 6441 | if( in_name == 0 ) |
| 6442 | return asINVALID_ARG; |
| 6443 | |
| 6444 | asCString name = in_name; |
| 6445 | asCString scope; |
| 6446 | asSNameSpace *ns = implicitNs; |
| 6447 | |
| 6448 | // Check if the given name contains a scope |
| 6449 | int pos = name.FindLast("::"); |
| 6450 | if( pos >= 0 ) |
| 6451 | { |
| 6452 | scope = name.SubString(0, pos); |
| 6453 | name = name.SubString(pos+2); |
| 6454 | if( pos == 0 ) |
| 6455 | { |
| 6456 | // The scope is '::' so the search must start in the global namespace |
| 6457 | ns = nameSpaces[0]; |
| 6458 | } |
| 6459 | else if( scope.SubString(0, 2) == "::" ) |
| 6460 | { |
| 6461 | // The scope starts with '::' so the given scope is fully qualified |
| 6462 | ns = FindNameSpace(scope.SubString(2).AddressOf()); |
| 6463 | } |
| 6464 | else |
| 6465 | { |
| 6466 | // The scope doesn't start with '::' so it is relative to the current namespace |
| 6467 | if( implicitNs->name == "" ) |
| 6468 | ns = FindNameSpace(scope.AddressOf()); |
| 6469 | else |
| 6470 | ns = FindNameSpace((implicitNs->name + "::" + scope).AddressOf()); |
| 6471 | } |
| 6472 | } |
| 6473 | |
| 6474 | out_name = name; |
| 6475 | out_ns = ns; |
| 6476 | |
| 6477 | return 0; |
| 6478 | } |
| 6479 | |
| 6480 | |
| 6481 | // interface |
no test coverage detected