From 2fbbbca1a0826b862867a8e7e6b04a062a28a618 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 8 Jun 2007 10:11:00 +0000 Subject: [PATCH] From Mike Wittman, "This change to genwrapper and osgIntrospection gives access to the declaring file for a given type via the new member function osgIntrospection::Type::getDeclaringFile. This information is useful in order to know what header to include when auto-generating wrappers for a given type. During the C# wrapper generator development I've been keeping the declaring file configuration state up-to-date manually with changes to OSG, and it's proven to require substantial effort. So it would be extremely valuable to get this change in before 2.0 to reduce maintenance during the lifetime of the release. It'll also be equally useful to others looking to create wrapper generators using osgIntrospection. This is a fairly simple change and was tested with a fresh rebuild of the entire suite of osgWrapper libraries, so it should be relatively low risk (fingers crossed)." --- include/osgIntrospection/ReflectionMacros | 2 ++ include/osgIntrospection/Reflector | 9 +++++++++ include/osgIntrospection/Type | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/include/osgIntrospection/ReflectionMacros b/include/osgIntrospection/ReflectionMacros index 1a96287df..7fdf86205 100644 --- a/include/osgIntrospection/ReflectionMacros +++ b/include/osgIntrospection/ReflectionMacros @@ -164,6 +164,8 @@ namespace osgIntrospection // BASIC CONFIGURATION // -------------------------------------------------------------------------- +#define I_DeclaringFile(f) setDeclaringFile(f); + #define I_Attribute(c) cap->addAttribute(new c); #define I_ReaderWriter(x) setReaderWriter(new x); diff --git a/include/osgIntrospection/Reflector b/include/osgIntrospection/Reflector index 10cec79a0..ff236a862 100644 --- a/include/osgIntrospection/Reflector +++ b/include/osgIntrospection/Reflector @@ -113,6 +113,9 @@ namespace osgIntrospection /// Sets the current type's ReaderWriter object. void setReaderWriter(const ReaderWriter* rw); + + /// Sets the current type's declaring file. + void setDeclaringFile(const std::string& file) const; private: struct PtrConstructor: ConstructorInfo @@ -962,6 +965,12 @@ namespace osgIntrospection _type->_cmp = cmp; } + template + void Reflector::setDeclaringFile(const std::string& file) const + { + _type->_declaringFile = file; + } + } #endif diff --git a/include/osgIntrospection/Type b/include/osgIntrospection/Type index 2bb3db48e..359e24c65 100644 --- a/include/osgIntrospection/Type +++ b/include/osgIntrospection/Type @@ -242,6 +242,11 @@ namespace osgIntrospection /// this type, if any. Otherwise it returns the null pointer. inline const Comparator* getComparator() const; + /// Returns the path to the file where this type is declared, + /// relative the the OpenSceneGraph include directory. Returns + /// the empty string if no path information is available. + inline const std::string &getDeclaringFile() const; + /// Creates an instance of the reflected type. The returned Value /// can be casted to T*, where T is the reflected type. If the type /// is abstract, an exception is thrown. @@ -302,6 +307,8 @@ namespace osgIntrospection std::string _briefHelp; std::string _detailedHelp; + + std::string _declaringFile; }; // OPERATORS @@ -550,6 +557,10 @@ namespace osgIntrospection return false; } + inline const std::string &Type::getDeclaringFile() const + { + return _declaringFile; + } } #endif