Skip to content
Snippets Groups Projects
Commit 814a9637 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[P] return by ptr, not value, saves a copy

parent fce3dd52
No related branches found
No related tags found
3 merge requests!41Fix compilation with icc, several other changes,!39Make functions copyable,!35dailywork-ftschindler
...@@ -96,7 +96,7 @@ class CutoffFunction ...@@ -96,7 +96,7 @@ class CutoffFunction
const ScalarFunction& diffusion_factor, const ScalarFunction& diffusion_factor,
const TensorFunction& diffusion_tensor, const TensorFunction& diffusion_tensor,
const R& poincare_constant, const R& poincare_constant,
const std::string& name) { return type(diffusion_factor, diffusion_tensor, poincare_constant, name); }, const std::string& name) { return new type(diffusion_factor, diffusion_tensor, poincare_constant, name); },
"grid_provider"_a, "grid_provider"_a,
"diffusion_factor"_a, "diffusion_factor"_a,
"diffusion_tesor"_a, "diffusion_tesor"_a,
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
c.def(py::init([](){return std::make_unique<type>();})); c.def(py::init([](){return std::make_unique<type>();}));
c.def("__repr__", [ClassId](type&){ return ClassId + "()";}); c.def("__repr__", [ClassId](type&){ return ClassId + "()";});
m.def(ClassId.c_str(), [](const Grid::GridProvider<G>&){return type();}); m.def(ClassId.c_str(), [](const Grid::GridProvider<G>&){return new type();});
return c; return c;
} // ... bind(...) } // ... bind(...)
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
c.def(py::init([](){return std::make_unique<type>();})); c.def(py::init([](){return std::make_unique<type>();}));
c.def("__repr__", [ClassId](type&) { return ClassId + "()"; }); c.def("__repr__", [ClassId](type&) { return ClassId + "()"; });
m.def(ClassId.c_str(), [](const Grid::GridProvider<G>&) { return type(); }); m.def(ClassId.c_str(), [](const Grid::GridProvider<G>&) { return new type(); });
return c; return c;
} // ... bind(...) } // ... bind(...)
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
c.def(py::init([](const BoundaryInfo<I>& boundary_info, c.def(py::init([](const BoundaryInfo<I>& boundary_info,
const BoundaryType& boundary_type, const BoundaryType& boundary_type,
const std::string& logging_prefix) { const std::string& logging_prefix) {
return type(boundary_info, boundary_type.copy(), logging_prefix); return new type(boundary_info, boundary_type.copy(), logging_prefix);
}), }),
"boundary_info"_a, "boundary_info"_a,
"boundary_type"_a, "boundary_type"_a,
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
[](const Grid::GridProvider<G>&, [](const Grid::GridProvider<G>&,
const BoundaryInfo<I>& boundary_info, const BoundaryInfo<I>& boundary_info,
const BoundaryType& boundary_type, const BoundaryType& boundary_type,
const std::string& logging_prefix) { return type(boundary_info, boundary_type.copy(), logging_prefix); }, const std::string& logging_prefix) { return new type(boundary_info, boundary_type.copy(), logging_prefix); },
"grid_provider"_a, "grid_provider"_a,
"boundary_info"_a, "boundary_info"_a,
"boundary_type"_a, "boundary_type"_a,
......
...@@ -74,13 +74,13 @@ public: ...@@ -74,13 +74,13 @@ public:
auto ClassName = Common::to_camel_case(class_id + "_" + grid_id); auto ClassName = Common::to_camel_case(class_id + "_" + grid_id);
bound_type c(m, ClassName.c_str(), ClassName.c_str()); bound_type c(m, ClassName.c_str(), ClassName.c_str());
c.def(py::init([](GridProvider<G>& grid_provider) { return type(grid_provider.leaf_view()); }), "grid_provider"_a); c.def(py::init([](GridProvider<G>& grid_provider) { return new type(grid_provider.leaf_view()); }), "grid_provider"_a);
addbind_methods(c); addbind_methods(c);
// factories // factories
m.def(Common::to_camel_case(class_id).c_str(), m.def(Common::to_camel_case(class_id).c_str(),
[](GridProvider<G>& grid_provider) { return type(grid_provider.leaf_view()); }, [](GridProvider<G>& grid_provider) { return new type(grid_provider.leaf_view()); },
"grid_provider"_a); "grid_provider"_a);
return c; return c;
......
...@@ -59,7 +59,7 @@ private: ...@@ -59,7 +59,7 @@ private:
c.def(pybind11::init<>()); c.def(pybind11::init<>());
m.def(makename(class_name, layer_name).c_str(), []() { return type(); }); m.def(makename(class_name, layer_name).c_str(), []() { return new type(); });
} }
}; };
...@@ -74,7 +74,7 @@ private: ...@@ -74,7 +74,7 @@ private:
m.def(makename(class_name, layer_name).c_str(), m.def(makename(class_name, layer_name).c_str(),
[](const BoundaryInfoType& boundary_info, XT::Grid::BoundaryType*&& boundary_type) { [](const BoundaryInfoType& boundary_info, XT::Grid::BoundaryType*&& boundary_type) {
return type(boundary_info, std::move(boundary_type)); return new type(boundary_info, std::move(boundary_type));
}, },
"boundary_info"_a, "boundary_info"_a,
"boundary_type"_a); "boundary_type"_a);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment