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
f6c4c104
Commit
f6c4c104
authored
Sep 04, 2019
by
Lori A. Burns
Committed by
Wenzel Jakob
Sep 04, 2019
Browse files
restores __invert__ to arithmetic-enabled enum, fixes #1907 (#1909)
parent
5b4751af
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
0 deletions
+3
-0
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+2
-0
tests/test_enum.py
tests/test_enum.py
+1
-0
No files found.
include/pybind11/pybind11.h
View file @
f6c4c104
...
@@ -1484,6 +1484,8 @@ struct enum_base {
...
@@ -1484,6 +1484,8 @@ struct enum_base {
PYBIND11_ENUM_OP_CONV
(
"__ror__"
,
a
|
b
);
PYBIND11_ENUM_OP_CONV
(
"__ror__"
,
a
|
b
);
PYBIND11_ENUM_OP_CONV
(
"__xor__"
,
a
^
b
);
PYBIND11_ENUM_OP_CONV
(
"__xor__"
,
a
^
b
);
PYBIND11_ENUM_OP_CONV
(
"__rxor__"
,
a
^
b
);
PYBIND11_ENUM_OP_CONV
(
"__rxor__"
,
a
^
b
);
m_base
.
attr
(
"__invert__"
)
=
cpp_function
(
[](
object
arg
)
{
return
~
(
int_
(
arg
));
},
is_method
(
m_base
));
}
}
}
else
{
}
else
{
PYBIND11_ENUM_OP_STRICT
(
"__eq__"
,
int_
(
a
).
equal
(
int_
(
b
)),
return
false
);
PYBIND11_ENUM_OP_STRICT
(
"__eq__"
,
int_
(
a
).
equal
(
int_
(
b
)),
return
false
);
...
...
tests/test_enum.py
View file @
f6c4c104
...
@@ -140,6 +140,7 @@ def test_binary_operators():
...
@@ -140,6 +140,7 @@ def test_binary_operators():
assert
int
(
m
.
Flags
.
Read
|
m
.
Flags
.
Execute
)
==
5
assert
int
(
m
.
Flags
.
Read
|
m
.
Flags
.
Execute
)
==
5
assert
int
(
m
.
Flags
.
Write
|
m
.
Flags
.
Execute
)
==
3
assert
int
(
m
.
Flags
.
Write
|
m
.
Flags
.
Execute
)
==
3
assert
int
(
m
.
Flags
.
Write
|
1
)
==
3
assert
int
(
m
.
Flags
.
Write
|
1
)
==
3
assert
~
m
.
Flags
.
Write
==
-
3
state
=
m
.
Flags
.
Read
|
m
.
Flags
.
Write
state
=
m
.
Flags
.
Read
|
m
.
Flags
.
Write
assert
(
state
&
m
.
Flags
.
Read
)
!=
0
assert
(
state
&
m
.
Flags
.
Read
)
!=
0
...
...
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