From 4e41b8c02ec70d7553ab62d3862928a1e9aed265 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Fri, 29 Aug 2008 14:39:43 +0100 Subject: [PATCH] Scanning of anonymous containers is now disabled by default, due to a bug in gccxml and the problems it causes. --- pybindgen/gccxmlparser.py | 15 +++++++++++++++ pybindgen/module.py | 2 +- tests/foo.cc | 4 ++-- tests/foo.h | 7 ++++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pybindgen/gccxmlparser.py b/pybindgen/gccxmlparser.py index fd08cb3..4ae1ab2 100644 --- a/pybindgen/gccxmlparser.py +++ b/pybindgen/gccxmlparser.py @@ -499,6 +499,15 @@ class PygenClassifier(object): class ModuleParser(object): + """ + @ivar enable_anonymous_containers: if True, pybindgen will attempt + to scan for all std containers, even the ones that have no + typedef'ed name. However, due to a + U{bug} in gccxml + this is disabled by default. + + """ + def __init__(self, module_name, module_namespace_name='::'): """ Creates an object that will be able parse header files and @@ -529,6 +538,7 @@ class ModuleParser(object): self._anonymous_structs = [] # list of (pygccxml_anonymous_class, outer_pybindgen_class) self._containers_to_register = [] self._containers_registered = {} + self.enable_anonymous_containers = False def add_pre_scan_hook(self, hook): """ @@ -946,6 +956,8 @@ pybindgen.settings.error_handler = ErrorHandler() if traits is None: continue name = normalize_name(type_info.partial_decl_string) + #print >> sys.stderr, "** type: %s; ---> partial_decl_string: %r; name: %r" %\ + # (type_info, type_info.partial_decl_string, name) self._containers_to_register.append((traits, type_info, None, name)) ## scan enumerations @@ -1312,6 +1324,9 @@ pybindgen.settings.error_handler = ErrorHandler() pygen_sink.writeln() def _register_container(self, module, traits, definition, outer_class, name): + if '<' in name and not self.enable_anonymous_containers: + return + kwargs = {} if traits is container_traits.list_traits: diff --git a/pybindgen/module.py b/pybindgen/module.py index 867877a..ff816f1 100644 --- a/pybindgen/module.py +++ b/pybindgen/module.py @@ -554,7 +554,7 @@ class ModuleBase(dict): """ Add a container to the module. - @param container_: a Container object + @param container: a L{Container} object """ assert isinstance(container, Container) container.module = self diff --git a/tests/foo.cc b/tests/foo.cc index 3a4aeff..d0e9934 100644 --- a/tests/foo.cc +++ b/tests/foo.cc @@ -363,10 +363,10 @@ get_map () return rv; } -std::set +std::set get_set () { - std::set rv; + std::set rv; return rv; } diff --git a/tests/foo.h b/tests/foo.h index d097d28..6c65bfb 100644 --- a/tests/foo.h +++ b/tests/foo.h @@ -742,6 +742,7 @@ struct simple_struct_t // -- Containers: typedef std::vector SimpleStructList; +typedef std::vector SimpleStructVec; SimpleStructList get_simple_list (); int set_simple_list (SimpleStructList list); @@ -757,8 +758,8 @@ public: // -#- @inout_list(direction=inout) -#- virtual int set_simple_list_by_ref (SimpleStructList &inout_list); - virtual std::vector get_simple_vec (); - virtual int set_simple_vec (std::vector vec); + virtual SimpleStructVec get_simple_vec (); + virtual int set_simple_vec (SimpleStructVec vec); private: SimpleStructList m_simpleList; @@ -766,6 +767,6 @@ private: std::map get_map (); -std::set get_set (); +std::set get_set (); #endif /* !FOO_H_ */