Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
56e9f494
Commit
56e9f494
authored
Jan 17, 2016
by
Wenzel Jakob
Browse files
improved signature names for subclasses of pybind11::handle
parent
d0325bbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
include/pybind11/cast.h
include/pybind11/cast.h
+5
-3
include/pybind11/common.h
include/pybind11/common.h
+2
-0
include/pybind11/numpy.h
include/pybind11/numpy.h
+4
-0
No files found.
include/pybind11/cast.h
View file @
56e9f494
...
@@ -467,6 +467,9 @@ protected:
...
@@ -467,6 +467,9 @@ protected:
holder_type
holder
;
holder_type
holder
;
};
};
template
<
typename
T
>
struct
handle_type_name
{
static
PYBIND11_DESCR
name
()
{
return
_
<
T
>
();
}
};
template
<
>
struct
handle_type_name
<
bytes
>
{
static
PYBIND11_DESCR
name
()
{
return
_
(
PYBIND11_BYTES_NAME
);
}
};
template
<
typename
type
>
template
<
typename
type
>
struct
type_caster
<
type
,
typename
std
::
enable_if
<
std
::
is_base_of
<
handle
,
type
>::
value
>::
type
>
{
struct
type_caster
<
type
,
typename
std
::
enable_if
<
std
::
is_base_of
<
handle
,
type
>::
value
>::
type
>
{
public:
public:
...
@@ -477,10 +480,9 @@ public:
...
@@ -477,10 +480,9 @@ public:
bool
load
(
PyObject
*
src
,
bool
/* convert */
)
{
value
=
type
(
src
,
true
);
return
value
.
check
();
}
bool
load
(
PyObject
*
src
,
bool
/* convert */
)
{
value
=
type
(
src
,
true
);
return
value
.
check
();
}
static
PyObject
*
cast
(
const
handle
&
src
,
return_value_policy
/* policy */
,
PyObject
*
/* parent */
)
{
static
PyObject
*
cast
(
const
handle
&
src
,
return_value_policy
/* policy */
,
PyObject
*
/* parent */
)
{
src
.
inc_ref
();
src
.
inc_ref
();
return
(
PyObject
*
)
src
.
ptr
();
return
(
PyObject
*
)
src
.
ptr
();
}
}
PYBIND11_TYPE_CASTER
(
type
,
_
<
type
>
());
PYBIND11_TYPE_CASTER
(
type
,
handle_type_name
<
type
>::
name
());
};
};
NAMESPACE_END
(
detail
)
NAMESPACE_END
(
detail
)
...
...
include/pybind11/common.h
View file @
56e9f494
...
@@ -94,6 +94,7 @@
...
@@ -94,6 +94,7 @@
#define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
#define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
#define PYBIND11_LONG_AS_UNSIGNED_LONGLONG(o) PyLong_AsUnsignedLongLong(o)
#define PYBIND11_LONG_AS_UNSIGNED_LONGLONG(o) PyLong_AsUnsignedLongLong(o)
#define PYBIND11_BYTES_NAME "bytes"
#define PYBIND11_STRING_NAME "str"
#define PYBIND11_STRING_NAME "str"
#define PYBIND11_SLICE_OBJECT PyObject
#define PYBIND11_SLICE_OBJECT PyObject
#else
#else
...
@@ -105,6 +106,7 @@
...
@@ -105,6 +106,7 @@
#define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o))
#define PYBIND11_LONG_CHECK(o) (PyInt_Check(o) || PyLong_Check(o))
#define PYBIND11_LONG_AS_LONGLONG(o) (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o))
#define PYBIND11_LONG_AS_LONGLONG(o) (PyInt_Check(o) ? (long long) PyLong_AsLong(o) : PyLong_AsLongLong(o))
#define PYBIND11_LONG_AS_UNSIGNED_LONGLONG(o) (PyInt_Check(o) ? (unsigned long long) PyLong_AsUnsignedLong(o) : PyLong_AsUnsignedLongLong(o))
#define PYBIND11_LONG_AS_UNSIGNED_LONGLONG(o) (PyInt_Check(o) ? (unsigned long long) PyLong_AsUnsignedLong(o) : PyLong_AsUnsignedLongLong(o))
#define PYBIND11_BYTES_NAME "str"
#define PYBIND11_STRING_NAME "unicode"
#define PYBIND11_STRING_NAME "unicode"
#define PYBIND11_SLICE_OBJECT PySliceObject
#define PYBIND11_SLICE_OBJECT PySliceObject
#endif
#endif
...
...
include/pybind11/numpy.h
View file @
56e9f494
...
@@ -150,6 +150,10 @@ DECL_FMT(std::complex<double>, NPY_CDOUBLE);
...
@@ -150,6 +150,10 @@ DECL_FMT(std::complex<double>, NPY_CDOUBLE);
NAMESPACE_BEGIN
(
detail
)
NAMESPACE_BEGIN
(
detail
)
template
<
typename
T
>
struct
handle_type_name
<
array_t
<
T
>>
{
static
PYBIND11_DESCR
name
()
{
return
_
(
"array["
)
+
type_caster
<
T
>::
name
()
+
_
(
"]"
);
}
};
template
<
typename
Func
,
typename
Return
,
typename
...
Args
>
template
<
typename
Func
,
typename
Return
,
typename
...
Args
>
struct
vectorize_helper
{
struct
vectorize_helper
{
typename
std
::
remove_reference
<
Func
>::
type
f
;
typename
std
::
remove_reference
<
Func
>::
type
f
;
...
...
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