On Thu, Oct 1, 2009 at 5:46 PM, Christopher Bruns <cmbr...@stanford.edu> wrote: > I disagree. Py++ does have a way to find out. The only time > "explicit" matters is when a constructor takes exactly one argument. > gccxml sets "explicit=1" in all cases when the number of arguments is > other than 1. That is why you saw "explicit=1" in all of the > constructors in the previous example. However, in the case where > there is exactly one argument, gccxml does the right thing. Consider > the following case: > > ### test.h #### > struct Foo1 {}; > struct Foo2 {}; > > struct Bar { > explicit Bar(Foo1&); // no implicit conversion > Bar(Foo2&); // allows implicit conversion > }; > ############# > > > ### fragment of resulting xml file from gccxml ### > <Constructor id="_10" name="Bar" explicit="1" context="_3" > access="public" mangled="_ZN3BarC1ER4Foo1 *INTERNAL* " > demangled="Bar::Bar(Foo1&)" location="f0:5" file="f0" line="5" > extern="1"> > <Argument type="_22" location="f0:5" file="f0" line="5"/> > </Constructor> > <Constructor id="_11" name="Bar" context="_3" access="public" > mangled="_ZN3BarC1ER4Foo2 *INTERNAL* " demangled="Bar::Bar(Foo2&)" > location="f0:6" file="f0" line="6" extern="1"> > <Argument type="_23" location="f0:6" file="f0" line="6"/> > </Constructor> > ####################### > > Notice that gccxml sets "explicit=1" for the first Bar constructor, > but not for the second.
I didn't know that, so pygccxml didn't provided access to the information. > However, Py++ sets "allow_implicit_conversion" to True for both > constructors. I think gccxml is doing the right thing here. But I am > not so sure about Py++ behavior. Well, these days I would implement "allow_implicit_conversion" to be a mix of the user desire and "explicit" attribute. But, this change will introduce backward compatibility problem, which I would like to avoid. > I would have assumed that the first > Bar constructor would have "allow_implicit_conversion" set to False. > I was wrong about being able to use "allow_implicit_conversion" for > this task. Is there another way to get at the "explicit" xml tag from > the module_builder object? Or do I need to parse the xml file or > source code separately to discover this information? No. I updated pygccxml package http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1761&view=rev All you need is to write the following code: mb = module_builder_t(...) mb.constructors( lambda c: c.explicit == True ).allow_implicit_conversion = False That's all > Thank you Roman for your diligent feedback. I sincerely appreciate > the quick and thoughtful feedback you provide to everyone on this > mailing list. Wow :-). Thank you for such words! -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig