Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pywrap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EBRAINS RI
Tech Hub
Apps
BrainScaleS
pywrap
Commits
961e7e3f
Commit
961e7e3f
authored
6 years ago
by
Eric Müller
Committed by
Felix Passenberg
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add add_optional_vector_converter_for
Change-Id: I1485ff934519b10802be704dd53265d7eb390e26
parent
ecac2a60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pywrap/classes.py
+29
-0
29 additions, 0 deletions
pywrap/classes.py
with
29 additions
and
0 deletions
pywrap/classes.py
+
29
−
0
View file @
961e7e3f
...
...
@@ -266,6 +266,35 @@ def add_variant_converters_for(mb, cl):
return
True
def
add_optional_vector_wrapper_for
(
mb
,
variable
):
if
not
templates
.
is_instantiation
(
variable
.
type
.
decl_string
):
return
False
name
,
args
=
templates
.
split
(
variable
.
type
.
decl_string
)
if
not
name
==
'
::boost::optional
'
:
return
False
assert
(
len
(
args
)
==
1
)
vec
,
v_type
=
templates
.
split
(
args
[
0
])
mb
.
add_registration_code
(
textwrap
.
dedent
(
"""
bp::class_<{optional}>(
"
{optional}
"
, bp::init<>()) // support default non-construct init
.def(
"
is_initialized
"
, &{optional}::is_initialized)
.def(
"
value
"
, &{optional}::value, bp::return_internal_reference<>())
.add_property(
"
access
"
, +[]({optional} const & self){{return *self;}}, +[]({optional} self , bp::object& value)
{{
auto& vect = *self;
vect.clear();
for ( auto it = bp::stl_input_iterator< {v_type} > (value); it != bp::stl_input_iterator< {v_type} > (); it++) {{
vect.push_back(*it);
}}
self = vect;
}} )
;
;
"""
).
format
(
optional
=
variable
.
type
.
decl_string
,
alias
=
args
[
0
],
v_type
=
v_type
[
0
]))
return
True
def
add_omp_safe_virtual_functions
(
cls
,
*
args
,
**
kwargs
):
"""
Adds OMP based locking around callback to python in virtual function overrides
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment