[C++-sig] pygccxml not picking up optional parameters in std::vector constructor

Nindi Singh nindi73 at yahoo.co.uk
Fri Dec 28 19:35:01 CET 2007


Roman,
The output from gccxml -v is :
__________________________________________________
#include wrapper search starts here:
 /usr/share/gccxml-0.7/GCC/4.1
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.1.3
 /usr/include/c++/4.1.3/x86_64-linux-gnu
 /usr/include/c++/4.1.3/backward
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.1.3/include
 /usr/include
End of search list.
__________________________________________________

The header file example.hpp is
_________________________________________________
#ifndef TESTVECTOR
#define TESTVECTOR
#include<vector>
template std::vector<double>;
#endif
________________________________________________

The pygccxml script is 
________________________________________________
import sys
from pygccxml import parser
from pygccxml import declarations
from pygccxml.declarations import templates
from pygccxml.declarations import type_traits 

decls = parser.parse( ['example.hpp'])#, config )
global_ns = declarations.get_global_namespace( decls )

query = declarations.custom_matcher_t (lambda vec : templates.name(vec.name)=='vector')
vectorClass = global_ns.classes(function=query)

def processArgument(arg):
    if type_traits.is_const(arg):
        return 'const '+processArgument(type_traits.remove_const(arg)) + ' '
    if type_traits.is_reference(arg):
        return processArgument(type_traits.remove_reference(arg))  + '&'
    if type_traits.is_pointer(arg):
        return processArgument(type_traits.remove_pointer(arg))   + '*'
    if type_traits.is_fundamental(arg):
        return  str(arg)
    if type_traits.is_class(arg):
                theType = type_traits.remove_declarated(arg)
        return theType.demangled  
    if type_traits.is_class_declaration(arg):
                theType = type_traits.remove_declarated(arg)
        return theType.demangled  

for class_ in vectorClass:
    theConstructors =  class_.constructors()
    for c in theConstructors:
        print '\n\n'
        print 'name         :',c.demangled
        print 'location     :',c.location.file_name
        if len(c.required_args)==0:
          print 'No required args'
        else :
          print 'required args:'
          for a in c.required_args:
            print ' ',processArgument(a.type)
        if len(c.optional_args)==0:
          print 'No optional args'
        else :
          print 'optional args:'
          for a in c.optional_args:
            print ' ',processArgument(a.type)
______________________________________________________________________
INFO Parsing source file "example.hpp" ... 

INFO gccxml cmd: /usr/bin/gccxml  -I"."   "example.hpp" -fxml="/tmp/tmpJvYj92.xml"

name         : std::vector<double, std::allocator<double> >::vector(std::allocator<double> const&)
location     : /usr/include/c++/4.1.3/bits/stl_vector.h
required args:
  const std::allocator<double> &
No optional args

name         : std::vector<double, std::allocator<double> >::vector(unsigned long, double const&, std::allocator<double> const&)
location     : /usr/include/c++/4.1.3/bits/stl_vector.h
required args:
  size_t
  const double &
  const std::allocator<double> &
No optional args

name         : std::vector<double, std::allocator<double> >::vector(std::vector<double, std::allocator<double> > const&)
location     : /usr/include/c++/4.1.3/bits/stl_vector.h
required args:
  const std::vector<double, std::allocator<double> > &
No optional args
The output from this script is 
____________________________________________________

In /usr/include/c++/4.1.3/bits/stl_vector.h

line 202        : vector(const allocator_type& __a = allocator_type())
line 214-215  : vector(size_type __n, const value_type& __value = value_type(),
                     const allocator_type& __a = allocator_type())
line 232        : vector(const vector& __x)

I just cannot figure out why the optional parameters ( allocator ) do not show up as optional







      __________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com




More information about the Cplusplus-sig mailing list