Skip to content

Commit cc89202

Browse files
author
Dilawar Singh
committed
Default parameters in connect is now working. First argument is not
needed if it is a class member function.
1 parent 8092a8e commit cc89202

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

pybind11/pymoose.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
#include <typeinfo>
1515
#include <utility>
1616
#include <vector>
17+
#include <functional>
1718

18-
#include "../external/pybind11/include/pybind11/numpy.h"
1919
#include "../external/pybind11/include/pybind11/pybind11.h"
2020
#include "../external/pybind11/include/pybind11/stl.h"
21+
#include "../external/pybind11/include/pybind11/numpy.h"
2122

2223
namespace py = pybind11;
24+
using namespace std;
25+
using namespace pybind11::literals;
2326

2427
#include "../basecode/global.h"
2528
#include "../basecode/header.h"
@@ -34,8 +37,6 @@ namespace py = pybind11;
3437
#include "helper.h"
3538
#include "pymoose.h"
3639

37-
using namespace std;
38-
using namespace pybind11::literals;
3940

4041
Id initModule(py::module &m)
4142
{
@@ -259,16 +260,18 @@ PYBIND11_MODULE(_moose, m)
259260
// Connect
260261
//---------------------------------------------------------------------
261262
// This would be so much easier with c++17.
262-
.def("connect",
263-
[](const ObjId &src, const string &srcfield, const ObjId &tgt,
264-
const string &tgtfield, const string &type) {
265-
return shellConnect(src, srcfield, tgt, tgtfield, type);
266-
})
267-
.def("connect", [](const ObjId &src, const string &srcfield,
268-
const MooseVec &tgtvec, const string &tgtfield,
269-
const string &type) {
270-
return shellConnect(src, srcfield, tgtvec.obj(), tgtfield, type);
271-
})
263+
.def("connect", &shellConnect, "srcfield"_a, "dest"_a
264+
, "destfield"_a, "msgtype"_a="Single")
265+
// .def("connect",
266+
// [](const ObjId &src, const string &srcfield, const ObjId &tgt,
267+
// const string &tgtfield, const string &type) {
268+
// return shellConnect(src, srcfield, tgt, tgtfield, type);
269+
// }, "src"_a, "srcfield"_a, "dest"_a, "destfield"_a, "msgtype"_a = "Single")
270+
// .def("connect", [](const ObjId &src, const string &srcfield,
271+
// const MooseVec &tgtvec, const string &tgtfield,
272+
// const string &type) {
273+
// return shellConnect(src, srcfield, tgtvec.obj(), tgtfield, type);
274+
// }, "src"_a, "srcfield"_a, "dest"_a, "destfield"_a, "msgtype"_a="Single")
272275
//---------------------------------------------------------------------
273276
// Extra
274277
//---------------------------------------------------------------------

0 commit comments

Comments
 (0)