From: David Elliott Date: Mon, 18 Feb 2008 20:36:16 +0000 (+0000) Subject: Add a new macro to the Objective-C uniquifying support that allows a X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/83259e23a41c7569ab125ce67211397b7342a1e9 Add a new macro to the Objective-C uniquifying support that allows a uniquified class to be a subclasses of another uniquified class. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/cocoa/objc/objc_uniquifying.h b/include/wx/cocoa/objc/objc_uniquifying.h index f81ad00ee5..667503c223 100644 --- a/include/wx/cocoa/objc/objc_uniquifying.h +++ b/include/wx/cocoa/objc/objc_uniquifying.h @@ -296,6 +296,16 @@ inline objc_class * wxObjcCompilerInformation::GetCompiledClass() \ return objc_getClass(#ObjcSuperClass); \ } +// The WX_IMPLEMENT_OBJC_GET_UNIQUIFIED_SUPERCLASS macro implements the template +// specialization to get the superclass when the superclass is another uniquified +// Objective-C class. +#define WX_IMPLEMENT_OBJC_GET_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) \ + template <> \ + inline objc_class* wxObjcCompilerInformation::GetSuperclass() \ + { \ + return wx_GetObjcClass_ ## ObjcSuperClass(); \ + } + // The WX_IMPLEMENT_OBJC_CLASS_NAME macro implements the template specialization // of the sm_theClassName constant. As soon as this specialization is in place // sizeof(sm_theClassName) will return the number of bytes at compile time. @@ -303,17 +313,31 @@ inline objc_class * wxObjcCompilerInformation::GetCompiledClass() \ template <> \ const char wxObjcCompilerInformation::sm_theClassName[] = #ObjcClass; -// The WX_IMPLEMENT_GET_OBJC_CLASS macro combines all of these together and adds -// a global wx_GetObjcClass_ObjcClass() function. -#define WX_IMPLEMENT_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass) \ - WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \ - WX_IMPLEMENT_OBJC_GET_SUPERCLASS(ObjcClass,ObjcSuperClass) \ - WX_IMPLEMENT_OBJC_CLASS_NAME(ObjcClass) \ +// The WX_IMPLEMENT_OBJC_GET_OBJC_CLASS macro is the final one that actually provides +// the wx_GetObjcClass_XXX function that will be called in lieu of asking the Objective-C +// runtime for the class. All the others are really machinery to make this happen. +#define WX_IMPLEMENT_OBJC_GET_OBJC_CLASS(ObjcClass) \ objc_class* wx_GetObjcClass_ ## ObjcClass() \ { \ return wxObjcClassInitializer::Get(); \ } +// The WX_IMPLEMENT_GET_OBJC_CLASS macro combines all of these together +// for the case when the superclass is a non-uniquified class. +#define WX_IMPLEMENT_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass) \ + WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \ + WX_IMPLEMENT_OBJC_GET_SUPERCLASS(ObjcClass,ObjcSuperClass) \ + WX_IMPLEMENT_OBJC_CLASS_NAME(ObjcClass) \ + WX_IMPLEMENT_OBJC_GET_OBJC_CLASS(ObjcClass) + +// The WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS macro combines all +// of these together for the case when the superclass is another uniquified class. +#define WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) \ + WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \ + WX_IMPLEMENT_OBJC_GET_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) \ + WX_IMPLEMENT_OBJC_CLASS_NAME(ObjcClass) \ + WX_IMPLEMENT_OBJC_GET_OBJC_CLASS(ObjcClass) + // The WX_GET_OBJC_CLASS macro is intended to wrap the class name when the class // is used as a message receiver (e.g. for calling class methods). When // class name uniquifying is used, this calls the global function implemented @@ -326,6 +350,8 @@ inline objc_class * wxObjcCompilerInformation::GetCompiledClass() \ #define WX_DECLARE_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass) // Define WX_IMPLEMENT_GET_OBJC_CLASS as nothing #define WX_IMPLEMENT_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass) +// Define WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS as nothing +#define WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) // Define WX_GET_OBJC_CLASS macro to output the class name and let the compiler do the normal thing // The WX_GET_OBJC_CLASS macro is intended to wrap the class name when the class