internal
| 1205 | |
| 1206 | // internal |
| 1207 | int asCScriptEngine::ParseNamespace(const char* nameSpace, asCArray<asCString>& nsStrings) const |
| 1208 | { |
| 1209 | if (nameSpace == 0) |
| 1210 | return asINVALID_ARG; |
| 1211 | |
| 1212 | asCString ns = nameSpace; |
| 1213 | if (ns != "") |
| 1214 | { |
| 1215 | // Make sure the namespace is composed of alternating identifier and :: |
| 1216 | size_t pos = 0; |
| 1217 | bool expectIdentifier = true; |
| 1218 | size_t len; |
| 1219 | eTokenType t = ttIdentifier; |
| 1220 | |
| 1221 | for (; pos < ns.GetLength(); pos += len) |
| 1222 | { |
| 1223 | t = tok.GetToken(ns.AddressOf() + pos, ns.GetLength() - pos, &len); |
| 1224 | if ((expectIdentifier && t != ttIdentifier) || (!expectIdentifier && t != ttScope)) |
| 1225 | return asINVALID_DECLARATION; |
| 1226 | |
| 1227 | // Make sure parent namespaces are registred in case of nested namespaces |
| 1228 | if (expectIdentifier) |
| 1229 | nsStrings.PushLast(ns.SubString(0, pos + len)); |
| 1230 | |
| 1231 | expectIdentifier = !expectIdentifier; |
| 1232 | } |
| 1233 | |
| 1234 | // If the namespace ends with :: then strip it off |
| 1235 | if (t == ttScope) |
| 1236 | ns.SetLength(ns.GetLength() - 2); |
| 1237 | } |
| 1238 | |
| 1239 | nsStrings.PushLast(ns); |
| 1240 | |
| 1241 | return asSUCCESS; |
| 1242 | } |
| 1243 | |
| 1244 | // interface |
| 1245 | int asCScriptEngine::SetDefaultNamespace(const char *nameSpace) |