Adding isinstance<mpty> in type_caster::load functions.

parent 08fe834c
...@@ -101,7 +101,8 @@ struct type_caster<mpty> { ...@@ -101,7 +101,8 @@ struct type_caster<mpty> {
operator mpty const*() { return rtrn_mpty_cptr(); } operator mpty const*() { return rtrn_mpty_cptr(); }
operator mpty*() { return rtrn_mpty_mptr(); } operator mpty*() { return rtrn_mpty_mptr(); }
bool load(handle /*src*/, bool /*convert*/) { bool load(handle src, bool /*convert*/) {
if (!isinstance<mpty>(src)) return false;
return true; return true;
} }
}; };
...@@ -120,7 +121,8 @@ struct type_caster<std::shared_ptr<mpty>> { ...@@ -120,7 +121,8 @@ struct type_caster<std::shared_ptr<mpty>> {
operator std::shared_ptr<mpty>() { return rtrn_mpty_shmp(); } operator std::shared_ptr<mpty>() { return rtrn_mpty_shmp(); }
bool load(handle /*src*/, bool /*convert*/) { bool load(handle src, bool /*convert*/) {
if (!isinstance<mpty>(src)) return false;
return true; return true;
} }
}; };
...@@ -139,7 +141,8 @@ struct type_caster<std::shared_ptr<mpty const>> { ...@@ -139,7 +141,8 @@ struct type_caster<std::shared_ptr<mpty const>> {
operator std::shared_ptr<mpty const>() { return rtrn_mpty_shcp(); } operator std::shared_ptr<mpty const>() { return rtrn_mpty_shcp(); }
bool load(handle /*src*/, bool /*convert*/) { bool load(handle src, bool /*convert*/) {
if (!isinstance<mpty>(src)) return false;
return true; return true;
} }
}; };
...@@ -158,7 +161,8 @@ struct type_caster<std::unique_ptr<mpty>> { ...@@ -158,7 +161,8 @@ struct type_caster<std::unique_ptr<mpty>> {
operator std::unique_ptr<mpty>() { return rtrn_mpty_uqmp(); } operator std::unique_ptr<mpty>() { return rtrn_mpty_uqmp(); }
bool load(handle /*src*/, bool /*convert*/) { bool load(handle src, bool /*convert*/) {
if (!isinstance<mpty>(src)) return false;
return true; return true;
} }
}; };
...@@ -177,7 +181,8 @@ struct type_caster<std::unique_ptr<mpty const>> { ...@@ -177,7 +181,8 @@ struct type_caster<std::unique_ptr<mpty const>> {
operator std::unique_ptr<mpty const>() { return rtrn_mpty_uqcp(); } operator std::unique_ptr<mpty const>() { return rtrn_mpty_uqcp(); }
bool load(handle /*src*/, bool /*convert*/) { bool load(handle src, bool /*convert*/) {
if (!isinstance<mpty>(src)) return false;
return true; return true;
} }
}; };
......
...@@ -23,12 +23,12 @@ def test_cast(): ...@@ -23,12 +23,12 @@ def test_cast():
def test_load(): def test_load():
assert m.pass_mpty_valu(None) == "load_valu" assert m.pass_mpty_valu(m.mpty()) == "load_valu"
assert m.pass_mpty_rref(None) == "load_rref" assert m.pass_mpty_rref(m.mpty()) == "load_rref"
assert m.pass_mpty_cref(None) == "load_cref" assert m.pass_mpty_cref(m.mpty()) == "load_cref"
assert m.pass_mpty_mref(None) == "load_mref" assert m.pass_mpty_mref(m.mpty()) == "load_mref"
assert m.pass_mpty_cptr(None) == "load_cptr" assert m.pass_mpty_cptr(m.mpty()) == "load_cptr"
assert m.pass_mpty_mptr(None) == "load_mptr" assert m.pass_mpty_mptr(m.mpty()) == "load_mptr"
def test_cast_shared_ptr(): def test_cast_shared_ptr():
...@@ -37,8 +37,8 @@ def test_cast_shared_ptr(): ...@@ -37,8 +37,8 @@ def test_cast_shared_ptr():
def test_load_shared_ptr(): def test_load_shared_ptr():
assert m.pass_mpty_shmp(None) == "load_shmp" assert m.pass_mpty_shmp(m.mpty()) == "load_shmp"
assert m.pass_mpty_shcp(None) == "load_shcp" assert m.pass_mpty_shcp(m.mpty()) == "load_shcp"
def test_cast_unique_ptr(): def test_cast_unique_ptr():
...@@ -47,5 +47,5 @@ def test_cast_unique_ptr(): ...@@ -47,5 +47,5 @@ def test_cast_unique_ptr():
def test_load_unique_ptr(): def test_load_unique_ptr():
assert m.pass_mpty_uqmp(None) == "load_uqmp" assert m.pass_mpty_uqmp(m.mpty()) == "load_uqmp"
assert m.pass_mpty_uqcp(None) == "load_uqcp" assert m.pass_mpty_uqcp(m.mpty()) == "load_uqcp"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment