using System;
using System.Collections;
using System.Xml;
namespace ABG.API.Core
{
public class Class: TypeBase
{
// contained elements
internal ArrayList classList = new ArrayList();
internal ArrayList constructorList = new ArrayList();
internal ArrayList converterList = new ArrayList();
internal ArrayList enumerationList = new ArrayList();
internal ArrayList fieldList = new ArrayList();
internal ArrayList methodList = new ArrayList();
internal ArrayList operatorMethodList = new ArrayList();
internal ArrayList structList = new ArrayList();
internal ArrayList typedefList = new ArrayList();
internal ArrayList unionList = new ArrayList();
internal ArrayList variableList = new ArrayList();
// Can have at most one Destructor
internal Destructor destructor = null;
// List of base-class elements
internal ArrayList baseClassList = new ArrayList();
public Class(XmlTextReader rd): base(rd)
{
// Base types are indicated in two way: as attributes in
// the class element, and as child elements of the class
// element. Only the latter indicates whether inheritance
// is public, private, or protected. Given how rare non-public
// inheritance is, we can just use the attribute version for
// now.
}
// Polish() required because items contained in the class may
// not have their declarations loaded when Class is instantiated.
protected internal override void Polish(IDictionary table)
{
base.Polish(table);
foreach (string s in StringListToArray(attributes["bases"]))
baseClassList.Add(table[s]);
foreach (string s in StringListToArray(attributes["members"]))
{
object o = table[s];
if (o == null)
{
Log.LogEvent(LogLevel.Detailed, "Class {0} declares member {1}, which is not available.", this.Name, s);
continue;
}
Declaration decl = (Declaration) o;
switch (decl.DeclarationKind)
{
case DeclarationKind.Method:
methodList.Add(decl);
break;
case DeclarationKind.Constructor:
constructorList.Add(decl);
break;
case DeclarationKind.Converter:
converterList.Add(decl);
break;
case DeclarationKind.OperatorMethod:
operatorMethodList.Add(decl);
break;
case DeclarationKind.Enumeration:
enumerationList.Add(decl);
break;
case DeclarationKind.Field:
fieldList.Add(decl);
break;
case DeclarationKind.Class:
classList.Add(decl);
break;
case DeclarationKind.Struct:
structList.Add(decl);
break;
case DeclarationKind.Typedef:
typedefList.Add(decl);
break;
case DeclarationKind.Union:
unionList.Add(decl);
break;
case DeclarationKind.Variable:
variableList.Add(decl);
break;
case DeclarationKind.Destructor:
destructor = (Destructor) decl;
break;
default:
Log.LogEvent(LogLevel.Detailed, "Class {0} declares member {1}, with unhandled DeclarationKind {2}",
this.Name, decl.Name, decl.DeclarationKind);
break;
}
} // foreach
} // Polish
public IList Classes
{
get { return classList; }
}
public IList Constructors
{
get { return constructorList; }
}
public IList Converters
{
get { return converterList; }
}
public IList Enumerations
{
get { return enumerationList; }
}
public IList Fields
{
get { return fieldList; }
}
public IList Methods
{
get { return methodList; }
}
public IList OperatorMethods
{
get { return operatorMethodList; }
}
public IList Structs
{
get { return structList; }
}
public IList Typedefs
{
get { return typedefList; }
}
public IList Unions
{
get { return unionList; }
}
// Note: These are actually static fields.
public IList Variables
{
get { return variableList; }
}
public Destructor Destructor
{
get { return destructor; }
}
public IList BaseClasses
{
get { return baseClassList; }
}
public override DeclarationKind DeclarationKind
{
get { return DeclarationKind.Class; }
}
}
} // namespace