From Paul Obermeier, "Please find enclosed some changed OSG header files.

The changes are more or less just beautifications
(when looked at them from the C++ view), but make
wrapping OSG with SWIG easier.
I have tested the changes with both 2.8.1-rc4 and the
current head and would appreciate to incorporate the
changes in both branches.

Here is a description of the changes:

osg/BoundingSphere:
   Use the following typedef (like used in BoundingBox)
       typedef typename VT::value_type value_type;
   instead of
       typedef typename vec_type::value_type value_type;

   SWIG reports errors on the latter construct.
   Also makes it consistent with BoundingBox.


osg/Vec4ub:
   Consistent use of "value_type" throughout the file.


osg/Vec?b:
   Consistent use of "value_type" throughout the files.

   Also changed
       typedef char value_type;
   to
       typedef signed char value_type;

   In the case of a simple "char", SWIG assumes a string.
   Using "signed char" instead of "char" does not change
   the behaviour of the class."
This commit is contained in:
Robert Osfield
2009-05-18 14:53:11 +00:00
parent d4ec341573
commit 0c345e76d4
9 changed files with 58 additions and 58 deletions

View File

@@ -35,7 +35,7 @@ class BoundingSphereImpl
{
public:
typedef VT vec_type;
typedef typename vec_type::value_type value_type;
typedef typename VT::value_type value_type;
vec_type _center;
value_type _radius;

View File

@@ -29,7 +29,7 @@ class Vec2b
// Methods are defined here so that they are implicitly inlined
/** Type of Vec class.*/
typedef char value_type;
typedef signed char value_type;
/** Number of vector components. */
enum { num_components = 2 };
@@ -39,7 +39,7 @@ class Vec2b
Vec2b() { _v[0]=0; _v[1]=0; }
Vec2b(char r, char g)
Vec2b(value_type r, value_type g)
{
_v[0]=r; _v[1]=g;
}
@@ -94,8 +94,8 @@ class Vec2b
/** Unary multiply by scalar. */
inline Vec2b& operator *= (float rhs)
{
_v[0]=(char)((float)_v[0]*rhs);
_v[1]=(char)((float)_v[1]*rhs);
_v[0]=(value_type)((float)_v[0]*rhs);
_v[1]=(value_type)((float)_v[1]*rhs);
return *this;
}

View File

@@ -27,7 +27,7 @@ class Vec3b
public:
/** Type of Vec class.*/
typedef char value_type;
typedef signed char value_type;
/** Number of vector components. */
enum { num_components = 3 };
@@ -94,9 +94,9 @@ class Vec3b
/** Unary multiply by scalar. */
inline Vec3b& operator *= (float rhs)
{
_v[0]=(char)((float)_v[0]*rhs);
_v[1]=(char)((float)_v[1]*rhs);
_v[2]=(char)((float)_v[2]*rhs);
_v[0]=(value_type)((float)_v[0]*rhs);
_v[1]=(value_type)((float)_v[1]*rhs);
_v[2]=(value_type)((float)_v[2]*rhs);
return *this;
}

View File

@@ -27,7 +27,7 @@ class Vec4b
public:
/** Type of Vec class.*/
typedef char value_type;
typedef signed char value_type;
/** Number of vector components. */
enum { num_components = 4 };
@@ -101,10 +101,10 @@ class Vec4b
/** Unary multiply by scalar. */
inline Vec4b& operator *= (float rhs)
{
_v[0]=(char)((float)_v[0]*rhs);
_v[1]=(char)((float)_v[1]*rhs);
_v[2]=(char)((float)_v[2]*rhs);
_v[3]=(char)((float)_v[3]*rhs);
_v[0]=(value_type)((float)_v[0]*rhs);
_v[1]=(value_type)((float)_v[1]*rhs);
_v[2]=(value_type)((float)_v[2]*rhs);
_v[3]=(value_type)((float)_v[3]*rhs);
return *this;
}

View File

@@ -62,26 +62,26 @@ class Vec4ub
else return (_v[3]<v._v[3]);
}
inline unsigned char* ptr() { return _v; }
inline const unsigned char* ptr() const { return _v; }
inline value_type* ptr() { return _v; }
inline const value_type* ptr() const { return _v; }
inline void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
inline void set(value_type r, value_type g, value_type b, value_type a)
{
_v[0]=r; _v[1]=g; _v[2]=b; _v[3]=a;
}
inline unsigned char& operator [] (unsigned int i) { return _v[i]; }
inline unsigned char operator [] (unsigned int i) const { return _v[i]; }
inline value_type& operator [] (unsigned int i) { return _v[i]; }
inline value_type operator [] (unsigned int i) const { return _v[i]; }
inline unsigned char& r() { return _v[0]; }
inline unsigned char& g() { return _v[1]; }
inline unsigned char& b() { return _v[2]; }
inline unsigned char& a() { return _v[3]; }
inline value_type& r() { return _v[0]; }
inline value_type& g() { return _v[1]; }
inline value_type& b() { return _v[2]; }
inline value_type& a() { return _v[3]; }
inline unsigned char r() const { return _v[0]; }
inline unsigned char g() const { return _v[1]; }
inline unsigned char b() const { return _v[2]; }
inline unsigned char a() const { return _v[3]; }
inline value_type r() const { return _v[0]; }
inline value_type g() const { return _v[1]; }
inline value_type b() const { return _v[2]; }
inline value_type a() const { return _v[3]; }
/** Multiply by scalar. */
inline Vec4ub operator * (float rhs) const
@@ -94,10 +94,10 @@ class Vec4ub
/** Unary multiply by scalar. */
inline Vec4ub& operator *= (float rhs)
{
_v[0]=(unsigned char)((float)_v[0]*rhs);
_v[1]=(unsigned char)((float)_v[1]*rhs);
_v[2]=(unsigned char)((float)_v[2]*rhs);
_v[3]=(unsigned char)((float)_v[3]*rhs);
_v[0]=(value_type)((float)_v[0]*rhs);
_v[1]=(value_type)((float)_v[1]*rhs);
_v[2]=(value_type)((float)_v[2]*rhs);
_v[3]=(value_type)((float)_v[3]*rhs);
return *this;
}

View File

@@ -22,7 +22,7 @@
#include <osg/io_utils>
TYPE_NAME_ALIAS(char, osg::Vec2b::value_type)
TYPE_NAME_ALIAS(signed char, osg::Vec2b::value_type)
BEGIN_VALUE_REFLECTOR(osg::Vec2b)
I_ReaderWriter(osgIntrospection::StdReaderWriter<reflected_type>); // user-defined
@@ -31,8 +31,8 @@ BEGIN_VALUE_REFLECTOR(osg::Vec2b)
I_Constructor0(____Vec2b,
"",
"");
I_Constructor2(IN, char, r, IN, char, g,
____Vec2b__char__char,
I_Constructor2(IN, osg::Vec2b::value_type, r, IN, osg::Vec2b::value_type, g,
____Vec2b__value_type__value_type,
"",
"");
I_Method0(osg::Vec2b::value_type *, ptr,

View File

@@ -22,7 +22,7 @@
#include <osg/io_utils>
TYPE_NAME_ALIAS(char, osg::Vec3b::value_type)
TYPE_NAME_ALIAS(signed char, osg::Vec3b::value_type)
BEGIN_VALUE_REFLECTOR(osg::Vec3b)
I_ReaderWriter(osgIntrospection::StdReaderWriter<reflected_type>); // user-defined

View File

@@ -22,7 +22,7 @@
#include <osg/io_utils>
TYPE_NAME_ALIAS(char, osg::Vec4b::value_type)
TYPE_NAME_ALIAS(signed char, osg::Vec4b::value_type)
BEGIN_VALUE_REFLECTOR(osg::Vec4b)
I_ReaderWriter(osgIntrospection::StdReaderWriter<reflected_type>); // user-defined

View File

@@ -35,59 +35,59 @@ BEGIN_VALUE_REFLECTOR(osg::Vec4ub)
____Vec4ub__value_type__value_type__value_type__value_type,
"",
"");
I_Method0(unsigned char *, ptr,
I_Method0(osg::Vec4ub::value_type *, ptr,
Properties::NON_VIRTUAL,
__unsigned_char_P1__ptr,
__value_type_P1__ptr,
"",
"");
I_Method0(const unsigned char *, ptr,
I_Method0(const osg::Vec4ub::value_type *, ptr,
Properties::NON_VIRTUAL,
__C5_unsigned_char_P1__ptr,
__C5_value_type_P1__ptr,
"",
"");
I_Method4(void, set, IN, unsigned char, r, IN, unsigned char, g, IN, unsigned char, b, IN, unsigned char, a,
I_Method4(void, set, IN, osg::Vec4ub::value_type, r, IN, osg::Vec4ub::value_type, g, IN, osg::Vec4ub::value_type, b, IN, osg::Vec4ub::value_type, a,
Properties::NON_VIRTUAL,
__void__set__unsigned_char__unsigned_char__unsigned_char__unsigned_char,
__void__set__value_type__value_type__value_type__value_type,
"",
"");
I_Method0(unsigned char &, r,
I_Method0(osg::Vec4ub::value_type &, r,
Properties::NON_VIRTUAL,
__unsigned_char_R1__r,
__value_type_R1__r,
"",
"");
I_Method0(unsigned char &, g,
I_Method0(osg::Vec4ub::value_type &, g,
Properties::NON_VIRTUAL,
__unsigned_char_R1__g,
__value_type_R1__g,
"",
"");
I_Method0(unsigned char &, b,
I_Method0(osg::Vec4ub::value_type &, b,
Properties::NON_VIRTUAL,
__unsigned_char_R1__b,
__value_type_R1__b,
"",
"");
I_Method0(unsigned char &, a,
I_Method0(osg::Vec4ub::value_type &, a,
Properties::NON_VIRTUAL,
__unsigned_char_R1__a,
__value_type_R1__a,
"",
"");
I_Method0(unsigned char, r,
I_Method0(osg::Vec4ub::value_type, r,
Properties::NON_VIRTUAL,
__unsigned_char__r,
__value_type__r,
"",
"");
I_Method0(unsigned char, g,
I_Method0(osg::Vec4ub::value_type, g,
Properties::NON_VIRTUAL,
__unsigned_char__g,
__value_type__g,
"",
"");
I_Method0(unsigned char, b,
I_Method0(osg::Vec4ub::value_type, b,
Properties::NON_VIRTUAL,
__unsigned_char__b,
__value_type__b,
"",
"");
I_Method0(unsigned char, a,
I_Method0(osg::Vec4ub::value_type, a,
Properties::NON_VIRTUAL,
__unsigned_char__a,
__value_type__a,
"",
"");
END_REFLECTOR