MCPcopy Create free account
hub / github.com/anjo76/angelscript / ParseNamespace

Method ParseNamespace

sdk/angelscript/source/as_scriptengine.cpp:1207–1242  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1205
1206// internal
1207int 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
1245int asCScriptEngine::SetDefaultNamespace(const char *nameSpace)

Callers

nothing calls this directly

Calls 6

PushLastMethod · 0.80
SubStringMethod · 0.80
GetLengthMethod · 0.45
GetTokenMethod · 0.45
AddressOfMethod · 0.45
SetLengthMethod · 0.45

Tested by

no test coverage detected