From Mike Wittman, updates to support new protected method support

This commit is contained in:
Robert Osfield 2007-03-04 13:03:47 +00:00
parent 267079e4d8
commit 9fa317c550

View File

@ -47,77 +47,8 @@ bool type_order(const Type *v1, const Type *v2)
return v1->getQualifiedName().compare(v2->getQualifiedName()) < 0;
}
void print_types()
void print_method(const MethodInfo &mi)
{
// get the map of types that have been reflected
const TypeMap &tm = Reflection::getTypes();
// create a sortable list of types
TypeList types(tm.size());
TypeList::iterator j = types.begin();
for (TypeMap::const_iterator i=tm.begin(); i!=tm.end(); ++i, ++j)
*j = i->second;
// sort the map
std::sort(types.begin(), types.end(), &type_order);
// iterate through the type map and display some
// details for each type
for (TypeList::const_iterator i=types.begin(); i!=types.end(); ++i)
{
// ignore pointer types and undefined types
if (!(*i)->isDefined() || (*i)->isPointer() || (*i)->isReference())
continue;
// print the type name
std::cout << (*i)->getQualifiedName() << "\n";
// check whether the type is abstract
if ((*i)->isAbstract()) std::cout << "\t[abstract]\n";
// check whether the type is atomic
if ((*i)->isAtomic()) std::cout << "\t[atomic]\n";
// check whether the type is an enumeration. If yes, display
// the list of enumeration labels
if ((*i)->isEnum())
{
std::cout << "\t[enum]\n";
std::cout << "\tenumeration values:\n";
const EnumLabelMap &emap = (*i)->getEnumLabels();
for (EnumLabelMap::const_iterator j=emap.begin(); j!=emap.end(); ++j)
{
std::cout << "\t\t" << j->second << " = " << j->first << "\n";
}
}
// if the type has one or more base types, then display their
// names
if ((*i)->getNumBaseTypes() > 0)
{
std::cout << "\tderived from: ";
for (int j=0; j<(*i)->getNumBaseTypes(); ++j)
{
const Type &base = (*i)->getBaseType(j);
if (base.isDefined())
std::cout << base.getQualifiedName() << " ";
else
std::cout << "[undefined type] ";
}
std::cout << "\n";
}
// display a list of methods defined for the current type
const MethodInfoList &mil = (*i)->getMethods();
if (!mil.empty())
{
std::cout << "\t* methods:\n";
for (MethodInfoList::const_iterator j=mil.begin(); j!=mil.end(); ++j)
{
// get the MethodInfo object that describes the current
// method
const MethodInfo &mi = **j;
std::cout << "\t ";
// display if the method is virtual
@ -167,10 +98,83 @@ void print_types()
std::cout << " = 0";
std::cout << "\n";
}
void print_type(const Type &type)
{
// ignore pointer types and undefined types
if (!type.isDefined() || type.isPointer() || type.isReference())
return;
// print the type name
std::cout << type.getQualifiedName() << "\n";
// check whether the type is abstract
if (type.isAbstract()) std::cout << "\t[abstract]\n";
// check whether the type is atomic
if (type.isAtomic()) std::cout << "\t[atomic]\n";
// check whether the type is an enumeration. If yes, display
// the list of enumeration labels
if (type.isEnum())
{
std::cout << "\t[enum]\n";
std::cout << "\tenumeration values:\n";
const EnumLabelMap &emap = type.getEnumLabels();
for (EnumLabelMap::const_iterator j=emap.begin(); j!=emap.end(); ++j)
{
std::cout << "\t\t" << j->second << " = " << j->first << "\n";
}
}
// if the type has one or more base types, then display their
// names
if (type.getNumBaseTypes() > 0)
{
std::cout << "\tderived from: ";
for (int j=0; j<type.getNumBaseTypes(); ++j)
{
const Type &base = type.getBaseType(j);
if (base.isDefined())
std::cout << base.getQualifiedName() << " ";
else
std::cout << "[undefined type] ";
}
std::cout << "\n";
}
// display a list of public methods defined for the current type
const MethodInfoList &mil = type.getMethods();
if (!mil.empty())
{
std::cout << "\t* public methods:\n";
for (MethodInfoList::const_iterator j=mil.begin(); j!=mil.end(); ++j)
{
// get the MethodInfo object that describes the current
// method
const MethodInfo &mi = **j;
print_method(mi);
}
}
// display a list of protected methods defined for the current type
const MethodInfoList &bmil = type.getMethods(Type::PROTECTED_FUNCTIONS);
if (!bmil.empty())
{
std::cout << "\t* protected methods:\n";
for (MethodInfoList::const_iterator j=bmil.begin(); j!=bmil.end(); ++j)
{
// get the MethodInfo object that describes the current
// method
const MethodInfo &mi = **j;
print_method(mi);
}
}
// display a list of properties defined for the current type
const PropertyInfoList &pil = (*i)->getProperties();
const PropertyInfoList &pil = type.getProperties();
if (!pil.empty())
{
std::cout << "\t* properties:\n";
@ -229,6 +233,27 @@ void print_types()
}
std::cout << "\n" << std::string(75, '-') << "\n";
}
void print_types()
{
// get the map of types that have been reflected
const TypeMap &tm = Reflection::getTypes();
// create a sortable list of types
TypeList types(tm.size());
TypeList::iterator j = types.begin();
for (TypeMap::const_iterator i=tm.begin(); i!=tm.end(); ++i, ++j)
*j = i->second;
// sort the map
std::sort(types.begin(), types.end(), &type_order);
// iterate through the type map and display some
// details for each type
for (TypeList::const_iterator i=types.begin(); i!=types.end(); ++i)
{
print_type(**i);
}
}
int main()