Skip to content

Commit

Permalink
Remove option, always access wrapped members as shared refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentzell committed May 26, 2020
1 parent 83ea698 commit 17a7bfb
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
4 changes: 1 addition & 3 deletions bin/c++2py.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ parser.add_argument('--includes', '-I', action='append', help='Includes to pass
parser.add_argument('--system_includes', '-isystem', action='append', help='System includes to pass to clang')
parser.add_argument('--cxxflags', default = '', help='Options to pass to clang')
parser.add_argument('--target_file_only', action='store_true', help='Disable recursion into included header files')
parser.add_argument('--wrapped_members_as_shared_refs', action='store_true', help='Disable recursion into included header files')

args = parser.parse_args()

Expand Down Expand Up @@ -78,8 +77,7 @@ W= Cpp2Desc(filename = args.filename,
shell_command = shell_command,
parse_all_comments = args.parse_all_comments,
namespace_to_factor= (), # unused now
target_file_only = args.target_file_only,
wrapped_members_as_shared_refs = args.wrapped_members_as_shared_refs
target_file_only = args.target_file_only
)

# Make the desc file
Expand Down
2 changes: 1 addition & 1 deletion c++/cpp2py/py_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace cpp2py {
if (p == nullptr) return NULL;
py_type *self = (py_type *)p->tp_alloc(p, 0);
if (self != NULL) {
if constexpr (is_ref && wrapped_members_as_shared_refs) {
if constexpr (is_ref) {
// Keep parent alive for lifetime of self
if (parent != nullptr) {
self->parent = parent;
Expand Down
9 changes: 3 additions & 6 deletions cpp2py/cpp2desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Cpp2Desc:
""" """
def __init__(self, filename, namespaces=(), classes= (), namespace_to_factor= (), appname= '',
modulename = '', moduledoc ='', use_properties = False, members_read_only = True, converters = (),
compiler_options=None, includes= None, system_includes= None, libclang_location = None, shell_command = '', parse_all_comments = True, target_file_only = False, wrapped_members_as_shared_refs = False):
compiler_options=None, includes= None, system_includes= None, libclang_location = None, shell_command = '', parse_all_comments = True, target_file_only = False):
"""
Parse the file at construction
Expand Down Expand Up @@ -59,12 +59,9 @@ def __init__(self, filename, namespaces=(), classes= (), namespace_to_factor= ()
target_file_only : bool
Neglect any included files during desc generation [default = False]
wrapped_members_as_shared_refs : bool
For classes with members which are a wrapped type, do not copy them on access but return them as shared references instead. Note that members with types that are only converted (e.g. std::vector) will continue to be copied on access [default = False]
"""
for x in ['filename', 'namespaces', 'classes', 'namespace_to_factor', 'appname', 'modulename', 'moduledoc',
'use_properties', 'members_read_only', 'shell_command', 'target_file_only', 'wrapped_members_as_shared_refs']:
for x in ['filename', 'namespaces', 'classes', 'namespace_to_factor', 'appname', 'modulename', 'moduledoc',
'use_properties', 'members_read_only', 'shell_command', 'target_file_only']:
setattr(self, x, locals()[x])
self.DE = dependency_analyzer.DependencyAnalyzer(converters)
# parse the file
Expand Down
2 changes: 1 addition & 1 deletion cpp2py/mako/desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from cpp2py.wrap_generator import *

# The module
module = module_(full_name = "${W.modulename}", doc = r"${doc.replace_latex(W.moduledoc)}", app_name = "${W.appname}", wrapped_members_as_shared_refs = ${W.wrapped_members_as_shared_refs})
module = module_(full_name = "${W.modulename}", doc = r"${doc.replace_latex(W.moduledoc)}", app_name = "${W.appname}")

# Imports
%if import_list:
Expand Down
3 changes: 0 additions & 3 deletions cpp2py/mako/wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include<iostream> //for std::cout...
using dcomplex = std::complex<double>;

// global options
constexpr bool wrapped_members_as_shared_refs = ${int(module.wrapped_members_as_shared_refs)};

// first the basic stuff
#include <cpp2py/cpp2py.hpp>
#include <cpp2py/converters/string.hpp>
Expand Down
3 changes: 1 addition & 2 deletions cpp2py/wrap_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class module_:
"""
Representation of a module
"""
def __init__(self, full_name, doc = '', app_name = None, wrapped_members_as_shared_refs = False) :
def __init__(self, full_name, doc = '', app_name = None) :
"""
Parameters
----------
Expand All @@ -701,7 +701,6 @@ def __init__(self, full_name, doc = '', app_name = None, wrapped_members_as_sha
"""
self.full_name = full_name if app_name is None or app_name=="triqs" else app_name+"."+full_name
self.wrapped_members_as_shared_refs = wrapped_members_as_shared_refs
self.name = full_name.rsplit('.',1)[-1]
self.doc = doc
self.classes = {} # dict : string -> class_. Key is the Python type
Expand Down

0 comments on commit 17a7bfb

Please sign in to comment.