| 160 | } |
| 161 | |
| 162 | InplaceStr GetNameInNamespace(InplaceStr name, bool alwaysRelocate = false) |
| 163 | { |
| 164 | if(namespaceStack.size() > 1) |
| 165 | { |
| 166 | // A full name must be created if we are in a namespace |
| 167 | unsigned nameLength = int(name.end - name.begin) + 1, lastLength = nameLength; |
| 168 | for(unsigned int i = 1; i < namespaceStack.size(); i++) |
| 169 | nameLength += namespaceStack[i]->nameLength + 1; // add space for namespace name and a point |
| 170 | char *newName = AllocateString(nameLength), *currPos = newName; |
| 171 | for(unsigned int i = 1; i < namespaceStack.size(); i++) |
| 172 | { |
| 173 | memcpy(currPos, namespaceStack[i]->name.begin, namespaceStack[i]->nameLength); |
| 174 | currPos += namespaceStack[i]->nameLength; |
| 175 | *currPos++ = '.'; |
| 176 | } |
| 177 | memcpy(currPos, name.begin, lastLength); |
| 178 | currPos[lastLength - 1] = 0; |
| 179 | name = InplaceStr(newName); |
| 180 | }else if(alwaysRelocate){ |
| 181 | char *newName = AllocateString(int(name.end - name.begin) + 1); |
| 182 | memcpy(newName, name.begin, int(name.end - name.begin)); |
| 183 | newName[int(name.end - name.begin)] = 0; |
| 184 | name = InplaceStr(newName); |
| 185 | } |
| 186 | return name; |
| 187 | } |
| 188 | unsigned AddNamespaceToHash(unsigned hash, NamespaceInfo* info) |
| 189 | { |
| 190 | if(info->parent) |
no test coverage detected