// FIXME: This makes no attempt to actually verify that the parts compose a valid C++ type.
private void Parse(object [] parts)
{
foreach (object part in parts)
{
if (part is CppModifiers)
{
Modifiers.Add((CppModifiers)part);
continue;
}
if (part is CppModifiers [] || part is IEnumerable <CppModifiers> )
{
Modifiers.AddRange((IEnumerable <CppModifiers>)part);
continue;
}
if (part is CppTypes)
{
ElementType = (CppTypes)part;
continue;
}
Type managedType = part as Type;
if (managedType != null)
{
CppType mapped = CppType.ForManagedType(managedType);
CopyTypeFrom(mapped);
continue;
}
string strPart = part as string;
if (strPart != null)
{
var parsed = CppModifiers.Parse(strPart);
if (parsed.Count > 0)
{
if (internalModifiers == null)
{
internalModifiers = parsed;
}
else
{
internalModifiers.AddRange(parsed);
}
strPart = CppModifiers.Remove(strPart);
}
// if we have something left, it must be a type name
strPart = strPart.Trim();
if (strPart != "")
{
string [] qualifiedName = strPart.Split(new string [] { "::" }, StringSplitOptions.RemoveEmptyEntries);
int numNamespaces = qualifiedName.Length - 1;
if (numNamespaces > 0)
{
Namespaces = new string [numNamespaces];
for (int i = 0; i < numNamespaces; i++)
{
Namespaces [i] = qualifiedName [i];
}
}
strPart = qualifiedName [numNamespaces];
// FIXME: Fix this mess
switch (strPart)
{
case "void":
ElementType = CppTypes.Void;
break;
case "bool":
ElementType = CppTypes.Bool;
break;
case "char":
ElementType = CppTypes.Char;
break;
case "int":
ElementType = CppTypes.Int;
break;
case "float":
ElementType = CppTypes.Float;
break;
case "double":
ElementType = CppTypes.Double;
break;
default:
// otherwise it is the element type name...
ElementTypeName = strPart;
break;
}
}
}
}
}