|
From: Frank V. C. <fr...@us...> - 2000-10-30 05:01:29
|
Update of /cvsroot/corelinux/clfw/clfw In directory slayer.i.sourceforge.net:/tmp/cvs-serv14134/clfw Modified Files: MetaType.hpp Log Message: 119678 Completed dispatch table functionality with example Index: MetaType.hpp =================================================================== RCS file: /cvsroot/corelinux/clfw/clfw/MetaType.hpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** MetaType.hpp 2000/10/29 17:16:18 1.18 --- MetaType.hpp 2000/10/30 05:01:25 1.19 *************** *** 32,36 **** #include <cstdio> ! namespace corelinux { DECLARE_CLASS( FrameworkEntity ); --- 32,36 ---- #include <cstdio> ! namespace corelinux { DECLARE_CLASS( FrameworkEntity ); *************** *** 38,41 **** --- 38,42 ---- DECLARE_CLASS( DescriptorNotFound ); DECLARE_CLASS( AccessorNotFound ); + } /*! *************** *** 58,67 **** \return a const pointer to the MetaType \ */ \ ! static MetaTypeCptr getTypeDescriptor( void ); \ /** \ get the type \ \return a const pointer to the MetaType \ */ \ ! virtual MetaTypeCptr getType( void ) const; \ /** \ create a new instance of className \ --- 59,68 ---- \return a const pointer to the MetaType \ */ \ ! static corelinux::MetaTypeCptr getTypeDescriptor( void ); \ /** \ get the type \ \return a const pointer to the MetaType \ */ \ ! virtual corelinux::MetaTypePtr getType( void ) const; \ /** \ create a new instance of className \ *************** *** 74,79 **** */ \ static void destroy( className##Ptr aPointer ); \ ! static className##Ptr castDown( FrameworkEntityPtr ); \ ! static className##Ref castDown( FrameworkEntityRef ); \ /** \ redefine the operator new[] \ --- 75,80 ---- */ \ static void destroy( className##Ptr aPointer ); \ ! static className##Ptr castDown( corelinux::FrameworkEntityPtr ); \ ! static className##Ref castDown( corelinux::FrameworkEntityRef ); \ /** \ redefine the operator new[] \ *************** *** 81,90 **** \return a VoidPtr \ */ \ ! VoidPtr operator new(size_t aSize); \ /** \ redefine the operator delete[] \ \arg aVoidPtr the pointer to delete \ */ \ ! void operator delete(VoidPtr aVoidPtr); \ protected: \ private: \ --- 82,91 ---- \return a VoidPtr \ */ \ ! void * operator new(size_t aSize); \ /** \ redefine the operator delete[] \ \arg aVoidPtr the pointer to delete \ */ \ ! void operator delete(void * aVoidPtr); \ protected: \ private: \ *************** *** 92,96 **** the MetaType descriptor \ */ \ ! static MetaType theTypeDesc; #define OPEN_METATYPE_PARENTS( className ) \ --- 93,97 ---- the MetaType descriptor \ */ \ ! static corelinux::MetaType theTypeDesc; #define OPEN_METATYPE_PARENTS( className ) \ *************** *** 98,102 **** array storing the parents descriptors \ */ \ ! MetaType const * className##MetaType##Parents[] = \ { \ --- 99,103 ---- array storing the parents descriptors \ */ \ ! corelinux::MetaType const * className##MetaType##Parents[] = \ { \ *************** *** 111,128 **** The parent type descriptor array must be termined by the NULLPTR \ */ \ ! MetaTypeCptr(NULLPTR) \ } ! typedef void * (*PfnGet)( FrameworkEntityPtr ); ! typedef void (*PfnSet)( FrameworkEntityPtr, VoidPtr ); struct _InstanceMemberDescriptor { ! char *theTypeName; ! char *theTypeVariableName; ! Dword theSizeInBytes; ! MetaTypeCptr theTypePointer; ! PfnGet theGetter; ! PfnSet theSetter; } ; --- 112,129 ---- The parent type descriptor array must be termined by the NULLPTR \ */ \ ! corelinux::MetaTypeCptr(NULLPTR) \ } ! typedef void * (*PfnGet)( corelinux::FrameworkEntityPtr ); ! typedef void (*PfnSet)( corelinux::FrameworkEntityPtr, corelinux::VoidPtr ); struct _InstanceMemberDescriptor { ! char *theTypeName; ! char *theTypeVariableName; ! Dword theSizeInBytes; ! corelinux::MetaTypeCptr theTypePointer; ! PfnGet theGetter; ! PfnSet theSetter; } ; *************** *** 137,145 **** #define _DECLARE_INSTANCEDATA_STATICS(dataName) \ static MemberDescriptor the##dataName##Descriptor; \ ! static void *get##dataName##AsVPtr( FrameworkEntityPtr ); \ static void set##dataName##AsVPtr \ ( \ ! FrameworkEntityPtr , \ ! VoidPtr \ ); \ --- 138,146 ---- #define _DECLARE_INSTANCEDATA_STATICS(dataName) \ static MemberDescriptor the##dataName##Descriptor; \ ! static void *get##dataName##AsVPtr( corelinux::FrameworkEntityPtr ); \ static void set##dataName##AsVPtr \ ( \ ! corelinux::FrameworkEntityPtr , \ ! corelinux::VoidPtr \ ); \ *************** *** 168,172 **** void * get##dataName##AsVoidPtr( void ) const \ { \ ! return (VoidPtr)get##dataName##AsPointer(); \ } \ /** \ --- 169,173 ---- void * get##dataName##AsVoidPtr( void ) const \ { \ ! return (void *)get##dataName##AsPointer(); \ } \ /** \ *************** *** 206,214 **** const type & get##dataName##AsReference( void ) const \ { \ ! return (const type &) baseClass::get##dataName##AsReference(); \ } \ const type * get##dataName##AsPointer( void ) const \ { \ ! return (const type *)baseClass::get##dataName##AsPointer(); \ } \ void * get##dataName##AsVoidPtr( void ) const \ --- 207,215 ---- const type & get##dataName##AsReference( void ) const \ { \ ! return (const type &) baseClass::get##dataName##AsReference(); \ } \ const type * get##dataName##AsPointer( void ) const \ { \ ! return (const type *)baseClass::get##dataName##AsPointer(); \ } \ void * get##dataName##AsVoidPtr( void ) const \ *************** *** 232,236 **** { \ baseType btr = (baseType) *((type *) aType); \ ! baseClass::set##dataName##FromVPtr((VoidPtr)&btr); \ } \ --- 233,237 ---- { \ baseType btr = (baseType) *((type *) aType); \ ! baseClass::set##dataName##FromVPtr((void *)&btr); \ } \ *************** *** 244,248 **** void *className::get##dataName##AsVPtr \ ( \ ! FrameworkEntityPtr aSelf \ ) \ { \ --- 245,249 ---- void *className::get##dataName##AsVPtr \ ( \ ! corelinux::FrameworkEntityPtr aSelf \ ) \ { \ *************** *** 252,257 **** void className::set##dataName##AsVPtr \ ( \ ! FrameworkEntityPtr aSelf, \ ! VoidPtr aType \ ) \ { \ --- 253,258 ---- void className::set##dataName##AsVPtr \ ( \ ! corelinux::FrameworkEntityPtr aSelf, \ ! corelinux::VoidPtr aType \ ) \ { \ *************** *** 319,327 **** ! typedef void (*DispatchFunction)( FrameworkEntityPtr, void **, void * ); struct __DispatchDescriptor { ! CharPtr theClassMethodName; ! DispatchFunction theFunction; } ; --- 320,328 ---- ! typedef void (*DispatchFunction)( corelinux::FrameworkEntityPtr, void **, void * ); struct __DispatchDescriptor { ! corelinux::CharPtr theClassMethodName; ! DispatchFunction theFunction; } ; *************** *** 334,347 **** \arg methName : unique name identifier */ #define DISPATCH_FUNCTION( className, methName ) \ ! static extern "C" void className##methName \ ! ( \ ! FrameworkEntityPtr aClass, \ ! void **args, \ ! void *ret \ ! ) \ ! { \ ! className##Ptr myPointer = className:::castDown( aClass ); #define CLOSE_DISPATH_FUNCTION \ } --- 335,367 ---- \arg methName : unique name identifier */ + #define DISPATCH_FUNCTION( className, methName ) \ ! static void className##methName \ ! ( \ ! corelinux::FrameworkEntityPtr aClass, \ ! void **args, \ ! void *ret \ ! ) \ ! { \ ! className##Ptr myPointer = className::castDown( aClass ); + /*! + \def DISPATCH_FUNCTION_NORETURN( className, methName ) + \brief Opens the standard header, body required to do something + but ignores return value + \arg className : base name for method + \arg methName : unique name identifier + */ + + #define DISPATCH_FUNCTION_NORETURN( className, methName ) \ + static void className##methName \ + ( \ + corelinux::FrameworkEntityPtr aClass, \ + void **args, \ + void * \ + ) \ + { \ + className##Ptr myPointer = className::castDown( aClass ); + #define CLOSE_DISPATH_FUNCTION \ } *************** *** 424,432 **** aAlPtr->destroyType(aPtr); \ } \ ! className##Ref className::castDown( FrameworkEntityRef aP ) \ { \ return dynamic_cast<className##Ref>(aP); \ } \ ! className##Ptr className::castDown( FrameworkEntityPtr aP ) \ { \ return dynamic_cast<className##Ptr>(aP); \ --- 444,452 ---- aAlPtr->destroyType(aPtr); \ } \ ! className##Ref className::castDown( corelinux::FrameworkEntityRef aP ) \ { \ return dynamic_cast<className##Ref>(aP); \ } \ ! className##Ptr className::castDown( corelinux::FrameworkEntityPtr aP ) \ { \ return dynamic_cast<className##Ptr>(aP); \ *************** *** 438,444 **** \return a VoidPtr \ */ \ ! VoidPtr className::operator new( size_t ) \ { \ ! return (VoidPtr)className::create(); \ } \ /** \ --- 458,464 ---- \return a VoidPtr \ */ \ ! void * className::operator new( size_t ) \ { \ ! return (void *)className::create(); \ } \ /** \ *************** *** 448,452 **** \arg the pointer aVoidPtr \ */ \ ! void className::operator delete(VoidPtr aVoidPtr) \ { \ className##Ptr aPtr = (className##Ptr)aVoidPtr; \ --- 468,472 ---- \arg the pointer aVoidPtr \ */ \ ! void className::operator delete(void * aVoidPtr) \ { \ className##Ptr aPtr = (className##Ptr)aVoidPtr; \ *************** *** 472,476 **** Cast to type \ */ \ ! className##Ptr className::castDown( FrameworkEntityPtr aP ) \ { \ return dynamic_cast<className##Ptr>(aP); \ --- 492,496 ---- Cast to type \ */ \ ! className##Ptr className::castDown( corelinux::FrameworkEntityPtr aP ) \ { \ return dynamic_cast<className##Ptr>(aP); \ *************** *** 482,488 **** \return a VoidPtr \ */ \ ! VoidPtr className::operator new( size_t ) \ { \ ! return (VoidPtr)className::create(); \ } \ /** \ --- 502,508 ---- \return a VoidPtr \ */ \ ! void * className::operator new( size_t ) \ { \ ! return (void *)className::create(); \ } \ /** \ *************** *** 492,496 **** \arg the pointer aVoidPtr \ */ \ ! void className::operator delete(VoidPtr aVoidPtr) \ { \ className##Ptr aPtr = (className##Ptr)aVoidPtr; \ --- 512,516 ---- \arg the pointer aVoidPtr \ */ \ ! void className::operator delete(void *aVoidPtr) \ { \ className##Ptr aPtr = (className##Ptr)aVoidPtr; \ *************** *** 521,525 **** className##Ptr className::create( void ) \ { \ ! throw AbstractEntityException \ ( \ className##AllocExc, \ --- 541,545 ---- className##Ptr className::create( void ) \ { \ ! throw corelinux::AbstractEntityException \ ( \ className##AllocExc, \ *************** *** 534,538 **** void className::destroy( className##Ptr ) \ { \ ! throw AbstractEntityException \ ( \ className##DeAllocExc, \ --- 554,558 ---- void className::destroy( className##Ptr ) \ { \ ! throw corelinux::AbstractEntityException \ ( \ className##DeAllocExc, \ *************** *** 540,544 **** ); \ } \ ! className##Ptr className::castDown( FrameworkEntityPtr aP ) \ { \ return dynamic_cast<className##Ptr>(aP); \ --- 560,564 ---- ); \ } \ ! className##Ptr className::castDown( corelinux::FrameworkEntityPtr aP ) \ { \ return dynamic_cast<className##Ptr>(aP); \ *************** *** 550,556 **** \return a VoidPtr \ */ \ ! VoidPtr className::operator new( size_t ) \ { \ ! throw AbstractEntityException \ ( \ className##AllocExc, \ --- 570,576 ---- \return a VoidPtr \ */ \ ! void * className::operator new( size_t ) \ { \ ! throw corelinux::AbstractEntityException \ ( \ className##AllocExc, \ *************** *** 565,571 **** \arg the pointer aVoidPtr \ */ \ ! void className::operator delete( VoidPtr ) \ { \ ! throw AbstractEntityException \ ( \ className##DeAllocExc, \ --- 585,591 ---- \arg the pointer aVoidPtr \ */ \ ! void className::operator delete( void * ) \ { \ ! throw corelinux::AbstractEntityException \ ( \ className##DeAllocExc, \ *************** *** 605,609 **** implements the getType() function \ */ \ ! MetaTypeCptr className::getType( void ) const \ { \ return &theTypeDesc; \ --- 625,629 ---- implements the getType() function \ */ \ ! MetaTypePtr className::getType( void ) const \ { \ return &theTypeDesc; \ *************** *** 714,717 **** --- 734,739 ---- _DEFINE_ENTITY_ALWAYS(className) + namespace corelinux + { /*! \class MetaType *************** *** 934,937 **** --- 956,976 ---- //@} + /** @name Instance Mutators and methods interfaces + */ + //@{ + /** + Attempts to call the method via a dispatch function on + the object + @param FrameworkEntity pointer to the object + @param char pointer to the named method (used for lookup) + @param void pointer array of arguments + @param void pointer to return value + @exception NullpointerException if object or name are null + @exception DescriptorNotFound if no match + */ + + void dispatch( FrameworkEntityPtr, char *, void **, void * ) + throw( NullPointerException, DescriptorNotFound ); + //@} protected: |