From 11c641b03883941f4de627c170ab28d97e6d8fcc Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Wed, 8 Oct 2014 14:09:03 +0000 Subject: [PATCH] ngpython --- libsrc/csg/python_csg.cpp | 28 +------------------------- libsrc/general/ngpython.hpp | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 libsrc/general/ngpython.hpp diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index aa253320..bb27b4eb 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -1,39 +1,13 @@ #ifdef NG_PYTHON -#include +#include <../general/ngpython.hpp> #include using namespace netgen; -namespace bp = boost::python; -////////////////////////////////////////////////////////////////////// -// Lambda to function pointer conversion -template -struct function_traits - : public function_traits {}; -template -struct function_traits { - typedef ReturnType (*pointer)(Args...); - typedef ReturnType return_type; -}; - -template -typename function_traits::pointer -FunctionPointer (const Function& lambda) { - return static_cast::pointer>(lambda); -} - - -template -inline string ToString (const T& t) -{ - stringstream ss; - ss << t; - return ss.str(); -} // a shadow solid tree using shared pointers. diff --git a/libsrc/general/ngpython.hpp b/libsrc/general/ngpython.hpp new file mode 100644 index 00000000..12b31cec --- /dev/null +++ b/libsrc/general/ngpython.hpp @@ -0,0 +1,40 @@ +#ifdef NG_PYTHON + +#include +namespace bp = boost::python; + + +namespace netgen +{ + + ////////////////////////////////////////////////////////////////////// + // Lambda to function pointer conversion + template + struct function_traits + : public function_traits {}; + + template + struct function_traits { + typedef ReturnType (*pointer)(Args...); + typedef ReturnType return_type; + }; + + template + typename function_traits::pointer + FunctionPointer (const Function& lambda) { + return static_cast::pointer>(lambda); + } + + + template + inline std::string ToString (const T& t) + { + std::stringstream ss; + ss << t; + return ss.str(); + } + +} + +#endif +