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
317524ff
Commit
317524ff
authored
Aug 28, 2016
by
Dean Moldovan
Browse files
Make arg_t hold a pointer instead of a copy of the value
parent
6f017cf6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
9 deletions
+5
-9
include/pybind11/attr.h
include/pybind11/attr.h
+4
-9
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+1
-0
No files found.
include/pybind11/attr.h
View file @
317524ff
...
...
@@ -14,18 +14,12 @@
NAMESPACE_BEGIN
(
pybind11
)
template
<
typename
T
>
struct
arg_t
;
/// Annotation for keyword arguments
struct
arg
{
constexpr
explicit
arg
(
const
char
*
name
)
:
name
(
name
)
{
}
template
<
typename
T
>
constexpr
arg_t
<
T
>
operator
=
(
const
T
&
value
)
const
{
return
{
name
,
value
};
}
template
<
typename
T
,
size_t
N
>
constexpr
arg_t
<
const
T
*>
operator
=
(
T
const
(
&
value
)[
N
])
const
{
return
operator
=
((
const
T
*
)
value
);
}
const
char
*
name
;
};
...
...
@@ -33,8 +27,9 @@ struct arg {
/// Annotation for keyword arguments with default values
template
<
typename
T
>
struct
arg_t
:
public
arg
{
constexpr
arg_t
(
const
char
*
name
,
const
T
&
value
,
const
char
*
descr
=
nullptr
)
:
arg
(
name
),
value
(
value
),
descr
(
descr
)
{
}
T
value
;
:
arg
(
name
),
value
(
&
value
),
descr
(
descr
)
{
}
const
T
*
value
;
const
char
*
descr
;
};
...
...
@@ -246,7 +241,7 @@ struct process_attribute<arg_t<T>> : process_attribute_default<arg_t<T>> {
/* Convert keyword value into a Python object */
object
o
=
object
(
detail
::
type_caster
<
typename
detail
::
intrinsic_type
<
T
>::
type
>::
cast
(
a
.
value
,
return_value_policy
::
automatic
,
handle
()),
false
);
*
a
.
value
,
return_value_policy
::
automatic
,
handle
()),
false
);
if
(
!
o
)
{
#if !defined(NDEBUG)
...
...
include/pybind11/pytypes.h
View file @
317524ff
...
...
@@ -17,6 +17,7 @@ NAMESPACE_BEGIN(pybind11)
/* A few forward declarations */
class
object
;
class
str
;
class
object
;
class
dict
;
class
iterator
;
struct
arg
;
template
<
typename
T
>
struct
arg_t
;
namespace
detail
{
class
accessor
;
class
args_proxy
;
class
kwargs_proxy
;
}
/// Holds a reference to a Python object (no reference counting)
...
...
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