Code Monkey home page Code Monkey logo

pygccxml's Introduction

CastXML

Introduction

CastXML is a C-family abstract syntax tree XML output tool.

This project is maintained by Kitware in support of ITK, the Insight Segmentation and Registration Toolkit.

Manual

See the castxml(1) manual page for instructions to run the tool.

License

CastXML is licensed under the Apache License, Version 2.0. See the LICENSE and NOTICE files for details.

Superbuild

If you are looking for pre-built binaries, or a compact way to build this project, please see CastXMLSuperbuild.

Build

To build CastXML from source, first obtain the prerequisites:

  • A C++ compiler supporting the c++11 standard language level.
  • CMake cross-platform build system generator.
  • LLVM/Clang compiler SDK install tree built using the C++ compiler. This version of CastXML has been tested with LLVM/Clang
    • Git main as of 2024-03-06 (f7d354af57)
    • Release 18.1
    • Release 17.0
    • Release 16.0
    • Release 15.0
    • Release 14.0
    • Release 13.0
    • Release 12.0
    • Release 11.0
    • Release 10.0
    • Release 9.0
    • Release 8.0
    • Release 7.0
    • Release 6.0
    • Release 5.0
    • Release 4.0
    • Release 3.9
    • Release 3.8
    • Release 3.7
    • Release 3.6
  • Optionally, the Sphinx documentation generator to build documentation.

Run CMake on the CastXML source tree to generate a build tree using a C++ compiler compatible with that used to build the LLVM/Clang SDK. CMake options include:

Clang_DIR

Location of the LLVM/Clang SDK. Set to <prefix>/lib/cmake/clang, where <prefix> is the top of the LLVM/Clang SDK install tree. Alternatively, LLVM_DIR may be set to <prefix>/lib/cmake/llvm.

SPHINX_EXECUTABLE

Location of the sphinx-build executable. Required only if building documentation.

SPHINX_HTML

Build documentation in html format.

SPHINX_MAN

Build documentation in man format.

Run the corresponding native build tool (e.g. make) in the CastXML build tree, and optionally build the install target. The castxml command-line tool may be used either from the build tree or the install tree. The install tree is relocatable.

pygccxml's People

Contributors

andeepak01 avatar bettercallbene avatar ericcousineau-tri avatar ethanhs avatar hbr-det avatar hugovk avatar imichka avatar josephsnyder avatar mamoll avatar markoates avatar mgorny avatar praetorian20 avatar royvorster avatar tao558 avatar thewtex avatar vogelsgesang avatar xgdgsc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pygccxml's Issues

Add method to fetch the type of an argument

In ITK we need to fetch the type of an argument. For this, I hacked some code together, but there could be a method for this in pygccxml 1.7.0. Using str() is not really intuitive; and also not documented.

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/SwigInterface/igenerator.py#L698

for arg in method.arguments:
        # arg.type is an instance, there is no clean API in pygccxml to get the
        # name of the type as a string. This functionnality needs to be added
        # to pygccxml. Meanwhile, we can use the __str__() method.
        if arg.type.__str__() == "std::string &":
            applyFileNames.append(arg.name)

Add support for castxml

A basic support for castxml needs to be added. At least all the tests need to pass I guess.
Implementation details and code cleanup can follow later.

Castxml can be used since this commit:
fc18c8d

Now I need to fix all the tests.

  • Missing locations for some fields (gp_offset, fp_offset, overflow_arg_area, reg_save_area)
  • error: '--castxml-gccxml' does not work with c11
  • warning: control reaches end of non-void function [-Wreturn-type]
  • no align and size attributes for some xml tags <FundamentalType>, <Class>, <Union>, <Struct> ... (fixed by CastXML/CastXML@45d5a24)
  • no offset attributes for <Field> tags (fixed by CastXML/CastXML@57c93df)
  • namespace joining fails (fixed by CastXML/CastXML@d687d1d)
  • no mangled and demangled attributes for <Namespace> tag
  • warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
  • name attributes cluttered with std::__1 : this causes a lot of tests to fail. I need to clean this up while parsing the xml files.
  • test_calldef_free_functions: AssertionError: function 'no_return_no_args' should have extern qualifier
  • throw attribute is called throws with castxml (Fixed by CastXML/CastXML@2393116)
  • error: unsupported option '--castxml-start=E11,ns::ns12::E13' in test_simple
  • AssertionError: the compound type('int ( ::core::types::members_pointers_t::* )') should be 'pointer_t' in core test
  • KeyError: 'file' when parsing cached file
  • the config has a gccxml_path argument. Needs to be changed to caster_path. Keep the old one for retrocompatibility.
  • Problem with default argument type: #19 (comment)
  • templated code is not dumped to the xml file (CastXML/CastXML#20)
  • 4 errors in remove_template_defaults_tester.py, the new maps and sets need to be recognised
  • clang finds trivial default constructors (type_traits_tester.py). This was not possible before (http://www.boost.org/doc/libs/1_58_0/libs/type_traits/doc/html/boost_typetraits/reference/has_trivial_constructor.html)
  • ERROR Unable to find out actual class definition: 'rebindstd::__tree_node<std::basic_string<char, void *> >'. in find_container_traits_tester.py

fatal error in producing log messages

I get this error with pygccxml 1.6.0:

  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/declarations/class_declaration.py", line 603, in find_noncopyable_vars
    message +
UnboundLocalError: local variable 'message' referenced before assignment

I am not sure what message should be initialized to in line 603 of declarations/class_declaration.py.

There also non-fatal errors in the logger.debug(...) calls in lines 589-597. These can be fixed by putting parentheses around message + " - array" (analogous for the other cases) to force self.decl_string to match %s in message.

RTFD badge broken by 0974027

New readthedocs.io URLs were used in 0974027. The new url seem to give a text/html (https://readthedocs.org/?version=master, actually) in its final destination and fails the image. Likewise, the https://readthedocs.io/projects/pygccxml/?badge=master link only takes you to https://readthedocs.org/?badge=master. Since the badges are not part of the pygccxml project-subdomain, it's almost certain that it's a mistake to change the badge URLs too.

Regarding project-subdomains, personally I don't think it's a good idea to change as long as https://readthedocs.org/projects/pygccxml/ is giving the .org site instead of the .io site...

Use new style decorators (@property)

In many classes, the getters and setters are defined using the property() function.

I made a test on two classes, rewriting the code with new style decorators. This is working well, reduces slightly the code size and increases readability. See: e53d868

The same changes should be applied on all the other property() calls.

Wrong decl_type for function pointers ?

When the argument is a function pointer, there seems to be a few problems:

For instance for the function int atexit(void (*function)(void));, the pygccxml code decl.arguments[0].decl_type returns: void (*)( ) * which has 1 more asterisk then necessary ?

Nb: I made a mistake and ended up posting it first here
CastXML/CastXML#67

Remove INFO gccxml message

When running pygccxml, there is an annoying info message which is displayed:
INFO GCCXML version - 0.9( 1.135 )

This message should be only displayed when working in debug/verbose mode.

Python bindings and pygccxml missing in Centos 6.4

I trying to install ns3 on centos 6.4 since I have to work with a specific os and kernel versions for atheros wlan device feauture I need. I followed the instructions to install all pre-requisite for ns3 and proceeded to ns3 installation and it seems fine. Also I installed Python binding. However, I couldn't run .py tests and codes. When I run ./waf --apiscan=all I received that "(py)gccxml" is missing and rescan APIs message. Also I received "python bindgen missing" when I run ./waf configure.
I installed pygccxml successfully from source and could locate it using "locate" and "find" commands.
Am I missing something that could help the system to see the bindings. I hope you have a solution for this problem.

Loop over declarations inside a template

Is there a way to loop over the types defined inside a template? I'm currently testing the library with the following code:

namespace A {
struct B {
  struct D { bool d; };
};
struct D {};

template <typename T1, typename T2>
struct T {
  struct E { int e; };
};

T<B::D, bool> fun();
}

Starting with namespace A, I'm able to go to the template declaration but then I'm stuck.

>>> decls = pgx.parser.parse_string(cppsource, pgx_config)
>>> globalNamespace = pgx.declarations.get_global_namespace(decls)
>>> aNamespace = globalNamespace.namespace("A")

>>> x = aNamespace.declarations[2]
>>> x.decl_string
'::A::T<A::B::D, bool>'
>>> x.declarations
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'class_declaration_t' object has no attribute 'declarations'

Is there somewhere a link from class_declaration_t to the scope so that I can recurse into the template?

Add unit test for example.py

The example.py in the documentation should have a unit test which runs it, just to be sure it works on python 2/3 and runs correctly.

pygccxml fails in enum/typedef hash function

` File "./../pygccxml/declarations/enumeration.py", line 51, in hash
return super(enumeration_t, self).hash(self)
TypeError: hash() takes exactly 1 argument (2 given)

def __hash__(self):
    return super(enumeration_t, self).__hash__()
   -->  #return super(enumeration_t, self).__hash__(self)

def __hash__(self):
    return super(typedef_t, self).__hash__()
    --> #return super(typedef_t, self).__hash__(self)

`
hash.zip

Creating reference (or reference-to-const) from a class_t

I'm not sure how to accomplish the following: I have a class_t and would like to create a reference to this class. Finally I would like to get the full name. For example, my global namespace has an Object and I would like to create a Object& or even const Object&.

Here is what I have tried:

>>> c = globalNamespace.class_("Object")
>>> c
<pygccxml.declarations.class_declaration.class_t object at 0x7f7ecd655850>
>>> print(c)
Object [class]
>>> r = reference_t(c)
>>> print(r)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 24, in __str__
    res = self.decl_string
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 51, in decl_string
    self.cache.decl_string = self.build_decl_string()
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 596, in build_decl_string
    return self.base.build_decl_string(with_defaults) + ' &'
AttributeError: 'class_t' object has no attribute 'build_decl_string'

pygccxml.parser.source_reader.gccxml_runtime_error_t: Error occured while running GCC-XML:

Hi, I am trying to make a python-bindings of a motion planning library.
The fllowing error appears:

INFO Parsing source file "bindings/util.h" ...
INFO gccxml cmd: /usr/local/bin/gccxml -I"." -I"/home/sherry/Workspace/batch-infromed-trees/ompl/src" -I"/home/sherry/Workspace/batch-infromed-trees/src" -I"/usr/include/python2.7" -I"/usr/include" -I"/usr/include/assimp" -I"/usr/local/include/eigen3" "bindings/util.h" -fxml="/tmp/tmpMlywrt.xml"
In file included from /usr/local/include/eigen3/Eigen/Core:265,
from bindings/util.h:120:
/usr/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h: In function 'Packet Eigen::internal::pset1(const typename Eigen::internal::unpacket_traits::type&) [with Packet = Eigen::internal::Packet2cf]':
/usr/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h:95: error: #pragma GCC diagnostic not allowed inside functions
/usr/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h:96: error: #pragma GCC diagnostic not allowed inside functions
/usr/local/include/eigen3/Eigen/src/Core/arch/SSE/Complex.h:98: error: #pragma GCC diagnostic not allowed inside functions
Traceback (most recent call last):
File "/home/sherry/Workspace/batch-infromed-trees/ompl/py-bindings/generate_bindings.py", line 735, in
globals()'ompl_'+module+'_generator_t'
File "/home/sherry/Workspace/batch-infromed-trees/ompl/py-bindings/generate_bindings.py", line 671, in init
code_generator_t.init(self, 'util', None, replacement, 1)
File "/home/sherry/Workspace/batch-infromed-trees/ompl/py-bindings/ompl/bindings_generator.py", line 148, in init
indexing_suite_version = indexing_suite_version )
File "/usr/local/lib/python2.7/dist-packages/pyplusplus/module_builder/boost_python_builder.py", line 95, in init
, indexing_suite_version)
File "/usr/local/lib/python2.7/dist-packages/pyplusplus/module_builder/boost_python_builder.py", line 138, in __parse_declarations
decls = reader.read_files( files, compilation_mode )
File "build/bdist.linux-x86_64/egg/pygccxml/parser/project_reader.py", line 250, in read_files
File "build/bdist.linux-x86_64/egg/pygccxml/parser/project_reader.py", line 279, in __parse_file_by_file
File "build/bdist.linux-x86_64/egg/pygccxml/parser/source_reader.py", line 226, in read_file
File "build/bdist.linux-x86_64/egg/pygccxml/parser/source_reader.py", line 260, in read_gccxml_file
pygccxml.parser.source_reader.gccxml_runtime_error_t: Error occured while running GCC-XML:

Please tell me the cause of error. Is the version of gcc or the version of gccxml ? Or the version of system?
(64bit Ubuntu 14.04, gcc 4.8.2 , gccxml and pygccxml are the latest version)
I try to change the version of gcc, like 4.6.3, 4.6.4, 4.7 and 4.9. But, it still doesn't work.
ps: The only successful attempt is on 32bit Ubuntu 12.04 ,and the gcc version is 4.6.3.
Please tell me how can I solve it on Ubuntu 14.04.
Regards!

KeyError 'file' when using pyplusplus

Hi I tried to use py++ to automatic wrap c++ files.
Using gccxml and pygccxml is ok, now I changed to use castxml, and I face below, seems in
def __read_location(self, decl, attrs):
'file' is not in attrs.

{'name': '', 'access': 'public', 'context': '_590', 'offset': '0', 'type': '_3541', 'id': '_1405'}
Traceback (most recent call last):
File "chg.py", line 8, in
,xml_generator_path='/usr/local/bin/castxml')
File "/usr/local/lib/python2.7/dist-packages/pyplusplus/module_builder/boost_python_builder.py", line 104, in init
, indexing_suite_version)
File "/usr/local/lib/python2.7/dist-packages/pyplusplus/module_builder/boost_python_builder.py", line 147, in __parse_declarations
decls = reader.read_files( files, compilation_mode )
File "build/bdist.linux-x86_64/egg/pygccxml/parser/project_reader.py", line 249, in read_files
File "build/bdist.linux-x86_64/egg/pygccxml/parser/project_reader.py", line 278, in __parse_file_by_file
File "build/bdist.linux-x86_64/egg/pygccxml/parser/source_reader.py", line 334, in read_file
File "build/bdist.linux-x86_64/egg/pygccxml/parser/source_reader.py", line 354, in read_cpp_source_file
File "build/bdist.linux-x86_64/egg/pygccxml/parser/source_reader.py", line 443, in __parse_xml_file
File "build/bdist.linux-x86_64/egg/pygccxml/parser/etree_scanner.py", line 56, in read
File "build/bdist.linux-x86_64/egg/pygccxml/parser/scanner.py", line 221, in startElement
File "build/bdist.linux-x86_64/egg/pygccxml/parser/scanner.py", line 274, in __read_location
KeyError: 'file'

I printed attrs
{'context': '_586', 'artificial': '1', 'access': 'public', 'location': 'f28:20', 'file': 'f28', 'inline': '1', 'line': '20', 'id': '_1403', 'name': 'Chg'}
{'file': 'f28', 'name': '=', 'mangled': 'ZN3ChgaSERKS', 'artificial': '1', 'access': 'public', 'returns': '_3982', 'location': 'f28:20', 'context': '_586', 'inline': '1', 'line': '20', 'id': '_1404'}
{'name': '', 'access': 'public', 'context': '_590', 'offset': '0', 'type': '_3541', 'id': '_1405'}
Traceback (most recent call last):
File "chg.py", line 8, in
,xml_generator_path='/usr/local/bin/castxml')

Here 'name' is empty and no 'file',
for a workaround, I modified this py file

    #print attrs
    #if "name" in attrs and attrs["name"] in to_skip:
    if "name" in attrs and attrs["name"] in to_skip or "file" not in attrs:

After that for my simple c++ code, I can wrap correctly just as using gccxml.

Setup travis builds for castxml epic version 1

Due to the introduction of the new xml format version in castxml, which can be enabled by using the --castxml-output=1 flag, the buildbots need to be upgraded.

For this we need:

  • New castxml binaries for OS X, Linux and Windows.
  • Make all the castxml tests run twice on travis and appveyor: once with and without the new flag. The builds will run twice as long, but this is still acceptable (around 5 to 6 min).

Add unit test for sphinx documentation

We need to add an unit test building the sphinx documentation and failing if there are errors/warnings. This will ensure the documentation always builds correctly.

CastXML is default even when only GCC-XML is present

On a system with GCC-XML but not CastXML, this fails:

pygccxml.parser.parse(files)
gccxml_cc1plus: error: unrecognized command line option "-x"
gccxml_cc1plus: error: unrecognized command line option "--castxml-cc-gnu"
gccxml_cc1plus: error: unrecognized command line option "--castxml-gccxml"
gccxml_cc1plus: error: c++: No such file or directory

But by doing a little dance with pygccxml.utils (which is labelled 'internal' in the docs), this succeeds:

xml_generator_path, xml_generator = pygccxml.utils.find_xml_generator()
config = pygccxml.parser.xml_generator_configuration_t(xml_generator=xml_generator)
pygccxml.parser.parse(files, config=config)

So pygccxml finds the right configuration, it just doesn't sensibly default to it.

This is a regression in 1.8; it does not occur in 1.7.6.

Failing tests with castxml + gcc5 (container traits)

There are a bunch of errors with container traits under Wily (Ubuntu 5.2.1-22ubuntu2).

ERROR: test_hash_map (remove_template_defaults_tester.tester_t)

Traceback (most recent call last):
File "/home/popoff/repo/pygccxml/unittests/remove_template_defaults_tester.py", line 166, in test_hash_map
(name + '< int, double >') == hm_traits.remove_defaults(hm_i2d))
File "../pygccxml/pygccxml/declarations/container_traits.py", line 530, in remove_defaults
name = self.class_declaration(type_or_string).name
File "../pygccxml/pygccxml/declarations/container_traits.py", line 457, in class_declaration
(type_.decl_string, self.name()))
TypeError: Type "::rtd::hash_maps::hm_i2d" is not instantiation of std::unordered_map

ERROR: test_hash_multimap (remove_template_defaults_tester.tester_t)

Traceback (most recent call last):
File "/home/popoff/repo/pygccxml/unittests/remove_template_defaults_tester.py", line 182, in test_hash_multimap
hmm_traits.remove_defaults(hmm_i2d))
File "../pygccxml/pygccxml/declarations/container_traits.py", line 530, in remove_defaults
name = self.class_declaration(type_or_string).name
File "../pygccxml/pygccxml/declarations/container_traits.py", line 457, in class_declaration
(type_.decl_string, self.name()))
TypeError: Type "::rtd::hash_multimaps::hmm_i2d" is not instantiation of std::unordered_multimap

ERROR: test_hash_multiset (remove_template_defaults_tester.tester_t)

Traceback (most recent call last):
File "/home/popoff/repo/pygccxml/unittests/remove_template_defaults_tester.py", line 151, in test_hash_multiset
mhs_traits.remove_defaults(mhs_v_int))
File "../pygccxml/pygccxml/declarations/container_traits.py", line 530, in remove_defaults
name = self.class_declaration(type_or_string).name
File "../pygccxml/pygccxml/declarations/container_traits.py", line 457, in class_declaration
(type_.decl_string, self.name()))
TypeError: Type "::rtd::hash_multisets::mhs_v_int" is not instantiation of std::unordered_multiset

ERROR: test_hash_set (remove_template_defaults_tester.tester_t)

Traceback (most recent call last):
File "/home/popoff/repo/pygccxml/unittests/remove_template_defaults_tester.py", line 135, in test_hash_set
hs_traits.remove_defaults(hs_v_int),
File "../pygccxml/pygccxml/declarations/container_traits.py", line 530, in remove_defaults
name = self.class_declaration(type_or_string).name
File "../pygccxml/pygccxml/declarations/container_traits.py", line 457, in class_declaration
(type_.decl_string, self.name()))
TypeError: Type "::rtd::hash_sets::hs_v_int" is not instantiation of std::unordered_set

FAIL: test_find_traits (find_container_traits_tester.tester_t)

Traceback (most recent call last):
File "/home/popoff/repo/pygccxml/unittests/find_container_traits_tester.py", line 99, in test_find_traits
"unordered_set< std::vector< int > >")
File "/home/popoff/repo/pygccxml/unittests/find_container_traits_tester.py", line 39, in __cmp_traits
traits.name()))
AssertionError: container "rtd::hash_sets::hs_v_int [typedef]", expected unordered_set_traits, got hash_set_traits

removing static members in pygccxml.declaration.* broke pyplusplus

Applying the current commits leads to more problems regarding pyplusplus bubbling up .., e.g.,

File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/module_builder/boost_python_builder.py", line 373, in split_module
, encoding=self.encoding)
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/file_writers/init.py", line 37, in write_multiple_files
mfs.write()
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/file_writers/multiple_files.py", line 396, in write
self.split_classes()
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/file_writers/multiple_files.py", line 300, in split_classes
for cls in class_creators: self.split_class(cls)
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/file_writers/multiple_files.py", line 288, in split_class
self.split_class_impl( class_creator )
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/file_writers/multiple_files.py", line 265, in split_class_impl
cpp_code = self.create_source( class_creator.alias, function_name, [class_creator] )
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/file_writers/multiple_files.py", line 250, in create_source
answer.append( code_creators.code_creator_t.indent( creator.create() ) )
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/code_creator.py", line 107, in create
code = self._create_impl()
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/class_declaration.py", line 321, in _create_impl
return self._generate_code_with_scope()
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/class_declaration.py", line 302, in _generate_code_with_scope
result.append( '%s.%s;' % ( self.class_var_name, x.create() ) )
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/code_creator.py", line 107, in create
code = self._create_impl()
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/member_variable.py", line 161, in _create_impl
return self._generate_for_pointer()
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/member_variable.py", line 72, in _generate_for_pointer
, 'getter_type' : self.wrapper.getter_type
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/code_creators/member_variable.py", line 227, in _get_getter_type
, with_defaults=False)
TypeError: create_decl_string() missing 1 required positional argument: 'self'

The corresponding part in pyplusplus reads:

return declarations.free_function_type_t.create_decl_string(
return_type=self.declaration.type
, arguments_types=arguments_types
, with_defaults=False)

which needs pygccxml/declarations.cpptyps.free_function_type_t.create_decl_string(...)
to be a static memberfunction, which seems to me a valid requisite in this context.

Bests and thanks for your afford.

Issue about getting gccxml to work

I've compiled gccxml using VC++ 10 version on Windows 8. I have both pygccxml and gccxml latest versions installed on my system. There is no problem when using gccxml standalone from commandline but if I try to run it through pygccxml API, I always get the error: "gccxml_runtime_error_t: Error occured while running GCC-XML."

I am not able to resolve this problem by myself.
Helps would be really appreciated.

download_url in setup.py should point to github tag snapshot instead

The current download_url is hardcoded to https://github.com/gccxml/pygccxml/archive/master.zip, and it causes confusion in the PyPI page for older versions. It's better to make use of GitHub tag snapshots like:

version="v1.7.3"
setup(...,
      version=version,
      download_url="https://github.com/gccxml/pygccxml/archive/{0}.tar.gz".format(version),
      ...)

You can also use ZIPs like what you have done currently, but ZIPs almost mean losing a couple of attributes. (I don't know if GitHub uses Info-ZIP extensions -- if they do so, then there's no such problem. But tar-gz archives provide solid, whole-archive compression.)

Use sphinx autodoc for API

We need to setup sphinx autodoc for the API documentation. This is far easier to maintain than using manually created .rst files for each package.

Fix warning in core_class_hierarchy.hpp with clang / xcode7.2

The Travis bots reports a warning (xcode7.2 travis image) in core_class_hierarchy.hpp that needs to be fixed.

/Users/travis/build/gccxml/pygccxml/unittests/data/core_class_hierarchy.hpp:30:44: warning: direct base 'core::class_hierarchy::base_t' is inaccessible due to ambiguity:
class core::class_hierarchy::multi_derived_t -> class core::class_hierarchy::derived_private_t -> class core::class_hierarchy::base_t
class core::class_hierarchy::multi_derived_t -> class core::class_hierarchy::base_t [-Winaccessible-base]
class multi_derived_t : derived_private_t, protected base_t, private other_base_t{
^~~~~~~~~~~~~~~~
1 warning generated.

static variables incorrectly read

in pygccxml/pygccxml/parser/scanner.py: 559, should

type_qualifiers.has_static = attrs.get(XML_AN_EXTERN, False)

be

type_qualifiers.has_static = attrs.get(XML_AN_STATIC, False)

?

declarations/pattern_parser.py:109 Assertion fail

When using pyplusplus, I face this problem when finally write result, and if comment out , I can get wrapper code generated.

def split(self, decl_string):
    """implementation details"""
    #assert self.has_pattern(decl_string)
    return self.name(decl_string), self.args(decl_string)

Running the Unit Tests

Trying to tun the unit tests from the pygccxm source unitests dir, used to able to do so, now with python2/python3.

python decl_string_tester.py
Traceback (most recent call last):
File "decl_string_tester.py", line 9, in
from . import autoconfig
ValueError: Attempted relative import in non-package

Type name inconsistencies

I'm right now playing around with templates and noticed a few inconsistencies in the naming. For example:

>>> type(x)
<class 'pygccxml.declarations.class_declaration.class_declaration_t'>
>>> x.decl_string
'::A::T<A::B::D, bool>'
>>> x.partial_decl_string
'::A::T< A::B::D, bool >'

So the partial_decl_string has spaces after < and before > where the decl_string does not.

Even more severe for me is that the decl string for all types returns a fully qualified name starting
with :: but the template arguments do not. In the example above, I wished that the first template argument would be rendered as ::A::B::D and not only A::B::D.

Is it possible to harmonize the output?

pygccxml error

Hello,
i was trying to scan python API that time i got these type of error
so anyone help me to solve this error?

ubuntu@mn:~/ns-allinone-3.18.2/ns-3.18.1$ sudo ./waf --apiscan=netanim
sudo: unable to resolve host mn
Waf: Entering directory /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build' Modules to scan: ['netanim'] api-scan-gcc_ILP32 INFO Parsing source file "/home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h" ... INFO gccxml cmd: /usr/bin/gccxml --gccxml-cxxflags "-m32 -DPYTHON_SCAN" -I"." -I"/home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build" "/home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h" -fxml="/tmp/tmp01L_WN.xml" Traceback (most recent call last): File "/home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/bindings/python/ns3modulescan-modular.py", line 280, in <module> ns3_module_scan(sys.argv[1], sys.argv[2], eval(sys.argv[3]), sys.argv[4], sys.argv[5]) File "/home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/bindings/python/ns3modulescan-modular.py", line 260, in ns3_module_scan gccxml_options=gccxml_options) File "/home/ubuntu/ns-allinone-3.18.2/pybindgen-0.16.0.834/pybindgen/gccxmlparser.py", line 683, in parse_init self.declarations = parser.parse(header_files, self.gccxml_config) File "/usr/lib/pymodules/python2.7/pygccxml/parser/__init__.py", line 50, in parse answer = parser.read_files(files, compilation_mode) File "/usr/lib/pymodules/python2.7/pygccxml/parser/project_reader.py", line 225, in read_files return self.__parse_file_by_file(files) File "/usr/lib/pymodules/python2.7/pygccxml/parser/project_reader.py", line 250, in __parse_file_by_file decls = reader.read_file( header ) File "/usr/lib/pymodules/python2.7/pygccxml/parser/source_reader.py", line 197, in read_file return self.read_gccxml_file( source_file ) File "/usr/lib/pymodules/python2.7/pygccxml/parser/source_reader.py", line 224, in read_gccxml_file raise error pygccxml.parser.source_reader.gccxml_runtime_error_t: Error occured while running GCC-XML: gccxml_cc1plus: error: gccxml_builtins.h: No such file or directory In file included from /usr/include/c++/4.8/vector:60, from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:24, from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24, from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10: /usr/include/c++/4.8/bits/stl_algobase.h: In function '_OI std::__copy_move_a(_II, _II, _OI)': /usr/include/c++/4.8/bits/stl_algobase.h:384: error: expected primary-expression before ')' token /usr/include/c++/4.8/bits/stl_algobase.h:384: error: there are no arguments to '__is_trivial' that depend on a template parameter, so a declaration of '__is_trivial' must be available /usr/include/c++/4.8/bits/stl_algobase.h:384: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) /usr/include/c++/4.8/bits/stl_algobase.h:389: error: '__simple' cannot appear in a constant-expression /usr/include/c++/4.8/bits/stl_algobase.h:390: error: template argument 2 is invalid /usr/include/c++/4.8/bits/stl_algobase.h: In function '_BI2 std::__copy_move_backward_a(_BI1, _BI1, _BI2)': /usr/include/c++/4.8/bits/stl_algobase.h:579: error: expected primary-expression before ')' token /usr/include/c++/4.8/bits/stl_algobase.h:579: error: there are no arguments to '__is_trivial' that depend on a template parameter, so a declaration of '__is_trivial' must be available /usr/include/c++/4.8/bits/stl_algobase.h:584: error: '__simple' cannot appear in a constant-expression /usr/include/c++/4.8/bits/stl_algobase.h:585: error: template argument 2 is invalid /usr/include/c++/4.8/bits/stl_algobase.h: In function 'typename __gnu_cxx::__enable_if<(! std::__is_scalar<_Tp>::__value), _OutputIterator>::__type std::__fill_n_a(_OutputIterator, _Size, const _Tp&)': /usr/include/c++/4.8/bits/stl_algobase.h:737: error: expected;' before '__niter'
/usr/include/c++/4.8/bits/stl_algobase.h:738: error: '__niter' was not declared in this scope
/usr/include/c++/4.8/bits/stl_algobase.h: In function 'typename __gnu_cxx::__enable_ifstd::__is_scalar<_Tp::__value, _OutputIterator>::__type std::__fill_n_a(_OutputIterator, _Size, const _Tp&)':
/usr/include/c++/4.8/bits/stl_algobase.h:749: error: expected `;' before '__niter'
/usr/include/c++/4.8/bits/stl_algobase.h:750: error: '__niter' was not declared in this scope
In file included from /usr/include/c++/4.8/vector:61,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10:
/usr/include/c++/4.8/bits/allocator.h: At global scope:
/usr/include/c++/4.8/bits/allocator.h:159: error: expected primary-expression before ')' token
/usr/include/c++/4.8/bits/allocator.h:159: error: there are no arguments to '__is_empty' that depend on a template parameter, so a declaration of '__is_empty' must be available
/usr/include/c++/4.8/bits/allocator.h:176: error: expected primary-expression before ')' token
/usr/include/c++/4.8/bits/allocator.h:176: error: there are no arguments to '__is_empty' that depend on a template parameter, so a declaration of '__is_empty' must be available
In file included from /usr/include/c++/4.8/bits/stl_construct.h:61,
from /usr/include/c++/4.8/vector:62,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10:
/usr/include/c++/4.8/ext/alloc_traits.h: In static member function 'static void __gnu_cxx::__alloc_traits<_Alloc>::_S_on_swap(_Alloc&, _Alloc&)':
/usr/include/c++/4.8/ext/alloc_traits.h:230: error: there are no arguments to '__is_empty' that depend on a template parameter, so a declaration of '__is_empty' must be available
/usr/include/c++/4.8/ext/alloc_traits.h:230: error: '__is_empty' was not declared in this scope
/usr/include/c++/4.8/ext/alloc_traits.h:230: error: template argument 2 is invalid
/usr/include/c++/4.8/ext/alloc_traits.h:230: error: invalid type in declaration before '(' token
In file included from /usr/include/c++/4.8/vector:62,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10:
/usr/include/c++/4.8/bits/stl_construct.h: In function 'void std::_Destroy(_ForwardIterator, _ForwardIterator)':
/usr/include/c++/4.8/bits/stl_construct.h:126: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.8/bits/stl_construct.h:126: error: template argument 1 is invalid
/usr/include/c++/4.8/bits/stl_construct.h:127: error: invalid type in declaration before '(' token
/usr/include/c++/4.8/bits/stl_construct.h:127: error: invalid use of qualified-name '::__destroy'
In file included from /usr/include/c++/4.8/vector:63,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10:
/usr/include/c++/4.8/bits/stl_uninitialized.h: In function '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator)':
/usr/include/c++/4.8/bits/stl_uninitialized.h:115: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.8/bits/stl_uninitialized.h:116: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.8/bits/stl_uninitialized.h:116: error: template argument 1 is invalid
/usr/include/c++/4.8/bits/stl_uninitialized.h: In function 'void std::uninitialized_fill(_ForwardIterator, _ForwardIterator, const _Tp&)':
/usr/include/c++/4.8/bits/stl_uninitialized.h:170: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.8/bits/stl_uninitialized.h:170: error: template argument 1 is invalid
/usr/include/c++/4.8/bits/stl_uninitialized.h:171: error: invalid type in declaration before '(' token
/usr/include/c++/4.8/bits/stl_uninitialized.h:171: error: invalid use of qualified-name '::__uninit_fill'
/usr/include/c++/4.8/bits/stl_uninitialized.h: In function 'void std::uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&)':
/usr/include/c++/4.8/bits/stl_uninitialized.h:223: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.8/bits/stl_uninitialized.h:223: error: template argument 1 is invalid
/usr/include/c++/4.8/bits/stl_uninitialized.h:224: error: invalid type in declaration before '(' token
/usr/include/c++/4.8/bits/stl_uninitialized.h:224: error: invalid use of qualified-name '::__uninit_fill_n'
In file included from /usr/include/c++/4.8/vector:65,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10:
/usr/include/c++/4.8/bits/stl_bvector.h: In member function 'void std::vector<bool, _Alloc>::swap(std::vector<bool, _Alloc>&)':
/usr/include/c++/4.8/bits/stl_bvector.h:844: error: there are no arguments to '__is_empty' that depend on a template parameter, so a declaration of '__is_empty' must be available
/usr/include/c++/4.8/bits/stl_bvector.h:844: error: '__is_empty' was not declared in this scope
/usr/include/c++/4.8/bits/stl_bvector.h:844: error: template argument 2 is invalid
/usr/include/c++/4.8/bits/stl_bvector.h:845: error: invalid type in declaration before '(' token
In file included from /usr/include/c++/4.8/string:40,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/object.h:25,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/node.h:26,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/animation-interface-helper.h:24,
from /home/ubuntu/ns-allinone-3.18.2/ns-3.18.1/build/ns3/netanim-module.h:10:
/usr/include/c++/4.8/bits/char_traits.h: In static member function 'static const char* std::char_traits::find(const char*, std::size_t, const char&)':

Explicit and Implicit Class Declarations

Hello,

Is there any way to differentiate implicit and explicit constructors, assignment operators and destructors in a c++ class using pygccxml? For example, pygccxml(or gccxml) treats implicit or explicit constructors, destructors or assignment operators as if they are all the same. Even though a class declaration doesn't have any explicit declaration of a constructor(constructor is not explicitly declared either inside public or private field), pygccxml stores those implicit constructors, destructors in its declaration tree, and as far as I know, there is no way to differentiate those that are explicit and those that are not.

Any suggestions would be appreciated.

Windows & castxml, compiler not found

I just started with the following very basic example:

from pygccxml import utils, parser, declarations

generator_path, generator_name = utils.find_xml_generator()
path= parser.config.create_compiler_path(generator_name,generator_path)

xml_generator_config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name)

filename = "C:\\Qt\\Qt5.6.0\\5.6\\msvc2015\\include\\QtCore\\qobject.h"


decls = parser.parse([filename], xml_generator_config)

And it fails saying that compiler_path is not defined, when it checks if I am using mingw or not (I'm not).

# Platform specific options
        if platform.system() == 'Windows':

            if "mingw" in self.__config.compiler_path.lower(): # HERE self.__config.compiler_path is None, so .lower() doesn't work
                # Look at the compiler path. This is a bad way
                # to find out if we are using mingw; but it
                # should probably work in most of the cases
                cmd.append('--castxml-cc-gnu ' + self.__config.compiler_path)
            else:
                # We are using msvc
                cmd.append('--castxml-cc-msvc cl')
                if 'msvc9' == self.__config.compiler:
                    cmd.append('-D"_HAS_TR1=0"')
        else:
                #more code

In the docs, it says that creating a compiler path is only needed on Mac and Linux. Are the docs in error, or is this an issue with the code finding my Visual Studio compiler?

I am on Windows 10, Python 3.5, VS 14

Experiences setting up pygccxml on OSX

I wanted to drop a log on my experiences for building pygccxml for the first time. It wasn't completely seamless but I managed to overcome a few snags and I'm hoping it might help future development of this really awesome library.

Initially, compiling, installing, and configuring the dependencies was a bit daunting, particularly considering that it takes about 45 minutes to compile Clang and I was still uncertain if I had installed or configured all the correct components. Despite poking around in that, I came across https://github.com/thewtex/CastXMLSuperbuild which I would recommend to anybody installing pygccxml for the first time. I think a link should be included in the main pygccxml README.md.

Despite having both GCC-XML and CastXML on my system, I found that pygccxml defaulted to using gccxml when calling utils.find_xml_generator() in the examples. I think castxml should be used by default. This lead to a bit of confusion, and I think it should be documented somewhere that strings name='gccxml' and name='castxml' are options for names. Maybe a nice message upon invocation using the 'gccxml' backend or something similar would also be nice.

Also, I had to manually set utils.find_xml_generator(name='castxml') in order to get proper usage of parser.xml_generator_configuration_t(compiler='gcc' ...). Without having more insight, it seemed that with the GCC-XML pygccxml could not operate using a g++ compiler, and only seemed to work with pure C gcc code. pygccxml would throw errors when I would simply add #include <string> at the top of an example program and it took a bit of investigation.

After trying to manually use CastXML from the command line, was I able to clue in that the issue was closer to pygccxml implementation designation of castxml and gccxml. (It's also very likely that my compiler configurations are a bit mangled as well, as c++ and g++ are aliases Clang on OSX). I also had to add the location of the executable for castxml to my PATH, and that step was not included or documented in the CastXMLSuperbuild process.

Also, the parser.xml_generator_configuration_t argument include_paths is an array even though it is documented as a string delimited by ;.

I felt like the documentation needed just one more tutorial that included and example with a compiler definition, include directories, and cflags.

Anyway, thank you guys for making this library. I hope my experience helps in some way.

ostream recursive loop in find_noncopyable_vars

Hi,
I found the problem I had with the recursive loop in find_noncopyable_vars. It appears to happen for a class with a stream variable(std::istream*) and when base classes are known for ostream in class_declaration.hierarchy_info_t in is_noncopyable().

I think ::std::basic_ostream processes it base class std::basic_ios which holds a pointer to ostream and so on.

Stream.zip

Add CastXML Travis build

To prepare for the migration to CastXML as being the default xml parser, we need a Travis build running CastXML.

Once solution would be to installed castxml like I did with gccxml, but the debian package is currently only available in Ubuntu Wily.

Castxml is now available in homebrew, so that seems to be fastest solution. The https://github.com/gccxml/pygccxml/tree/TravisCastXML branch is already up and running; but castxml currently crashes. Once this is cleared we should have a build to start with.

I could also download and use the precompiled castxml we are using in ITK (either on Mac or Linux). Let's see what works out best.

Performance problems with CastXML and py++

The main effort was to make pygccxml and py++ work with CastXML. Now that this is done, one problem remains to be solved: performance. @mamoll reported that using py++ is now much slower than before.

When comparing the xml files (between gccxml and castxml), one thing which seems very different is for example the std namespace. All the internals are now exposed with CastXML. With gccxml std contained around 260 elements. With castxml it has more than 20000 … This is probably making pygccxml slow when parsing for declarations.

This will need to be benchmarked and tested. Probably we can just skip some of these declarations or re-order the dictionaries / lists to make the algorithm faster. I plan to do this for the 1.8.0 release.

calldef_matcher matches on structure too

I am looking for the declaration of the "sigaction" function defined in <signal.h> with the following code. Problem is pygccxml returns the declaration of the "struct sigaction".

I've reduced my code to an autonomeous example:

#!/usr/bin/env python3
# Example taken out of http://pygccxml.readthedocs.io/en/develop/examples/searching1/example.html
from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser
from pygccxml.declarations import declaration_utils
import os
import argparse
import csv
import subprocess
import logging
import sys


"""
Must be able to generate:
    - 

todo do same for dl/pthread/rt
"""

log = logging.getLogger("dce")
# log.setLevel(logging.DEBUG)
log.addHandler(logging.StreamHandler())

class Generator:
    def __init__(self):
        pass

    def parse(self, filename):
        """
        cache parsing
        """
        utils.loggers.set_level(logging.DEBUG)

        # Find the location of the xml generator (castxml or gccxml)
        generator_path, generator_name = utils.find_xml_generator()

        # Configure the xml generator
        xml_generator_config = parser.xml_generator_configuration_t(
            xml_generator_path=generator_path,
            xml_generator=generator_name,
            cflags=" -nostdinc -I/usr/include",

            # asked on tracker to generate va_list but not ok
            # flags= ["f1"]
            )
        # config.flags = 
        # The c++ file we want to parse
        # printf is declared in stdio.h
        # filename = "/home/teto/glibc/libio/stdio.h"
        filename = "test.h"
        code = """
#include <signal.h>
        """

        self.project_reader = parser.project_reader_t(xml_generator_config)
        self.decls = self.project_reader.read_string(code)


    def generate_wrappers(self, input_filename, out_filename):
        """
        Generate wrappers + headers
        """

        # input_filename = "natives.h.txt"
        # out_filename = 
        global_namespace = declarations.get_global_namespace(self.decls)

        locations = {}

        # look for a match
        criteria = declarations.calldef_matcher(name="sigaction")
        results = declarations.matcher.find(criteria, global_namespace) 

        # print("decl", results)
        decl = results[0]
        # print( "islist ? len",len(func1))
        name = declaration_utils.full_name(decl)
        if name[:2] == "::":
            name = name[2:]
        log.info("Parsing function %s" % name)
        extern="extern" if decl.has_extern else ""
        rtype = "%s" % (decl.return_type if decl.return_type is not None else "void")

        temp = []
        for arg in decl.arguments:
            s = str(arg.decl_type)
            if s.startswith("?unknown?"):
                print("UNKNOWN")
                s = "va_list"
            elif "(" in s:
                print ("TOTO")
                s= s.rstrip("*")
            temp.append(s)

        for arg in temp:
            print("arg=%s"% arg)

        # temp = ["va_list" else str(a.decl_type) for a in decl.arguments]
        fullargs = ",".join(temp)
        res = """
            {extern} {ret} {name} ({fullargs});

        """.format(
                extern=extern,
                ret=rtype,
                fullargs=fullargs,
                name=name,
                retstmt="return" if rtype is not "void" else "",
                arg_names=",".join([arg.name for arg in decl.arguments]),
        )
        print(res)



def main():
    parser  = argparse.ArgumentParser()
    g = Generator()
    g.parse("toto")
    g.generate_wrappers("temp", "model/libc.generated.cc")

if __name__ == "__main__":
    main()

commit: 5dfded3 "More pep8 fixes" broke 'utils.py'

Hello,
I dont't understand completely why, but the function:

def contains_parent_dir(fpath, dirs)

from pygccxml/utils/utils.py

raise the following exception after the mentioned commit.

INFO GCCXML version - 0.9( 1.135 )
Traceback (most recent call last):
File "/home/carsten/src/bert/trunk/python/generate_pybert_code.py", line 297, in
generate(defined_symbols, options.extraIncludes, options.gimliBuild)
File "/home/carsten/src/bert/trunk/python/generate_pybert_code.py", line 181, in generate
, indexing_suite_version = 2)
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/module_builder/boost_python_builder.py", line 95, in init
, indexing_suite_version)
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/module_builder/boost_python_builder.py", line 153, in __parse_declarations
self.__apply_decls_defaults(decls)
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/module_builder/boost_python_builder.py", line 177, in __apply_decls_defaults
self.__filter_by_location( flatten_decls )
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pyplusplus/module_builder/boost_python_builder.py", line 163, in __filter_by_location
if pygccxml_utils.contains_parent_dir( fpath, self.__parsed_dirs ):
File "/home/carsten/src/gimli/thirdParty/dist-GNU-4.8.3-64/pygccxml/utils/utils.py", line 118, in contains_parent_dir
return bool(list(filter(fpath.startswith(dirs), dirs)))
TypeError: startswith first arg must be str, unicode, or tuple, not list

With the old version everything works perfectly.

There seems to be some more problems folllowing up and broke my toolchain with the current branch .. i will investigate and send it.

Bests and thanks for maintaining this great software,
Carsten

Unable to find out actual class definition: ''.

I seem to have stumbled on a bug while trying to use Py++ on a larger project.

Here is a snippet that reproduces the bug (edited out the namespace blunder for clearness sake):

#include <map>
using namespace std;
class apta_node;
typedef map<int, apta_node*> child_map;
class apta_node{
public:
    child_map children;
};

Here's how I try to build the module:

from pyplusplus import module_builder
mb = module_builder.module_builder_t(
    files=['test.h'],
    include_paths=["/usr/include/x86_64-linux-gnu/c++/5", "/usr/include/c++/5"],
    cflags="-std=c++11"
)

And here's the output and error message:

d@machine:~/dev/pyplusplustest$ python3 test_generate.py 
INFO Parsing source file "test.h" ... 
error: invalid argument '-std=c++11' not allowed with 'C/ObjC'         # I need to add it or --castxml-gccxml doesn't work. The XML files generates fine.
Traceback (most recent call last):
  File "test_generate.py", line 8, in <module>
    cflags="-std=c++11"
  File "/usr/local/lib/python3.4/dist-packages/pyplusplus-1.1.0-py3.4.egg/pyplusplus/module_builder/boost_python_builder.py", line 106, in __init__
  File "/usr/local/lib/python3.4/dist-packages/pyplusplus-1.1.0-py3.4.egg/pyplusplus/module_builder/boost_python_builder.py", line 149, in __parse_declarations
  File "/usr/local/lib/python3.4/dist-packages/pygccxml/parser/project_reader.py", line 249, in read_files
    return self.__parse_file_by_file(files)
  File "/usr/local/lib/python3.4/dist-packages/pygccxml/parser/project_reader.py", line 319, in __parse_file_by_file
    self._relink_declarated_types(leaved_classes, types)
  File "/usr/local/lib/python3.4/dist-packages/pygccxml/parser/project_reader.py", line 544, in _relink_declarated_types
    raise Exception(os.linesep.join(msg))
Exception: Unable to find out actual class definition: ''.
Class definition has been changed from one compilation to an other.
Why did it happen to me? Here is a short list of reasons: 
    1. There are different preprocessor definitions applied on same file during compilation
    2. Bug in pygccxml.

After a bit of fiddling, I think the problematic line is /usr/include/c++/5/bits/stl_tree.h:1407

Using Ubuntu 15.10, pygccxml 1.7.2 (and latest development branch), gccxml from Ubuntu repository (wrapper around CastXML 0.1-g8a08a44).

Coverage scans pep8.py file

The code coverage tool scans the pep8.py file in site-packages.
We need to restrict the coverage scan to files inside pygccxml (this can be done in the .travis.yml file)

pygccxml.utils.xml_generator not always set

When trying to regenerate python bindings and using the cache file mechanism I run into the following problem:

INFO Loading cache file "/Users/mmoll/build/omplapp/Release/pyplusplus_util.cache".
INFO Parsing source file "bindings/util.h" ... 
Traceback (most recent call last):
  File "/Users/mmoll/omplapp/ompl/py-bindings/generate_bindings.py", line 803, in <module>
    globals()['ompl_'+module+'_generator_t']()
  File "/Users/mmoll/omplapp/ompl/py-bindings/generate_bindings.py", line 737, in __init__
    code_generator_t.__init__(self, 'util', None, replacement, 1)
  File "/Users/mmoll/omplapp/ompl/py-bindings/ompl/bindings_generator.py", line 157, in __init__
    indexing_suite_version = indexing_suite_version )
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyplusplus/module_builder/boost_python_builder.py", line 95, in __init__
    , indexing_suite_version)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pyplusplus/module_builder/boost_python_builder.py", line 138, in __parse_declarations
    decls = reader.read_files( files, compilation_mode )
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/parser/project_reader.py", line 249, in read_files
    return self.__parse_file_by_file(files)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/parser/project_reader.py", line 315, in __parse_file_by_file
    reader.join_declarations(ns)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/parser/source_reader.py", line 488, in join_declarations
    self.join_declarations(ns)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/parser/source_reader.py", line 485, in join_declarations
    self._join_namespaces(declref)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/parser/source_reader.py", line 507, in _join_namespaces
    if decl not in joined_decls[decl._name]:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pygccxml/declarations/calldef.py", line 249, in __eq__
    if "GCC" in utils.xml_generator:
TypeError: argument of type 'NoneType' is not utterable

Failure in algorithm.py with c++11

Initially reported here: #47 (comment)
(There are also two xml files in the comment that may be interesting).

/home/ompl/castxml/bin/castxml  -std=c++11   -I. -I. -I/home/ompl/omplapp/ompl/src -I/home/ompl/omplapp/src -I/usr/include/python2.7 -I/usr/include -I/usr/include/assimp -I/usr/include/eigen3 -I/home/ompl/omplapp/ompl/src/../py-bindings -c -x c++ --castxml-cc-gnu  "(" /usr/bin/g++ -std=c++11 ")" --castxml-gccxml -o /tmp/tmpT4yHPz.xml bindings/util.h
Traceback (most recent call last):
  File "/home/ompl/omplapp/ompl/py-bindings/generate_bindings.py", line 800, in <module>
    globals()['ompl_'+module+'_generator_t']()
  File "/home/ompl/omplapp/ompl/py-bindings/generate_bindings.py", line 734, in __init__
    code_generator_t.__init__(self, 'util', None, replacement, 1)
  File "/home/ompl/omplapp/ompl/py-bindings/ompl/bindings_generator.py", line 136, in __init__
    self.mb.split_module('bindings/' + name, use_files_sum_repository=True)
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/module_builder/boost_python_builder.py", line 384, in split_module
    , encoding=self.encoding)
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/file_writers/__init__.py", line 36, in write_multiple_files
    mfs = multiple_files_t( extmodule, dir_path, files_sum_repository=files_sum_repository, encoding=encoding )
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/file_writers/multiple_files.py", line 34, in __init__
    writer.writer_t.__init__( self, extmodule, files_sum_repository, encoding=encoding )
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/file_writers/writer.py", line 36, in __init__
    , extmodule.specially_exposed_decls )
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/utils/__init__.py", line 200, in register_decls
    row = self.row_t( decl )
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/utils/__init__.py", line 71, in __init__
    self.__init_from_decl( decl_or_string )
  File "/usr/local/lib/python2.7/dist-packages/pyplusplus/utils/__init__.py", line 100, in __init_from_decl
    self.signature = decl.create_decl_string( with_defaults=False )
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/calldef.py", line 616, in create_decl_string
    return f_type.partial_decl_string
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 54, in partial_decl_string
    return self.build_decl_string(False)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 829, in build_decl_string
    with_defaults)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 820, in create_decl_string
    [_f(x, with_defaults) for x in arguments_types]),
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 486, in _f
    return x.build_decl_string(with_defaults)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 584, in build_decl_string
    return self.base.build_decl_string(with_defaults) + ' &'
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/cpptypes.py", line 895, in build_decl_string
    return self._declaration.partial_decl_string
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/declaration.py", line 361, in partial_decl_string
    return self.create_decl_string(with_defaults=False)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/declaration.py", line 343, in create_decl_string
    return algorithm.full_name(self, with_defaults)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/algorithm.py", line 133, in full_name
    partial_declaration_path(decl))
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/algorithm.py", line 64, in partial_declaration_path
    result = [decl.partial_name]
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/declaration.py", line 195, in partial_name
    self._partial_name = self._get_partial_name_impl()
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/class_declaration.py", line 575, in _get_partial_name_impl
    if type_traits.is_std_string(self):
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/type_traits.py", line 1309, in is_std_string
    return remove_cv(type_).decl_string in string_equivalences
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/declaration.py", line 352, in decl_string
    return self.create_decl_string()
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/declaration.py", line 343, in create_decl_string
    return algorithm.full_name(self, with_defaults)
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/algorithm.py", line 128, in full_name
    declaration_path(decl))
  File "/usr/local/lib/python2.7/dist-packages/pygccxml/declarations/algorithm.py", line 107, in full_name_from_declaration_path
    result = result[0] + '::'.join(result[1:])
IndexError: list index out of range
Command exited with non-zero status 1

Happens with gcc4.9 and gcc5. @mamoll do you have a minimal c++ code example to help setup a test for this ?

prepend arguments of type struct with "struct"'

the decl_string of for instance "struct sysinfo" should be sysinfo and not just "sysinfo".

For instance matching the sysinfo syscall and printing its first parameter decl_string returns
" ::sysinfo *"

When printing the result of the matcher.find, it gives

resultats= [<pygccxml.declarations.free_calldef.free_function_t object at 0x7f83a8262eb8>]
resultat: extern int sysinfo(sysinfo * __info) [free function]

I would expect
resultat: extern int sysinfo(struct sysinfo * __info) [free function]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.