Selaa lähdekoodia

Port linmath classes to the new extension system

rdb 15 vuotta sitten
vanhempi
sitoutus
c32b599370
55 muutettua tiedostoa jossa 1480 lisäystä ja 1200 poistoa
  1. 13 9
      panda/src/linmath/Sources.pp
  2. 73 0
      panda/src/linmath/lmatrix3_ext_src.I
  3. 0 13
      panda/src/linmath/lmatrix3_src.I
  4. 0 51
      panda/src/linmath/lmatrix3_src.cxx
  5. 5 11
      panda/src/linmath/lmatrix3_src.h
  6. 82 0
      panda/src/linmath/lmatrix4_ext_src.I
  7. 0 13
      panda/src/linmath/lmatrix4_src.I
  8. 0 60
      panda/src/linmath/lmatrix4_src.cxx
  9. 5 11
      panda/src/linmath/lmatrix4_src.h
  10. 23 0
      panda/src/linmath/lmatrix_ext.I
  11. 22 0
      panda/src/linmath/lpoint2_ext.I
  12. 72 0
      panda/src/linmath/lpoint2_ext_src.I
  13. 0 12
      panda/src/linmath/lpoint2_src.I
  14. 0 49
      panda/src/linmath/lpoint2_src.cxx
  15. 3 7
      panda/src/linmath/lpoint2_src.h
  16. 22 0
      panda/src/linmath/lpoint3_ext.I
  17. 81 0
      panda/src/linmath/lpoint3_ext_src.I
  18. 0 11
      panda/src/linmath/lpoint3_src.I
  19. 0 57
      panda/src/linmath/lpoint3_src.cxx
  20. 3 7
      panda/src/linmath/lpoint3_src.h
  21. 22 0
      panda/src/linmath/lpoint4_ext.I
  22. 95 0
      panda/src/linmath/lpoint4_ext_src.I
  23. 0 11
      panda/src/linmath/lpoint4_src.I
  24. 0 71
      panda/src/linmath/lpoint4_src.cxx
  25. 3 7
      panda/src/linmath/lpoint4_src.h
  26. 22 0
      panda/src/linmath/lvecBase2_ext.I
  27. 175 0
      panda/src/linmath/lvecBase2_ext_src.I
  28. 0 27
      panda/src/linmath/lvecBase2_src.I
  29. 1 143
      panda/src/linmath/lvecBase2_src.cxx
  30. 5 11
      panda/src/linmath/lvecBase2_src.h
  31. 22 0
      panda/src/linmath/lvecBase3_ext.I
  32. 180 0
      panda/src/linmath/lvecBase3_ext_src.I
  33. 0 29
      panda/src/linmath/lvecBase3_src.I
  34. 1 147
      panda/src/linmath/lvecBase3_src.cxx
  35. 5 11
      panda/src/linmath/lvecBase3_src.h
  36. 22 0
      panda/src/linmath/lvecBase4_ext.I
  37. 194 0
      panda/src/linmath/lvecBase4_ext_src.I
  38. 0 29
      panda/src/linmath/lvecBase4_src.I
  39. 1 160
      panda/src/linmath/lvecBase4_src.cxx
  40. 5 11
      panda/src/linmath/lvecBase4_src.h
  41. 22 0
      panda/src/linmath/lvector2_ext.I
  42. 72 0
      panda/src/linmath/lvector2_ext_src.I
  43. 0 12
      panda/src/linmath/lvector2_src.I
  44. 0 49
      panda/src/linmath/lvector2_src.cxx
  45. 3 7
      panda/src/linmath/lvector2_src.h
  46. 22 0
      panda/src/linmath/lvector3_ext.I
  47. 81 0
      panda/src/linmath/lvector3_ext_src.I
  48. 0 11
      panda/src/linmath/lvector3_src.I
  49. 0 57
      panda/src/linmath/lvector3_src.cxx
  50. 3 7
      panda/src/linmath/lvector3_src.h
  51. 22 0
      panda/src/linmath/lvector4_ext.I
  52. 95 0
      panda/src/linmath/lvector4_ext_src.I
  53. 0 11
      panda/src/linmath/lvector4_src.I
  54. 0 71
      panda/src/linmath/lvector4_src.cxx
  55. 3 7
      panda/src/linmath/lvector4_src.h

+ 13 - 9
panda/src/linmath/Sources.pp

@@ -14,7 +14,7 @@
      compose_matrix_src.cxx compose_matrix_src.h config_linmath.h  \
      coordinateSystem.h dbl2fltnames.h dblnames.h deg_2_rad.h  \
      flt2dblnames.h fltnames.h lcast_to.h lcast_to_src.h  \
-     lcast_to_src.I lmatrix.h  lmatrix3_src.I  \
+     lcast_to_src.I lmatrix.h lmatrix_ext.I lmatrix3_src.I  \
      lmatrix3_src.cxx lmatrix3_src.h lmatrix4_src.I  \
      lmatrix4_src.cxx lmatrix4_src.h lorientation.h  \
      lorientation_src.I lorientation_src.cxx lorientation_src.h  \
@@ -26,14 +26,18 @@
      lrotation_src.cxx lrotation_src.h luse.I luse.N luse.h  \
      lvec2_ops.h lvec2_ops_src.I lvec2_ops_src.h lvec3_ops.h  \
      lvec3_ops_src.I lvec3_ops_src.h lvec4_ops.h lvec4_ops_src.I  \
-     lvec4_ops_src.h lvecBase2.h lvecBase2_src.I  \
-     lvecBase2_src.cxx lvecBase2_src.h lvecBase3.h  \
-     lvecBase3_src.I lvecBase3_src.cxx lvecBase3_src.h  \
-     lvecBase4.h lvecBase4_src.I lvecBase4_src.cxx  \
-     lvecBase4_src.h lvector2.h lvector2_src.I lvector2_src.cxx  \
-     lvector2_src.h lvector3.h lvector3_src.I lvector3_src.cxx  \
-     lvector3_src.h lvector4.h lvector4_src.I lvector4_src.cxx  \
-     lvector4_src.h mathNumbers.h mathNumbers.I vector_Colorf.h  \
+     lvec4_ops_src.h \
+     lvecBase2.h lvecBase2_src.I lvecBase2_src.cxx lvecBase2_src.h  \
+     lvecBase3.h lvecBase3_src.I lvecBase3_src.cxx lvecBase3_src.h  \
+     lvecBase4.h lvecBase4_src.I lvecBase4_src.cxx lvecBase4_src.h  \
+     lvector2.h lvector2_src.I lvector2_src.cxx lvector2_src.h  \
+     lvector3.h lvector3_src.I lvector3_src.cxx lvector3_src.h  \
+     lvector4.h lvector4_src.I lvector4_src.cxx lvector4_src.h  \
+     lvector4.h lvector4_src.I lvector4_src.cxx lvector4_src.h  \
+     lvecBase2_ext.I lvecBase3_ext.I lvecBase4_ext.I \
+     lpoint2_ext.I lpoint3_ext.I lpoint4_ext.I \
+     lvector2_ext.I lvector3_ext.I lvector4_ext.I \
+     mathNumbers.h mathNumbers.I vector_Colorf.h  \
      vector_LPoint2f.h vector_LVecBase3f.h vector_Normalf.h  \
      vector_TexCoordf.h vector_Vertexf.h
     

+ 73 - 0
panda/src/linmath/lmatrix3_ext_src.I

@@ -0,0 +1,73 @@
+// Filename: lmatrix3_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::Row::__setitem__
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_NESTED_METHOD_ARGS(FLOATNAME(LMatrix3), Row,
+__setitem__, int i, FLOATTYPE v) {
+  nassertv(i >= 0 && i < 3);
+  this->_row[i] = v;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::__reduce__
+//       Access: Published
+//  Description: This special Python method is implement to provide
+//               support for the pickle module.
+////////////////////////////////////////////////////////////////////
+PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix3),
+__reduce__, PyObject *self) {
+  // We should return at least a 2-tuple, (Class, (args)): the
+  // necessary class object whose constructor we should call
+  // (e.g. this), and the arguments necessary to reconstruct this
+  // object.
+  PyObject *this_class = PyObject_Type(self);
+  if (this_class == NULL) {
+    return NULL;
+  }
+
+  PyObject *result = Py_BuildValue("(O(fffffffff))", this_class, 
+    this->_m.m._00, this->_m.m._01, this->_m.m._02,
+    this->_m.m._10, this->_m.m._11, this->_m.m._12,
+    this->_m.m._20, this->_m.m._21, this->_m.m._22);
+
+  Py_DECREF(this_class);
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix3::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix3),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_m.m._00) << ", "
+      << MAYBE_ZERO(this->_m.m._01) << ", "
+      << MAYBE_ZERO(this->_m.m._02) << ", "
+
+      << MAYBE_ZERO(this->_m.m._10) << ", "
+      << MAYBE_ZERO(this->_m.m._11) << ", "
+      << MAYBE_ZERO(this->_m.m._12) << ", "
+
+      << MAYBE_ZERO(this->_m.m._20) << ", "
+      << MAYBE_ZERO(this->_m.m._21) << ", "
+      << MAYBE_ZERO(this->_m.m._22) << ")";
+}
+

+ 0 - 13
panda/src/linmath/lmatrix3_src.I

@@ -44,19 +44,6 @@ operator [](int i) {
   return _row[i];
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix3::Row::__setitem__
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LMatrix3)::Row::
-__setitem__(int i, FLOATTYPE v) {
-  nassertv(i >= 0 && i < 3);
-  _row[i] = v;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix3::Row::size
 //       Access: Public, Static

+ 0 - 51
panda/src/linmath/lmatrix3_src.cxx

@@ -45,34 +45,6 @@ const FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::_lz_to_ry_mat =
 const FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::_ly_to_rz_mat =
   FLOATNAME(LMatrix3)::_flip_z_mat * FLOATNAME(LMatrix3)::_y_to_z_up_mat;
 
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix3::__reduce__
-//       Access: Published
-//  Description: This special Python method is implement to provide
-//               support for the pickle module.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LMatrix3)::
-__reduce__(PyObject *self) const {
-  // We should return at least a 2-tuple, (Class, (args)): the
-  // necessary class object whose constructor we should call
-  // (e.g. this), and the arguments necessary to reconstruct this
-  // object.
-  PyObject *this_class = PyObject_Type(self);
-  if (this_class == NULL) {
-    return NULL;
-  }
-
-  PyObject *result = Py_BuildValue("(O(fffffffff))", this_class, 
-                                   _m.m._00, _m.m._01, _m.m._02,
-                                   _m.m._10, _m.m._11, _m.m._12,
-                                   _m.m._20, _m.m._21, _m.m._22);
-  Py_DECREF(this_class);
-  return result;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix::set_scale_shear_mat
 //       Access: Public
@@ -432,29 +404,6 @@ write(ostream &out, int indent_level) const {
     << "\n";
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix3::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-void FLOATNAME(LMatrix3)::
-python_repr(ostream &out, const string &class_name) const {
-  out << class_name << "(" 
-      << MAYBE_ZERO(_m.m._00) << ", "
-      << MAYBE_ZERO(_m.m._01) << ", "
-      << MAYBE_ZERO(_m.m._02) << ", "
-
-      << MAYBE_ZERO(_m.m._10) << ", "
-      << MAYBE_ZERO(_m.m._11) << ", "
-      << MAYBE_ZERO(_m.m._12) << ", "
-
-      << MAYBE_ZERO(_m.m._20) << ", "
-      << MAYBE_ZERO(_m.m._21) << ", "
-      << MAYBE_ZERO(_m.m._22) << ")";
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix3::generate_hash
 //       Access: Public

+ 5 - 11
panda/src/linmath/lmatrix3_src.h

@@ -35,11 +35,9 @@ PUBLISHED:
   PUBLISHED:
     INLINE_LINMATH FLOATTYPE operator [](int i) const;
     INLINE_LINMATH FLOATTYPE &operator [](int i);
-#ifdef HAVE_PYTHON
-    INLINE_LINMATH void __setitem__(int i, FLOATTYPE v);
-#endif
+    EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
     INLINE_LINMATH static int size();
-  private:
+  public:
     FLOATTYPE *_row;
     friend class FLOATNAME(LMatrix3);
   };
@@ -49,7 +47,7 @@ PUBLISHED:
   PUBLISHED:
     INLINE_LINMATH FLOATTYPE operator [](int i) const;
     INLINE_LINMATH static int size();
-  private:
+  public:
     const FLOATTYPE *_row;
     friend class FLOATNAME(LMatrix3);
   };
@@ -65,9 +63,7 @@ PUBLISHED:
     FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22);
   ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix3));
 
-#ifdef HAVE_PYTHON
-  PyObject *__reduce__(PyObject *self) const;
-#endif
+  EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
   void fill(FLOATTYPE fill_value);
   INLINE_LINMATH void set(
@@ -272,9 +268,7 @@ PUBLISHED:
 
   void output(ostream &out) const;
   void write(ostream &out, int indent_level = 0) const;
-#ifdef HAVE_PYTHON
-  void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(void python_repr(ostream &out, const string &class_name) const);
 
 public:
   INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 82 - 0
panda/src/linmath/lmatrix4_ext_src.I

@@ -0,0 +1,82 @@
+// Filename: lmatrix4_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::Row::__setitem__
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_NESTED_METHOD_ARGS(FLOATNAME(LMatrix4), Row,
+__setitem__, int i, FLOATTYPE v) {
+  nassertv(i >= 0 && i < 4);
+  this->_row[i] = v;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::__reduce__
+//       Access: Published
+//  Description: This special Python method is implement to provide
+//               support for the pickle module.
+////////////////////////////////////////////////////////////////////
+PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix4),
+__reduce__, PyObject *self) {
+  // We should return at least a 2-tuple, (Class, (args)): the
+  // necessary class object whose constructor we should call
+  // (e.g. this), and the arguments necessary to reconstruct this
+  // object.
+  PyObject *this_class = PyObject_Type(self);
+  if (this_class == NULL) {
+    return NULL;
+  }
+
+  PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, 
+    this->_m.m._00, this->_m.m._01, this->_m.m._02, this->_m.m._03,
+    this->_m.m._10, this->_m.m._11, this->_m.m._12, this->_m.m._13,
+    this->_m.m._20, this->_m.m._21, this->_m.m._22, this->_m.m._23,
+    this->_m.m._30, this->_m.m._31, this->_m.m._32, this->_m.m._33);
+
+  Py_DECREF(this_class);
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LMatrix4::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+void EXT_CONST_METHOD_ARGS(FLOATNAME(LMatrix4),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_m.m._00) << ", "
+      << MAYBE_ZERO(this->_m.m._01) << ", "
+      << MAYBE_ZERO(this->_m.m._02) << ", "
+      << MAYBE_ZERO(this->_m.m._03) << ", "
+
+      << MAYBE_ZERO(this->_m.m._10) << ", "
+      << MAYBE_ZERO(this->_m.m._11) << ", "
+      << MAYBE_ZERO(this->_m.m._12) << ", "
+      << MAYBE_ZERO(this->_m.m._13) << ", "
+
+      << MAYBE_ZERO(this->_m.m._20) << ", "
+      << MAYBE_ZERO(this->_m.m._21) << ", "
+      << MAYBE_ZERO(this->_m.m._22) << ", "
+      << MAYBE_ZERO(this->_m.m._23) << ", "
+
+      << MAYBE_ZERO(this->_m.m._30) << ", "
+      << MAYBE_ZERO(this->_m.m._31) << ", "
+      << MAYBE_ZERO(this->_m.m._32) << ", "
+      << MAYBE_ZERO(this->_m.m._33) << ")";
+}
+

+ 0 - 13
panda/src/linmath/lmatrix4_src.I

@@ -44,19 +44,6 @@ operator [](int i) {
   return _row[i];
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix4::Row::__setitem__
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LMatrix4)::Row::
-__setitem__(int i, FLOATTYPE v) {
-  nassertv(i >= 0 && i < 4);
-  _row[i] = v;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::Row::size
 //       Access: Public, Static

+ 0 - 60
panda/src/linmath/lmatrix4_src.cxx

@@ -62,35 +62,6 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_lz_to_ry_mat =
 const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ly_to_rz_mat =
   FLOATNAME(LMatrix4)::_flip_z_mat * FLOATNAME(LMatrix4)::_y_to_z_up_mat;
 
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix4::__reduce__
-//       Access: Published
-//  Description: This special Python method is implement to provide
-//               support for the pickle module.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LMatrix4)::
-__reduce__(PyObject *self) const {
-  // We should return at least a 2-tuple, (Class, (args)): the
-  // necessary class object whose constructor we should call
-  // (e.g. this), and the arguments necessary to reconstruct this
-  // object.
-  PyObject *this_class = PyObject_Type(self);
-  if (this_class == NULL) {
-    return NULL;
-  }
-
-  PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, 
-                                   _m.m._00, _m.m._01, _m.m._02, _m.m._03,
-                                   _m.m._10, _m.m._11, _m.m._12, _m.m._13,
-                                   _m.m._20, _m.m._21, _m.m._22, _m.m._23,
-                                   _m.m._30, _m.m._31, _m.m._32, _m.m._33);
-  Py_DECREF(this_class);
-  return result;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix::convert_mat
 //       Access: Public, Static
@@ -368,37 +339,6 @@ output(ostream &out) const {
       << " ]";
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LMatrix4::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-void FLOATNAME(LMatrix4)::
-python_repr(ostream &out, const string &class_name) const {
-  out << class_name << "(" 
-      << MAYBE_ZERO(_m.m._00) << ", "
-      << MAYBE_ZERO(_m.m._01) << ", "
-      << MAYBE_ZERO(_m.m._02) << ", "
-      << MAYBE_ZERO(_m.m._03) << ", "
-
-      << MAYBE_ZERO(_m.m._10) << ", "
-      << MAYBE_ZERO(_m.m._11) << ", "
-      << MAYBE_ZERO(_m.m._12) << ", "
-      << MAYBE_ZERO(_m.m._13) << ", "
-
-      << MAYBE_ZERO(_m.m._20) << ", "
-      << MAYBE_ZERO(_m.m._21) << ", "
-      << MAYBE_ZERO(_m.m._22) << ", "
-      << MAYBE_ZERO(_m.m._23) << ", "
-
-      << MAYBE_ZERO(_m.m._30) << ", "
-      << MAYBE_ZERO(_m.m._31) << ", "
-      << MAYBE_ZERO(_m.m._32) << ", "
-      << MAYBE_ZERO(_m.m._33) << ")";
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LMatrix4::write
 //       Access: Public

+ 5 - 11
panda/src/linmath/lmatrix4_src.h

@@ -30,11 +30,9 @@ PUBLISHED:
   PUBLISHED:
     INLINE_LINMATH FLOATTYPE operator [](int i) const;
     INLINE_LINMATH FLOATTYPE &operator [](int i);
-#ifdef HAVE_PYTHON
-    INLINE_LINMATH void __setitem__(int i, FLOATTYPE v);
-#endif
+    EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
     INLINE_LINMATH static int size();
-  private:
+  public:
     FLOATTYPE *_row;
     friend class FLOATNAME(LMatrix4);
   };
@@ -44,7 +42,7 @@ PUBLISHED:
   PUBLISHED:
     INLINE_LINMATH FLOATTYPE operator [](int i) const;
     INLINE_LINMATH static int size();
-  private:
+  public:
     const FLOATTYPE *_row;
     friend class FLOATNAME(LMatrix4);
   };
@@ -60,9 +58,7 @@ PUBLISHED:
                                      FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33);
   ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix4));
 
-#ifdef HAVE_PYTHON
-  PyObject *__reduce__(PyObject *self) const;
-#endif
+  EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
   // Construct a 4x4 matrix given a 3x3 rotation matrix and an optional
   // translation component.
@@ -236,9 +232,7 @@ PUBLISHED:
 
   void output(ostream &out) const;
   void write(ostream &out, int indent_level = 0) const;
-#ifdef HAVE_PYTHON
-  void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(void python_repr(ostream &out, const string &class_name) const);
 
 public:
   INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 23 - 0
panda/src/linmath/lmatrix_ext.I

@@ -0,0 +1,23 @@
+// Filename: lmatrix_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lmatrix.h"
+
+#include "fltnames.h"
+#include "lmatrix3_ext_src.I"
+#include "lmatrix4_ext_src.I"
+
+#include "dblnames.h"
+#include "lmatrix3_ext_src.I"
+#include "lmatrix4_ext_src.I"

+ 22 - 0
panda/src/linmath/lpoint2_ext.I

@@ -0,0 +1,22 @@
+// Filename: lpoint2_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lpoint2.h"
+
+#include "fltnames.h"
+#include "lpoint2_ext_src.I"
+
+#include "dblnames.h"
+#include "lpoint2_ext_src.I"
+

+ 72 - 0
panda/src/linmath/lpoint2_ext_src.I

@@ -0,0 +1,72 @@
+// Filename: lpoint2_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint2::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint2),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "("
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint2::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint2),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it != 'x' && *it != 'y') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
+  }
+
+  return NULL;
+}
+
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase2), __setattr__, PyObject*, const string&, PyObject*);
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint2::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+INLINE int EXT_METHOD_ARGS(FLOATNAME(LPoint2),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+  return CALL_EXT_METHOD(FLOATNAME(LVecBase2), __setattr__, this, self, attr_name, assign);
+}
+

+ 0 - 12
panda/src/linmath/lpoint2_src.I

@@ -196,15 +196,3 @@ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2)::
 project(const FLOATNAME(LVecBase2) &onto) const {
   return FLOATNAME(LVecBase2)::project(onto);
 }
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint2::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LPoint2)::
-python_repr(ostream &out, const string &class_name) const {
-  FLOATNAME(LVecBase2)::python_repr(out, class_name);
-}
-#endif  // HAVE_PYTHON

+ 0 - 49
panda/src/linmath/lpoint2_src.cxx

@@ -14,55 +14,6 @@
 
 TypeHandle FLOATNAME(LPoint2)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
-#endif
-#endif  // HAVE_PYTHON
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint2::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LPoint2)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it != 'x' && *it != 'y') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint2::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LPoint2)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-  return FLOATNAME(LVecBase2)::__setattr__(self, attr_name, assign);
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LPoint2::init_type
 //       Access: Public, Static

+ 3 - 7
panda/src/linmath/lpoint2_src.h

@@ -26,10 +26,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE x, FLOATTYPE y);
 
-#ifdef HAVE_PYTHON
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LPoint2) &zero();
   INLINE_LINMATH static const FLOATNAME(LPoint2) &unit_x();
@@ -53,9 +51,7 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint2) operator / (FLOATTYPE scalar) const;
   INLINE_LINMATH FLOATNAME(LPoint2) project(const FLOATNAME(LVecBase2) &onto) const;
 
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   static TypeHandle get_class_type() {

+ 22 - 0
panda/src/linmath/lpoint3_ext.I

@@ -0,0 +1,22 @@
+// Filename: lpoint3_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lpoint3.h"
+
+#include "fltnames.h"
+#include "lpoint3_ext_src.I"
+
+#include "dblnames.h"
+#include "lpoint3_ext_src.I"
+

+ 81 - 0
panda/src/linmath/lpoint3_ext_src.I

@@ -0,0 +1,81 @@
+// Filename: lpoint3_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint3::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint3),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ", "
+      << MAYBE_ZERO(this->_v.v._2) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint3::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint3),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'x' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
+
+  } else if (attr_name.size() == 3) {
+    FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
+  }
+
+  return NULL;
+}
+
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase3), __setattr__, PyObject*, const string&, PyObject*);
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint3::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+INLINE int EXT_METHOD_ARGS(FLOATNAME(LPoint3),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+  return CALL_EXT_METHOD(FLOATNAME(LVecBase3), __setattr__, this, self, attr_name, assign);
+}
+

+ 0 - 11
panda/src/linmath/lpoint3_src.I

@@ -277,14 +277,3 @@ rfu(FLOATTYPE right_v, FLOATTYPE fwd_v, FLOATTYPE up_v,
     FLOATNAME(LVector3)::rfu(right_v, fwd_v, up_v, cs);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint3::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LPoint3)::
-python_repr(ostream &out, const string &class_name) const {
-  FLOATNAME(LVecBase3)::python_repr(out, class_name);
-}
-#endif  // HAVE_PYTHON

+ 0 - 57
panda/src/linmath/lpoint3_src.cxx

@@ -14,63 +14,6 @@
 
 TypeHandle FLOATNAME(LPoint3)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3);
-#endif
-#endif  // HAVE_PYTHON
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint3::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LPoint3)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'x' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
-
-  } else if (attr_name.size() == 3) {
-    FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[attr_name[2] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint3::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LPoint3)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-  return FLOATNAME(LVecBase3)::__setattr__(self, attr_name, assign);
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LPoint3::init_type
 //       Access: Public, Static

+ 3 - 7
panda/src/linmath/lpoint3_src.h

@@ -31,10 +31,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
 
-#ifdef HAVE_PYTHON
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LPoint3) &zero();
   INLINE_LINMATH static const FLOATNAME(LPoint3) &unit_x();
@@ -72,9 +70,7 @@ PUBLISHED:
                                        FLOATTYPE up,
                                        CoordinateSystem cs = CS_default);
 
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   static TypeHandle get_class_type() {

+ 22 - 0
panda/src/linmath/lpoint4_ext.I

@@ -0,0 +1,22 @@
+// Filename: lpoint4_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lpoint4.h"
+
+#include "fltnames.h"
+#include "lpoint4_ext_src.I"
+
+#include "dblnames.h"
+#include "lpoint4_ext_src.I"
+

+ 95 - 0
panda/src/linmath/lpoint4_ext_src.I

@@ -0,0 +1,95 @@
+// Filename: lpoint4_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint4::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint4),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ", "
+      << MAYBE_ZERO(this->_v.v._2) << ", "
+      << MAYBE_ZERO(this->_v.v._3) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint4::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LPoint4),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'w' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    if (attr_name[0] == 'w') {
+      return PyFloat_FromDouble(this->_v.data[3]);
+    } else {
+      return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    }
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
+
+  } else if (attr_name.size() == 3) {
+    FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
+
+  } else if (attr_name.size() == 4) {
+    FLOATNAME(LPoint4) *vec = new FLOATNAME(LPoint4);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    vec->_v.v._3 = this->_v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint4), true, false);
+  }
+
+  return NULL;
+}
+
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase4), __setattr__, PyObject*, const string&, PyObject*);
+
+////////////////////////////////////////////////////////////////////
+//     Function: LPoint4::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+INLINE int EXT_METHOD_ARGS(FLOATNAME(LPoint4),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+  return CALL_EXT_METHOD(FLOATNAME(LVecBase4), __setattr__, this, self, attr_name, assign);
+}
+

+ 0 - 11
panda/src/linmath/lpoint4_src.I

@@ -217,14 +217,3 @@ project(const FLOATNAME(LVecBase4) &onto) const {
   return FLOATNAME(LVecBase4)::project(onto);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint4::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LPoint4)::
-python_repr(ostream &out, const string &class_name) const {
-  FLOATNAME(LVecBase4)::python_repr(out, class_name);
-}
-#endif  // HAVE_PYTHON

+ 0 - 71
panda/src/linmath/lpoint4_src.cxx

@@ -14,76 +14,6 @@
 
 TypeHandle FLOATNAME(LPoint4)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4);
-#endif
-#endif  // HAVE_PYTHON
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint4::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LPoint4)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'w' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    if (attr_name[0] == 'w') {
-      return PyFloat_FromDouble(_v.data[3]);
-    } else {
-      return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-    }
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LPoint2) *vec = new FLOATNAME(LPoint2);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint2), true, false);
-
-  } else if (attr_name.size() == 3) {
-    FLOATNAME(LPoint3) *vec = new FLOATNAME(LPoint3);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint3), true, false);
-
-  } else if (attr_name.size() == 4) {
-    FLOATNAME(LPoint4) *vec = new FLOATNAME(LPoint4);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    vec->_v.v._3 = _v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LPoint4), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LPoint4::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LPoint4)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-  return FLOATNAME(LVecBase4)::__setattr__(self, attr_name, assign);
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LPoint4::init_type
 //       Access: Public, Static
@@ -100,4 +30,3 @@ init_type() {
   }
 }
 
-

+ 3 - 7
panda/src/linmath/lpoint4_src.h

@@ -25,10 +25,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
 
-#ifdef HAVE_PYTHON
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LPoint4) &zero();
   INLINE_LINMATH static const FLOATNAME(LPoint4) &unit_x();
@@ -54,9 +52,7 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint4) operator / (FLOATTYPE scalar) const;
   INLINE_LINMATH FLOATNAME(LPoint4) project(const FLOATNAME(LVecBase4) &onto) const;
 
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   static TypeHandle get_class_type() {

+ 22 - 0
panda/src/linmath/lvecBase2_ext.I

@@ -0,0 +1,22 @@
+// Filename: lvecBase2_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lvecBase2.h"
+
+#include "fltnames.h"
+#include "lvecBase2_ext_src.I"
+
+#include "dblnames.h"
+#include "lvecBase2_ext_src.I"
+

+ 175 - 0
panda/src/linmath/lvecBase2_ext_src.I

@@ -0,0 +1,175 @@
+// Filename: lvecBase2_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase2::__setitem__
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase2),
+__setitem__, int i, FLOATTYPE v) {
+  nassertv(i >= 0 && i < 2);
+  this->_v.data[i] = v;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase2::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase2),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "("
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase2::__reduce__
+//       Access: Published
+//  Description: This special Python method is implement to provide
+//               support for the pickle module.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase2),
+__reduce__, PyObject *self) {
+  // We should return at least a 2-tuple, (Class, (args)): the
+  // necessary class object whose constructor we should call
+  // (e.g. this), and the arguments necessary to reconstruct this
+  // object.
+  PyObject *this_class = PyObject_Type(self);
+  if (this_class == NULL) {
+    return NULL;
+  }
+
+  PyObject *result = Py_BuildValue("(O(ff))", this_class, 
+                                   (*this)[0], (*this)[1]);
+  Py_DECREF(this_class);
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase2::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase2),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it != 'x' && *it != 'y') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
+  }
+
+  return NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase2::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase2),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it != 'x' && *it != 'y') {
+      PyTypeObject *tp = self->ob_type;
+      PyErr_Format(PyExc_AttributeError,
+                   "'%.100s' object has no attribute '%.200s'",
+                   tp->tp_name, attr_name.c_str());
+      return -1;
+    }
+  }
+#endif
+
+  // It is a sequence, perhaps another vector?
+  if (PySequence_Check(assign)) {
+
+    // Whoosh.
+    PyObject* fast = PySequence_Fast(assign, "");
+    nassertr(fast != NULL, -1);
+    
+    // Let's be strict about size mismatches, to prevent user error.
+    if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
+      PyErr_SetString(PyExc_ValueError, "length mismatch");
+      Py_DECREF(fast);
+      return -1;
+    }
+    
+    // Get a pointer to the items, iterate over it and
+    // perform our magic assignment.  Fast fast.  Oh yeah.
+    PyObject** items = PySequence_Fast_ITEMS(fast);
+    for (int i = 0; i < attr_name.size(); ++i) {
+
+      PyObject* fl = PyNumber_Float(items[i]);
+      if (fl == NULL) {
+        // Oh darn.  Not when we've come this far.
+        PyErr_SetString(PyExc_ValueError, "a sequence of floats is required");
+        Py_DECREF(fast);
+        return -1;
+      }
+      double value = PyFloat_AS_DOUBLE(fl);
+      Py_DECREF(fl);
+
+      this->_v.data[attr_name[i] - 'x'] = value;
+    }
+
+    Py_DECREF(fast);
+
+  } else {
+    // Maybe it's a single floating-point value.
+    PyObject* fl = PyNumber_Float(assign);
+    if (fl == NULL) {
+      // It's not a floating-point value either?
+      // Sheesh, I don't know what to do with it then.
+      if (attr_name.size() == 1) {
+        PyErr_SetString(PyExc_ValueError, "a float is required");
+      } else {
+        PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable",
+          assign->ob_type->tp_name);
+      }
+      return -1;
+    }
+    double value = PyFloat_AS_DOUBLE(fl);
+    Py_DECREF(fl);
+
+    // Loop through the components in the attribute name,
+    // and assign the floating-point value to every one of them.
+    for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+      this->_v.data[(*it) - 'x'] = value;
+    } 
+  }
+
+  return 0;
+}
+

+ 0 - 27
panda/src/linmath/lvecBase2_src.I

@@ -144,19 +144,6 @@ operator [](int i) {
   return _v.data[i];
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase2::__setitem__
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVecBase2)::
-__setitem__(int i, FLOATTYPE v) {
-  nassertv(i >= 0 && i < 2);
-  _v.data[i] = v;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase2::size
 //       Access: Public, Static
@@ -707,20 +694,6 @@ output(ostream &out) const {
       << MAYBE_ZERO(_v.v._1);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase2::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVecBase2)::
-python_repr(ostream &out, const string &class_name) const {
-  out << class_name << "("
-      << MAYBE_ZERO(_v.v._0) << ", "
-      << MAYBE_ZERO(_v.v._1) << ")";
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase2::generate_hash
 //       Access: Public

+ 1 - 143
panda/src/linmath/lvecBase2_src.cxx

@@ -14,14 +14,6 @@
 
 TypeHandle FLOATNAME(LVecBase2)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
-#endif
-#endif  // HAVE_PYTHON
-
 const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_zero =
   FLOATNAME(LVecBase2)(0.0f, 0.0f);
 const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_x =
@@ -29,141 +21,6 @@ const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_x =
 const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_y =
   FLOATNAME(LVecBase2)(0.0f, 1.0f);
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase2::__reduce__
-//       Access: Published
-//  Description: This special Python method is implement to provide
-//               support for the pickle module.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVecBase2)::
-__reduce__(PyObject *self) const {
-  // We should return at least a 2-tuple, (Class, (args)): the
-  // necessary class object whose constructor we should call
-  // (e.g. this), and the arguments necessary to reconstruct this
-  // object.
-  PyObject *this_class = PyObject_Type(self);
-  if (this_class == NULL) {
-    return NULL;
-  }
-
-  PyObject *result = Py_BuildValue("(O(ff))", this_class, 
-                                   (*this)[0], (*this)[1]);
-  Py_DECREF(this_class);
-  return result;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase2::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVecBase2)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it != 'x' && *it != 'y') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase2::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LVecBase2)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it != 'x' && *it != 'y') {
-      PyTypeObject *tp = self->ob_type;
-      PyErr_Format(PyExc_AttributeError,
-                   "'%.100s' object has no attribute '%.200s'",
-                   tp->tp_name, attr_name.c_str());
-      return -1;
-    }
-  }
-#endif
-
-  // It is a sequence, perhaps another vector?
-  if (PySequence_Check(assign)) {
-
-    // Whoosh.
-    PyObject* fast = PySequence_Fast(assign, "");
-    nassertr(fast != NULL, -1);
-    
-    // Let's be strict about size mismatches, to prevent user error.
-    if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
-      PyErr_SetString(PyExc_ValueError, "length mismatch");
-      Py_DECREF(fast);
-      return -1;
-    }
-    
-    // Get a pointer to the items, iterate over it and
-    // perform our magic assignment.  Fast fast.  Oh yeah.
-    PyObject** items = PySequence_Fast_ITEMS(fast);
-    for (int i = 0; i < attr_name.size(); ++i) {
-
-      PyObject* fl = PyNumber_Float(items[i]);
-      if (fl == NULL) {
-        // Oh darn.  Not when we've come this far.
-        PyErr_SetString(PyExc_ValueError, "a sequence of floats is required");
-        Py_DECREF(fast);
-        return -1;
-      }
-      double value = PyFloat_AS_DOUBLE(fl);
-      Py_DECREF(fl);
-
-      _v.data[attr_name[i] - 'x'] = value;
-    }
-
-    Py_DECREF(fast);
-
-  } else {
-    // Maybe it's a single floating-point value.
-    PyObject* fl = PyNumber_Float(assign);
-    if (fl == NULL) {
-      // It's not a floating-point value either?
-      // Sheesh, I don't know what to do with it then.
-      if (attr_name.size() == 1) {
-        PyErr_SetString(PyExc_ValueError, "a float is required");
-      } else {
-        PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable",
-          assign->ob_type->tp_name);
-      }
-      return -1;
-    }
-    double value = PyFloat_AS_DOUBLE(fl);
-    Py_DECREF(fl);
-
-    // Loop through the components in the attribute name,
-    // and assign the floating-point value to every one of them.
-    for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-      _v.data[(*it) - 'x'] = value;
-    } 
-  }
-
-  return 0;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase2::init_type
 //       Access: Public, Static
@@ -178,3 +35,4 @@ init_type() {
     register_type(_type_handle, name);
   }
 }
+

+ 5 - 11
panda/src/linmath/lvecBase2_src.h

@@ -39,17 +39,13 @@ PUBLISHED:
 
   INLINE_LINMATH ~FLOATNAME(LVecBase2)();
 
-#ifdef HAVE_PYTHON
-  PyObject *__reduce__(PyObject *self) const;
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH FLOATTYPE operator [](int i) const;
   INLINE_LINMATH FLOATTYPE &operator [](int i);
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void __setitem__(int i, FLOATTYPE v);
-#endif
+  EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
   INLINE_LINMATH static int size();
 
   INLINE_LINMATH bool is_nan() const;
@@ -127,9 +123,7 @@ PUBLISHED:
   INLINE_LINMATH bool almost_equal(const FLOATNAME(LVecBase2) &other) const;
 
   INLINE_LINMATH void output(ostream &out) const;
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 22 - 0
panda/src/linmath/lvecBase3_ext.I

@@ -0,0 +1,22 @@
+// Filename: lvecBase3_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lvecBase3.h"
+
+#include "fltnames.h"
+#include "lvecBase3_ext_src.I"
+
+#include "dblnames.h"
+#include "lvecBase3_ext_src.I"
+

+ 180 - 0
panda/src/linmath/lvecBase3_ext_src.I

@@ -0,0 +1,180 @@
+// Filename: lvecBase3_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase3::__setitem__
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase3),
+__setitem__, int i, FLOATTYPE v) {
+  nassertv(i >= 0 && i < 3);
+  this->_v.data[i] = v;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase3::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase3),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ", "
+      << MAYBE_ZERO(this->_v.v._2) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase3::__reduce__
+//       Access: Published
+//  Description: This special Python method is implement to provide
+//               support for the pickle module.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase3),
+__reduce__, PyObject *self) {
+  // We should return at least a 2-tuple, (Class, (args)): the
+  // necessary class object whose constructor we should call
+  // (e.g. this), and the arguments necessary to reconstruct this
+  // object.
+  PyObject *this_class = PyObject_Type(self);
+  if (this_class == NULL) {
+    return NULL;
+  }
+
+  PyObject *result = Py_BuildValue("(O(fff))", this_class, 
+                                   (*this)[0], (*this)[1], (*this)[2]);
+  Py_DECREF(this_class);
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase3::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase3),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'x' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
+
+  } else if (attr_name.size() == 3) {
+    FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
+  }
+
+  return NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase3::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase3),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'x' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  // It is a sequence, perhaps another vector?
+  if (PySequence_Check(assign)) {
+
+    // Whoosh.
+    PyObject* fast = PySequence_Fast(assign, "");
+    nassertr(fast != NULL, -1);
+    
+    // Let's be strict about size mismatches, to prevent user error.
+    if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
+      PyErr_SetString(PyExc_ValueError, "length mismatch");
+      Py_DECREF(fast);
+      return -1;
+    }
+    
+    // Get a pointer to the items, iterate over it and
+    // perform our magic assignment.  Fast fast.  Oh yeah.
+    PyObject** items = PySequence_Fast_ITEMS(fast);
+    for (int i = 0; i < attr_name.size(); ++i) {
+
+      PyObject* fl = PyNumber_Float(items[i]);
+      if (fl == NULL) {
+        // Oh darn.  Not when we've come this far.
+        PyErr_SetString(PyExc_ValueError, "a sequence of floats is required");
+        Py_DECREF(fast);
+        return -1;
+      }
+      double value = PyFloat_AS_DOUBLE(fl);
+      Py_DECREF(fl);
+
+      this->_v.data[attr_name[i] - 'x'] = value;
+    }
+
+    Py_DECREF(fast);
+
+  } else {
+    // Maybe it's a single floating-point value.
+    PyObject* fl = PyNumber_Float(assign);
+    if (fl == NULL) {
+      // It's not a floating-point value either?
+      // Sheesh, I don't know what to do with it then.
+      if (attr_name.size() == 1) {
+        PyErr_SetString(PyExc_ValueError, "a float is required");
+      } else {
+        PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable",
+          assign->ob_type->tp_name);
+      }
+      return -1;
+    }
+    double value = PyFloat_AS_DOUBLE(fl);
+    Py_DECREF(fl);
+
+    // Loop through the components in the attribute name,
+    // and assign the floating-point value to every one of them.
+    for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+      this->_v.data[(*it) - 'x'] = value;
+    } 
+  }
+
+  return 0;
+}
+

+ 0 - 29
panda/src/linmath/lvecBase3_src.I

@@ -156,19 +156,6 @@ operator [](int i) {
   return _v.data[i];
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase3::__setitem__
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVecBase3)::
-__setitem__(int i, FLOATTYPE v) {
-  nassertv(i >= 0 && i < 3);
-  _v.data[i] = v;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase3::size
 //       Access: Public, Static
@@ -875,22 +862,6 @@ output(ostream &out) const {
       << MAYBE_ZERO(_v.v._2);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase3::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVecBase3)::
-python_repr(ostream &out, const string &class_name) const {
-  out << class_name << "(" 
-      << MAYBE_ZERO(_v.v._0) << ", "
-      << MAYBE_ZERO(_v.v._1) << ", "
-      << MAYBE_ZERO(_v.v._2) << ")";
-}
-#endif  // HAVE_PYTHON
-
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase3::generate_hash
 //       Access: Public

+ 1 - 147
panda/src/linmath/lvecBase3_src.cxx

@@ -15,15 +15,6 @@
 
 TypeHandle FLOATNAME(LVecBase3)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
-#endif
-#endif  // HAVE_PYTHON
-
 const FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::_zero =
   FLOATNAME(LVecBase3)(0.0f, 0.0f, 0.0f);
 const FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::_unit_x =
@@ -33,144 +24,6 @@ const FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::_unit_y =
 const FLOATNAME(LVecBase3) FLOATNAME(LVecBase3)::_unit_z =
   FLOATNAME(LVecBase3)(0.0f, 0.0f, 1.0f);
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase3::__reduce__
-//       Access: Published
-//  Description: This special Python method is implement to provide
-//               support for the pickle module.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVecBase3)::
-__reduce__(PyObject *self) const {
-  // We should return at least a 2-tuple, (Class, (args)): the
-  // necessary class object whose constructor we should call
-  // (e.g. this), and the arguments necessary to reconstruct this
-  // object.
-  PyObject *this_class = PyObject_Type(self);
-  if (this_class == NULL) {
-    return NULL;
-  }
-
-  PyObject *result = Py_BuildValue("(O(fff))", this_class, 
-                                   (*this)[0], (*this)[1], (*this)[2]);
-  Py_DECREF(this_class);
-  return result;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase3::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVecBase3)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'x' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
-
-  } else if (attr_name.size() == 3) {
-    FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[attr_name[2] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase3::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LVecBase3)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'x' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  // It is a sequence, perhaps another vector?
-  if (PySequence_Check(assign)) {
-
-    // Whoosh.
-    PyObject* fast = PySequence_Fast(assign, "");
-    nassertr(fast != NULL, -1);
-    
-    // Let's be strict about size mismatches, to prevent user error.
-    if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
-      PyErr_SetString(PyExc_ValueError, "length mismatch");
-      Py_DECREF(fast);
-      return -1;
-    }
-    
-    // Get a pointer to the items, iterate over it and
-    // perform our magic assignment.  Fast fast.  Oh yeah.
-    PyObject** items = PySequence_Fast_ITEMS(fast);
-    for (int i = 0; i < attr_name.size(); ++i) {
-
-      PyObject* fl = PyNumber_Float(items[i]);
-      if (fl == NULL) {
-        // Oh darn.  Not when we've come this far.
-        PyErr_SetString(PyExc_ValueError, "a sequence of floats is required");
-        Py_DECREF(fast);
-        return -1;
-      }
-      double value = PyFloat_AS_DOUBLE(fl);
-      Py_DECREF(fl);
-
-      _v.data[attr_name[i] - 'x'] = value;
-    }
-
-    Py_DECREF(fast);
-
-  } else {
-    // Maybe it's a single floating-point value.
-    PyObject* fl = PyNumber_Float(assign);
-    if (fl == NULL) {
-      // It's not a floating-point value either?
-      // Sheesh, I don't know what to do with it then.
-      if (attr_name.size() == 1) {
-        PyErr_SetString(PyExc_ValueError, "a float is required");
-      } else {
-        PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable",
-          assign->ob_type->tp_name);
-      }
-      return -1;
-    }
-    double value = PyFloat_AS_DOUBLE(fl);
-    Py_DECREF(fl);
-
-    // Loop through the components in the attribute name,
-    // and assign the floating-point value to every one of them.
-    for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-      _v.data[(*it) - 'x'] = value;
-    } 
-  }
-
-  return 0;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase3::init_type
 //       Access: Public, Static
@@ -185,3 +38,4 @@ init_type() {
     register_type(_type_handle, name);
   }
 }
+

+ 5 - 11
panda/src/linmath/lvecBase3_src.h

@@ -37,17 +37,13 @@ PUBLISHED:
 
   INLINE_LINMATH ~FLOATNAME(LVecBase3)();
 
-#ifdef HAVE_PYTHON
-  PyObject *__reduce__(PyObject *self) const;
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH FLOATTYPE operator [](int i) const;
   INLINE_LINMATH FLOATTYPE &operator [](int i);
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void __setitem__(int i, FLOATTYPE v);
-#endif
+  EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
   INLINE_LINMATH static int size();
 
   INLINE_LINMATH bool is_nan() const;
@@ -137,9 +133,7 @@ PUBLISHED:
   INLINE_LINMATH bool almost_equal(const FLOATNAME(LVecBase3) &other) const;
 
   INLINE_LINMATH void output(ostream &out) const;
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 22 - 0
panda/src/linmath/lvecBase4_ext.I

@@ -0,0 +1,22 @@
+// Filename: lvecBase4_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lvecBase4.h"
+
+#include "fltnames.h"
+#include "lvecBase4_ext_src.I"
+
+#include "dblnames.h"
+#include "lvecBase4_ext_src.I"
+

+ 194 - 0
panda/src/linmath/lvecBase4_ext_src.I

@@ -0,0 +1,194 @@
+// Filename: lvecBase4_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase4::__setitem__
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_METHOD_ARGS(FLOATNAME(LVecBase4),
+__setitem__, int i, FLOATTYPE v) {
+  nassertv(i >= 0 && i < 4);
+  this->_v.data[i] = v;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase4::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ", "
+      << MAYBE_ZERO(this->_v.v._2) << ", "
+      << MAYBE_ZERO(this->_v.v._3) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase4::__reduce__
+//       Access: Published
+//  Description: This special Python method is implement to provide
+//               support for the pickle module.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
+__reduce__, PyObject *self) {
+  // We should return at least a 2-tuple, (Class, (args)): the
+  // necessary class object whose constructor we should call
+  // (e.g. this), and the arguments necessary to reconstruct this
+  // object.
+  PyObject *this_class = PyObject_Type(self);
+  if (this_class == NULL) {
+    return NULL;
+  }
+
+  PyObject *result = Py_BuildValue("(O(ffff))", this_class, 
+                                   (*this)[0], (*this)[1], (*this)[2], (*this)[3]);
+  Py_DECREF(this_class);
+  return result;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase4::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVecBase4),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'w' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    if (attr_name[0] == 'w') {
+      return PyFloat_FromDouble(this->_v.data[3]);
+    } else {
+      return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    }
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
+
+  } else if (attr_name.size() == 3) {
+    FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
+
+  } else if (attr_name.size() == 4) {
+    FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    vec->_v.v._3 = this->_v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
+  }
+
+  return NULL;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVecBase4::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase4),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'w' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  // It is a sequence, perhaps another vector?
+  if (PySequence_Check(assign)) {
+
+    // Whoosh.
+    PyObject* fast = PySequence_Fast(assign, "");
+    nassertr(fast != NULL, -1);
+    
+    // Let's be strict about size mismatches, to prevent user error.
+    if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
+      PyErr_SetString(PyExc_ValueError, "length mismatch");
+      Py_DECREF(fast);
+      return -1;
+    }
+    
+    // Get a pointer to the items, iterate over it and
+    // perform our magic assignment.  Fast fast.  Oh yeah.
+    PyObject** items = PySequence_Fast_ITEMS(fast);
+    for (int i = 0; i < attr_name.size(); ++i) {
+
+      PyObject* fl = PyNumber_Float(items[i]);
+      if (fl == NULL) {
+        // Oh darn.  Not when we've come this far.
+        PyErr_SetString(PyExc_ValueError, "a sequence of floats is required");
+        Py_DECREF(fast);
+        return -1;
+      }
+      double value = PyFloat_AS_DOUBLE(fl);
+      Py_DECREF(fl);
+
+      this->_v.data[(attr_name[i] == 'w') ? 3 : attr_name[i] - 'x'] = value;
+    }
+
+    Py_DECREF(fast);
+
+  } else {
+    // Maybe it's a single floating-point value.
+    PyObject* fl = PyNumber_Float(assign);
+    if (fl == NULL) {
+      // It's not a floating-point value either?
+      // Sheesh, I don't know what to do with it then.
+      if (attr_name.size() == 1) {
+        PyErr_SetString(PyExc_ValueError, "a float is required");
+      } else {
+        PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable",
+          assign->ob_type->tp_name);
+      }
+      return -1;
+    }
+    double value = PyFloat_AS_DOUBLE(fl);
+    Py_DECREF(fl);
+
+    // Loop through the components in the attribute name,
+    // and assign the floating-point value to every one of them.
+    for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+      this->_v.data[((*it) == 'w') ? 3 : (*it) - 'x'] = value;
+    } 
+  }
+
+  return 0;
+}
+

+ 0 - 29
panda/src/linmath/lvecBase4_src.I

@@ -170,19 +170,6 @@ operator [](int i) {
   return _v.data[i];
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase4::__setitem__
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVecBase4)::
-__setitem__(int i, FLOATTYPE v) {
-  nassertv(i >= 0 && i < 4);
-  _v.data[i] = v;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase4::size
 //       Access: Public, Static
@@ -833,22 +820,6 @@ output(ostream &out) const {
       << MAYBE_ZERO(_v.v._3);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase4::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVecBase4)::
-python_repr(ostream &out, const string &class_name) const {
-  out << class_name << "(" 
-      << MAYBE_ZERO(_v.v._0) << ", "
-      << MAYBE_ZERO(_v.v._1) << ", "
-      << MAYBE_ZERO(_v.v._2) << ", "
-      << MAYBE_ZERO(_v.v._3) << ")";
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase4::generate_hash
 //       Access: Public

+ 1 - 160
panda/src/linmath/lvecBase4_src.cxx

@@ -14,16 +14,6 @@
 
 TypeHandle FLOATNAME(LVecBase4)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4);
-#endif
-#endif  // HAVE_PYTHON
-
 const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_zero =
   FLOATNAME(LVecBase4)(0.0f, 0.0f, 0.0f, 0.0f);
 const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_unit_x =
@@ -35,156 +25,6 @@ const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_unit_z =
 const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_unit_w =
   FLOATNAME(LVecBase4)(0.0f, 0.0f, 0.0f, 1.0f);
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase4::__reduce__
-//       Access: Published
-//  Description: This special Python method is implement to provide
-//               support for the pickle module.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVecBase4)::
-__reduce__(PyObject *self) const {
-  // We should return at least a 2-tuple, (Class, (args)): the
-  // necessary class object whose constructor we should call
-  // (e.g. this), and the arguments necessary to reconstruct this
-  // object.
-  PyObject *this_class = PyObject_Type(self);
-  if (this_class == NULL) {
-    return NULL;
-  }
-
-  PyObject *result = Py_BuildValue("(O(ffff))", this_class, 
-                                   (*this)[0], (*this)[1], (*this)[2], (*this)[3]);
-  Py_DECREF(this_class);
-  return result;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase4::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVecBase4)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'w' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    if (attr_name[0] == 'w') {
-      return PyFloat_FromDouble(_v.data[3]);
-    } else {
-      return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-    }
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LVecBase2) *vec = new FLOATNAME(LVecBase2);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase2), true, false);
-
-  } else if (attr_name.size() == 3) {
-    FLOATNAME(LVecBase3) *vec = new FLOATNAME(LVecBase3);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase3), true, false);
-
-  } else if (attr_name.size() == 4) {
-    FLOATNAME(LVecBase4) *vec = new FLOATNAME(LVecBase4);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    vec->_v.v._3 = _v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVecBase4), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVecBase4::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LVecBase4)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'w' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  // It is a sequence, perhaps another vector?
-  if (PySequence_Check(assign)) {
-
-    // Whoosh.
-    PyObject* fast = PySequence_Fast(assign, "");
-    nassertr(fast != NULL, -1);
-    
-    // Let's be strict about size mismatches, to prevent user error.
-    if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
-      PyErr_SetString(PyExc_ValueError, "length mismatch");
-      Py_DECREF(fast);
-      return -1;
-    }
-    
-    // Get a pointer to the items, iterate over it and
-    // perform our magic assignment.  Fast fast.  Oh yeah.
-    PyObject** items = PySequence_Fast_ITEMS(fast);
-    for (int i = 0; i < attr_name.size(); ++i) {
-
-      PyObject* fl = PyNumber_Float(items[i]);
-      if (fl == NULL) {
-        // Oh darn.  Not when we've come this far.
-        PyErr_SetString(PyExc_ValueError, "a sequence of floats is required");
-        Py_DECREF(fast);
-        return -1;
-      }
-      double value = PyFloat_AS_DOUBLE(fl);
-      Py_DECREF(fl);
-
-      _v.data[(attr_name[i] == 'w') ? 3 : attr_name[i] - 'x'] = value;
-    }
-
-    Py_DECREF(fast);
-
-  } else {
-    // Maybe it's a single floating-point value.
-    PyObject* fl = PyNumber_Float(assign);
-    if (fl == NULL) {
-      // It's not a floating-point value either?
-      // Sheesh, I don't know what to do with it then.
-      if (attr_name.size() == 1) {
-        PyErr_SetString(PyExc_ValueError, "a float is required");
-      } else {
-        PyErr_Format(PyExc_ValueError, "'%.200s' object is not iterable",
-          assign->ob_type->tp_name);
-      }
-      return -1;
-    }
-    double value = PyFloat_AS_DOUBLE(fl);
-    Py_DECREF(fl);
-
-    // Loop through the components in the attribute name,
-    // and assign the floating-point value to every one of them.
-    for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-      _v.data[((*it) == 'w') ? 3 : (*it) - 'x'] = value;
-    } 
-  }
-
-  return 0;
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVecBase4::init_type
 //       Access: Public, Static
@@ -199,3 +39,4 @@ init_type() {
     register_type(_type_handle, name);
   }
 }
+

+ 5 - 11
panda/src/linmath/lvecBase4_src.h

@@ -41,17 +41,13 @@ PUBLISHED:
 
   INLINE_LINMATH ~FLOATNAME(LVecBase4)();
 
-#ifdef HAVE_PYTHON
-  PyObject *__reduce__(PyObject *self) const;
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH FLOATTYPE operator [](int i) const;
   INLINE_LINMATH FLOATTYPE &operator [](int i);
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void __setitem__(int i, FLOATTYPE v);
-#endif
+  EXTENSION(INLINE_LINMATH void __setitem__(int i, FLOATTYPE v));
   INLINE_LINMATH static int size();
 
   INLINE_LINMATH bool is_nan() const;
@@ -135,9 +131,7 @@ PUBLISHED:
   INLINE_LINMATH bool almost_equal(const FLOATNAME(LVecBase4) &other) const;
 
   INLINE_LINMATH void output(ostream &out) const;
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 22 - 0
panda/src/linmath/lvector2_ext.I

@@ -0,0 +1,22 @@
+// Filename: lvector2_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lvector2.h"
+
+#include "fltnames.h"
+#include "lvector2_ext_src.I"
+
+#include "dblnames.h"
+#include "lvector2_ext_src.I"
+

+ 72 - 0
panda/src/linmath/lvector2_ext_src.I

@@ -0,0 +1,72 @@
+// Filename: lvector2_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector2::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector2),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector2::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVector2),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it != 'x' && *it != 'y') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
+  }
+
+  return NULL;
+}
+
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase2), __setattr__, PyObject*, const string&, PyObject*);
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector2::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+INLINE int EXT_METHOD_ARGS(FLOATNAME(LVector2),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+  return CALL_EXT_METHOD(FLOATNAME(LVecBase2), __setattr__, this, self, attr_name, assign);
+}
+

+ 0 - 12
panda/src/linmath/lvector2_src.I

@@ -209,15 +209,3 @@ signed_angle_deg(const FLOATNAME(LVector2) &other) const {
   return rad_2_deg(signed_angle_rad(other));
 }
 
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVector2::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVector2)::
-python_repr(ostream &out, const string &class_name) const {
-  FLOATNAME(LVecBase2)::python_repr(out, class_name);
-}
-#endif  // HAVE_PYTHON

+ 0 - 49
panda/src/linmath/lvector2_src.cxx

@@ -14,55 +14,6 @@
 
 TypeHandle FLOATNAME(LVector2)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
-#endif
-#endif  // HAVE_PYTHON
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVector2::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVector2)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it != 'x' && *it != 'y') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVector2::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LVector2)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-  return FLOATNAME(LVecBase2)::__setattr__(self, attr_name, assign);
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVector2::init_type
 //       Access: Public, Static

+ 3 - 7
panda/src/linmath/lvector2_src.h

@@ -25,10 +25,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE x, FLOATTYPE y);
 
-#ifdef HAVE_PYTHON
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LVector2) &zero();
   INLINE_LINMATH static const FLOATNAME(LVector2) &unit_x();
@@ -49,9 +47,7 @@ PUBLISHED:
   INLINE_LINMATH FLOATTYPE signed_angle_rad(const FLOATNAME(LVector2) &other) const;
   INLINE_LINMATH FLOATTYPE signed_angle_deg(const FLOATNAME(LVector2) &other) const;
 
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   static TypeHandle get_class_type() {

+ 22 - 0
panda/src/linmath/lvector3_ext.I

@@ -0,0 +1,22 @@
+// Filename: lvector3_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lvector3.h"
+
+#include "fltnames.h"
+#include "lvector3_ext_src.I"
+
+#include "dblnames.h"
+#include "lvector3_ext_src.I"
+

+ 81 - 0
panda/src/linmath/lvector3_ext_src.I

@@ -0,0 +1,81 @@
+// Filename: lvector3_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector3::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector3),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ", "
+      << MAYBE_ZERO(this->_v.v._2) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector3::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVector3),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'x' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
+
+  } else if (attr_name.size() == 3) {
+    FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
+    vec->_v.v._0 = this->_v.data[attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[attr_name[2] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
+  }
+
+  return NULL;
+}
+
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase3), __setattr__, PyObject*, const string&, PyObject*);
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector3::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+INLINE int EXT_METHOD_ARGS(FLOATNAME(LVector3),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+  return CALL_EXT_METHOD(FLOATNAME(LVecBase3), __setattr__, this, self, attr_name, assign);
+}
+

+ 0 - 11
panda/src/linmath/lvector3_src.I

@@ -484,14 +484,3 @@ rfu(FLOATTYPE right_v, FLOATTYPE fwd_v, FLOATTYPE up_v,
  return FLOATNAME(LVector3)(right_v,vy,vz);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVector3::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVector3)::
-python_repr(ostream &out, const string &class_name) const {
-  FLOATNAME(LVecBase3)::python_repr(out, class_name);
-}
-#endif  // HAVE_PYTHON

+ 0 - 57
panda/src/linmath/lvector3_src.cxx

@@ -14,63 +14,6 @@
 
 TypeHandle FLOATNAME(LVector3)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
-#endif
-#endif  // HAVE_PYTHON
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVector3::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVector3)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'x' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
-
-  } else if (attr_name.size() == 3) {
-    FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
-    vec->_v.v._0 = _v.data[attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[attr_name[2] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVector3::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LVector3)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-  return FLOATNAME(LVecBase3)::__setattr__(self, attr_name, assign);
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVector3::init_type
 //       Access: Public, Static

+ 3 - 7
panda/src/linmath/lvector3_src.h

@@ -31,10 +31,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
 
-#ifdef HAVE_PYTHON
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LVector3) &zero();
   INLINE_LINMATH static const FLOATNAME(LVector3) &unit_x();
@@ -84,9 +82,7 @@ PUBLISHED:
   INLINE_LINMATH static FLOATNAME(LVector3) rfu(FLOATTYPE right,
                                         FLOATTYPE fwd,FLOATTYPE up,     CoordinateSystem cs = CS_default);
 
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   static TypeHandle get_class_type() {

+ 22 - 0
panda/src/linmath/lvector4_ext.I

@@ -0,0 +1,22 @@
+// Filename: lvector4_ext.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+#include "lvector4.h"
+
+#include "fltnames.h"
+#include "lvector4_ext_src.I"
+
+#include "dblnames.h"
+#include "lvector4_ext_src.I"
+

+ 95 - 0
panda/src/linmath/lvector4_ext_src.I

@@ -0,0 +1,95 @@
+// Filename: lvector4_ext_src.I
+// Created by:  rdb (02Jan11)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) Carnegie Mellon University.  All rights reserved.
+//
+// All use of this software is subject to the terms of the revised BSD
+// license.  You should have received a copy of this license along
+// with this source code in a file named "LICENSE."
+//
+////////////////////////////////////////////////////////////////////
+
+
+#ifndef CPPPARSER
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
+IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
+#endif
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector4::python_repr
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE void EXT_CONST_METHOD_ARGS(FLOATNAME(LVector4),
+python_repr, ostream &out, const string &class_name) {
+  out << class_name << "(" 
+      << MAYBE_ZERO(this->_v.v._0) << ", "
+      << MAYBE_ZERO(this->_v.v._1) << ", "
+      << MAYBE_ZERO(this->_v.v._2) << ", "
+      << MAYBE_ZERO(this->_v.v._3) << ")";
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector4::__getattr__
+//       Access: Published
+//  Description: This is used to implement swizzle masks.
+////////////////////////////////////////////////////////////////////
+INLINE PyObject *EXT_CONST_METHOD_ARGS(FLOATNAME(LVector4),
+__getattr__, const string &attr_name) {
+#ifndef NDEBUG
+  // Validate the attribute name.
+  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
+    if (*it < 'w' || *it > 'z') {
+      return NULL;
+    }
+  }
+#endif
+
+  if (attr_name.size() == 1) {
+    if (attr_name[0] == 'w') {
+      return PyFloat_FromDouble(this->_v.data[3]);
+    } else {
+      return PyFloat_FromDouble(this->_v.data[attr_name[0] - 'x']);
+    }
+
+  } else if (attr_name.size() == 2) {
+    FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
+
+  } else if (attr_name.size() == 3) {
+    FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
+
+  } else if (attr_name.size() == 4) {
+    FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
+    vec->_v.v._0 = this->_v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
+    vec->_v.v._1 = this->_v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
+    vec->_v.v._2 = this->_v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
+    vec->_v.v._3 = this->_v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
+    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
+  }
+
+  return NULL;
+}
+
+int EXT_METHOD_ARGS(FLOATNAME(LVecBase4), __setattr__, PyObject*, const string&, PyObject*);
+
+////////////////////////////////////////////////////////////////////
+//     Function: LVector4::__setattr__
+//       Access: Published
+//  Description: This is used to implement write masks.
+////////////////////////////////////////////////////////////////////
+INLINE int EXT_METHOD_ARGS(FLOATNAME(LVector4),
+__setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
+  return CALL_EXT_METHOD(FLOATNAME(LVecBase4), __setattr__, this, self, attr_name, assign);
+}
+

+ 0 - 11
panda/src/linmath/lvector4_src.I

@@ -208,14 +208,3 @@ project(const FLOATNAME(LVecBase4) &onto) const {
   return FLOATNAME(LVecBase4)::project(onto);
 }
 
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVector4::python_repr
-//       Access: Published
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE_LINMATH void FLOATNAME(LVector4)::
-python_repr(ostream &out, const string &class_name) const {
-  FLOATNAME(LVecBase4)::python_repr(out, class_name);
-}
-#endif  // HAVE_PYTHON

+ 0 - 71
panda/src/linmath/lvector4_src.cxx

@@ -14,76 +14,6 @@
 
 TypeHandle FLOATNAME(LVector4)::_type_handle;
 
-#ifdef HAVE_PYTHON
-#include "py_panda.h"  
-
-#ifndef CPPPARSER
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3);
-IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4);
-#endif
-#endif  // HAVE_PYTHON
-
-#ifdef HAVE_PYTHON
-////////////////////////////////////////////////////////////////////
-//     Function: LVector4::__getattr__
-//       Access: Published
-//  Description: This is used to implement swizzle masks.
-////////////////////////////////////////////////////////////////////
-PyObject *FLOATNAME(LVector4)::
-__getattr__(const string &attr_name) const {
-#ifndef NDEBUG
-  // Validate the attribute name.
-  for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) {
-    if (*it < 'w' || *it > 'z') {
-      return NULL;
-    }
-  }
-#endif
-
-  if (attr_name.size() == 1) {
-    if (attr_name[0] == 'w') {
-      return PyFloat_FromDouble(_v.data[3]);
-    } else {
-      return PyFloat_FromDouble(_v.data[attr_name[0] - 'x']);
-    }
-
-  } else if (attr_name.size() == 2) {
-    FLOATNAME(LVector2) *vec = new FLOATNAME(LVector2);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector2), true, false);
-
-  } else if (attr_name.size() == 3) {
-    FLOATNAME(LVector3) *vec = new FLOATNAME(LVector3);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector3), true, false);
-
-  } else if (attr_name.size() == 4) {
-    FLOATNAME(LVector4) *vec = new FLOATNAME(LVector4);
-    vec->_v.v._0 = _v.data[(attr_name[0] == 'w') ? 3 : attr_name[0] - 'x'];
-    vec->_v.v._1 = _v.data[(attr_name[1] == 'w') ? 3 : attr_name[1] - 'x'];
-    vec->_v.v._2 = _v.data[(attr_name[2] == 'w') ? 3 : attr_name[2] - 'x'];
-    vec->_v.v._3 = _v.data[(attr_name[3] == 'w') ? 3 : attr_name[3] - 'x'];
-    return DTool_CreatePyInstance((void *)vec, FLOATNAME(Dtool_LVector4), true, false);
-  }
-
-  return NULL;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: LVector4::__setattr__
-//       Access: Published
-//  Description: This is used to implement write masks.
-////////////////////////////////////////////////////////////////////
-int FLOATNAME(LVector4)::
-__setattr__(PyObject *self, const string &attr_name, PyObject *assign) {
-  return FLOATNAME(LVecBase4)::__setattr__(self, attr_name, assign);
-}
-#endif  // HAVE_PYTHON
-
 ////////////////////////////////////////////////////////////////////
 //     Function: LVector2::init_type
 //       Access: Public, Static
@@ -100,4 +30,3 @@ init_type() {
   }
 }
 
-

+ 3 - 7
panda/src/linmath/lvector4_src.h

@@ -25,10 +25,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
 
-#ifdef HAVE_PYTHON
-  PyObject *__getattr__(const string &attr_name) const;
-  int __setattr__(PyObject *self, const string &attr_name, PyObject *assign);
-#endif
+  EXTENSION(PyObject *__getattr__(const string &attr_name) const);
+  EXTENSION(int __setattr__(PyObject *self, const string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LVector4) &zero();
   INLINE_LINMATH static const FLOATNAME(LVector4) &unit_x();
@@ -49,9 +47,7 @@ PUBLISHED:
 
   INLINE_LINMATH FLOATNAME(LVector4) project(const FLOATNAME(LVecBase4) &onto) const;
 
-#ifdef HAVE_PYTHON
-  INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const;
-#endif
+  EXTENSION(INLINE_LINMATH void python_repr(ostream &out, const string &class_name) const);
 
 public:
   static TypeHandle get_class_type() {