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
768472f4
Commit
768472f4
authored
Feb 15, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Splitting out smart_holder_init_inline_include.h.
parent
17e232c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
49 deletions
+53
-49
include/pybind11/detail/init.h
+4
-49
include/pybind11/detail/smart_holder_init_inline_include.h
+49
-0
No files found.
include/pybind11/detail/init.h
View file @
768472f4
...
...
@@ -169,55 +169,10 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
v_h
.
value_ptr
()
=
new
Alias
<
Class
>
(
std
::
move
(
result
));
}
//DETAIL/SMART_HOLDER_INIT_H/BEGIN/////////////////////////////////////////////////////////////////
template
<
typename
Class
,
typename
D
=
std
::
default_delete
<
Cpp
<
Class
>>
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Cpp
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
unique_ptr
<
Cpp
<
Class
>
,
D
>
&&
unq_ptr
,
bool
need_alias
)
{
auto
*
ptr
=
unq_ptr
.
get
();
no_nullptr
(
ptr
);
if
(
Class
::
has_alias
&&
need_alias
)
throw
type_error
(
"pybind11::init(): construction failed: returned std::unique_ptr pointee "
"is not an alias instance"
);
auto
smhldr
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
unq_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
template
<
typename
Class
,
typename
D
=
std
::
default_delete
<
Alias
<
Class
>>
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Alias
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
unique_ptr
<
Alias
<
Class
>
,
D
>
&&
unq_ptr
,
bool
/*need_alias*/
)
{
auto
*
ptr
=
unq_ptr
.
get
();
no_nullptr
(
ptr
);
auto
smhldr
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
unq_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
template
<
typename
Class
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Cpp
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
shared_ptr
<
Cpp
<
Class
>>
&&
shd_ptr
,
bool
need_alias
)
{
auto
*
ptr
=
shd_ptr
.
get
();
no_nullptr
(
ptr
);
if
(
Class
::
has_alias
&&
need_alias
)
throw
type_error
(
"pybind11::init(): construction failed: returned std::shared_ptr pointee "
"is not an alias instance"
);
auto
smhldr
=
smart_holder
::
from_shared_ptr
(
std
::
move
(
shd_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
template
<
typename
Class
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Alias
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
shared_ptr
<
Alias
<
Class
>>
&&
shd_ptr
,
bool
/*need_alias*/
)
{
auto
*
ptr
=
shd_ptr
.
get
();
no_nullptr
(
ptr
);
auto
smhldr
=
smart_holder
::
from_shared_ptr
(
std
::
move
(
shd_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
//DETAIL/SMART_HOLDER_INIT_H/END///////////////////////////////////////////////////////////////////
// SMART_HOLDER_WIP: Needs refactoring of existing pybind11 code.
#define PYBIND11_DETAIL_INIT_H_SMART_HOLDER_INIT_INLINE_INCLUDE_SAFETY_GUARD
#include "smart_holder_init_inline_include.h"
#undef PYBIND11_DETAIL_INIT_H_SMART_HOLDER_INIT_INLINE_INCLUDE_SAFETY_GUARD
// Implementing class for py::init<...>()
template
<
typename
...
Args
>
...
...
include/pybind11/detail/smart_holder_init_inline_include.h
0 → 100644
View file @
768472f4
#ifndef PYBIND11_DETAIL_INIT_H_SMART_HOLDER_INIT_INLINE_INCLUDE_SAFETY_GUARD
#error "THIS FILE MUST ONLY BE INCLUDED FROM pybind11/detail/init.h"
#endif
template
<
typename
Class
,
typename
D
=
std
::
default_delete
<
Cpp
<
Class
>>
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Cpp
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
unique_ptr
<
Cpp
<
Class
>
,
D
>
&&
unq_ptr
,
bool
need_alias
)
{
auto
*
ptr
=
unq_ptr
.
get
();
no_nullptr
(
ptr
);
if
(
Class
::
has_alias
&&
need_alias
)
throw
type_error
(
"pybind11::init(): construction failed: returned std::unique_ptr pointee "
"is not an alias instance"
);
auto
smhldr
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
unq_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
template
<
typename
Class
,
typename
D
=
std
::
default_delete
<
Alias
<
Class
>>
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Alias
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
unique_ptr
<
Alias
<
Class
>
,
D
>
&&
unq_ptr
,
bool
/*need_alias*/
)
{
auto
*
ptr
=
unq_ptr
.
get
();
no_nullptr
(
ptr
);
auto
smhldr
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
unq_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
template
<
typename
Class
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Cpp
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
shared_ptr
<
Cpp
<
Class
>>
&&
shd_ptr
,
bool
need_alias
)
{
auto
*
ptr
=
shd_ptr
.
get
();
no_nullptr
(
ptr
);
if
(
Class
::
has_alias
&&
need_alias
)
throw
type_error
(
"pybind11::init(): construction failed: returned std::shared_ptr pointee "
"is not an alias instance"
);
auto
smhldr
=
smart_holder
::
from_shared_ptr
(
std
::
move
(
shd_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
template
<
typename
Class
,
detail
::
enable_if_t
<
detail
::
is_smart_holder_type_caster
<
Alias
<
Class
>>::
value
,
int
>
=
0
>
void
construct
(
value_and_holder
&
v_h
,
std
::
shared_ptr
<
Alias
<
Class
>>
&&
shd_ptr
,
bool
/*need_alias*/
)
{
auto
*
ptr
=
shd_ptr
.
get
();
no_nullptr
(
ptr
);
auto
smhldr
=
smart_holder
::
from_shared_ptr
(
std
::
move
(
shd_ptr
));
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
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