Alexandria  2.27.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExpressionTreeBuilder.h
Go to the documentation of this file.
1 
19 #ifndef PYSTON_EXPRESSIONTREEBUILDER_H
20 #define PYSTON_EXPRESSIONTREEBUILDER_H
21 
22 #include <boost/python/list.hpp>
23 #include <boost/python/object.hpp>
24 #include <boost/python/object/add_to_namespace.hpp>
25 #include <boost/python/tuple.hpp>
26 #include <functional>
27 #include <tuple>
28 
29 #include "Pyston/Exceptions.h"
30 #include "Pyston/ExpressionTree.h"
31 #include "Pyston/GIL.h"
34 #include "Pyston/Helpers.h"
35 
36 namespace Pyston {
37 
44 public:
58  template <typename Signature, typename... BuildParams>
59  ExpressionTree<Signature> build(const boost::python::object& pyfunc, BuildParams&&... build_params) const {
60  return buildHelper<Signature>::build(pyfunc, std::forward<BuildParams>(build_params)...);
61  }
62 
72  template <typename Signature>
73  void registerFunction(const std::string& repr, std::function<Signature> functor);
74 
75 private:
79  template <typename Signature>
80  struct buildHelper;
81 
90  template <typename R, typename T>
91  struct buildHelper<R(const std::vector<T>&)> {
92  static ExpressionTree<R(const std::vector<T>&)> build(const boost::python::object&, size_t n);
93  };
94 
98  template <typename R, typename... Args>
99  struct buildHelper<R(Args...)> {
100  template <typename... Prototypes>
101  static ExpressionTree<R(Args...)> build(const boost::python::object&, Prototypes&&...);
102  };
103 
107  template <typename R, typename... Args>
108  static ExpressionTree<R(Args...)> compiledOrWrapped(const boost::python::object& pyfunc,
109  const boost::python::list& placeholders);
110 };
111 
112 } // end of namespace Pyston
113 
114 #define PYSTON_EXPRESSIONTREEBUILDER_IMPL
116 #undef PYSTON_EXPRESSIONTREEBUILDER_IMPL
117 
118 #endif // PYSTON_EXPRESSIONTREEBUILDER_H
static ExpressionTree< R(Args...)> compiledOrWrapped(const boost::python::object &pyfunc, const boost::python::list &placeholders)
STL class.
void registerFunction(const std::string &repr, std::function< Signature > functor)
std::function< double()> Signature
Definition: InitFunc.h:35
ExpressionTree< Signature > build(const boost::python::object &pyfunc, BuildParams &&...build_params) const