[C++-sig] Py++: automatic type aliases

Roman Yakovenko roman.yakovenko at gmail.com
Wed Jun 4 19:50:42 CEST 2008


On Wed, Jun 4, 2008 at 4:55 PM, Hans Meine
<meine at informatik.uni-hamburg.de> wrote:
> Hi Roman,
>
> I looked at the py++ source code in order to fix the fact that my classes
> often get the wrong alias.  For instance,
>
> template<class T>
> class Vector2
> {};
>
> typedef Vector2<short> ShortVector2;
>
> class SomeOther
> {
> typedef Vector2<short> Vector; // class-internal typedef!
> };
>
> Since "Vector" is shorter than "ShortVector2", it wins in the "be_smart" mode.
> Also, I am getting W1047 (There are two or more classes that use same
> alias("Base"). ...) because I often typedef complex base classes to "Base" in
> order to refer to Base::foo.  Can py++ be made more "intelligent" by
> discarding scoped typedefs if there are global ones?  (I did not find where
> self.aliases is filled and how to fix this.)

There are few ways to rename class:

1. To use "rename" function:

mb = module_builder_t( ... )
v = mb.class_( Vector< short > )
v.rename( 'Vector' )

2. To define the alias within the source code:

http://language-binding.net/pyplusplus/documentation/how_to/hints.html#pyplusplus-aliases-namespace

HTH

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list