Adobe.com
Contents Suites Classes Class Index Member Index

VTableSupport.hpp

Go to the documentation of this file.
00001 
00002 #ifndef _VTABLESUPPORT_HPP_
00003 #define _VTABLESUPPORT_HPP_
00004 
00005 /*
00006  *        Name: VTableSupport.hpp
00007  *     Purpose: 
00008  *
00009  * ADOBE SYSTEMS INCORPORATED
00010  * Copyright 2005-2007 Adobe Systems Incorporated.
00011  * All rights reserved.
00012  *
00013  * NOTICE:  Adobe permits you to use, modify, and distribute this file 
00014  * in accordance with the terms of the Adobe license agreement 
00015  * accompanying it. If you have received this file from a source other 
00016  * than Adobe, then your use, modification, or distribution of it 
00017  * requires the prior written permission of Adobe.
00018  *
00019  */
00020 
00021 #include "AIHeaderBegin.h"
00022 
00024 //
00025 // If your plugin has a C++ object attached to it's globals, and if
00026 // the class of that object has virtual functions, those functions
00027 // will not work after the plugin is unloaded and then reloaded.
00028 //
00029 // The following macro (FIXUP_VTABLE) can be used to provide a means
00030 // of restoring the virtual function table of a globally-persistent
00031 // C++ object by calling FixupVTable() prior to the use of any of
00032 // the object's virtual functions after a reload.
00033 //
00034 // Here is how you might use the macro:
00035 //
00036 // class MyGlobals
00037 // {
00038 // public:
00039 //     //
00040 //     [some class definition code skipped];
00041 //     //
00042 //     // pass class name to macro
00043 //     FIXUP_VTABLE(MyGlobals);
00044 //     //
00045 //     // Note: private access at this point
00046 //     //
00047 // protected:
00048 //     //
00049 //     [more class definition code skipped];
00050 // };
00051 //
00052 // //
00053 // // Then, later in the translation:
00054 // //
00055 //
00056 // ASErr
00057 // OnReloadPlugin(SPInterfaceMessage *pMsg)
00058 // {
00059 //     MyGlobals *pGlobals = (MyGlobals *) pMsg->d.globals;
00060 //
00061 //     // don't use any of MyGlobals' virtual functions here
00062 //     [some code skipped];
00063 //
00064 //     // should probably do this early on.
00065 //     MyGlobals::FixupVTable(pGlobals);
00066 //
00067 //     // o.k. to use virtual functions now
00068 //     [more code skipped];
00069 // }
00070 //
00072 
00073 #define FIXUP_VTABLE(CLASSNAME) \
00074 public: \
00075         static void FixupVTable(CLASSNAME *pThis) {pThis = new(pThis) CLASSNAME((FixupVTableSignature) 0);} \
00076 private: \
00077         typedef ai::int32 FixupVTableSignature; \
00078         CLASSNAME(FixupVTableSignature) {} \
00079         static void *operator new(size_t /*uiSize*/, CLASSNAME * pThis) {return pThis;} \
00080         static void operator delete(void * /*pMem*/, CLASSNAME * /*pThis*/) {} \
00081         //
00082 
00084 //
00085 // If you are using operator new from a base class, you can use the
00086 // following macro so that the compiler can resolve the overloading
00087 // in the scope of your derived class.
00088 //
00090 
00091 #define FIXUP_VTABLE_EX(CLASSNAME, BASECLASS) \
00092 public: \
00093         void *operator new(size_t uiSize) {return BASECLASS::operator new(uiSize);} \
00094         void operator delete(void *pMem) {BASECLASS::operator delete(pMem);} \
00095         FIXUP_VTABLE(CLASSNAME)
00096         
00098 //
00099 // If you are using a global operator new, you can use the
00100 // following macro so that the compiler can resolve the overloading
00101 // in the scope of your derived class.
00102 //
00104 
00105 #define FIXUP_VTABLE_EX1(CLASSNAME) \
00106 public: \
00107         void *operator new(size_t uiSize) {return ::operator new(uiSize);} \
00108         void operator delete(void *pMem) {::operator delete(pMem); } \
00109         FIXUP_VTABLE(CLASSNAME)
00110         
00111 #include "AIHeaderEnd.h"
00112 
00113 #endif // _VTABLESUPPORT_HPP_
00114 


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2016 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks