Commit da4fa6b2 authored by John Parent's avatar John Parent
Browse files

Changes for review

parent a0e29fce
......@@ -9,6 +9,8 @@ from stl_container import (
Int2String,
Int2Double,
simple,
VectoVec,
simpleT_int,
)
......
......@@ -808,8 +808,10 @@ class BindingsGenerator:
def is_stl(self, x):
if type(x) is str:
return self.check_decl("std", x)
else:
elif type(x) is dec.scopedef_t or issubclass(type(x), dec.scopedef_t):
return self.check_decl("std", x.decl_string)
else:
return False
def depends_on_eigen(self, x, member=None):
return self.check_decl("Eigen", x.decl_string)
......@@ -833,7 +835,7 @@ class BindingsGenerator:
except AttributeError:
return decl
def derive_stl_deps(self, decl_string, incs=set()):
def derive_stl_deps(self, decl_string, incs):
if self.is_templated(decl_string):
rec_gen = dec.templates.split_recursive(decl_string)
for split in rec_gen:
......@@ -862,27 +864,26 @@ class BindingsGenerator:
std = pygccxml_data.namespace(name="std")
except dec.runtime_errors.declaration_not_found_t:
return []
finally:
# further avoid RT increase by leveraging decl_type looking for class_t
stl_data = []
for container in self.stl_binders:
if container.stl_bind:
try:
stl_data.append(
std.decl(
lambda declaration: dec.templates.normalize(
self.derive_stl_defaults(
declaration.partial_decl_string
)
# further avoid RT increase by leveraging decl_type looking for class_t
stl_data = []
for container in self.stl_binders:
if container.stl_bind:
try:
stl_data.append(
std.decl(
lambda declaration: dec.templates.normalize(
self.derive_stl_defaults(
declaration.partial_decl_string
)
== dec.templates.normalize(
container.get_partial_decl()
),
decl_type=dec.class_declaration.class_t,
)
== dec.templates.normalize(
container.get_partial_decl()
),
decl_type=dec.class_declaration.class_t,
)
except pygccxml.declarations.runtime_errors.declaration_not_found_t:
continue
)
except pygccxml.declarations.runtime_errors.declaration_not_found_t:
continue
return stl_data
def generate_stl_class_bindings(self, container, pygccxml_data):
......@@ -987,7 +988,6 @@ class BindingsGenerator:
:return: the header file name and a string representing the opaque
declarations
"""
header_str = "#ifndef STL_OPAQUE\n#define STL_OPAQUE\n#include <pybind11/pybind11.h>\n#include <pybind11/stl_bind.h>\n{}\n{}\n#endif\n"
binder_str = ""
file_ = "stl_opaque_dec.h"
self.universal_includes += '#include "{}"\n'.format(file_)
......@@ -996,7 +996,7 @@ class BindingsGenerator:
binder_str += (
self.opts.make_opaque_fmt.format(container.cpp_name) + "\n"
)
return header_str.format(stl_incs, binder_str), file_
return self.opts.stl_header_str.format(stl_incs, binder_str), file_
def write_stl_opaque_header(self, containers, outdir):
"""
......@@ -2715,9 +2715,8 @@ class BindingsGenerator:
stl_struct.add(x)
for inc in addl_incs:
inc_str = "<{}>".format(self.strip_std(inc))
if inc_str not in res_dict["to_include"]:
res_dict["to_include"].add(inc_str)
# res_dict["stl_insts"].add(x.cpp_name)
res_dict["to_include"].add(inc_str)
self.stl_binders.extend(stl_binders_)
res_dict["stl_insts"] = self.compose_stl_struct(stl_struct)
res_dict["all_qualified_names"].add("stl_names")
......@@ -3704,6 +3703,7 @@ def main(argv=None):
arg.add("--bind_stl_type_fmt", required=False, default=tb.bind_stl_type)
arg.add("--generic_include", required=False, default=tb.generic_include)
arg.add("--stl_struct", required=False, default=tb.stl_naming_struct)
arg.add("--stl_header_str", required=False, default=tb.stl_header_str)
options = arg.parse_args(argv)
# CastXML Check for a relatively recent version
rtn = subprocess.check_output([options.castxml_path, "--version"])
......
......@@ -7,7 +7,9 @@ These strings will be formatted in generator.py, then used to
generate valid pybind11 binding code
"""
submodule_signature = """py::module {mod_name} = m.def_submodule("{name}", "");"""
submodule_signature = (
"""py::module {mod_name} = m.def_submodule("{name}", "");"""
)
arg_val_cast = " = {type}({val})"
nullptr_arg_val = " = ({type}){val}"
common_cpp_body = """
......@@ -274,3 +276,5 @@ stl_naming_struct = """struct stl_names{{
{body}
}} bind_stl_names;
"""
stl_header_str = "#ifndef STL_OPAQUE\n#define STL_OPAQUE\n#include <pybind11/pybind11.h>\n#include <pybind11/stl_bind.h>\n{}\n{}\n#endif\n"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment