Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
ca9f3b2d
Commit
ca9f3b2d
authored
May 25, 2016
by
Wenzel Jakob
Browse files
Merge pull request #213 from yungyuc/yyc-args
pybind11::args should have been derived from tuple
parents
1e3be73a
114bfeb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
example/example11.cpp
example/example11.cpp
+2
-2
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+2
-2
No files found.
example/example11.cpp
View file @
ca9f3b2d
...
@@ -27,8 +27,8 @@ py::object call_kw_func(py::function f) {
...
@@ -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
)
{
...
...
include/pybind11/pytypes.h
View file @
ca9f3b2d
...
@@ -491,7 +491,7 @@ public:
...
@@ -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:
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment