Hi!
Some osgPython users reported me a bug in output parameters ( for example
osg::Quat::getRotate(...) function).
I did a C++ test to check if it was a osgIntrospection bug or a osgPython
bug. I think it is a osgIntrospection bug, but I haven't the knowledge to
fix this.
I attach a C++ test file.
Greets,
Miguel
// g++ -Wl,-E -fno-strict-aliasing -g -O2 -W -Wall -fPIC -losg -losgDB -losgIntrospection -o test test.cpp
#include <iostream>
#include <osgIntrospection/Reflection>
#include <osgIntrospection/MethodInfo>
#include <osgIntrospection/Type>
#include <osgDB/DynamicLibrary>
#include <osg/ref_ptr>
// borrowed from osgDB...
std::string createLibraryNameForWrapper(const std::string& ext)
{
#if defined(WIN32)
// !! recheck evolving Cygwin DLL extension naming protocols !! NHV
#ifdef __CYGWIN__
return "cygosgwrapper_"+ext+".dll";
#elif defined(__MINGW32__)
return "libosgwrapper_"+ext+".dll";
#else
#ifdef _DEBUG
return "osgwrapper_"+ext+"d.dll";
#else
return "osgwrapper_"+ext+".dll";
#endif
#endif
#elif macintosh
return "osgwrapper_"+ext;
#elif defined(__hpux__)
// why don't we use PLUGIN_EXT from the makefiles here?
return "osgwrapper_"+ext+".sl";
#else
return "osgwrapper_"+ext+".so";
#endif
}
osgDB::DynamicLibrary *loadWrapper(const std::string &name)
{
std::cout << "loading ... " << name << std::endl;
return osgDB::DynamicLibrary::loadLibrary(
createLibraryNameForWrapper(name)
);
}
int main()
{
osg::ref_ptr<osgDB::DynamicLibrary> osg_lib = loadWrapper("osg");
osgIntrospection::ValueList vlquat;
osgIntrospection::ValueList vlvec3;
osgIntrospection::ValueList vlcall;
const osgIntrospection::Type &quattype = osgIntrospection::Reflection::getType("osg::Quat");
const osgIntrospection::Type &vec3type = osgIntrospection::Reflection::getType("osg::Vec3");
//quat = osg.Quat();
osgIntrospection::Value quat = quattype.createInstance(vlquat);
//axis = osg.Vec3(10,10,10);
osgIntrospection::Value v = osgIntrospection::Value(10.0f);
vlvec3.push_back(v);
vlvec3.push_back(v);
vlvec3.push_back(v);
osgIntrospection::Value axis = vec3type.createInstance(vlvec3);
//angle = 5
osgIntrospection::Value angle = osgIntrospection::Value(5.0);
//quat.getRotate(angle,axis);
vlcall.push_back(angle);
vlcall.push_back(axis);
const osgIntrospection::MethodInfo *m = quattype.getCompatibleMethod("getRotate", vlcall, true);
if (m){
osgIntrospection::ValueList::const_iterator it;
std::string str;
// Print to screen some info
str = "Calling to: " + quattype.getQualifiedName() + "::getRotate (";
for (it=vlcall.begin(); it != vlcall.end(); ++it){
str += it->getType().getQualifiedName() + ", ";
}
str += "\b\b)";
std::cout << str << std::endl;
//Call Method
osgIntrospection::Value v = m->invoke(quat, vlcall);
// Print to screen some info
str = "Return from: " + quattype.getQualifiedName() + "::getRotate (";
for (it=vlcall.begin(); it != vlcall.end(); ++it){
str += it->getType().getQualifiedName() + ", ";
}
str += "\b\b)";
std::cout << str << std::endl;
// Print Original Values
std::cout << std::endl << "Values: " << std::endl;
std::cout << " - angle = " << angle.toString() << std::endl;
std::cout << " - axis = " << axis.toString() << std::endl;
}
else{
osgIntrospection::ValueList::const_iterator it;
std::string error = "Method " + quattype.getQualifiedName() + "::getRotate (";
for (it=vlcall.begin(); it != vlcall.end(); ++it){
error += it->getType().getQualifiedName() + ", ";
}
error += ") not found.";
std::cerr << "Error: " << error << std::endl;
}
return 0;
}
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/