scope is only informed when looking for a base class' method
| 5929 | |
| 5930 | // scope is only informed when looking for a base class' method |
| 5931 | void asCBuilder::GetObjectMethodDescriptions(const char *name, asCObjectType *objectType, asCArray<int> &methods, bool objIsConst, const asCString &scope, asCScriptNode *errNode, asCScriptCode *script) |
| 5932 | { |
| 5933 | asASSERT(objectType); |
| 5934 | |
| 5935 | if( scope != "" ) |
| 5936 | { |
| 5937 | // If searching with a scope informed, then the node and script must also be informed for potential error reporting |
| 5938 | asASSERT( errNode && script ); |
| 5939 | |
| 5940 | // If the scope contains ::identifier, then use the last identifier as the class name and the rest of it as the namespace |
| 5941 | // TODO: child funcdef: A scope can include a template type, e.g. array<ns::type> |
| 5942 | int n = scope.FindLast("::"); |
| 5943 | asCString className = n >= 0 ? scope.SubString(n+2) : scope; |
| 5944 | asCString nsName = n >= 0 ? scope.SubString(0, n) : asCString(""); |
| 5945 | |
| 5946 | // If a namespace was specifically defined, then this must be used |
| 5947 | asSNameSpace *ns = 0; |
| 5948 | if (n >= 0) |
| 5949 | { |
| 5950 | if (nsName == "") |
| 5951 | ns = engine->nameSpaces[0]; |
| 5952 | else |
| 5953 | ns = GetNameSpaceByString(nsName, objectType->nameSpace, errNode, script, 0, false); |
| 5954 | |
| 5955 | // If the namespace isn't found return silently and let the calling |
| 5956 | // function report the error if it cannot resolve the symbol |
| 5957 | if (ns == 0) |
| 5958 | return; |
| 5959 | } |
| 5960 | |
| 5961 | // Find the base class with the specified scope |
| 5962 | while (objectType) |
| 5963 | { |
| 5964 | // If the name and namespace matches it is the correct class. If no |
| 5965 | // specific namespace was given, then don't compare the namespace |
| 5966 | if (objectType->name == className && (ns == 0 || objectType->nameSpace == ns)) |
| 5967 | break; |
| 5968 | |
| 5969 | objectType = objectType->derivedFrom; |
| 5970 | } |
| 5971 | |
| 5972 | // If the scope is not any of the base classes, then return no methods |
| 5973 | if( objectType == 0 ) |
| 5974 | return; |
| 5975 | } |
| 5976 | |
| 5977 | // Find the methods in the object that match the name |
| 5978 | // TODO: optimize: Improve linear search |
| 5979 | for( asUINT n = 0; n < objectType->methods.GetLength(); n++ ) |
| 5980 | { |
| 5981 | asCScriptFunction *func = engine->scriptFunctions[objectType->methods[n]]; |
| 5982 | if( func->name == name && |
| 5983 | (!objIsConst || func->IsReadOnly()) && |
| 5984 | (func->accessMask & module->m_accessMask) ) |
| 5985 | { |
| 5986 | // When the scope is defined the returned methods should be the true methods, not the virtual method stubs |
| 5987 | if( scope == "" ) |
| 5988 | methods.PushLast(engine->scriptFunctions[objectType->methods[n]]->id); |
no test coverage detected