2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2005-04-29 18:06:50 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
//osgIntrospection - Copyright (C) 2005 Marco Jez
|
|
|
|
|
2004-12-09 13:28:20 +08:00
|
|
|
#ifndef OSGINTROSPECTION_REFLECTOR_
|
|
|
|
#define OSGINTROSPECTION_REFLECTOR_
|
|
|
|
|
|
|
|
#include <osgIntrospection/Reflection>
|
|
|
|
#include <osgIntrospection/Type>
|
2005-04-04 21:50:07 +08:00
|
|
|
#include <osgIntrospection/Value>
|
2004-12-09 13:28:20 +08:00
|
|
|
#include <osgIntrospection/PropertyInfo>
|
2005-04-04 21:50:07 +08:00
|
|
|
#include <osgIntrospection/MethodInfo>
|
|
|
|
#include <osgIntrospection/ConstructorInfo>
|
|
|
|
#include <osgIntrospection/InstanceCreator>
|
2004-12-09 13:28:20 +08:00
|
|
|
#include <osgIntrospection/ReaderWriter>
|
2005-04-04 21:50:07 +08:00
|
|
|
#include <osgIntrospection/TypedConstructorInfo>
|
|
|
|
#include <osgIntrospection/Comparator>
|
2005-09-28 22:18:31 +08:00
|
|
|
#include <osgIntrospection/Utility>
|
2004-12-09 13:28:20 +08:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
2005-04-04 21:50:07 +08:00
|
|
|
#include <iterator>
|
2004-12-09 13:28:20 +08:00
|
|
|
|
|
|
|
namespace osgIntrospection
|
|
|
|
{
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
class CustomAttribute;
|
|
|
|
class ReaderWriter;
|
|
|
|
|
|
|
|
/// A Reflector is a proxy class that is used to create a new description
|
|
|
|
/// of a given type. If the type to be described is simple and doesn't
|
|
|
|
/// require additional details such as properties and methods, it can be
|
|
|
|
/// reflected by simply creating a global instance of one of the classes
|
|
|
|
/// derived from Reflector, for example ValueReflector. Other types may
|
|
|
|
/// need further information and therefore it could be necessary to create
|
|
|
|
/// a new subclass of Reflector or extend one of the existing subclasses.
|
|
|
|
/// The reflected type can be set by calling Reflector's protected
|
|
|
|
/// methods.
|
|
|
|
///
|
|
|
|
/// NOTE: when you create a Reflector for type T, it will automatically
|
2007-02-13 01:14:46 +08:00
|
|
|
/// create descriptions for types T*, const T*, T&, and const T&. You
|
|
|
|
/// should NEVER create reflectors for pointer or reference types
|
|
|
|
/// explicitly.
|
2005-03-14 17:28:31 +08:00
|
|
|
///
|
|
|
|
template<typename T>
|
|
|
|
class Reflector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef T reflected_type;
|
|
|
|
typedef Reflector<T> inherited;
|
|
|
|
|
|
|
|
/// Virtual destructor.
|
|
|
|
virtual ~Reflector() {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Direct initialization constructor. Parameter 'name' is the name
|
2005-04-04 21:50:07 +08:00
|
|
|
/// of the type being reflected and 'ns' is its namespace.
|
2005-04-29 19:19:58 +08:00
|
|
|
Reflector(const std::string& name, const std::string& ns, bool abstract = false);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// Direct initialization constructor. Parameter 'qname' is the
|
|
|
|
/// fully-qualified name of the type being reflected, i.e. containing
|
2005-04-04 21:50:07 +08:00
|
|
|
/// both the namespace and the name (separated by "::").
|
2005-04-29 19:19:58 +08:00
|
|
|
Reflector(const std::string& qname, bool abstract = false);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/// Returns the Type object being described.
|
2005-04-29 19:19:58 +08:00
|
|
|
Type* getType() { return _type; }
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// Declares a new base type for the current type.
|
2005-04-29 19:19:58 +08:00
|
|
|
void addBaseType(const Type& type);
|
2005-04-04 21:50:07 +08:00
|
|
|
|
|
|
|
/// Sets the comparator object for the current type.
|
2005-04-29 19:19:58 +08:00
|
|
|
void setComparator(const Comparator* cmp);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// Adds a property description to the current type.
|
2005-04-29 19:19:58 +08:00
|
|
|
PropertyInfo* addProperty(PropertyInfo* pi);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// Adds a method description to the current type.
|
2005-04-29 19:19:58 +08:00
|
|
|
MethodInfo* addMethod(MethodInfo* mi);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2007-03-01 19:54:30 +08:00
|
|
|
/// Adds a protected method description to the current type.
|
|
|
|
MethodInfo* addProtectedMethod(MethodInfo* mi);
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
/// Adds an enumeration label to the current type.
|
2005-04-29 19:19:58 +08:00
|
|
|
void addEnumLabel(int v, const std::string& label, bool strip_namespace = true);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
/// Adds a constructor description to the current type.
|
|
|
|
/// As soon as a constructor is added through this method,
|
|
|
|
/// the automatically-generated default constructor is
|
|
|
|
/// removed.
|
2005-04-29 19:19:58 +08:00
|
|
|
ConstructorInfo* addConstructor(ConstructorInfo* ci);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2007-03-01 19:54:30 +08:00
|
|
|
/// Adds a protected constructor description to the current
|
|
|
|
/// type.
|
|
|
|
ConstructorInfo* addProtectedConstructor(ConstructorInfo* ci);
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
/// Returns a string containing the qualified version of 'name'.
|
2005-04-29 19:19:58 +08:00
|
|
|
std::string qualifyName(const std::string& name) const;
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// Adds a custom attribute to the type being described.
|
2005-04-29 19:19:58 +08:00
|
|
|
CustomAttributeProvider *addAttribute(const CustomAttribute* attrib);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// Sets the current type's ReaderWriter object.
|
2005-04-29 19:19:58 +08:00
|
|
|
void setReaderWriter(const ReaderWriter* rw);
|
2007-06-08 18:11:00 +08:00
|
|
|
|
|
|
|
/// Sets the current type's declaring file.
|
|
|
|
void setDeclaringFile(const std::string& file) const;
|
2005-09-28 22:18:31 +08:00
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
private:
|
2005-04-29 19:19:58 +08:00
|
|
|
struct PtrConstructor: ConstructorInfo
|
|
|
|
{
|
|
|
|
PtrConstructor(const Type* pt)
|
|
|
|
: ConstructorInfo(*pt, ParameterInfoList())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Value createInstance(ValueList& ) const { T* x = 0; return x; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ConstPtrConstructor: ConstructorInfo
|
|
|
|
{
|
|
|
|
ConstPtrConstructor(const Type* pt)
|
|
|
|
: ConstructorInfo(*pt, ParameterInfoList())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Value createInstance(ValueList& ) const { const T *x = 0; return x; }
|
|
|
|
};
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
void init();
|
2007-02-13 01:14:46 +08:00
|
|
|
void init_reference_types();
|
2005-04-29 19:19:58 +08:00
|
|
|
static std::string purify(const std::string& s);
|
|
|
|
static void split_qualified_name(const std::string& q, std::string& n, std::string& ns);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
typedef std::vector<MethodInfo* > TempMethodList;
|
|
|
|
TempMethodList _temp_methods;
|
2007-03-01 19:54:30 +08:00
|
|
|
TempMethodList _temp_protected_methods;
|
2005-04-29 19:19:58 +08:00
|
|
|
Type* _type;
|
2005-03-14 17:28:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// This reflector ought to be used to describe types that can be
|
|
|
|
/// created on the stack. Such types are for example int, double,
|
|
|
|
/// std::string, or other (possibly small) user-defined structs or
|
|
|
|
/// classes. The instance creator associated to types created through
|
|
|
|
/// this reflector will create Value objects whose internal type is T.
|
|
|
|
template<typename T>
|
2005-04-04 21:50:07 +08:00
|
|
|
struct ValueReflector: Reflector<T>
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
typedef ValueReflector<T> inherited;
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef ValueInstanceCreator<typename Reflector<T>::reflected_type> instance_creator_type;
|
2007-03-01 19:54:30 +08:00
|
|
|
typedef ProtectedConstructorInstanceCreator<typename Reflector<T>::reflected_type> invalid_instance_creator_type;
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
ValueReflector(const std::string& name, const std::string& ns)
|
2005-04-04 21:50:07 +08:00
|
|
|
: Reflector<T>(name, ns, false)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
ValueReflector(const std::string& qname)
|
2005-04-04 21:50:07 +08:00
|
|
|
: Reflector<T>(qname, false)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This reflector is to be used to describe abstract types that can't
|
2005-04-04 21:50:07 +08:00
|
|
|
/// be instantiated. For this reason a DummyInstanceCreator is used in
|
|
|
|
/// order to avoid compiler errors.
|
2005-03-14 17:28:31 +08:00
|
|
|
template<typename T>
|
2005-04-04 21:50:07 +08:00
|
|
|
struct AbstractObjectReflector: Reflector<T>
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
typedef AbstractObjectReflector<T> inherited;
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef DummyInstanceCreator<typename Reflector<T>::reflected_type> instance_creator_type;
|
2007-03-01 19:54:30 +08:00
|
|
|
typedef ProtectedConstructorInstanceCreator<typename Reflector<T>::reflected_type> invalid_instance_creator_type;
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
AbstractObjectReflector(const std::string& name, const std::string& ns)
|
2005-04-04 21:50:07 +08:00
|
|
|
: Reflector<T>(name, ns, true)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
AbstractObjectReflector(const std::string& qname)
|
2005-04-04 21:50:07 +08:00
|
|
|
: Reflector<T>(qname, true)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This reflector is to be used to describe types that ought to be
|
|
|
|
/// created on the heap. Such types are for example all classes derived
|
|
|
|
/// from osg::Referenced. The instance creator associated to types
|
|
|
|
/// created through this reflector will create Value objects whose
|
|
|
|
/// internal type is T*.
|
|
|
|
template<typename T>
|
2005-04-04 21:50:07 +08:00
|
|
|
struct ObjectReflector: Reflector<T>
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
typedef ObjectReflector<T> inherited;
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef ObjectInstanceCreator<typename Reflector<T>::reflected_type> instance_creator_type;
|
2007-03-01 19:54:30 +08:00
|
|
|
typedef ProtectedConstructorInstanceCreator<typename Reflector<T>::reflected_type> invalid_instance_creator_type;
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
ObjectReflector(const std::string& name, const std::string& ns)
|
2005-04-04 21:50:07 +08:00
|
|
|
: Reflector<T>(name, ns, false)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
ObjectReflector(const std::string& qname)
|
2005-04-04 21:50:07 +08:00
|
|
|
: Reflector<T>(qname, false)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// This reflector is a ValueReflector that should be used to define
|
|
|
|
/// types that can be read and written from/to streams using the <<
|
|
|
|
/// and >> operators. A StdReaderWriter is assigned by default.
|
|
|
|
template<typename T>
|
2005-04-04 21:50:07 +08:00
|
|
|
struct AtomicValueReflector: ValueReflector<T>
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
AtomicValueReflector(const std::string& name, const std::string& ns)
|
2005-04-04 21:50:07 +08:00
|
|
|
: ValueReflector<T>(name, ns)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
setReaderWriter(new StdReaderWriter<T>);
|
|
|
|
setComparator(new PartialOrderComparator<T>);
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
AtomicValueReflector(const std::string& qname)
|
2005-04-04 21:50:07 +08:00
|
|
|
: ValueReflector<T>(qname)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
setReaderWriter(new StdReaderWriter<T>);
|
|
|
|
setComparator(new PartialOrderComparator<T>);
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-09-01 20:52:15 +08:00
|
|
|
template<typename T>
|
|
|
|
struct WAtomicValueReflector: ValueReflector<T>
|
|
|
|
{
|
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2006-09-01 20:52:15 +08:00
|
|
|
WAtomicValueReflector(const std::string& name, const std::string& ns)
|
|
|
|
: ValueReflector<T>(name, ns)
|
|
|
|
{
|
|
|
|
setReaderWriter(new StdWReaderWriter<T>);
|
|
|
|
setComparator(new PartialOrderComparator<T>);
|
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
|
|
|
}
|
|
|
|
|
|
|
|
WAtomicValueReflector(const std::string& qname)
|
|
|
|
: ValueReflector<T>(qname)
|
|
|
|
{
|
|
|
|
setReaderWriter(new StdWReaderWriter<T>);
|
|
|
|
setComparator(new PartialOrderComparator<T>);
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
2006-09-01 20:52:15 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
/// This reflector is a ValueReflector that should be used to define
|
|
|
|
/// enumerations. It assigns an EnumReaderWriter by default.
|
|
|
|
template<typename T>
|
2005-04-04 21:50:07 +08:00
|
|
|
struct EnumReflector: ValueReflector<T>
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
typedef EnumReflector<T> inherited;
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
EnumReflector(const std::string& name, const std::string& ns)
|
2005-04-04 21:50:07 +08:00
|
|
|
: ValueReflector<T>(name, ns)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
setReaderWriter(new EnumReaderWriter<T>);
|
|
|
|
setComparator(new TotalOrderComparator<T>);
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
EnumReflector(const std::string& qname)
|
2005-04-04 21:50:07 +08:00
|
|
|
: ValueReflector<T>(qname)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
setReaderWriter(new EnumReaderWriter<T>);
|
|
|
|
setComparator(new TotalOrderComparator<T>);
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
2005-03-14 17:28:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// This class allows to define the means for reflecting STL containers
|
|
|
|
/// such as std::deque and std::vector.
|
|
|
|
template<typename T, typename VT>
|
2005-04-04 21:50:07 +08:00
|
|
|
struct StdVectorReflector: ValueReflector<T>
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
2005-04-29 19:19:58 +08:00
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
struct Getter: PropertyGetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(Value& instance, int i) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
return getInstance<T>(instance).at(i);
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(const Value& instance, int i) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
return getInstance<T>(instance).at(i);
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Setter: PropertySetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void set(Value& instance, int i, const Value& v) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
getInstance<T>(instance).at(i) = variant_cast<const typename T::value_type& >(v);
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Counter: PropertyCounter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual int count(const Value& instance) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
return static_cast<int>(getInstance<T>(instance).size());
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Adder: PropertyAdder
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void add(Value& instance, const Value& v) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
getInstance<T>(instance).push_back(variant_cast<const typename T::value_type& >(v));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
struct Remover: PropertyRemover
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void remove(Value& instance, int i) const
|
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-29 19:19:58 +08:00
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
ctr.erase(j);
|
|
|
|
}
|
2005-04-04 21:50:07 +08:00
|
|
|
};
|
|
|
|
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
struct Inserter: PropertyInserter
|
|
|
|
{
|
|
|
|
virtual void insert(Value& instance, int i, const Value& v) const
|
|
|
|
{
|
|
|
|
T& ctr = getInstance<T>(instance);
|
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
ctr.insert(j, variant_cast<const typename T::value_type& >(v));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
StdVectorReflector(const std::string& name): ValueReflector<T>(name)
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
|
|
|
PropertyInfo* pi = new PropertyInfo(typeof(T), typeof(typename T::value_type), "Item", 0, 0, 0, 0, 0, 0);
|
2005-04-04 21:50:07 +08:00
|
|
|
pi->addAttribute(new CustomPropertyGetAttribute(new Getter));
|
|
|
|
pi->addAttribute(new CustomPropertySetAttribute(new Setter));
|
|
|
|
pi->addAttribute(new CustomPropertyCountAttribute(new Counter));
|
|
|
|
pi->addAttribute(new CustomPropertyAddAttribute(new Adder));
|
|
|
|
pi->addAttribute(new CustomPropertyRemoveAttribute(new Remover));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
pi->addAttribute(new CustomPropertyInsertAttribute(new Inserter));
|
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
if (typeid(VT).before(typeid(typename T::value_type)) ||
|
|
|
|
typeid(typename T::value_type).before(typeid(VT)))
|
|
|
|
{
|
|
|
|
pi->addAttribute(new PropertyTypeAttribute(typeof(VT)));
|
|
|
|
}
|
|
|
|
|
|
|
|
this->addProperty(pi);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This class allows to define the means for reflecting STL containers
|
|
|
|
/// such as std::set and std::multiset.
|
|
|
|
template<typename T, typename VT>
|
|
|
|
struct StdSetReflector: ValueReflector<T>
|
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
struct Getter: PropertyGetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(Value& instance, int i) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-04 21:50:07 +08:00
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
return *j;
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(const Value& instance, int i) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
const T& ctr = getInstance<T>(instance);
|
2005-04-04 21:50:07 +08:00
|
|
|
typename T::const_iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
return *j;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Counter: PropertyCounter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual int count(const Value& instance) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
return static_cast<int>(getInstance<T>(instance).size());
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Adder: PropertyAdder
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void add(Value& instance, const Value& v) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
getInstance<T>(instance).insert(variant_cast<const typename T::value_type& >(v));
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
};
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
struct Remover: PropertyRemover
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void remove(Value& instance, int i) const
|
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-29 19:19:58 +08:00
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
ctr.erase(j);
|
|
|
|
}
|
2005-04-04 21:50:07 +08:00
|
|
|
};
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
StdSetReflector(const std::string& name): ValueReflector<T>(name)
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
|
|
|
PropertyInfo* pi = new PropertyInfo(typeof(T), typeof(typename T::value_type), "Item", 0, 0, 0, 0, 0, 0);
|
2005-04-04 21:50:07 +08:00
|
|
|
pi->addAttribute(new CustomPropertyGetAttribute(new Getter));
|
|
|
|
pi->addAttribute(new CustomPropertyCountAttribute(new Counter));
|
|
|
|
pi->addAttribute(new CustomPropertyAddAttribute(new Adder));
|
|
|
|
pi->addAttribute(new CustomPropertyRemoveAttribute(new Remover));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
if (typeid(VT).before(typeid(typename T::value_type)) ||
|
|
|
|
typeid(typename T::value_type).before(typeid(VT)))
|
|
|
|
{
|
|
|
|
pi->addAttribute(new PropertyTypeAttribute(typeof(VT)));
|
|
|
|
}
|
|
|
|
|
|
|
|
this->addProperty(pi);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This class allows to define the means for reflecting STL containers
|
|
|
|
/// that cannot be indexed directly, such as std::list.
|
|
|
|
template<typename T, typename VT>
|
|
|
|
struct StdListReflector: ValueReflector<T>
|
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
struct Getter: PropertyGetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(Value& instance, int i) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-04 21:50:07 +08:00
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
return *j;
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(const Value& instance, int i) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
const T& ctr = getInstance<T>(instance);
|
2005-04-04 21:50:07 +08:00
|
|
|
typename T::const_iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
return *j;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Setter: PropertySetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void set(Value& instance, int i, const Value& v) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-04 21:50:07 +08:00
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
2005-04-29 19:19:58 +08:00
|
|
|
*j = variant_cast<const typename T::value_type& >(v);
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Counter: PropertyCounter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual int count(const Value& instance) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
return static_cast<int>(getInstance<T>(instance).size());
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Adder: PropertyAdder
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void add(Value& instance, const Value& v) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
getInstance<T>(instance).push_back(variant_cast<const typename T::value_type& >(v));
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Remover: PropertyRemover
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void remove(Value& instance, int i) const
|
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-29 19:19:58 +08:00
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
ctr.erase(j);
|
|
|
|
}
|
2005-04-04 21:50:07 +08:00
|
|
|
};
|
|
|
|
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
struct Inserter: PropertyInserter
|
|
|
|
{
|
|
|
|
virtual void insert(Value& instance, int i, const Value& v) const
|
|
|
|
{
|
|
|
|
T& ctr = getInstance<T>(instance);
|
|
|
|
typename T::iterator j=ctr.begin();
|
|
|
|
std::advance(j, i);
|
|
|
|
ctr.insert(j, variant_cast<const typename T::value_type& >(v));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
StdListReflector(const std::string& name): ValueReflector<T>(name)
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
|
|
|
PropertyInfo* pi = new PropertyInfo(typeof(T), typeof(typename T::value_type), "Item", 0, 0, 0, 0, 0, 0);
|
2005-03-14 17:28:31 +08:00
|
|
|
pi->addAttribute(new CustomPropertyGetAttribute(new Getter));
|
|
|
|
pi->addAttribute(new CustomPropertySetAttribute(new Setter));
|
|
|
|
pi->addAttribute(new CustomPropertyCountAttribute(new Counter));
|
|
|
|
pi->addAttribute(new CustomPropertyAddAttribute(new Adder));
|
2005-04-04 21:50:07 +08:00
|
|
|
pi->addAttribute(new CustomPropertyRemoveAttribute(new Remover));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
pi->addAttribute(new CustomPropertyInsertAttribute(new Inserter));
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
if (typeid(VT).before(typeid(typename T::value_type)) ||
|
|
|
|
typeid(typename T::value_type).before(typeid(VT)))
|
|
|
|
{
|
|
|
|
pi->addAttribute(new PropertyTypeAttribute(typeof(VT)));
|
|
|
|
}
|
|
|
|
|
|
|
|
this->addProperty(pi);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This class allows to define the means for reflecting STL associative
|
|
|
|
/// containers which hold pairs of key+value, such as std::map.
|
|
|
|
template<typename T, typename IT, typename VT>
|
|
|
|
struct StdMapReflector: ValueReflector<T>
|
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
typedef typename T::iterator iterator;
|
2005-03-14 17:28:31 +08:00
|
|
|
typedef typename T::const_iterator const_iterator;
|
|
|
|
typedef typename T::key_type key_type;
|
|
|
|
typedef typename T::mapped_type mapped_type;
|
|
|
|
|
|
|
|
struct Getter: PropertyGetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(Value& instance, const ValueList& indices) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-04-29 19:19:58 +08:00
|
|
|
const key_type& key = variant_cast<const key_type& >(indices.front());
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
iterator i = ctr.find(key);
|
|
|
|
if (i == ctr.end()) return Value();
|
|
|
|
return i->second;
|
|
|
|
}
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(const Value& instance, const ValueList& indices) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
const T& ctr = getInstance<T>(instance);
|
2005-04-29 19:19:58 +08:00
|
|
|
const key_type& key = variant_cast<const key_type& >(indices.front());
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
const_iterator i = ctr.find(key);
|
|
|
|
if (i == ctr.end()) return Value();
|
|
|
|
return i->second;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Setter: PropertySetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void set(Value& instance, const ValueList& indices, const Value& v) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
getInstance<T>(instance).insert(std::make_pair(variant_cast<const key_type& >(indices.front()),
|
|
|
|
variant_cast<const mapped_type& >(v)));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Indexer: IndexInfo
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
ParameterInfoList _params;
|
|
|
|
const Type& _itype;
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
Indexer()
|
2005-04-29 19:19:58 +08:00
|
|
|
: _itype(typeof(IT))
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_params.push_back(new ParameterInfo("key", typeof(key_type), 0, ParameterInfo::IN));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~Indexer()
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
delete _params.front();
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual const ParameterInfoList& getIndexParameters() const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
return _params;
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual void getIndexValueSet(int /*whichindex*/, const Value& instance, ValueList& values) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
const T& ctr = getInstance<T>(instance);
|
2005-03-14 17:28:31 +08:00
|
|
|
for (const_iterator i=ctr.begin();
|
|
|
|
i!=ctr.end();
|
|
|
|
++i)
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
values.push_back(Value(i->first).convertTo(_itype));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
struct Remover: PropertyRemover
|
|
|
|
{
|
|
|
|
virtual void remove(Value& instance, ValueList& values) const
|
|
|
|
{
|
|
|
|
getInstance<T>(instance).erase(getInstance<key_type>(values.front()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
StdMapReflector(const std::string& name): ValueReflector<T>(name)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
|
|
|
PropertyInfo* pi = new PropertyInfo(typeof(T), typeof(typename T::mapped_type), "Item", 0, 0, 0);
|
2005-03-14 17:28:31 +08:00
|
|
|
pi->addAttribute(new CustomPropertyGetAttribute(new Getter));
|
|
|
|
pi->addAttribute(new CustomPropertySetAttribute(new Setter));
|
|
|
|
pi->addAttribute(new CustomIndexAttribute(new Indexer));
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
pi->addAttribute(new CustomPropertyRemoveAttribute(new Remover));
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
if (typeid(VT).before(typeid(typename T::mapped_type)) ||
|
|
|
|
typeid(typename T::mapped_type).before(typeid(VT)))
|
|
|
|
{
|
|
|
|
pi->addAttribute(new PropertyTypeAttribute(typeof(VT)));
|
|
|
|
}
|
|
|
|
|
|
|
|
this->addProperty(pi);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T, typename PT1, typename PT2>
|
|
|
|
struct StdPairReflector: ValueReflector<T>
|
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
typedef typename ValueReflector<T>::instance_creator_type instance_creator_type;
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
struct Accessor: PropertyGetter, PropertySetter
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
Accessor(int i): _i(i) {}
|
From David Callu:
"
the main problem is the wrapper generation:
The PropertyInfo class use MethodInfo class to access to the value.
When the property are define with the I_Property* macro,
the MethodInfo use by the property to have access to the value
are instancied in the I_Property* macro, but there
are already instantied by the I_Method* macro before
secondary problem:
- the function used by the property could no be customized
in the genwrapper.conf file
- an array property can't insert a value
- the std::map reflector (and indexedProperty in general) haven't remove method
- about the help in wrapper ... why not ...
solution :
To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro
old macro :
#define I_Method0(ret, fn) (\
params.clear(),\
addMethod(new osgIntrospection::TypedMethodIn
fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params)))
new macro :
#define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \
params.clear(); \
osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature)
the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use
so for I_Property macro :
old macro :
#define I_PropertyWithReturnType(t, n, r) \
cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \
I_Method0(t, get##n), \
I_Method1(r, set##n, IN, t, value)))
new macro:
#define I_SimpleProperty(t, n, get, set) \
get, \
set))
The genwrapper has been modified in this way.
The method signature is define by the prototype of the method
For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature
solution for secondary problem:
The genwrapper accept new tokens in the configuration to custumize the property.
The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined
The PropertyRemover has been added to the StdMapReflector
The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class
modification:
I have modify the genwrapper files
Configuration.cpp Configuration.h add some tokens to custumize the property
Doxyfile.template add the comment in the output xml
genwrapper.conf customize some property in osg::Geometry
RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml)
TypeRegister.cpp TypeRegister.h optimize the property detection
TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc
WrapperGenerator.h WrapperGenerator.cpp modify the output
I also modify the fallowing osgIntrospection files:
include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class
include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class
add access function for the two new variables (_briefHelp and _detailedHelp)
modify the constructor to define the two new variables (_briefHelp and _detailedHelp)
include/osgIntrospection/ReflectionMacro remove unused I_Property* macro
modify all I_Method macro to accept the help string
modify all I_Method macro to define a MethodInfo signature
include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector
add the PropertyRemover in the StdMapReflector
include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter
include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter
include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class
"
2006-10-17 23:17:06 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(const Value& instance) const
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
switch (_i)
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
case 0: return getInstance<T>(instance).first;
|
|
|
|
case 1: return getInstance<T>(instance).second;
|
2005-04-04 21:50:07 +08:00
|
|
|
default: return Value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
virtual Value get(Value& instance) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
switch (_i)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
case 0: return getInstance<T>(instance).first;
|
|
|
|
case 1: return getInstance<T>(instance).second;
|
2005-03-14 17:28:31 +08:00
|
|
|
default: return Value();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-28 22:18:31 +08:00
|
|
|
virtual void set(Value& instance, const Value& v) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-09-28 22:18:31 +08:00
|
|
|
T& ctr = getInstance<T>(instance);
|
2005-03-14 17:28:31 +08:00
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
switch (_i)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:22:15 +08:00
|
|
|
case 0: ctr.first = variant_cast<const typename T::first_type& >(v); break;
|
|
|
|
case 1: ctr.second = variant_cast<const typename T::second_type& >(v); break;
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
int _i;
|
2005-03-14 17:28:31 +08:00
|
|
|
};
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
StdPairReflector(const std::string& name): ValueReflector<T>(name)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-05-16 04:32:10 +08:00
|
|
|
addConstructor(new TypedConstructorInfo0<T, instance_creator_type>(ParameterInfoList()));
|
2005-04-29 19:19:58 +08:00
|
|
|
|
|
|
|
PropertyInfo* pi1 = new PropertyInfo(typeof(T), typeof(typename T::first_type), "first", 0, 0);
|
2005-03-14 17:28:31 +08:00
|
|
|
pi1->addAttribute(new CustomPropertyGetAttribute(new Accessor(0)));
|
|
|
|
pi1->addAttribute(new CustomPropertySetAttribute(new Accessor(0)));
|
|
|
|
|
|
|
|
if (typeid(PT1).before(typeid(typename T::first_type)) ||
|
|
|
|
typeid(typename T::first_type).before(typeid(PT1)))
|
|
|
|
pi1->addAttribute(new PropertyTypeAttribute(typeof(PT1)));
|
|
|
|
|
|
|
|
this->addProperty(pi1);
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
PropertyInfo* pi2 = new PropertyInfo(typeof(T), typeof(typename T::second_type), "second", 0, 0);
|
2005-03-14 17:28:31 +08:00
|
|
|
pi2->addAttribute(new CustomPropertyGetAttribute(new Accessor(1)));
|
|
|
|
pi2->addAttribute(new CustomPropertySetAttribute(new Accessor(1)));
|
|
|
|
|
|
|
|
if (typeid(PT2).before(typeid(typename T::second_type)) ||
|
|
|
|
typeid(typename T::second_type).before(typeid(PT2)))
|
|
|
|
pi2->addAttribute(new PropertyTypeAttribute(typeof(PT2)));
|
|
|
|
|
|
|
|
this->addProperty(pi2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// TEMPLATE METHODS
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
Reflector<T>::Reflector(const std::string& name, const std::string& ns, bool abstract)
|
2007-02-13 01:14:46 +08:00
|
|
|
: _type(Reflection::getOrRegisterType(extended_typeid<T>(), true))
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
if (!_type->_name.empty())
|
|
|
|
_type->_aliases.push_back(ns.empty()? purify(name): purify(ns+"::"+name));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_type->_name = purify(name);
|
|
|
|
_type->_namespace = purify(ns);
|
|
|
|
}
|
|
|
|
_type->_is_abstract = abstract;
|
2005-04-04 21:50:07 +08:00
|
|
|
init();
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
Reflector<T>::Reflector(const std::string& qname, bool abstract)
|
2007-02-13 01:14:46 +08:00
|
|
|
: _type(Reflection::getOrRegisterType(extended_typeid<T>(), true))
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
if (!_type->_name.empty())
|
|
|
|
_type->_aliases.push_back(purify(qname));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
split_qualified_name(purify(qname), _type->_name, _type->_namespace);
|
|
|
|
}
|
|
|
|
_type->_is_abstract = abstract;
|
2005-03-14 17:28:31 +08:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void Reflector<T>::init()
|
|
|
|
{
|
|
|
|
// pointer type
|
2005-04-29 19:19:58 +08:00
|
|
|
if (!_type->_pointed_type)
|
|
|
|
{
|
2007-02-13 01:14:46 +08:00
|
|
|
Type* ptype = Reflection::getOrRegisterType(extended_typeid<T*>(), true);
|
2005-04-29 19:19:58 +08:00
|
|
|
ptype->_name = _type->_name;
|
|
|
|
ptype->_namespace = _type->_namespace;
|
|
|
|
ptype->_pointed_type = _type;
|
|
|
|
ptype->_is_defined = true;
|
|
|
|
ptype->_cons.push_back(new PtrConstructor(ptype));
|
|
|
|
ptype->_rw = new PtrReaderWriter<T*>();
|
|
|
|
ptype->_cmp = new TotalOrderComparator<T*>();
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// const pointer type
|
2005-04-29 19:19:58 +08:00
|
|
|
if (!_type->_pointed_type || !_type->_is_const)
|
|
|
|
{
|
2007-02-13 01:14:46 +08:00
|
|
|
Type* cptype = Reflection::getOrRegisterType(extended_typeid<const T*>(), true);
|
2005-04-29 19:19:58 +08:00
|
|
|
cptype->_name = _type->_name;
|
|
|
|
cptype->_namespace = _type->_namespace;
|
|
|
|
cptype->_is_const = true;
|
|
|
|
cptype->_pointed_type = _type;
|
|
|
|
cptype->_is_defined = true;
|
|
|
|
cptype->_cons.push_back(new ConstPtrConstructor(cptype));
|
|
|
|
cptype->_rw = new PtrReaderWriter<const T*>();
|
|
|
|
cptype->_cmp = new TotalOrderComparator<const T*>();
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2007-02-13 01:14:46 +08:00
|
|
|
init_reference_types();
|
|
|
|
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_is_defined = true;
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
2005-04-04 21:50:07 +08:00
|
|
|
|
2007-02-13 01:14:46 +08:00
|
|
|
template<typename T>
|
|
|
|
void Reflector<T>::init_reference_types()
|
|
|
|
{
|
|
|
|
// reference type
|
|
|
|
if (!_type->_referenced_type)
|
|
|
|
{
|
|
|
|
Type* ptype = Reflection::getOrRegisterType(extended_typeid<T&>(), true);
|
|
|
|
ptype->_name = _type->_name;
|
|
|
|
ptype->_namespace = _type->_namespace;
|
|
|
|
ptype->_referenced_type = _type;
|
|
|
|
ptype->_is_defined = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// const reference type
|
|
|
|
if (!_type->_referenced_type || !_type->_is_const)
|
|
|
|
{
|
|
|
|
Type* cptype = Reflection::getOrRegisterType(extended_typeid<const T&>(), true);
|
|
|
|
cptype->_name = _type->_name;
|
|
|
|
cptype->_namespace = _type->_namespace;
|
|
|
|
cptype->_is_const = true;
|
|
|
|
cptype->_referenced_type = _type;
|
|
|
|
cptype->_is_defined = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Reflector<void>::init_reference_types();
|
|
|
|
|
2005-04-04 21:50:07 +08:00
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
std::string Reflector<T>::purify(const std::string& s)
|
|
|
|
{
|
|
|
|
std::string r(s);
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
std::string::size_type p = r.find(" COMMA ");
|
|
|
|
if (p == std::string::npos) break;
|
|
|
|
r.replace(p, 7, ", ");
|
|
|
|
};
|
|
|
|
return r;
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
void Reflector<T>::split_qualified_name(const std::string& q, std::string& n, std::string& ns)
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
int templ = 0;
|
|
|
|
std::string::size_type split_point = std::string::npos;
|
|
|
|
std::string::size_type j = 0;
|
|
|
|
for (std::string::const_iterator i=q.begin(); i!=q.end(); ++i, ++j)
|
|
|
|
{
|
|
|
|
if (*i == '<') ++templ;
|
|
|
|
if (*i == '>') --templ;
|
|
|
|
if (templ == 0)
|
|
|
|
{
|
|
|
|
if (*i == ':' && (i+1)!=q.end() && *(i+1) == ':')
|
|
|
|
split_point = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (split_point == std::string::npos)
|
|
|
|
{
|
|
|
|
ns.clear();
|
|
|
|
n = q;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = q.substr(split_point+2);
|
|
|
|
ns = q.substr(0, split_point);
|
|
|
|
}
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
2005-03-14 17:28:31 +08:00
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
void Reflector<T>::addBaseType(const Type& type)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_base.push_back(&type);
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
PropertyInfo* Reflector<T>::addProperty(PropertyInfo* pi)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_props.push_back(pi);
|
2005-03-14 17:28:31 +08:00
|
|
|
return pi;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
MethodInfo* Reflector<T>::addMethod(MethodInfo* mi)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
for (TempMethodList::iterator i=_temp_methods.begin(); i!=_temp_methods.end(); ++i)
|
|
|
|
{
|
|
|
|
if (mi->overrides(*i))
|
|
|
|
return *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
_temp_methods.push_back(mi);
|
|
|
|
_type->_methods.push_back(mi);
|
2005-03-14 17:28:31 +08:00
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
2007-03-01 19:54:30 +08:00
|
|
|
template<typename T>
|
|
|
|
MethodInfo* Reflector<T>::addProtectedMethod(MethodInfo* mi)
|
|
|
|
{
|
|
|
|
for (TempMethodList::iterator i=_temp_protected_methods.begin(); i!=_temp_protected_methods.end(); ++i)
|
|
|
|
{
|
|
|
|
if (mi->overrides(*i))
|
|
|
|
return *i;
|
|
|
|
}
|
|
|
|
|
|
|
|
_temp_protected_methods.push_back(mi);
|
|
|
|
_type->_protected_methods.push_back(mi);
|
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
void Reflector<T>::addEnumLabel(int v, const std::string& label, bool strip_namespace)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
if (strip_namespace)
|
|
|
|
{
|
|
|
|
std::string::size_type p = label.rfind("::");
|
|
|
|
if (p != std::string::npos)
|
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_labels.insert(std::make_pair(v, label.substr(p+2)));
|
2005-03-14 17:28:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_labels.insert(std::make_pair(v, label));
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
ConstructorInfo* Reflector<T>::addConstructor(ConstructorInfo* ci)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_cons.push_back(ci);
|
2005-04-04 21:50:07 +08:00
|
|
|
return ci;
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
2007-03-01 19:54:30 +08:00
|
|
|
template<typename T>
|
|
|
|
ConstructorInfo* Reflector<T>::addProtectedConstructor(ConstructorInfo* ci)
|
|
|
|
{
|
|
|
|
_type->_protected_cons.push_back(ci);
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
2005-03-14 17:28:31 +08:00
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
std::string Reflector<T>::qualifyName(const std::string& name) const
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
|
|
|
std::string s;
|
2005-04-29 19:19:58 +08:00
|
|
|
if (!_type->_namespace.empty())
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
s.append(_type->_namespace);
|
2005-03-14 17:28:31 +08:00
|
|
|
s.append("::");
|
|
|
|
}
|
2005-04-29 19:19:58 +08:00
|
|
|
if (!_type->_name.empty())
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
s.append(_type->_name);
|
2005-03-14 17:28:31 +08:00
|
|
|
s.append("::");
|
|
|
|
}
|
|
|
|
s.append(name);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
CustomAttributeProvider *Reflector<T>::addAttribute(const CustomAttribute* attrib)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
return _type->addAttribute(attrib);
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
void Reflector<T>::setReaderWriter(const ReaderWriter* rw)
|
2005-03-14 17:28:31 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_rw = rw;
|
2005-03-14 17:28:31 +08:00
|
|
|
}
|
2005-04-04 21:50:07 +08:00
|
|
|
|
|
|
|
template<typename T>
|
2005-04-29 19:19:58 +08:00
|
|
|
void Reflector<T>::setComparator(const Comparator* cmp)
|
2005-04-04 21:50:07 +08:00
|
|
|
{
|
2005-04-29 19:19:58 +08:00
|
|
|
_type->_cmp = cmp;
|
2005-04-04 21:50:07 +08:00
|
|
|
}
|
2004-12-09 13:28:20 +08:00
|
|
|
|
2007-06-08 18:11:00 +08:00
|
|
|
template<typename T>
|
|
|
|
void Reflector<T>::setDeclaringFile(const std::string& file) const
|
|
|
|
{
|
|
|
|
_type->_declaringFile = file;
|
|
|
|
}
|
|
|
|
|
2004-12-09 13:28:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2005-05-16 04:32:10 +08:00
|
|
|
|