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
9d7f7a38
Commit
9d7f7a38
authored
Sep 08, 2016
by
Wenzel Jakob
Browse files
fixed Py_None reference couting
parent
5812d64b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
include/pybind11/cast.h
include/pybind11/cast.h
+5
-5
include/pybind11/functional.h
include/pybind11/functional.h
+1
-1
No files found.
include/pybind11/cast.h
View file @
9d7f7a38
...
@@ -185,7 +185,7 @@ public:
...
@@ -185,7 +185,7 @@ public:
const
void
*
existing_holder
=
nullptr
)
{
const
void
*
existing_holder
=
nullptr
)
{
void
*
src
=
const_cast
<
void
*>
(
_src
);
void
*
src
=
const_cast
<
void
*>
(
_src
);
if
(
src
==
nullptr
)
if
(
src
==
nullptr
)
return
none
();
return
none
()
.
inc_ref
()
;
auto
&
internals
=
get_internals
();
auto
&
internals
=
get_internals
();
...
@@ -414,7 +414,7 @@ template <> class type_caster<void_type> {
...
@@ -414,7 +414,7 @@ template <> class type_caster<void_type> {
public:
public:
bool
load
(
handle
,
bool
)
{
return
false
;
}
bool
load
(
handle
,
bool
)
{
return
false
;
}
static
handle
cast
(
void_type
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
static
handle
cast
(
void_type
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
return
none
();
return
none
()
.
inc_ref
()
;
}
}
PYBIND11_TYPE_CASTER
(
void_type
,
_
(
"None"
));
PYBIND11_TYPE_CASTER
(
void_type
,
_
(
"None"
));
};
};
...
@@ -452,7 +452,7 @@ public:
...
@@ -452,7 +452,7 @@ public:
if
(
ptr
)
if
(
ptr
)
return
capsule
(
ptr
).
release
();
return
capsule
(
ptr
).
release
();
else
else
return
none
();
return
none
()
.
inc_ref
()
;
}
}
template
<
typename
T
>
using
cast_op_type
=
void
*&
;
template
<
typename
T
>
using
cast_op_type
=
void
*&
;
...
@@ -569,7 +569,7 @@ public:
...
@@ -569,7 +569,7 @@ public:
}
}
static
handle
cast
(
const
char
*
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
static
handle
cast
(
const
char
*
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
if
(
src
==
nullptr
)
return
none
();
if
(
src
==
nullptr
)
return
none
()
.
inc_ref
()
;
return
PyUnicode_FromString
(
src
);
return
PyUnicode_FromString
(
src
);
}
}
...
@@ -592,7 +592,7 @@ public:
...
@@ -592,7 +592,7 @@ public:
}
}
static
handle
cast
(
const
wchar_t
*
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
static
handle
cast
(
const
wchar_t
*
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
if
(
src
==
nullptr
)
return
none
();
if
(
src
==
nullptr
)
return
none
()
.
inc_ref
()
;
return
PyUnicode_FromWideChar
(
src
,
(
ssize_t
)
wcslen
(
src
));
return
PyUnicode_FromWideChar
(
src
,
(
ssize_t
)
wcslen
(
src
));
}
}
...
...
include/pybind11/functional.h
View file @
9d7f7a38
...
@@ -62,7 +62,7 @@ public:
...
@@ -62,7 +62,7 @@ public:
template
<
typename
Func
>
template
<
typename
Func
>
static
handle
cast
(
Func
&&
f_
,
return_value_policy
policy
,
handle
/* parent */
)
{
static
handle
cast
(
Func
&&
f_
,
return_value_policy
policy
,
handle
/* parent */
)
{
if
(
!
f_
)
if
(
!
f_
)
return
none
();
return
none
()
.
inc_ref
()
;
auto
result
=
f_
.
template
target
<
Return
(
*
)(
Args
...)>();
auto
result
=
f_
.
template
target
<
Return
(
*
)(
Args
...)>();
if
(
result
)
if
(
result
)
...
...
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