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
18fb3e32
Commit
18fb3e32
authored
Apr 25, 2016
by
Wenzel Jakob
Browse files
added a pybind11::none class
parent
9b880ba7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+11
-3
No files found.
include/pybind11/pytypes.h
View file @
18fb3e32
...
...
@@ -212,7 +212,7 @@ private:
ssize_t
pos
=
0
;
};
inline
bool
i
terable_
c
heck
(
PyObject
*
obj
)
{
inline
bool
PyI
terable_
C
heck
(
PyObject
*
obj
)
{
PyObject
*
iter
=
PyObject_GetIter
(
obj
);
if
(
iter
)
{
Py_DECREF
(
iter
);
...
...
@@ -222,8 +222,10 @@ inline bool iterable_check(PyObject *obj) {
return
false
;
}
}
NAMESPACE_END
(
detail
)
inline
bool
PyNone_Check
(
PyObject
*
o
)
{
return
o
==
Py_None
;
}
NAMESPACE_END
(
detail
)
#define PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, CvtStmt) \
Name(const handle &h, bool borrowed) : Parent(h, borrowed) { CvtStmt; } \
...
...
@@ -261,7 +263,7 @@ private:
class
iterable
:
public
object
{
public:
PYBIND11_OBJECT_DEFAULT
(
iterable
,
object
,
detail
::
i
terable_
c
heck
)
PYBIND11_OBJECT_DEFAULT
(
iterable
,
object
,
detail
::
PyI
terable_
C
heck
)
};
inline
detail
::
accessor
handle
::
operator
[](
handle
key
)
const
{
return
detail
::
accessor
(
ptr
(),
key
.
ptr
(),
false
);
}
...
...
@@ -319,6 +321,12 @@ public:
}
};
class
none
:
public
object
{
public:
PYBIND11_OBJECT
(
none
,
object
,
detail
::
PyNone_Check
)
none
()
:
object
(
Py_None
,
true
)
{
}
};
class
bool_
:
public
object
{
public:
PYBIND11_OBJECT_DEFAULT
(
bool_
,
object
,
PyBool_Check
)
...
...
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