[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-cpp-sig
Subject:    [C++-sig] pyplusplus template instantiation handling improvement
From:       roman.yakovenko () gmail ! com (Roman Yakovenko)
Date:       2006-05-14 9:12:20
Message-ID: 7465b6170605140212wc5fd32dj2661a894c416f7f4 () mail ! gmail ! com
[Download RAW message or body]

Hi. I committed a set of changes, that improves pyplusplus template
instantiation
handling. In order to try them you need SVN version of gccxml + pygccxml +
pyplusplus.

You can find more information about pygccxml and pyplusplus here:
http://www.language-binding.net/

Examples

1. you have some template global function do_smth

template< class X >
struct basic_string{};

template< class Ch >
basic_string<Ch> do_smth(){
   return basic_string<Ch>();
}

inline void inst(){
   do_smth<wchar_t>();
   do_smth<char>();
}

gccxml reports that there are 2 functions with the same name - do_smth and
different return types. Obviously this is wrong. This fact causes pyplusplus to
generate wrong code( code, that could not be compiled ).

Another example is class templates:

namespace demangled{
template< unsigned long i1, unsigned long i2, unsigned long i3>
struct item_t{
   static const unsigned long v1 = i1;
   static const unsigned long v2 = i2;
   static const unsigned long v3 = i3;
};

struct buggy{
   typedef unsigned long ulong;
   typedef item_t< ulong( 0xDEECE66DUL ) | (ulong(0x5) << 32), 0xB,
ulong(1) << 31 >
               my_item_t;
   my_item_t my_item_var;
};
}

gccxml reports my_item_var class name as "item_t<0deece66d,11,080000000>"
Obviously the reported name is wrong.

Now about solution:

Recently I created a patch to gccxml, that adds demangled string to be dump
to generated file. gccxml already dumps mangled string for every declaration.
For example the mangled name of my_item_t class is:
N9demangled6item_tILm3740067437ELm11ELm2147483648EEE
If we demangle the string we will get:

demangled::item_t<3740067437l, 11l, 2147483648l>

As you can see, mangled string contains the correct name of the class.
So, from now pygccxml + pyplusplus takes into account information extracted
from demangled string.

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic