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