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
3d31698f
Commit
3d31698f
authored
Feb 23, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merging detail/smart_holder_init_inline_include.h into detail/init.h.
parent
044056a1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
63 deletions
+56
-63
CMakeLists.txt
+0
-1
include/pybind11/detail/init.h
+56
-4
include/pybind11/detail/smart_holder_init_inline_include.h
+0
-57
tests/extra_python_package/test_files.py
+0
-1
No files found.
CMakeLists.txt
View file @
3d31698f
...
@@ -105,7 +105,6 @@ set(PYBIND11_HEADERS
...
@@ -105,7 +105,6 @@ set(PYBIND11_HEADERS
include/pybind11/detail/descr.h
include/pybind11/detail/descr.h
include/pybind11/detail/init.h
include/pybind11/detail/init.h
include/pybind11/detail/internals.h
include/pybind11/detail/internals.h
include/pybind11/detail/smart_holder_init_inline_include.h
include/pybind11/detail/smart_holder_poc.h
include/pybind11/detail/smart_holder_poc.h
include/pybind11/detail/smart_holder_type_casters.h
include/pybind11/detail/smart_holder_type_casters.h
include/pybind11/detail/typeid.h
include/pybind11/detail/typeid.h
...
...
include/pybind11/detail/init.h
View file @
3d31698f
// clang-format off
/*
/*
pybind11/detail/init.h: init factory function implementation and support code.
pybind11/detail/init.h: init factory function implementation and support code.
...
@@ -169,10 +170,61 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
...
@@ -169,10 +170,61 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
v_h
.
value_ptr
()
=
new
Alias
<
Class
>
(
std
::
move
(
result
));
v_h
.
value_ptr
()
=
new
Alias
<
Class
>
(
std
::
move
(
result
));
}
}
// SMART_HOLDER_WIP: Needs refactoring of existing pybind11 code.
// clang-format on
#define PYBIND11_DETAIL_INIT_H_SMART_HOLDER_INIT_INLINE_INCLUDE_SAFETY_GUARD
template
<
typename
Class
,
#include "smart_holder_init_inline_include.h"
typename
D
=
std
::
default_delete
<
Cpp
<
Class
>>
,
#undef PYBIND11_DETAIL_INIT_H_SMART_HOLDER_INIT_INLINE_INCLUDE_SAFETY_GUARD
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
=
type_caster
<
Cpp
<
Class
>>::
template
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
=
type_caster
<
Alias
<
Class
>>::
template
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
=
type_caster
<
Cpp
<
Class
>>::
template
smart_holder_from_shared_ptr
(
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
=
type_caster
<
Alias
<
Class
>>::
template
smart_holder_from_shared_ptr
(
shd_ptr
);
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
// clang-format off
// Implementing class for py::init<...>()
// Implementing class for py::init<...>()
template
<
typename
...
Args
>
template
<
typename
...
Args
>
...
...
include/pybind11/detail/smart_holder_init_inline_include.h
deleted
100644 → 0
View file @
044056a1
#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
=
type_caster
<
Cpp
<
Class
>>::
template
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
=
type_caster
<
Alias
<
Class
>>::
template
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
=
type_caster
<
Cpp
<
Class
>>::
template
smart_holder_from_shared_ptr
(
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
=
type_caster
<
Alias
<
Class
>>::
template
smart_holder_from_shared_ptr
(
shd_ptr
);
v_h
.
value_ptr
()
=
ptr
;
v_h
.
type
->
init_instance
(
v_h
.
inst
,
&
smhldr
);
}
tests/extra_python_package/test_files.py
View file @
3d31698f
...
@@ -43,7 +43,6 @@ detail_headers = {
...
@@ -43,7 +43,6 @@ detail_headers = {
"include/pybind11/detail/descr.h"
,
"include/pybind11/detail/descr.h"
,
"include/pybind11/detail/init.h"
,
"include/pybind11/detail/init.h"
,
"include/pybind11/detail/internals.h"
,
"include/pybind11/detail/internals.h"
,
"include/pybind11/detail/smart_holder_init_inline_include.h"
,
"include/pybind11/detail/smart_holder_poc.h"
,
"include/pybind11/detail/smart_holder_poc.h"
,
"include/pybind11/detail/smart_holder_type_casters.h"
,
"include/pybind11/detail/smart_holder_type_casters.h"
,
"include/pybind11/detail/typeid.h"
,
"include/pybind11/detail/typeid.h"
,
...
...
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