Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
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
Commits
4f135ce8
Commit
4f135ce8
authored
Jan 14, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Making test_type_caster_bare_interface_demo.cpp slightly more realistic, ASAN, MSAN, UBSAN clean.
parent
1ac08dbc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
55 deletions
+49
-55
tests/test_type_caster_bare_interface_demo.cpp
+49
-55
No files found.
tests/test_type_caster_bare_interface_demo.cpp
View file @
4f135ce8
...
@@ -7,12 +7,14 @@ namespace type_caster_bare_interface_demo {
...
@@ -7,12 +7,14 @@ namespace type_caster_bare_interface_demo {
struct
mpty
{};
struct
mpty
{};
// clang-format off
mpty
rtrn_mpty_valu
()
{
mpty
obj
;
return
obj
;
}
mpty
rtrn_mpty_valu
()
{
mpty
obj
;
return
obj
;
}
mpty
&&
rtrn_mpty_rref
()
{
mpty
obj
;
return
std
::
move
(
obj
);
}
mpty
&&
rtrn_mpty_rref
()
{
static
mpty
obj
;
return
std
::
move
(
obj
);
}
mpty
const
&
rtrn_mpty_cref
()
{
static
mpty
obj
;
return
obj
;
}
mpty
const
&
rtrn_mpty_cref
()
{
static
mpty
obj
;
return
obj
;
}
mpty
&
rtrn_mpty_mref
()
{
static
mpty
obj
;
return
obj
;
}
mpty
&
rtrn_mpty_mref
()
{
static
mpty
obj
;
return
obj
;
}
mpty
const
*
rtrn_mpty_cptr
()
{
static
mpty
obj
;
return
&
obj
;
}
mpty
const
*
rtrn_mpty_cptr
()
{
return
new
mpty
;
}
mpty
*
rtrn_mpty_mptr
()
{
static
mpty
obj
;
return
&
obj
;
}
mpty
*
rtrn_mpty_mptr
()
{
return
new
mpty
;
}
const
char
*
pass_mpty_valu
(
mpty
)
{
return
"load_valu"
;
}
const
char
*
pass_mpty_valu
(
mpty
)
{
return
"load_valu"
;
}
const
char
*
pass_mpty_rref
(
mpty
&&
)
{
return
"load_rref"
;
}
const
char
*
pass_mpty_rref
(
mpty
&&
)
{
return
"load_rref"
;
}
...
@@ -21,18 +23,20 @@ const char* pass_mpty_mref(mpty&) { return "load_mref"; }
...
@@ -21,18 +23,20 @@ const char* pass_mpty_mref(mpty&) { return "load_mref"; }
const
char
*
pass_mpty_cptr
(
mpty
const
*
)
{
return
"load_cptr"
;
}
const
char
*
pass_mpty_cptr
(
mpty
const
*
)
{
return
"load_cptr"
;
}
const
char
*
pass_mpty_mptr
(
mpty
*
)
{
return
"load_mptr"
;
}
const
char
*
pass_mpty_mptr
(
mpty
*
)
{
return
"load_mptr"
;
}
std
::
shared_ptr
<
mpty
>
rtrn_mpty_shmp
()
{
return
std
::
shared_ptr
<
mpty
>
(
new
mpty
);
}
std
::
shared_ptr
<
mpty
>
rtrn_mpty_shmp
()
{
return
std
::
shared_ptr
<
mpty
>
(
new
mpty
);
}
std
::
shared_ptr
<
mpty
const
>
rtrn_mpty_shcp
()
{
return
std
::
shared_ptr
<
mpty
const
>
(
new
mpty
);
}
std
::
shared_ptr
<
mpty
const
>
rtrn_mpty_shcp
()
{
return
std
::
shared_ptr
<
mpty
const
>
(
new
mpty
);
}
const
char
*
pass_mpty_shmp
(
std
::
shared_ptr
<
mpty
>
)
{
return
"load_shmp"
;
}
const
char
*
pass_mpty_shmp
(
std
::
shared_ptr
<
mpty
>
)
{
return
"load_shmp"
;
}
const
char
*
pass_mpty_shcp
(
std
::
shared_ptr
<
mpty
const
>
)
{
return
"load_shcp"
;
}
const
char
*
pass_mpty_shcp
(
std
::
shared_ptr
<
mpty
const
>
)
{
return
"load_shcp"
;
}
std
::
unique_ptr
<
mpty
>
rtrn_mpty_uqmp
()
{
return
std
::
unique_ptr
<
mpty
>
(
new
mpty
);
}
std
::
unique_ptr
<
mpty
>
rtrn_mpty_uqmp
()
{
return
std
::
unique_ptr
<
mpty
>
(
new
mpty
);
}
std
::
unique_ptr
<
mpty
const
>
rtrn_mpty_uqcp
()
{
return
std
::
unique_ptr
<
mpty
const
>
(
new
mpty
);
}
std
::
unique_ptr
<
mpty
const
>
rtrn_mpty_uqcp
()
{
return
std
::
unique_ptr
<
mpty
const
>
(
new
mpty
);
}
const
char
*
pass_mpty_uqmp
(
std
::
unique_ptr
<
mpty
>
)
{
return
"load_uqmp"
;
}
const
char
*
pass_mpty_uqmp
(
std
::
unique_ptr
<
mpty
>
)
{
return
"load_uqmp"
;
}
const
char
*
pass_mpty_uqcp
(
std
::
unique_ptr
<
mpty
const
>
)
{
return
"load_uqcp"
;
}
const
char
*
pass_mpty_uqcp
(
std
::
unique_ptr
<
mpty
const
>
)
{
return
"load_uqcp"
;
}
// clang-format on
}
// namespace type_caster_bare_interface_demo
}
// namespace type_caster_bare_interface_demo
}
// namespace pybind11_tests
}
// namespace pybind11_tests
...
@@ -48,135 +52,125 @@ struct type_caster<mpty> {
...
@@ -48,135 +52,125 @@ struct type_caster<mpty> {
// static handle cast(mpty, ...)
// static handle cast(mpty, ...)
// is redundant (leads to ambiguous overloads).
// is redundant (leads to ambiguous overloads).
static
handle
cast
(
mpty
&&
/*src*/
,
static
handle
cast
(
mpty
&&
/*src*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return
str
(
"cast_rref"
).
release
();
return
str
(
"cast_rref"
).
release
();
}
}
static
handle
cast
(
mpty
const
&
/*src*/
,
static
handle
cast
(
mpty
const
&
/*src*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return
str
(
"cast_cref"
).
release
();
return
str
(
"cast_cref"
).
release
();
}
}
static
handle
cast
(
mpty
&
/*src*/
,
static
handle
cast
(
mpty
&
/*src*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return
str
(
"cast_mref"
).
release
();
return
str
(
"cast_mref"
).
release
();
}
}
static
handle
cast
(
mpty
const
*
/*src*/
,
static
handle
cast
(
mpty
const
*
src
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return_value_policy
/*policy*/
,
delete
src
;
handle
/*parent*/
)
{
return
str
(
"cast_cptr"
).
release
();
return
str
(
"cast_cptr"
).
release
();
}
}
static
handle
cast
(
mpty
*
/*src*/
,
static
handle
cast
(
mpty
*
src
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
return_value_policy
/*policy*/
,
delete
src
;
handle
/*parent*/
)
{
return
str
(
"cast_mptr"
).
release
();
return
str
(
"cast_mptr"
).
release
();
}
}
template
<
typename
T_
>
template
<
typename
T_
>
using
cast_op_type
=
conditional_t
<
using
cast_op_type
=
conditional_t
<
std
::
is_same
<
remove_reference_t
<
T_
>
,
mpty
const
*>::
value
,
mpty
const
*
,
std
::
is_same
<
remove_reference_t
<
T_
>
,
mpty
const
*>::
value
,
mpty
const
*
,
conditional_t
<
conditional_t
<
std
::
is_same
<
remove_reference_t
<
T_
>
,
mpty
*>::
value
,
mpty
*
,
std
::
is_same
<
remove_reference_t
<
T_
>
,
mpty
*>::
value
,
mpty
*
,
conditional_t
<
conditional_t
<
std
::
is_same
<
T_
,
mpty
const
&>::
value
,
mpty
const
&
,
std
::
is_same
<
T_
,
mpty
const
&>::
value
,
conditional_t
<
mpty
const
&
,
std
::
is_same
<
T_
,
mpty
&>::
value
,
mpty
&
,
conditional_t
<
std
::
is_same
<
T_
,
mpty
&>::
value
,
conditional_t
<
mpty
&
,
std
::
is_same
<
T_
,
mpty
&&>::
value
,
mpty
&&
,
conditional_t
<
std
::
is_same
<
T_
,
mpty
&&>::
value
,
mpty
&&
,
mpty
>>>>>
;
mpty
>>>>>
;
// clang-format off
operator
mpty
()
{
return
rtrn_mpty_valu
();
}
operator
mpty
()
{
return
rtrn_mpty_valu
();
}
operator
mpty
&&
()
&&
{
return
rtrn_mpty_rref
();
}
operator
mpty
&&
()
&&
{
return
rtrn_mpty_rref
();
}
operator
mpty
const
&
()
{
return
rtrn_mpty_cref
();
}
operator
mpty
const
&
()
{
return
rtrn_mpty_cref
();
}
operator
mpty
&
()
{
return
rtrn_mpty_mref
();
}
operator
mpty
&
()
{
return
rtrn_mpty_mref
();
}
operator
mpty
const
*
()
{
return
rtrn_mpty_cptr
()
;
}
operator
mpty
const
*
()
{
static
mpty
obj
;
return
&
obj
;
}
operator
mpty
*
()
{
return
rtrn_mpty_mptr
()
;
}
operator
mpty
*
()
{
static
mpty
obj
;
return
&
obj
;
}
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
// clang-format on
return
true
;
}
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
return
true
;
}
};
};
template
<>
template
<>
struct
type_caster
<
std
::
shared_ptr
<
mpty
>>
{
struct
type_caster
<
std
::
shared_ptr
<
mpty
>>
{
static
constexpr
auto
name
=
_
<
std
::
shared_ptr
<
mpty
>>
();
static
constexpr
auto
name
=
_
<
std
::
shared_ptr
<
mpty
>>
();
static
handle
cast
(
const
std
::
shared_ptr
<
mpty
>&
/*src*/
,
static
handle
cast
(
const
std
::
shared_ptr
<
mpty
>
&
/*src*/
,
return_value_policy
/*policy*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
handle
/*parent*/
)
{
return
str
(
"cast_shmp"
).
release
();
return
str
(
"cast_shmp"
).
release
();
}
}
template
<
typename
>
using
cast_op_type
=
std
::
shared_ptr
<
mpty
>
;
template
<
typename
>
using
cast_op_type
=
std
::
shared_ptr
<
mpty
>
;
operator
std
::
shared_ptr
<
mpty
>
()
{
return
rtrn_mpty_shmp
();
}
operator
std
::
shared_ptr
<
mpty
>
()
{
return
rtrn_mpty_shmp
();
}
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
return
true
;
}
return
true
;
}
};
};
template
<>
template
<>
struct
type_caster
<
std
::
shared_ptr
<
mpty
const
>>
{
struct
type_caster
<
std
::
shared_ptr
<
mpty
const
>>
{
static
constexpr
auto
name
=
_
<
std
::
shared_ptr
<
mpty
const
>>
();
static
constexpr
auto
name
=
_
<
std
::
shared_ptr
<
mpty
const
>>
();
static
handle
cast
(
const
std
::
shared_ptr
<
mpty
const
>&
/*src*/
,
static
handle
cast
(
const
std
::
shared_ptr
<
mpty
const
>
&
/*src*/
,
return_value_policy
/*policy*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
handle
/*parent*/
)
{
return
str
(
"cast_shcp"
).
release
();
return
str
(
"cast_shcp"
).
release
();
}
}
template
<
typename
>
using
cast_op_type
=
std
::
shared_ptr
<
mpty
const
>
;
template
<
typename
>
using
cast_op_type
=
std
::
shared_ptr
<
mpty
const
>
;
operator
std
::
shared_ptr
<
mpty
const
>
()
{
return
rtrn_mpty_shcp
();
}
operator
std
::
shared_ptr
<
mpty
const
>
()
{
return
rtrn_mpty_shcp
();
}
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
return
true
;
}
return
true
;
}
};
};
template
<>
template
<>
struct
type_caster
<
std
::
unique_ptr
<
mpty
>>
{
struct
type_caster
<
std
::
unique_ptr
<
mpty
>>
{
static
constexpr
auto
name
=
_
<
std
::
unique_ptr
<
mpty
>>
();
static
constexpr
auto
name
=
_
<
std
::
unique_ptr
<
mpty
>>
();
static
handle
cast
(
std
::
unique_ptr
<
mpty
>&&
/*src*/
,
static
handle
return_value_policy
/*policy*/
,
cast
(
std
::
unique_ptr
<
mpty
>
&&
/*src*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
handle
/*parent*/
)
{
return
str
(
"cast_uqmp"
).
release
();
return
str
(
"cast_uqmp"
).
release
();
}
}
template
<
typename
>
using
cast_op_type
=
std
::
unique_ptr
<
mpty
>
;
template
<
typename
>
using
cast_op_type
=
std
::
unique_ptr
<
mpty
>
;
operator
std
::
unique_ptr
<
mpty
>
()
{
return
rtrn_mpty_uqmp
();
}
operator
std
::
unique_ptr
<
mpty
>
()
{
return
rtrn_mpty_uqmp
();
}
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
return
true
;
}
return
true
;
}
};
};
template
<>
template
<>
struct
type_caster
<
std
::
unique_ptr
<
mpty
const
>>
{
struct
type_caster
<
std
::
unique_ptr
<
mpty
const
>>
{
static
constexpr
auto
name
=
_
<
std
::
unique_ptr
<
mpty
const
>>
();
static
constexpr
auto
name
=
_
<
std
::
unique_ptr
<
mpty
const
>>
();
static
handle
cast
(
std
::
unique_ptr
<
mpty
const
>&&
/*src*/
,
static
handle
cast
(
std
::
unique_ptr
<
mpty
const
>
&&
/*src*/
,
return_value_policy
/*policy*/
,
return_value_policy
/*policy*/
,
handle
/*parent*/
)
{
handle
/*parent*/
)
{
return
str
(
"cast_uqcp"
).
release
();
return
str
(
"cast_uqcp"
).
release
();
}
}
template
<
typename
>
using
cast_op_type
=
std
::
unique_ptr
<
mpty
const
>
;
template
<
typename
>
using
cast_op_type
=
std
::
unique_ptr
<
mpty
const
>
;
operator
std
::
unique_ptr
<
mpty
const
>
()
{
return
rtrn_mpty_uqcp
();
}
operator
std
::
unique_ptr
<
mpty
const
>
()
{
return
rtrn_mpty_uqcp
();
}
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
bool
load
(
handle
/*src*/
,
bool
/*convert*/
)
{
return
true
;
}
return
true
;
}
};
};
}
// namespace detail
}
// namespace detail
...
...
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