From d05c32248d8b7921e3795996f18389d01ec9d6bd Mon Sep 17 00:00:00 2001 From: Amorilia <amorilia@users.sourceforge.net> Date: Wed, 21 Mar 2007 16:31:34 +0000 Subject: [PATCH] Changed order of %include's: Ref.h is now %included before niflib.h. It looks like the problem with illegal return types under SWIG is solved. (Solution suggested by Shon.) --- swig/pyniflib.h | 4 ---- swig/pyniflib.i | 8 +++++++- test/niflib_test.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/swig/pyniflib.h b/swig/pyniflib.h index 3dbd281b..4ebb00d5 100644 --- a/swig/pyniflib.h +++ b/swig/pyniflib.h @@ -11,10 +11,6 @@ using namespace std; Niflib::NiNodeRef CreateNiNode() { return Niflib::NiNodeRef(new Niflib::NiNode); } -// SWIG does not like ReadNifTree; so far I have no idea why. -// As a workaround, you can use this wrapper function. -Niflib::NiObjectRef ReadNifFile( string name, Niflib::NifInfo * nifinfo) { return Niflib::ReadNifTree(name, nifinfo);} - }; #endif diff --git a/swig/pyniflib.i b/swig/pyniflib.i index 0f7a60a3..c9b7b2f9 100644 --- a/swig/pyniflib.i +++ b/swig/pyniflib.i @@ -355,8 +355,14 @@ POSSIBILITY OF SUCH DAMAGE. */ // Headers exposed to the Python interface -%include "../include/niflib.h" +// NOTE: It is mandatory that Ref.h is included before niflib.h, and actually, +// before any header that uses Ref types. +// Otherwise, swig will not recognize Ref<> to be part of the Niflib namespace +// and consequently all functions in niflib.h returning Ref<> types will not +// return correctly wrapped python types. +// Briefly, it is safest to include Ref.h first. %include "../include/Ref.h" +%include "../include/niflib.h" %include "../include/Type.h" %include "../include/nif_math.h" diff --git a/test/niflib_test.py b/test/niflib_test.py index 30fb606d..c0262e38 100644 --- a/test/niflib_test.py +++ b/test/niflib_test.py @@ -20,7 +20,7 @@ class TestNiNode(unittest.TestCase): # read nif file self.nifinfo_in = NifInfo() - root_obj = ReadNifFile("test.nif", self.nifinfo_in) + root_obj = ReadNifTree("test.nif", self.nifinfo_in) root_in = DynamicCastToNiNode(root_obj.Ptr()) self.x_in = root_in.GetLocalTransform() -- GitLab