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
ed23dda9
Commit
ed23dda9
authored
Aug 04, 2016
by
Dean Moldovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adopt PEP 484 type hints for C++ types exported to Python
parent
ecced6c5
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
72 additions
and
51 deletions
+72
-51
example/eigen.py
+6
-0
example/eigen.ref
+5
-0
example/example-arg-keywords-and-defaults.ref
+12
-12
example/example-callbacks.py
+3
-0
example/example-callbacks.ref
+4
-1
example/example-numpy-vectorize.py
+2
-0
example/example-numpy-vectorize.ref
+1
-0
example/example-opaque-types.ref
+1
-1
example/example-python-types.ref
+13
-13
example/issues.ref
+1
-1
include/pybind11/cast.h
+9
-8
include/pybind11/eigen.h
+3
-3
include/pybind11/functional.h
+3
-3
include/pybind11/numpy.h
+1
-1
include/pybind11/pybind11.h
+4
-4
include/pybind11/stl.h
+4
-4
No files found.
example/eigen.py
View file @
ed23dda9
...
@@ -106,3 +106,9 @@ for i in range(4):
...
@@ -106,3 +106,9 @@ for i in range(4):
print
(
"symmetric_lower
%
s"
%
(
"OK"
if
(
symmetric_lower
(
asymm
)
==
symm_lower
)
.
all
()
else
"FAILED"
))
print
(
"symmetric_lower
%
s"
%
(
"OK"
if
(
symmetric_lower
(
asymm
)
==
symm_lower
)
.
all
()
else
"FAILED"
))
print
(
"symmetric_upper
%
s"
%
(
"OK"
if
(
symmetric_upper
(
asymm
)
==
symm_upper
)
.
all
()
else
"FAILED"
))
print
(
"symmetric_upper
%
s"
%
(
"OK"
if
(
symmetric_upper
(
asymm
)
==
symm_upper
)
.
all
()
else
"FAILED"
))
print
(
double_col
.
__doc__
)
print
(
double_row
.
__doc__
)
print
(
double_mat_rm
.
__doc__
)
print
(
sparse_passthrough_r
.
__doc__
)
print
(
sparse_passthrough_c
.
__doc__
)
example/eigen.ref
View file @
ed23dda9
...
@@ -53,3 +53,8 @@ block(1,4,3,2) OK
...
@@ -53,3 +53,8 @@ block(1,4,3,2) OK
incr_diag OK
incr_diag OK
symmetric_lower OK
symmetric_lower OK
symmetric_upper OK
symmetric_upper OK
double_col(arg0: numpy.ndarray[float32[m, 1]]) -> numpy.ndarray[float32[m, 1]]
double_row(arg0: numpy.ndarray[float32[1, n]]) -> numpy.ndarray[float32[1, n]]
double_mat_rm(arg0: numpy.ndarray[float32[m, n]]) -> numpy.ndarray[float32[m, n]]
sparse_passthrough_r(arg0: scipy.sparse.csr_matrix[float32]) -> scipy.sparse.csr_matrix[float32]
sparse_passthrough_c(arg0: scipy.sparse.csc_matrix[float32]) -> scipy.sparse.csc_matrix[float32]
example/example-arg-keywords-and-defaults.ref
View file @
ed23dda9
Help on built-in function kw_func0 in module example
Help on built-in function kw_func0 in module example
kkww__ffuunncc00(...)
kkww__ffuunncc00(...)
kw_func0(arg0: int, arg1: int) -> None
Type
kw_func0(arg0: int, arg1: int) -> None
Help on built-in function kw_func1 in module example
Help on built-in function kw_func1 in module example
kkww__ffuunncc11(...)
kkww__ffuunncc11(...)
kw_func1(x: int, y: int) -> None
Type
kw_func1(x: int, y: int) -> None
Help on built-in function kw_func2 in module example
Help on built-in function kw_func2 in module example
kkww__ffuunncc22(...)
kkww__ffuunncc22(...)
kw_func2(x: int=100L, y: int=200L) -> None
Type
kw_func2(x: int=100L, y: int=200L) -> None
Help on built-in function kw_func3 in module example
Help on built-in function kw_func3 in module example
kkww__ffuunncc33(...)
kkww__ffuunncc33(...)
kw_func3(data: unicode=u'Hello world!') -> None
Type
kw_func3(data: unicode=u'Hello world!') -> None
Help on built-in function kw_func4 in module example
Help on built-in function kw_func4 in module example
kkww__ffuunncc44(...)
kkww__ffuunncc44(...)
kw_func4(myList:
list<int>=[13L, 17L]) -> NoneTyp
e
kw_func4(myList:
List[int]=[13L, 17L]) -> Non
e
Help on built-in function kw_func_udl in module example
Help on built-in function kw_func_udl in module example
kkww__ffuunncc__uuddll(...)
kkww__ffuunncc__uuddll(...)
kw_func_udl(x: int, y: int=300L) -> None
Type
kw_func_udl(x: int, y: int=300L) -> None
Help on built-in function kw_func_udl_z in module example
Help on built-in function kw_func_udl_z in module example
kkww__ffuunncc__uuddll__zz(...)
kkww__ffuunncc__uuddll__zz(...)
kw_func_udl_z(x: int, y: int=0L) -> None
Type
kw_func_udl_z(x: int, y: int=0L) -> None
Help on built-in function args_function in module example
Help on built-in function args_function in module example
aarrggss__ffuunnccttiioonn(...)
aarrggss__ffuunnccttiioonn(...)
args_function(*args) -> None
Type
args_function(*args) -> None
Help on built-in function args_kwargs_function in module example
Help on built-in function args_kwargs_function in module example
aarrggss__kkwwaarrggss__ffuunnccttiioonn(...)
aarrggss__kkwwaarrggss__ffuunnccttiioonn(...)
args_kwargs_function(*args, **kwargs) -> None
Type
args_kwargs_function(*args, **kwargs) -> None
foo0(self: KWClass, arg0: int, arg1: float) -> None
Type
foo0(self: KWClass, arg0: int, arg1: float) -> None
foo1(self: KWClass, x: int, y: float) -> None
Type
foo1(self: KWClass, x: int, y: float) -> None
kw_func(x=5, y=10)
kw_func(x=5, y=10)
...
@@ -58,7 +58,7 @@ kw_func(x=100, y=10)
...
@@ -58,7 +58,7 @@ kw_func(x=100, y=10)
kw_func(x=5, y=10)
kw_func(x=5, y=10)
kw_func(x=5, y=10)
kw_func(x=5, y=10)
Caught expected exception: Incompatible function arguments. The following argument types are supported:
Caught expected exception: Incompatible function arguments. The following argument types are supported:
1. (x: int=100L, y: int=200L) -> None
Type
1. (x: int=100L, y: int=200L) -> None
Invoked with:
Invoked with:
kw_func4: 13 17
kw_func4: 13 17
kw_func4: 1 2 3
kw_func4: 1 2 3
...
...
example/example-callbacks.py
View file @
ed23dda9
...
@@ -82,3 +82,6 @@ except Exception as e:
...
@@ -82,3 +82,6 @@ except Exception as e:
print
(
"All OK!"
)
print
(
"All OK!"
)
else
:
else
:
print
(
"Problem!"
)
print
(
"Problem!"
)
print
(
test_callback3
.
__doc__
)
print
(
test_callback4
.
__doc__
)
example/example-callbacks.ref
View file @
ed23dda9
...
@@ -6,7 +6,7 @@ Molly is a dog
...
@@ -6,7 +6,7 @@ Molly is a dog
Molly is a dog
Molly is a dog
Woof!
Woof!
The following error is expected: Incompatible function arguments. The following argument types are supported:
The following error is expected: Incompatible function arguments. The following argument types are supported:
1. (arg0: example.Dog) -> None
Type
1. (arg0: example.Dog) -> None
Invoked with: <example.Pet object at 0>
Invoked with: <example.Pet object at 0>
Callback function 1 called!
Callback function 1 called!
False
False
...
@@ -36,3 +36,6 @@ could not convert to a function pointer.
...
@@ -36,3 +36,6 @@ could not convert to a function pointer.
All OK!
All OK!
could not convert to a function pointer.
could not convert to a function pointer.
All OK!
All OK!
test_callback3(arg0: Callable[[int], int]) -> None
test_callback4() -> Callable[[int], int]
example/example-numpy-vectorize.py
View file @
ed23dda9
...
@@ -32,3 +32,5 @@ from example import selective_func
...
@@ -32,3 +32,5 @@ from example import selective_func
selective_func
(
np
.
array
([
1
],
dtype
=
np
.
int32
))
selective_func
(
np
.
array
([
1
],
dtype
=
np
.
int32
))
selective_func
(
np
.
array
([
1.0
],
dtype
=
np
.
float32
))
selective_func
(
np
.
array
([
1.0
],
dtype
=
np
.
float32
))
selective_func
(
np
.
array
([
1.0
j
],
dtype
=
np
.
complex64
))
selective_func
(
np
.
array
([
1.0
j
],
dtype
=
np
.
complex64
))
print
(
vectorized_func
.
__doc__
)
example/example-numpy-vectorize.ref
View file @
ed23dda9
...
@@ -76,3 +76,4 @@ my_func(x:int=6, y:float=3, z:float=2)
...
@@ -76,3 +76,4 @@ my_func(x:int=6, y:float=3, z:float=2)
Int branch taken.
Int branch taken.
Float branch taken.
Float branch taken.
Complex float branch taken.
Complex float branch taken.
vectorized_func(arg0: numpy.ndarray[int], arg1: numpy.ndarray[float], arg2: numpy.ndarray[float]) -> object
example/example-opaque-types.ref
View file @
ed23dda9
...
@@ -10,7 +10,7 @@ Called ExampleMandA default constructor..
...
@@ -10,7 +10,7 @@ Called ExampleMandA default constructor..
Got void ptr : 0x7f9ba0f3c430
Got void ptr : 0x7f9ba0f3c430
Called ExampleMandA destructor (0)
Called ExampleMandA destructor (0)
Caught expected exception: Incompatible function arguments. The following argument types are supported:
Caught expected exception: Incompatible function arguments. The following argument types are supported:
1. (
capsule) -> NoneTyp
e
1. (
arg0: capsule) -> Non
e
Invoked with: [1, 2, 3]
Invoked with: [1, 2, 3]
None
None
Got null str : 0x0
Got null str : 0x0
...
...
example/example-python-types.ref
View file @
ed23dda9
...
@@ -34,8 +34,8 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
...
@@ -34,8 +34,8 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
| x.__init__(...) initializes x; see help(type(x)) for signature
| x.__init__(...) initializes x; see help(type(x)) for signature
|
|
| ggeett__aarrrraayy(...)
| ggeett__aarrrraayy(...)
| Signature : (example.ExamplePythonTypes) -> list<unicode>[2]
|
|
| Signature : (example.ExamplePythonTypes) -> List[unicode[2]]
| Return a C++ array
| Return a C++ array
|
|
| ggeett__ddiicctt(...)
| ggeett__ddiicctt(...)
...
@@ -44,8 +44,8 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
...
@@ -44,8 +44,8 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
| Return a Python dictionary
| Return a Python dictionary
|
|
| ggeett__ddiicctt__22(...)
| ggeett__ddiicctt__22(...)
| Signature : (example.ExamplePythonTypes) -> dict<unicode, unicode>
|
|
| Signature : (example.ExamplePythonTypes) -> Dict[unicode, unicode]
| Return a C++ dictionary
| Return a C++ dictionary
|
|
| ggeett__lliisstt(...)
| ggeett__lliisstt(...)
...
@@ -54,8 +54,8 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
...
@@ -54,8 +54,8 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
| Return a Python list
| Return a Python list
|
|
| ggeett__lliisstt__22(...)
| ggeett__lliisstt__22(...)
| Signature : (example.ExamplePythonTypes) -> list<unicode>
|
|
| Signature : (example.ExamplePythonTypes) -> List[unicode]
| Return a C++ list
| Return a C++ list
|
|
| ggeett__sseett(...)
| ggeett__sseett(...)
...
@@ -69,53 +69,53 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
...
@@ -69,53 +69,53 @@ class EExxaammpplleePPyytthhoonnTTyyppeess(__builtin__.object)
| Return a C++ set
| Return a C++ set
|
|
| ppaaiirr__ppaasssstthhrroouugghh(...)
| ppaaiirr__ppaasssstthhrroouugghh(...)
| Signature : (example.ExamplePythonTypes, (bool, unicode)) -> (unicode, bool)
|
|
| Signature : (example.ExamplePythonTypes, Tuple[bool, unicode]) -> Tuple[unicode, bool]
| Return a pair in reversed order
| Return a pair in reversed order
|
|
| pprriinntt__aarrrraayy(...)
| pprriinntt__aarrrraayy(...)
| Signature : (example.ExamplePythonTypes, list<unicode>[2]) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, List[unicode[2]]) -> None
| Print entries of a C++ array
| Print entries of a C++ array
|
|
| pprriinntt__ddiicctt(...)
| pprriinntt__ddiicctt(...)
| Signature : (example.ExamplePythonTypes, dict) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, dict) -> None
| Print entries of a Python dictionary
| Print entries of a Python dictionary
|
|
| pprriinntt__ddiicctt__22(...)
| pprriinntt__ddiicctt__22(...)
| Signature : (example.ExamplePythonTypes, dict<unicode, unicode>) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, Dict[unicode, unicode]) -> None
| Print entries of a C++ dictionary
| Print entries of a C++ dictionary
|
|
| pprriinntt__lliisstt(...)
| pprriinntt__lliisstt(...)
| Signature : (example.ExamplePythonTypes, list) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, list) -> None
| Print entries of a Python list
| Print entries of a Python list
|
|
| pprriinntt__lliisstt__22(...)
| pprriinntt__lliisstt__22(...)
| Signature : (example.ExamplePythonTypes, list<unicode>) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, List[unicode]) -> None
| Print entries of a C++ list
| Print entries of a C++ list
|
|
| pprriinntt__sseett(...)
| pprriinntt__sseett(...)
| Signature : (example.ExamplePythonTypes, set) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, set) -> None
| Print entries of a Python set
| Print entries of a Python set
|
|
| pprriinntt__sseett__22(...)
| pprriinntt__sseett__22(...)
| Signature : (example.ExamplePythonTypes, set<unicode>) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes, Set[unicode]) -> None
| Print entries of a C++ set
| Print entries of a C++ set
|
|
| tthhrrooww__eexxcceeppttiioonn(...)
| tthhrrooww__eexxcceeppttiioonn(...)
| Signature : (example.ExamplePythonTypes) -> NoneType
|
|
| Signature : (example.ExamplePythonTypes) -> None
| Throw an exception
| Throw an exception
|
|
| ttuuppllee__ppaasssstthhrroouugghh(...)
| ttuuppllee__ppaasssstthhrroouugghh(...)
| Signature : (example.ExamplePythonTypes, (bool, unicode, int)) -> (int, unicode, bool)
|
|
| Signature : (example.ExamplePythonTypes, Tuple[bool, unicode, int]) -> Tuple[int, unicode, bool]
| Return a triple in reversed order
| Return a triple in reversed order
|
|
| ----------------------------------------------------------------------
| ----------------------------------------------------------------------
...
...
example/issues.ref
View file @
ed23dda9
...
@@ -6,7 +6,7 @@ Yay..
...
@@ -6,7 +6,7 @@ Yay..
[3, 5, 7, 9, 11, 13, 15]
[3, 5, 7, 9, 11, 13, 15]
0==0, 1==1, 2==2, 3==3, 4==4, 5==5, 6==6, 7==7, 8==8, 9==9,
0==0, 1==1, 2==2, 3==3, 4==4, 5==5, 6==6, 7==7, 8==8, 9==9,
Failed as expected: Incompatible function arguments. The following argument types are supported:
Failed as expected: Incompatible function arguments. The following argument types are supported:
1. (arg0: example.issues.ElementA) -> None
Type
1. (arg0: example.issues.ElementA) -> None
Invoked with: None
Invoked with: None
Failed as expected: Incompatible function arguments. The following argument types are supported:
Failed as expected: Incompatible function arguments. The following argument types are supported:
1. (arg0: int) -> int
1. (arg0: int) -> int
...
...
include/pybind11/cast.h
View file @
ed23dda9
...
@@ -399,7 +399,7 @@ public:
...
@@ -399,7 +399,7 @@ public:
static
handle
cast
(
void_type
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
static
handle
cast
(
void_type
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
return
handle
(
Py_None
).
inc_ref
();
return
handle
(
Py_None
).
inc_ref
();
}
}
PYBIND11_TYPE_CASTER
(
void_type
,
_
(
"None
Type
"
));
PYBIND11_TYPE_CASTER
(
void_type
,
_
(
"None"
));
};
};
template
<>
class
type_caster
<
void
>
:
public
type_caster
<
void_type
>
{
template
<>
class
type_caster
<
void
>
:
public
type_caster
<
void_type
>
{
...
@@ -440,7 +440,7 @@ public:
...
@@ -440,7 +440,7 @@ public:
template
<
typename
T
>
using
cast_op_type
=
void
*&
;
template
<
typename
T
>
using
cast_op_type
=
void
*&
;
operator
void
*&
()
{
return
value
;
}
operator
void
*&
()
{
return
value
;
}
static
PYBIND11_DESCR
name
()
{
return
_
(
"capsule"
);
}
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
_
(
"capsule"
)
);
}
private
:
private
:
void
*
value
=
nullptr
;
void
*
value
=
nullptr
;
};
};
...
@@ -615,8 +615,8 @@ public:
...
@@ -615,8 +615,8 @@ public:
static
PYBIND11_DESCR
name
()
{
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
return
type_descr
(
_
(
"
(
"
)
+
type_caster
<
typename
intrinsic_type
<
T1
>::
type
>::
name
()
+
_
(
"
Tuple[
"
)
+
type_caster
<
typename
intrinsic_type
<
T1
>::
type
>::
name
()
+
_
(
", "
)
+
type_caster
<
typename
intrinsic_type
<
T2
>::
type
>::
name
()
+
_
(
"
)
"
));
_
(
", "
)
+
type_caster
<
typename
intrinsic_type
<
T2
>::
type
>::
name
()
+
_
(
"
]
"
));
}
}
template
<
typename
T
>
using
cast_op_type
=
type
;
template
<
typename
T
>
using
cast_op_type
=
type
;
...
@@ -671,11 +671,12 @@ public:
...
@@ -671,11 +671,12 @@ public:
return
cast
(
src
,
policy
,
parent
,
typename
make_index_sequence
<
size
>::
type
());
return
cast
(
src
,
policy
,
parent
,
typename
make_index_sequence
<
size
>::
type
());
}
}
static
PYBIND11_DESCR
element_names
()
{
return
detail
::
concat
(
type_caster
<
typename
intrinsic_type
<
Tuple
>::
type
>::
name
()...);
}
static
PYBIND11_DESCR
name
()
{
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
return
type_descr
(
_
(
"Tuple["
)
+
element_names
()
+
_
(
"]"
));
_
(
"("
)
+
detail
::
concat
(
type_caster
<
typename
intrinsic_type
<
Tuple
>::
type
>::
name
()...)
+
_
(
")"
));
}
}
template
<
typename
ReturnValue
,
typename
Func
>
typename
std
::
enable_if
<!
std
::
is_void
<
ReturnValue
>::
value
,
ReturnValue
>::
type
call
(
Func
&&
f
)
{
template
<
typename
ReturnValue
,
typename
Func
>
typename
std
::
enable_if
<!
std
::
is_void
<
ReturnValue
>::
value
,
ReturnValue
>::
type
call
(
Func
&&
f
)
{
...
...
include/pybind11/eigen.h
View file @
ed23dda9
...
@@ -161,8 +161,8 @@ struct type_caster<Type, typename std::enable_if<is_eigen_dense<Type>::value &&
...
@@ -161,8 +161,8 @@ struct type_caster<Type, typename std::enable_if<is_eigen_dense<Type>::value &&
}
}
}
}
PYBIND11_TYPE_CASTER
(
Type
,
_
(
"numpy.ndarray[
dtype=
"
)
+
npy_format_descriptor
<
Scalar
>::
name
()
+
PYBIND11_TYPE_CASTER
(
Type
,
_
(
"numpy.ndarray["
)
+
npy_format_descriptor
<
Scalar
>::
name
()
+
_
(
"
, shape=("
)
+
rows
()
+
_
(
", "
)
+
cols
()
+
_
(
")
]"
));
_
(
"
["
)
+
rows
()
+
_
(
", "
)
+
cols
()
+
_
(
"]
]"
));
protected
:
protected
:
template
<
typename
T
=
Type
,
typename
std
::
enable_if
<
T
::
RowsAtCompileTime
==
Eigen
::
Dynamic
,
int
>::
type
=
0
>
template
<
typename
T
=
Type
,
typename
std
::
enable_if
<
T
::
RowsAtCompileTime
==
Eigen
::
Dynamic
,
int
>::
type
=
0
>
...
@@ -321,7 +321,7 @@ struct type_caster<Type, typename std::enable_if<is_eigen_sparse<Type>::value>::
...
@@ -321,7 +321,7 @@ struct type_caster<Type, typename std::enable_if<is_eigen_sparse<Type>::value>::
).
release
();
).
release
();
}
}
PYBIND11_TYPE_CASTER
(
Type
,
_
<
(
Type
::
Flags
&
Eigen
::
RowMajorBit
)
!=
0
>
(
"scipy.sparse.csr_matrix[
dtype="
,
"scipy.sparse.csc_matrix[dtype=
"
)
PYBIND11_TYPE_CASTER
(
Type
,
_
<
(
Type
::
Flags
&
Eigen
::
RowMajorBit
)
!=
0
>
(
"scipy.sparse.csr_matrix[
"
,
"scipy.sparse.csc_matrix[
"
)
+
npy_format_descriptor
<
Scalar
>::
name
()
+
_
(
"]"
));
+
npy_format_descriptor
<
Scalar
>::
name
()
+
_
(
"]"
));
};
};
...
...
include/pybind11/functional.h
View file @
ed23dda9
...
@@ -65,10 +65,10 @@ public:
...
@@ -65,10 +65,10 @@ public:
return
cpp_function
(
std
::
forward
<
Func
>
(
f_
),
policy
).
release
();
return
cpp_function
(
std
::
forward
<
Func
>
(
f_
),
policy
).
release
();
}
}
PYBIND11_TYPE_CASTER
(
type
,
_
(
"
function<
"
)
+
PYBIND11_TYPE_CASTER
(
type
,
_
(
"
Callable[[
"
)
+
type_caster
<
std
::
tuple
<
Args
...
>>::
name
()
+
_
(
" ->
"
)
+
type_caster
<
std
::
tuple
<
Args
...
>>::
element_names
()
+
_
(
"],
"
)
+
type_caster
<
retval_type
>::
name
()
+
type_caster
<
retval_type
>::
name
()
+
_
(
"
>
"
));
_
(
"
]
"
));
};
};
NAMESPACE_END
(
detail
)
NAMESPACE_END
(
detail
)
...
...
include/pybind11/numpy.h
View file @
ed23dda9
...
@@ -385,7 +385,7 @@ struct vectorize_helper {
...
@@ -385,7 +385,7 @@ struct vectorize_helper {
};
};
template
<
typename
T
,
int
Flags
>
struct
handle_type_name
<
array_t
<
T
,
Flags
>>
{
template
<
typename
T
,
int
Flags
>
struct
handle_type_name
<
array_t
<
T
,
Flags
>>
{
static
PYBIND11_DESCR
name
()
{
return
_
(
"numpy.ndarray[
dtype=
"
)
+
type_caster
<
T
>::
name
()
+
_
(
"]"
);
}
static
PYBIND11_DESCR
name
()
{
return
_
(
"numpy.ndarray["
)
+
type_caster
<
T
>::
name
()
+
_
(
"]"
);
}
};
};
NAMESPACE_END
(
detail
)
NAMESPACE_END
(
detail
)
...
...
include/pybind11/pybind11.h
View file @
ed23dda9
...
@@ -135,8 +135,8 @@ protected:
...
@@ -135,8 +135,8 @@ protected:
detail
::
process_attributes
<
Extra
...
>::
init
(
extra
...,
rec
);
detail
::
process_attributes
<
Extra
...
>::
init
(
extra
...,
rec
);
/* Generate a readable signature describing the function's arguments and return value types */
/* Generate a readable signature describing the function's arguments and return value types */
using
detail
::
descr
;
using
detail
::
descr
;
using
detail
::
_
;
PYBIND11_DESCR
signature
=
cast_in
::
name
()
+
detail
::
_
(
"
-> "
)
+
cast_out
::
name
();
PYBIND11_DESCR
signature
=
_
(
"("
)
+
cast_in
::
element_names
()
+
_
(
")
-> "
)
+
cast_out
::
name
();
/* Register the function with Python from generic (non-templated) code */
/* Register the function with Python from generic (non-templated) code */
initialize_generic
(
rec
,
signature
.
text
(),
signature
.
types
(),
sizeof
...(
Args
));
initialize_generic
(
rec
,
signature
.
text
(),
signature
.
types
(),
sizeof
...(
Args
));
...
@@ -183,7 +183,7 @@ protected:
...
@@ -183,7 +183,7 @@ protected:
if
(
c
==
'{'
)
{
if
(
c
==
'{'
)
{
// Write arg name for everything except *args, **kwargs and return type.
// Write arg name for everything except *args, **kwargs and return type.
if
(
type_depth
==
1
&&
text
[
char_index
]
!=
'*'
&&
arg_index
<
args
)
{
if
(
type_depth
==
0
&&
text
[
char_index
]
!=
'*'
&&
arg_index
<
args
)
{
if
(
!
rec
->
args
.
empty
())
{
if
(
!
rec
->
args
.
empty
())
{
signature
+=
rec
->
args
[
arg_index
].
name
;
signature
+=
rec
->
args
[
arg_index
].
name
;
}
else
if
(
arg_index
==
0
&&
rec
->
class_
)
{
}
else
if
(
arg_index
==
0
&&
rec
->
class_
)
{
...
@@ -196,7 +196,7 @@ protected:
...
@@ -196,7 +196,7 @@ protected:
++
type_depth
;
++
type_depth
;
}
else
if
(
c
==
'}'
)
{
}
else
if
(
c
==
'}'
)
{
--
type_depth
;
--
type_depth
;
if
(
type_depth
==
1
)
{
if
(
type_depth
==
0
)
{
if
(
arg_index
<
rec
->
args
.
size
()
&&
rec
->
args
[
arg_index
].
descr
)
{
if
(
arg_index
<
rec
->
args
.
size
()
&&
rec
->
args
[
arg_index
].
descr
)
{
signature
+=
"="
;
signature
+=
"="
;
signature
+=
rec
->
args
[
arg_index
].
descr
;
signature
+=
rec
->
args
[
arg_index
].
descr
;
...
...
include/pybind11/stl.h
View file @
ed23dda9
...
@@ -53,7 +53,7 @@ template <typename Type, typename Key> struct set_caster {
...
@@ -53,7 +53,7 @@ template <typename Type, typename Key> struct set_caster {
return
s
.
release
();
return
s
.
release
();
}
}
PYBIND11_TYPE_CASTER
(
type
,
_
(
"
set<"
)
+
key_conv
::
name
()
+
_
(
">
"
));
PYBIND11_TYPE_CASTER
(
type
,
_
(
"
Set["
)
+
key_conv
::
name
()
+
_
(
"]
"
));
};
};
template
<
typename
Type
,
typename
Key
,
typename
Value
>
struct
map_caster
{
template
<
typename
Type
,
typename
Key
,
typename
Value
>
struct
map_caster
{
...
@@ -89,7 +89,7 @@ template <typename Type, typename Key, typename Value> struct map_caster {
...
@@ -89,7 +89,7 @@ template <typename Type, typename Key, typename Value> struct map_caster {
return
d
.
release
();
return
d
.
release
();
}
}
PYBIND11_TYPE_CASTER
(
type
,
_
(
"
dict<"
)
+
key_conv
::
name
()
+
_
(
", "
)
+
value_conv
::
name
()
+
_
(
">
"
));
PYBIND11_TYPE_CASTER
(
type
,
_
(
"
Dict["
)
+
key_conv
::
name
()
+
_
(
", "
)
+
value_conv
::
name
()
+
_
(
"]
"
));
};
};
template
<
typename
Type
,
typename
Value
>
struct
list_caster
{
template
<
typename
Type
,
typename
Value
>
struct
list_caster
{
...
@@ -128,7 +128,7 @@ template <typename Type, typename Value> struct list_caster {
...
@@ -128,7 +128,7 @@ template <typename Type, typename Value> struct list_caster {
return
l
.
release
();
return
l
.
release
();
}
}
PYBIND11_TYPE_CASTER
(
Type
,
_
(
"
list<"
)
+
value_conv
::
name
()
+
_
(
">
"
));
PYBIND11_TYPE_CASTER
(
Type
,
_
(
"
List["
)
+
value_conv
::
name
()
+
_
(
"]
"
));
};
};
template
<
typename
Type
,
typename
Alloc
>
struct
type_caster
<
std
::
vector
<
Type
,
Alloc
>>
template
<
typename
Type
,
typename
Alloc
>
struct
type_caster
<
std
::
vector
<
Type
,
Alloc
>>
...
@@ -168,7 +168,7 @@ template <typename Type, size_t Size> struct type_caster<std::array<Type, Size>>
...
@@ -168,7 +168,7 @@ template <typename Type, size_t Size> struct type_caster<std::array<Type, Size>>
}
}
return
l
.
release
();
return
l
.
release
();
}
}
PYBIND11_TYPE_CASTER
(
array_type
,
_
(
"
list<"
)
+
value_conv
::
name
()
+
_
(
">"
)
+
_
(
"["
)
+
_
<
Size
>
()
+
_
(
"
]"
));
PYBIND11_TYPE_CASTER
(
array_type
,
_
(
"
List["
)
+
value_conv
::
name
()
+
_
(
"["
)
+
_
<
Size
>
()
+
_
(
"]
]"
));
};
};
template
<
typename
Key
,
typename
Compare
,
typename
Alloc
>
struct
type_caster
<
std
::
set
<
Key
,
Compare
,
Alloc
>>
template
<
typename
Key
,
typename
Compare
,
typename
Alloc
>
struct
type_caster
<
std
::
set
<
Key
,
Compare
,
Alloc
>>
...
...
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