Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11_abseil
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_abseil
Commits
53f661ef
Commit
53f661ef
authored
May 17, 2023
by
Xiaofei Wang
Committed by
Copybara-Service
May 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal Change.
PiperOrigin-RevId: 532970607
parent
a8fed755
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
pybind11_abseil/statusor_caster.h
+10
-4
No files found.
pybind11_abseil/statusor_caster.h
View file @
53f661ef
...
@@ -42,7 +42,13 @@ struct type_caster<absl::StatusOr<PayloadType>> {
...
@@ -42,7 +42,13 @@ struct type_caster<absl::StatusOr<PayloadType>> {
using
PayloadCaster
=
make_caster
<
PayloadType
>
;
using
PayloadCaster
=
make_caster
<
PayloadType
>
;
using
StatusCaster
=
make_caster
<
absl
::
Status
>
;
using
StatusCaster
=
make_caster
<
absl
::
Status
>
;
#if defined(PYBIND11_HAS_RETURN_VALUE_POLICY_PACK)
using
return_value_policy_t
=
const
return_value_policy_pack
&
;
PYBIND11_TYPE_CASTER_RVPP
(
absl
::
StatusOr
<
PayloadType
>
,
PayloadCaster
::
name
);
#else
using
return_value_policy_t
=
return_value_policy
;
PYBIND11_TYPE_CASTER
(
absl
::
StatusOr
<
PayloadType
>
,
PayloadCaster
::
name
);
PYBIND11_TYPE_CASTER
(
absl
::
StatusOr
<
PayloadType
>
,
PayloadCaster
::
name
);
#endif
bool
load
(
handle
src
,
bool
convert
)
{
bool
load
(
handle
src
,
bool
convert
)
{
PayloadCaster
payload_caster
;
PayloadCaster
payload_caster
;
...
@@ -70,27 +76,27 @@ struct type_caster<absl::StatusOr<PayloadType>> {
...
@@ -70,27 +76,27 @@ struct type_caster<absl::StatusOr<PayloadType>> {
// Convert C++ -> Python.
// Convert C++ -> Python.
static
handle
cast
(
const
absl
::
StatusOr
<
PayloadType
>*
src
,
static
handle
cast
(
const
absl
::
StatusOr
<
PayloadType
>*
src
,
return_value_policy
policy
,
handle
parent
,
return_value_policy
_t
policy
,
handle
parent
,
bool
throw_exception
=
true
)
{
bool
throw_exception
=
true
)
{
if
(
!
src
)
return
none
().
release
();
if
(
!
src
)
return
none
().
release
();
return
cast_impl
(
*
src
,
policy
,
parent
,
throw_exception
);
return
cast_impl
(
*
src
,
policy
,
parent
,
throw_exception
);
}
}
static
handle
cast
(
const
absl
::
StatusOr
<
PayloadType
>&
src
,
static
handle
cast
(
const
absl
::
StatusOr
<
PayloadType
>&
src
,
return_value_policy
policy
,
handle
parent
,
return_value_policy
_t
policy
,
handle
parent
,
bool
throw_exception
=
true
)
{
bool
throw_exception
=
true
)
{
return
cast_impl
(
src
,
policy
,
parent
,
throw_exception
);
return
cast_impl
(
src
,
policy
,
parent
,
throw_exception
);
}
}
static
handle
cast
(
absl
::
StatusOr
<
PayloadType
>&&
src
,
static
handle
cast
(
absl
::
StatusOr
<
PayloadType
>&&
src
,
return_value_policy
policy
,
handle
parent
,
return_value_policy
_t
policy
,
handle
parent
,
bool
throw_exception
=
true
)
{
bool
throw_exception
=
true
)
{
return
cast_impl
(
std
::
move
(
src
),
policy
,
parent
,
throw_exception
);
return
cast_impl
(
std
::
move
(
src
),
policy
,
parent
,
throw_exception
);
}
}
private
:
private
:
template
<
typename
CType
>
template
<
typename
CType
>
static
handle
cast_impl
(
CType
&&
src
,
return_value_policy
policy
,
static
handle
cast_impl
(
CType
&&
src
,
return_value_policy
_t
policy
,
handle
parent
,
bool
throw_exception
)
{
handle
parent
,
bool
throw_exception
)
{
google
::
internal
::
CheckStatusModuleImported
();
google
::
internal
::
CheckStatusModuleImported
();
if
(
src
.
ok
())
{
if
(
src
.
ok
())
{
...
...
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