Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
505466ff
Commit
505466ff
authored
Apr 13, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added variadic make_tuple() function
parent
2c5d5606
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
include/pybind11/cast.h
+10
-6
No files found.
include/pybind11/cast.h
View file @
505466ff
...
...
@@ -707,20 +707,24 @@ template <typename T> inline object cast(const T &value, return_value_policy pol
template
<
typename
T
>
inline
T
handle
::
cast
()
const
{
return
pybind11
::
cast
<
T
>
(
*
this
);
}
template
<>
inline
void
handle
::
cast
()
const
{
return
;
}
template
<
typename
...
Args
>
inline
object
handle
::
call
(
Args
&&
...
args_
)
const
{
template
<
typename
...
Args
>
inline
tuple
make_tuple
(
Args
&&
...
args_
)
{
const
size_t
size
=
sizeof
...(
Args
);
std
::
array
<
object
,
size
>
args
{
{
object
(
detail
::
type_caster
<
typename
detail
::
intrinsic_type
<
Args
>::
type
>::
cast
(
std
::
forward
<
Args
>
(
args_
),
return_value_policy
::
reference
,
nullptr
),
false
)...
}
std
::
forward
<
Args
>
(
args_
),
return_value_policy
::
automatic
,
nullptr
),
false
)...
}
};
for
(
auto
&
arg_value
:
args
)
if
(
!
arg_value
)
throw
cast_error
(
"handle::call(): unable to convert input "
"arguments to Python objects"
);
tuple
args_tuple
(
size
);
throw
cast_error
(
"make_tuple(): unable to convert arguments to Python objects"
);
tuple
result
(
size
);
int
counter
=
0
;
for
(
auto
&
arg_value
:
args
)
PyTuple_SET_ITEM
(
args_tuple
.
ptr
(),
counter
++
,
arg_value
.
release
().
ptr
());
PyTuple_SET_ITEM
(
result
.
ptr
(),
counter
++
,
arg_value
.
release
().
ptr
());
return
result
;
}
template
<
typename
...
Args
>
inline
object
handle
::
call
(
Args
&&
...
args
)
const
{
tuple
args_tuple
=
make_tuple
(
std
::
forward
<
Args
>
(
args
)...);
object
result
(
PyObject_CallObject
(
m_ptr
,
args_tuple
.
ptr
()),
false
);
if
(
!
result
)
throw
error_already_set
();
...
...
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