mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 21:25:13 +00:00
Merge pull request #213 from yungyuc/yyc-args
pybind11::args should have been derived from tuple
This commit is contained in:
commit
ca9f3b2d8e
@ -27,8 +27,8 @@ py::object call_kw_func(py::function f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void args_function(py::args args) {
|
void args_function(py::args args) {
|
||||||
for (auto item : args)
|
for (size_t it=0; it<args.size(); ++it)
|
||||||
std::cout << "got argument: " << item << std::endl;
|
std::cout << "got argument: " << py::object(args[it]) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void args_kwargs_function(py::args args, py::kwargs kwargs) {
|
void args_kwargs_function(py::args args, py::kwargs kwargs) {
|
||||||
|
@ -491,7 +491,7 @@ public:
|
|||||||
if (!m_ptr) pybind11_fail("Could not allocate tuple object!");
|
if (!m_ptr) pybind11_fail("Could not allocate tuple object!");
|
||||||
}
|
}
|
||||||
size_t size() const { return (size_t) PyTuple_Size(m_ptr); }
|
size_t size() const { return (size_t) PyTuple_Size(m_ptr); }
|
||||||
detail::tuple_accessor operator[](size_t index) const { return detail::tuple_accessor(ptr(), index); }
|
detail::tuple_accessor operator[](size_t index) const { return detail::tuple_accessor(*this, index); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class dict : public object {
|
class dict : public object {
|
||||||
@ -517,7 +517,7 @@ public:
|
|||||||
void append(const object &object) const { PyList_Append(m_ptr, object.ptr()); }
|
void append(const object &object) const { PyList_Append(m_ptr, object.ptr()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class args : public list { PYBIND11_OBJECT_DEFAULT(args, list, PyList_Check) };
|
class args : public tuple { PYBIND11_OBJECT_DEFAULT(args, tuple, PyTuple_Check) };
|
||||||
class kwargs : public dict { PYBIND11_OBJECT_DEFAULT(kwargs, dict, PyDict_Check) };
|
class kwargs : public dict { PYBIND11_OBJECT_DEFAULT(kwargs, dict, PyDict_Check) };
|
||||||
|
|
||||||
class set : public object {
|
class set : public object {
|
||||||
|
Loading…
Reference in New Issue
Block a user