diff --git a/simgear/nasal/cppbind/CMakeLists.txt b/simgear/nasal/cppbind/CMakeLists.txt
index ed8272fd..0439e6ed 100644
--- a/simgear/nasal/cppbind/CMakeLists.txt
+++ b/simgear/nasal/cppbind/CMakeLists.txt
@@ -4,21 +4,22 @@ set(HEADERS
Ghost.hxx
NasalHash.hxx
NasalString.hxx
- from_nasal_detail.hxx
from_nasal.hxx
- nasal_traits.hxx
to_nasal.hxx
)
set(DETAIL_HEADERS
+ detail/from_nasal_helper.hxx
detail/functor_templates.hxx
+ detail/nasal_traits.hxx
+ detail/to_nasal_helper.hxx
)
set(SOURCES
NasalHash.cxx
NasalString.cxx
- from_nasal.cxx
- to_nasal.cxx
+ detail/from_nasal_helper.cxx
+ detail/to_nasal_helper.cxx
)
simgear_component(nasal/cppbind nasal/cppbind "${SOURCES}" "${HEADERS}")
diff --git a/simgear/nasal/cppbind/cppbind_test.cxx b/simgear/nasal/cppbind/cppbind_test.cxx
index 90bbf855..9508ca5d 100644
--- a/simgear/nasal/cppbind/cppbind_test.cxx
+++ b/simgear/nasal/cppbind/cppbind_test.cxx
@@ -50,18 +50,21 @@ struct DoubleDerived:
{
};
+
+typedef boost::shared_ptr BasePtr;
+
struct DoubleDerived2:
public Derived
{
-
+ const BasePtr& getBase() const{return _base;}
+ BasePtr _base;
};
-typedef boost::shared_ptr BasePtr;
typedef boost::shared_ptr DerivedPtr;
typedef boost::shared_ptr DoubleDerivedPtr;
typedef boost::shared_ptr DoubleDerived2Ptr;
-naRef to_nasal(naContext c, const BasePtr& base)
+naRef to_nasal_helper(naContext c, const BasePtr& base)
{
return nasal::Ghost::create(c, base);
}
@@ -159,7 +162,8 @@ int main(int argc, char* argv[])
Ghost::init("DoubleDerivedPtr")
.bases();
Ghost::init("DoubleDerived2Ptr")
- .bases< Ghost >();
+ .bases< Ghost >()
+ .member("base", &DoubleDerived2::getBase);
BasePtr d( new Derived );
naRef derived = Ghost::create(c, d);
diff --git a/simgear/nasal/cppbind/from_nasal.cxx b/simgear/nasal/cppbind/detail/from_nasal_helper.cxx
similarity index 95%
rename from simgear/nasal/cppbind/from_nasal.cxx
rename to simgear/nasal/cppbind/detail/from_nasal_helper.cxx
index bed08e42..a094e4fb 100644
--- a/simgear/nasal/cppbind/from_nasal.cxx
+++ b/simgear/nasal/cppbind/detail/from_nasal_helper.cxx
@@ -16,9 +16,9 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-#include "from_nasal_detail.hxx"
-#include "NasalHash.hxx"
-#include "NasalString.hxx"
+#include "from_nasal_helper.hxx"
+#include
+#include
#include
diff --git a/simgear/nasal/cppbind/from_nasal_detail.hxx b/simgear/nasal/cppbind/detail/from_nasal_helper.hxx
similarity index 97%
rename from simgear/nasal/cppbind/from_nasal_detail.hxx
rename to simgear/nasal/cppbind/detail/from_nasal_helper.hxx
index 6ff72f25..865bc8d1 100644
--- a/simgear/nasal/cppbind/from_nasal_detail.hxx
+++ b/simgear/nasal/cppbind/detail/from_nasal_helper.hxx
@@ -17,8 +17,8 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-#ifndef SG_FROM_NASAL_DETAIL_HXX_
-#define SG_FROM_NASAL_DETAIL_HXX_
+#ifndef SG_FROM_NASAL_HELPER_HXX_
+#define SG_FROM_NASAL_HELPER_HXX_
#include "nasal_traits.hxx"
@@ -145,4 +145,4 @@ namespace nasal
} // namespace nasal
-#endif /* SG_FROM_NASAL_DETAIL_HXX_ */
+#endif /* SG_FROM_NASAL_HELPER_HXX_ */
diff --git a/simgear/nasal/cppbind/nasal_traits.hxx b/simgear/nasal/cppbind/detail/nasal_traits.hxx
similarity index 100%
rename from simgear/nasal/cppbind/nasal_traits.hxx
rename to simgear/nasal/cppbind/detail/nasal_traits.hxx
diff --git a/simgear/nasal/cppbind/to_nasal.cxx b/simgear/nasal/cppbind/detail/to_nasal_helper.cxx
similarity index 76%
rename from simgear/nasal/cppbind/to_nasal.cxx
rename to simgear/nasal/cppbind/detail/to_nasal_helper.cxx
index b5224ad2..bc1f25e2 100644
--- a/simgear/nasal/cppbind/to_nasal.cxx
+++ b/simgear/nasal/cppbind/detail/to_nasal_helper.cxx
@@ -16,15 +16,15 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-#include "to_nasal.hxx"
-#include "NasalHash.hxx"
+#include "to_nasal_helper.hxx"
+#include
#include
namespace nasal
{
//----------------------------------------------------------------------------
- naRef to_nasal(naContext c, const std::string& str)
+ naRef to_nasal_helper(naContext c, const std::string& str)
{
naRef ret = naNewString(c);
naStr_fromdata(ret, str.c_str(), str.size());
@@ -32,32 +32,32 @@ namespace nasal
}
//----------------------------------------------------------------------------
- naRef to_nasal(naContext c, const char* str)
+ naRef to_nasal_helper(naContext c, const char* str)
{
- return to_nasal(c, std::string(str));
+ return to_nasal_helper(c, std::string(str));
}
//----------------------------------------------------------------------------
- naRef to_nasal(naContext c, naCFunction func)
+ naRef to_nasal_helper(naContext c, naCFunction func)
{
return naNewFunc(c, naNewCCode(c, func));
}
//----------------------------------------------------------------------------
- naRef to_nasal(naContext c, const Hash& hash)
+ naRef to_nasal_helper(naContext c, const Hash& hash)
{
return hash.get_naRef();
}
//----------------------------------------------------------------------------
- naRef to_nasal(naContext c, const naRef& ref)
+ naRef to_nasal_helper(naContext c, const naRef& ref)
{
return ref;
}
//----------------------------------------------------------------------------
- naRef to_nasal(naContext c, const SGPath& path)
+ naRef to_nasal_helper(naContext c, const SGPath& path)
{
- return to_nasal(c, path.str());
+ return to_nasal_helper(c, path.str());
}
} // namespace nasal
diff --git a/simgear/nasal/cppbind/detail/to_nasal_helper.hxx b/simgear/nasal/cppbind/detail/to_nasal_helper.hxx
new file mode 100644
index 00000000..e367e00d
--- /dev/null
+++ b/simgear/nasal/cppbind/detail/to_nasal_helper.hxx
@@ -0,0 +1,163 @@
+///@file
+/// Conversion helpers used by to_nasal(naContext, T)
+///
+// Copyright (C) 2012 Thomas Geymayer
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+#ifndef SG_TO_NASAL_HELPER_HXX_
+#define SG_TO_NASAL_HELPER_HXX_
+
+#include "nasal_traits.hxx"
+
+#include
+
+#include
+#include
+#include
+
+#include