|
From: Frank V. C. <fr...@us...> - 2000-10-16 03:06:38
|
Update of /cvsroot/corelinux/clfw/src/testdrivers/exf1 In directory slayer.i.sourceforge.net:/tmp/cvs-serv2306/src/testdrivers/exf1 Modified Files: examp1.cpp Log Message: Preperations for 0.2.2 Index: examp1.cpp =================================================================== RCS file: /cvsroot/corelinux/clfw/src/testdrivers/exf1/examp1.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** examp1.cpp 2000/10/14 11:49:34 1.7 --- examp1.cpp 2000/10/16 03:06:35 1.8 *************** *** 22,28 **** This example is to show use of the MetaType object ! It is a trivial example of the metaClass features. It creates a type descriptor, aMT, for the FrameworkEntity ! class then it creates an instance, aFrameworkEntity, of this class. ! Finally it compares the type of aFrameworkEntity with FrameworkEntity (the answer should be yes :) ) */ --- 22,28 ---- This example is to show use of the MetaType object ! We primarily focus on the introspection capability by discovering ! parents and variables that an instance of the type may make ! available */ *************** *** 49,52 **** --- 49,55 ---- #endif + #if !defined(__SHORTINTEGER_HPP) + #include <clfw/ShortInteger.hpp> + #endif using namespace corelinux; *************** *** 64,67 **** --- 67,72 ---- void dumpMetaType( FrameworkEntityPtr ); + void dumpInstanceMembers( MetaTypeCptr ); + void dumpParents( MetaTypeCptr ); // *************** *** 94,119 **** dumpMetaType( aFrameworkEntity ); - // ! // Now we sweeten the pot with a number fetch and show off the class ! // factory stuff // IntegerPtr aInteger = Integer::create(); aInteger->setValue(8); dumpMetaType( aInteger ); ! cout << "Check metatype hiearchy (is " << ! aInteger->getType()->getMetaTypeName() << " a type of " << ! aFrameworkEntity->getType()->getMetaTypeName() << "?) = "; ! if ( aInteger->getType()->isTypeOf(aFrameworkEntity->getType()) == true ) ! { ! cout << "yes!" << endl; ! } ! else ! { ! cout << "no!" << endl; ! } // --- 99,115 ---- dumpMetaType( aFrameworkEntity ); // ! // Now we sweeten the pot with showing the factory methods // IntegerPtr aInteger = Integer::create(); aInteger->setValue(8); + dumpMetaType( aInteger ); ! ShortIntegerPtr aShort = ShortInteger::create(); ! aShort->setValue(3); ! dumpMetaType( aShort ); // *************** *** 122,125 **** --- 118,122 ---- Integer::destroy( aInteger ); + ShortInteger::destroy( aShort ); // *************** *** 145,151 **** cerr << "Unknown exception." << endl; } - // No line exceeds the 78 column positions (Section 4.6) --| ! return 0; // Single exit point (Section 4.0) } --- 142,147 ---- cerr << "Unknown exception." << endl; } ! return 0; } *************** *** 161,188 **** // Standard stuff // ! cout << endl << "entity address = " << anFEPtr << endl ! << "entity type version = " << aMTPtr->getTypeVersion() << endl ! << "entity instance size = " << aMTPtr->getTypeSize() << endl ! << "entity Instance name = " << aMTPtr->getInstanceTypeName() << endl ! << "entity Meta name = " << aMTPtr->getMetaTypeName() << endl; ! cout << "Compare meta-types with instance type = "; ! if ( anFEPtr->getType()->isType(aMTPtr) == true ) { ! cout << "yes!" << endl; } else { ! cout << "no!" << endl; } ! // ! // Member dump ! // MemberDescriptorCptr * const aMDescs = aMTPtr->getInstanceMembers(); if( aMDescs == NULLPTR ) { --- 157,227 ---- // Standard stuff // + + cout << endl + << "Analyzing class [" << aMTPtr->getInstanceTypeName() + << "] MetaType [" << aMTPtr->getMetaTypeName() << "]" << + endl; + + cout << endl + << "entity address = " << anFEPtr << endl + << "type class version = " << aMTPtr->getTypeVersion() << endl + << "instance size = " << aMTPtr->getTypeSize() << + endl; ! // ! // Parent Dump ! // ! dumpParents( aMTPtr ); ! // ! // Data Member dump ! // ! ! dumpInstanceMembers( aMTPtr ); ! } ! ! // ! // Parent information ! // ! ! void dumpParents( MetaTypeCptr aMTPtr ) ! { ! MetaTypeCptr * const parents = aMTPtr->getParentTypes(); ! ! cout << endl << "MetaType Parent List : " << endl; ! if( parents == NULLPTR ) { ! cout << "Internal class error for parents : " << ! aMTPtr->getInstanceTypeName() << endl; } else { ! if( parents[0] != NULLPTR ) ! { ! for( int x = 0; parents[x] != NULLPTR; ++x ) ! { ! cout ! << "\tClass = " << parents[x]->getInstanceTypeName() << endl ! << "\tMetaType = " << parents[x]->getMetaTypeName() << endl; ! } ! } ! else ! { ! cout << "\tType is root" << endl; ! } } ! } ! ! // ! // Data member information ! // + void dumpInstanceMembers( MetaTypeCptr aMTPtr ) + { MemberDescriptorCptr * const aMDescs = aMTPtr->getInstanceMembers(); + cout << endl << "Instance Data Member List : " << endl; if( aMDescs == NULLPTR ) { *************** *** 194,212 **** if( aMDescs[0] != NULLPTR ) { - void *pv(NULLPTR); - int val(5); - for( int x = 0; aMDescs[x] != NULLPTR; ++x ) { ! cout << "Var name = " << aMDescs[x]->theTypeVariableName << endl; ! cout << "Var type = " << aMDescs[x]->theTypeName << endl; ! cout << "Var size = " << aMDescs[x]->theSizeInBytes << endl; if( aMDescs[x]->theGetter != NULLPTR ) { ! pv = (*aMDescs[x]->theGetter)(anFEPtr); ! if( pv != NULLPTR ) ! { ! cout << "\tPre set = " << *((int *)pv) << endl; ! } } else --- 233,244 ---- if( aMDescs[0] != NULLPTR ) { for( int x = 0; aMDescs[x] != NULLPTR; ++x ) { ! cout << "\tVar name = " << aMDescs[x]->theTypeVariableName << endl; ! cout << "\tVar type = " << aMDescs[x]->theTypeName << endl; ! cout << "\tVar size = " << aMDescs[x]->theSizeInBytes << endl; if( aMDescs[x]->theGetter != NULLPTR ) { ! cout << "\tHas getter " << endl; } else *************** *** 216,220 **** if( aMDescs[x]->theSetter != NULLPTR ) { ! (*aMDescs[x]->theSetter)(anFEPtr,&val); } else --- 248,252 ---- if( aMDescs[x]->theSetter != NULLPTR ) { ! cout << "\tHas setter " << endl; } else *************** *** 222,242 **** ; // do nothing } - if( aMDescs[x]->theGetter != NULLPTR ) - { - pv = (*aMDescs[x]->theGetter)(anFEPtr); - if( pv != NULLPTR ) - { - cout << "\tPost set = " << *((int *)pv) << endl; - } - } - else - { - ; // d nothing - } } } else { ! ; // do nothing } } --- 254,262 ---- ; // do nothing } } } else { ! cout << "\tNo data members" << endl; } } *************** *** 280,283 **** --- 300,307 ---- cerr << endl; } + + // + // Default exception handler + // void handleException( ExceptionCref aExcp ) |