Skip to content

Commit

Permalink
New binders
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii Verbytskyi committed May 23, 2024
1 parent 664067c commit 413eda9
Show file tree
Hide file tree
Showing 26 changed files with 243 additions and 243 deletions.
6 changes: 3 additions & 3 deletions python/src/pyHepMC3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <pybind11/pybind11.h>

typedef std::function< pybind11::module & (std::string const &) > ModuleGetter;
using ModuleGetter = std::function< pybind11::module & (std::string const &) >;

void bind_pyHepMC3_0(std::function< pybind11::module &(std::string const &namespace_) > &M);
void bind_pyHepMC3_1(std::function< pybind11::module &(std::string const &namespace_) > &M);
Expand Down Expand Up @@ -48,7 +48,7 @@ PYBIND11_MODULE(pyHepMC3, root_module) {
auto mangle_namespace_name(
[](std::string const &ns) -> std::string {
if ( std::find(reserved_python_words.begin(), reserved_python_words.end(), ns) == reserved_python_words.end() ) return ns;
else return ns+'_';
return ns+'_';
}
);

Expand All @@ -57,7 +57,7 @@ PYBIND11_MODULE(pyHepMC3, root_module) {
{"", "LHEF"},
{"", "std"},
};
for(auto &p : sub_modules ) modules[p.first.size() ? p.first+"::"+p.second : p.second] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() );
for(auto &p : sub_modules ) modules[ p.first.empty() ? p.second : p.first+"::"+p.second ] = modules[p.first].def_submodule( mangle_namespace_name(p.second).c_str(), ("Bindings for " + p.first + "::" + p.second + " namespace").c_str() );

//pybind11::class_<std::shared_ptr<void>>(M(""), "_encapsulated_data_");

Expand Down
4 changes: 2 additions & 2 deletions python/src/pyHepMC3_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>, false)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*, false)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif

Expand Down
4 changes: 2 additions & 2 deletions python/src/pyHepMC3_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>, false)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*, false)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif

Expand Down
20 changes: 10 additions & 10 deletions python/src/pyHepMC3_10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>, false)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*, false)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif

Expand All @@ -53,7 +53,7 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
pybind11::pybind11_fail("Tried to call pure virtual function \"Writer::write_event\"");
}
Expand All @@ -66,7 +66,7 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<bool> caster;
return pybind11::detail::cast_ref<bool>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<bool>(std::move(o));
return pybind11::detail::cast_safe<bool>(std::move(o));
}
pybind11::pybind11_fail("Tried to call pure virtual function \"Writer::failed\"");
}
Expand All @@ -79,7 +79,7 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
pybind11::pybind11_fail("Tried to call pure virtual function \"Writer::close\"");
}
Expand All @@ -92,7 +92,7 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return Writer::set_run_info(a0);
}
Expand All @@ -105,7 +105,7 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<class std::shared_ptr<class HepMC3::GenRunInfo>> caster;
return pybind11::detail::cast_ref<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o));
return pybind11::detail::cast_safe<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o));
}
return Writer::run_info();
}
Expand All @@ -118,11 +118,11 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return Writer::set_options(a0);
}
using _binder_ret_0 = class std::map<std::string, std::string >;
using _binder_ret_0 = std::map<std::string, std::string >;
_binder_ret_0 get_options() const override {
pybind11::gil_scoped_acquire gil;
pybind11::function overload = pybind11::get_overload(static_cast<const HepMC3::Writer *>(this), "get_options");
Expand All @@ -132,7 +132,7 @@ struct PyCallBack_HepMC3_Writer : public HepMC3::Writer {
static pybind11::detail::override_caster_t<_binder_ret_0> caster;
return pybind11::detail::cast_ref<_binder_ret_0>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<_binder_ret_0>(std::move(o));
return pybind11::detail::cast_safe<_binder_ret_0>(std::move(o));
}
return Writer::get_options();
}
Expand Down
22 changes: 11 additions & 11 deletions python/src/pyHepMC3_11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>, false)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*, false)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif

Expand All @@ -49,7 +49,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<bool> caster;
return pybind11::detail::cast_ref<bool>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<bool>(std::move(o));
return pybind11::detail::cast_safe<bool>(std::move(o));
}
return Reader::skip(a0);
}
Expand All @@ -62,7 +62,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<bool> caster;
return pybind11::detail::cast_ref<bool>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<bool>(std::move(o));
return pybind11::detail::cast_safe<bool>(std::move(o));
}
pybind11::pybind11_fail("Tried to call pure virtual function \"Reader::read_event\"");
}
Expand All @@ -75,7 +75,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<bool> caster;
return pybind11::detail::cast_ref<bool>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<bool>(std::move(o));
return pybind11::detail::cast_safe<bool>(std::move(o));
}
pybind11::pybind11_fail("Tried to call pure virtual function \"Reader::failed\"");
}
Expand All @@ -88,7 +88,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
pybind11::pybind11_fail("Tried to call pure virtual function \"Reader::close\"");
}
Expand All @@ -101,7 +101,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<class std::shared_ptr<class HepMC3::GenRunInfo>> caster;
return pybind11::detail::cast_ref<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o));
return pybind11::detail::cast_safe<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o));
}
return Reader::run_info();
}
Expand All @@ -114,11 +114,11 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return Reader::set_options(a0);
}
using _binder_ret_0 = class std::map<std::string, std::string >;
using _binder_ret_0 = std::map<std::string, std::string >;
_binder_ret_0 get_options() const override {
pybind11::gil_scoped_acquire gil;
pybind11::function overload = pybind11::get_overload(static_cast<const HepMC3::Reader *>(this), "get_options");
Expand All @@ -128,7 +128,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<_binder_ret_0> caster;
return pybind11::detail::cast_ref<_binder_ret_0>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<_binder_ret_0>(std::move(o));
return pybind11::detail::cast_safe<_binder_ret_0>(std::move(o));
}
return Reader::get_options();
}
Expand All @@ -141,7 +141,7 @@ struct PyCallBack_HepMC3_Reader : public HepMC3::Reader {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return Reader::set_run_info(a0);
}
Expand Down
20 changes: 10 additions & 10 deletions python/src/pyHepMC3_12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#ifndef BINDER_PYBIND11_TYPE_CASTER
#define BINDER_PYBIND11_TYPE_CASTER
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>, false)
PYBIND11_DECLARE_HOLDER_TYPE(T, T*, false)
PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
#endif

Expand All @@ -53,7 +53,7 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return WriterAscii::write_event(a0);
}
Expand All @@ -66,7 +66,7 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<bool> caster;
return pybind11::detail::cast_ref<bool>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<bool>(std::move(o));
return pybind11::detail::cast_safe<bool>(std::move(o));
}
return WriterAscii::failed();
}
Expand All @@ -79,7 +79,7 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return WriterAscii::close();
}
Expand All @@ -92,7 +92,7 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return Writer::set_run_info(a0);
}
Expand All @@ -105,7 +105,7 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<class std::shared_ptr<class HepMC3::GenRunInfo>> caster;
return pybind11::detail::cast_ref<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o));
return pybind11::detail::cast_safe<class std::shared_ptr<class HepMC3::GenRunInfo>>(std::move(o));
}
return Writer::run_info();
}
Expand All @@ -118,11 +118,11 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<void> caster;
return pybind11::detail::cast_ref<void>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<void>(std::move(o));
return pybind11::detail::cast_safe<void>(std::move(o));
}
return Writer::set_options(a0);
}
using _binder_ret_0 = class std::map<std::string, std::string >;
using _binder_ret_0 = std::map<std::string, std::string >;
_binder_ret_0 get_options() const override {
pybind11::gil_scoped_acquire gil;
pybind11::function overload = pybind11::get_overload(static_cast<const HepMC3::WriterAscii *>(this), "get_options");
Expand All @@ -132,7 +132,7 @@ struct PyCallBack_HepMC3_WriterAscii : public HepMC3::WriterAscii {
static pybind11::detail::override_caster_t<_binder_ret_0> caster;
return pybind11::detail::cast_ref<_binder_ret_0>(std::move(o), caster);
}
else return pybind11::detail::cast_safe<_binder_ret_0>(std::move(o));
return pybind11::detail::cast_safe<_binder_ret_0>(std::move(o));
}
return Writer::get_options();
}
Expand Down
Loading

0 comments on commit 413eda9

Please sign in to comment.