The purpose of the GCC-XML extension is to generate an XML description of a C++ program from GCC's internal representation.
-- Introduction to GCC-XML
The purpose of pygccxml is to read a generated file and provide a simple framework to navigate C++ declarations, using Python classes.
Using pygccxml you can:
pygccxml provides simple and powerful API to query declarations tree. How many lines is needed to write next query?
select all free functions from the project
where
name equal to "do_smth"
return type is void
function has two arguments
second argument type is int
Only 1 ( one ) line of code is needed:
#global_ns is the reference to declarations, which describes global( :: ) namespace
global_ns.free_functions( "do_smth", return_type='void', arg_types=[None,'int'] )
None means "any type". In my opinion the code is prety clear and readable.
If you want to know more about provided API read query interface document or API documentation.
pygccxml provides a lot of functionality to analyze C++ types and relationship between them. For more information please refer to design document or API documentation. Just a few names of algorithms:
is_convertible( from, to )
returns True if there is a conversion from type from to type to, otherwise False
is_unary_operator( oper )
returns True if oper describes unary operator
You can query a declaration, about it dependencies - declarations it depends on. This is very powerful and useful feature. Py++, for example, uses this functionality to check that user creates Python bindings for all relevant declarations.
Consider the following situation: you have to parse the same set of files every day. There are 2 possible ways to complete the task:
The difference between these approaches is the caching algorithm used in the second case. pygccxml supports both of them. Actually pygccxml supports more caching strategies, read the API documentation for more information.
pygccxml comes with comprehensive unit tests. It is running on Windows XP and Ubuntu. I am using Python 2.4\2.5 and GCC-XML CVS. pygccxml has more then 215 tests. They test almost every piece of code. It also has performance tests. Most of the time I am using "white box" testing strategy.