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
cc4efe69
Commit
cc4efe69
authored
Nov 08, 2016
by
Wenzel Jakob
Browse files
more code style checks in Travis CI :)
parent
fe40dfe6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
20 deletions
+31
-20
include/pybind11/functional.h
include/pybind11/functional.h
+16
-18
include/pybind11/numpy.h
include/pybind11/numpy.h
+2
-2
tools/check-style.sh
tools/check-style.sh
+13
-0
No files found.
include/pybind11/functional.h
View file @
cc4efe69
...
@@ -27,25 +27,23 @@ public:
...
@@ -27,25 +27,23 @@ public:
if
(
!
src_
||
!
PyCallable_Check
(
src_
.
ptr
()))
if
(
!
src_
||
!
PyCallable_Check
(
src_
.
ptr
()))
return
false
;
return
false
;
{
/*
/*
When passing a C++ function as an argument to another C++
When passing a C++ function as an argument to another C++
function via Python, every function call would normally involve
function via Python, every function call would normally involve
a full C++ -> Python -> C++ roundtrip, which can be prohibitive.
a full C++ -> Python -> C++ roundtrip, which can be prohibitive.
Here, we try to at least detect the case where the function is
Here, we try to at least detect the case where the function is
stateless (i.e. function pointer or lambda function without
stateless (i.e. function pointer or lambda function without
captured variables), in which case the roundtrip can be avoided.
captured variables), in which case the roundtrip can be avoided.
*/
*/
if
(
PyCFunction_Check
(
src_
.
ptr
()))
{
if
(
PyCFunction_Check
(
src_
.
ptr
()))
{
capsule
c
(
PyCFunction_GetSelf
(
src_
.
ptr
()),
true
);
capsule
c
(
PyCFunction_GetSelf
(
src_
.
ptr
()),
true
);
auto
rec
=
(
function_record
*
)
c
;
auto
rec
=
(
function_record
*
)
c
;
using
FunctionType
=
Return
(
*
)
(
Args
...);
using
FunctionType
=
Return
(
*
)
(
Args
...);
if
(
rec
&&
rec
->
is_stateless
&&
rec
->
data
[
1
]
==
&
typeid
(
FunctionType
))
{
if
(
rec
&&
rec
->
is_stateless
&&
rec
->
data
[
1
]
==
&
typeid
(
FunctionType
))
{
struct
capture
{
FunctionType
f
;
};
struct
capture
{
FunctionType
f
;
};
value
=
((
capture
*
)
&
rec
->
data
)
->
f
;
value
=
((
capture
*
)
&
rec
->
data
)
->
f
;
return
true
;
return
true
;
}
}
}
}
}
...
...
include/pybind11/numpy.h
View file @
cc4efe69
...
@@ -693,8 +693,8 @@ struct field_descriptor {
...
@@ -693,8 +693,8 @@ struct field_descriptor {
inline
PYBIND11_NOINLINE
void
register_structured_dtype
(
inline
PYBIND11_NOINLINE
void
register_structured_dtype
(
const
std
::
initializer_list
<
field_descriptor
>&
fields
,
const
std
::
initializer_list
<
field_descriptor
>&
fields
,
const
std
::
type_info
&
tinfo
,
size_t
itemsize
,
const
std
::
type_info
&
tinfo
,
size_t
itemsize
,
bool
(
*
direct_converter
)(
PyObject
*
,
void
*&
))
bool
(
*
direct_converter
)(
PyObject
*
,
void
*&
))
{
{
auto
&
numpy_internals
=
get_numpy_internals
();
auto
&
numpy_internals
=
get_numpy_internals
();
if
(
numpy_internals
.
get_type_info
(
tinfo
,
false
))
if
(
numpy_internals
.
get_type_info
(
tinfo
,
false
))
pybind11_fail
(
"NumPy: dtype is already registered"
);
pybind11_fail
(
"NumPy: dtype is already registered"
);
...
...
tools/check-style.sh
View file @
cc4efe69
...
@@ -39,6 +39,19 @@ while read -u 3 f; do
...
@@ -39,6 +39,19 @@ while read -u 3 f; do
echo
"
$f
"
echo
"
$f
"
done
done
found
=
# The mt=41 sets a red background for matched tabs:
exec
3< <
(
GREP_COLORS
=
'mt=41'
grep
'^\s*{\s*$'
include/ docs/
*
.rst
-rn
--color
=
always
)
while
read
-u
3 f
;
do
if
[
-z
"
$found
"
]
;
then
echo
-e
'\e[31m\e[01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files: \e[0m'
found
=
1
errors
=
1
fi
echo
"
$f
"
done
found
=
found
=
exec
3< <
(
grep
'\<\(if\|for\|while\)(\|){'
include/ tests/
*
.
{
cpp,py,h
}
-rn
--color
=
always
)
exec
3< <
(
grep
'\<\(if\|for\|while\)(\|){'
include/ tests/
*
.
{
cpp,py,h
}
-rn
--color
=
always
)
while
read
-u
3 line
;
do
while
read
-u
3 line
;
do
...
...
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