OSDN Git Service

fix for gcc-4.5 on cygwin
[meshio/meshio.git] / swig / pmd.i
index 46db01e..bc2ec4e 100644 (file)
@@ -1,17 +1,17 @@
 %module pmd
+
 %{
 #include <pmd.h>
-using namespace meshio;
-using namespace pmd;
 %}
-%include "std_vector.i"
-%include "std_wstring.i"
-%include "../include/color.h"
-%include "../include/la.h"
-%include "../include/pmd.h"
+%include "../../src/pmd.h"
+%include "../../src/color.h"
+%include "../../src/la.h"
+%include "../../src/text.h"
 
+%include "std_pair.i"
+%include "std_vector.i"
 %template(VertexVector) std::vector<meshio::pmd::Vertex>;
-%template(MaterialVector) std::vector<meshio::pmd::Material*>;
+%template(MaterialVector) std::vector<meshio::pmd::Material>;
 %template(BoneVector) std::vector<meshio::pmd::Bone>;
 %template(IKVector) std::vector<meshio::pmd::IK>;
 %template(MorphVector) std::vector<meshio::pmd::Morph>;
@@ -19,90 +19,10 @@ using namespace pmd;
 %template(ConstraintVector) std::vector<meshio::pmd::Constraint>;
 %template(UintVector) std::vector<unsigned int>;
 %template(UshortVector) std::vector<unsigned short>;
-%template(Vector3Vector) std::vector<meshio::pmd::Vector3>;
+%template(Vector3Vector) std::vector<meshio::Vector3>;
 %template(PBoneVector) std::vector<meshio::pmd::Bone*>;
+%template(BoneGroupVector) std::vector<meshio::pmd::BoneGroup>;
+%template(DisplayPair) std::pair<unsigned short, unsigned char>;
+%template(BoneDisplayVector) std::vector<std::pair<unsigned short, unsigned char> >;
+%template(fixed_string_20) meshio::fixed_string<20>;
 
-///////////////////////////////////////////////////////////////////////////////
-// meshio::pmd::IO::each_vertex
-///////////////////////////////////////////////////////////////////////////////
-%inline %{
-//! Thin wrapper for ONLY the increment operator
-void _vertices_incr(std::vector<meshio::pmd::Vertex>::const_iterator* iter)
-{
-    // increment the iterator
-    ++(*iter);
-}
-%}
-
-%extend meshio::pmd::IO {
-%pythoncode {
-    def each_vertex(self):
-        iter = self._beginVertices()
-        while True:
-            vertex = self._dereferenceVertex(iter)
-            if vertex:
-                _vertices_incr(iter)
-                yield vertex
-            else:
-                break
-%}
-
-//! get the first element in the vector
-std::vector<meshio::pmd::Vertex>::const_iterator* _beginVertices()
-{
-    return new std::vector<meshio::pmd::Vertex>::const_iterator(
-            ($self->vertices.begin()));
-}
-
-//! dereference the iterator; return NULL if at the end
-const meshio::pmd::Vertex* _dereferenceVertex(
-        const std::vector<meshio::pmd::Vertex>::const_iterator* iter )
-{
-    // if at the end, return NULL
-    if (*iter == ($self)->vertices.end() ) {
-        return NULL;
-    }
-    // otherwise, return the face to which this iterator points
-    return &(**iter);
-}
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// addVertex
-// addMaterial
-// addBone
-// addMorph
-///////////////////////////////////////////////////////////////////////////////
-%extend meshio::pmd::IO {
-
-meshio::pmd::Vertex * addVertex()
-{
-    $self->vertices.push_back(meshio::pmd::Vertex());
-    return &($self->vertices.back());
-}
-
-meshio::pmd::Material *addMaterial()
-{
-    $self->materials.push_back(new meshio::pmd::Material);
-    return $self->materials.back();
-}
-
-meshio::pmd::Bone *addBone()
-{
-    $self->bones.push_back(meshio::pmd::Bone());
-    return &($self->bones.back());
-}
-
-meshio::pmd::Morph *addMorph()
-{
-    $self->morph_list.push_back(meshio::pmd::Morph());
-    return &($self->morph_list.back());
-}
-
-meshio::pmd::IK *addIK()
-{
-    $self->ik_list.push_back(meshio::pmd::IK());
-    return &($self->ik_list.back());
-}
-
-}