Git Product home page Git Product logo

cppinfo's Introduction

Extract type information from C++ code

There are three backends that I'm developing at the same time:

Each of these have strengths and weaknesses, and it's not clear to me which will be best for use.

What is output so far?

At the moment just class information. For each class, we return lists of constructors, methods and fields (public only for doxygen, all for gccxml/libclang). Template information. For each argument, name and type information is included. Everything has location information (file/line/column).

What is on the radar?

Functions. This is actually really easy, I just haven't got around to it.

The different backends

One unresolved difference is that Doxygen processes whole directories at once, while GCCXML and libclang operate one file at a time (being focussed on translation units).

Doxygen

This is the easiest to install. It presumably does a good job in parsing C++ given it is in very widespread use. We parse its XML output, which contains pretty much everything we need. What is not included is any system headers. So if you want information about, say, std::pair or a boost library, you'll have to get doxygen to document that directory too.

GCCXML

This is fairly easy to install, though it depends on Cmake, which is not always installed already. It also doesn't do well with system libraries (I think). But the biggest problem is that it can't/won't include information on uninstantiated templates. That's a problem if you want to point this at headers to get type information as the templates aren't instantiated there.

libclang

This is a pain to install, but apart from that is capable of doing pretty much everything.

Installing this requires at least rPython (not available on windows) and the Python libclang bindings. The version from pip install clang will not work: you must clone the repo here and install with sudo setup.py install. The reason for this is that we require clang_getTypeSpelling(), which is not exposed in the version on pip. Libclang must be installed. On OSX, this is locatable by running mdfind -name libclang.dylib. It is possibly in /Library/Developer/CommandLineTools/usr/lib/libclang.dylib. You'll need to either add this to $DYLD_LIBRARY_PATH or pass it through to cppinfo::libclang_set_library_file() so that the Python libclang module can find it. If you download the binaries from llvm some extra work is needed to set search paths. If you get that working please let me know or file an issue/PR with directions.

cppinfo's People

Contributors

richfitz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

cppinfo's Issues

Be careful with XML and memory leaks

From ?getNodeSet

          # this illustrates an approach to doing queries on a sub tree
          # within the document.
          # Note that there is a memory leak incurred here as we create a new
          # XMLInternalDocument in the getNodeSet().

         f = system.file("exampleData", "book.xml", package = "XML")
         doc = xmlParse(f)
         ch = getNodeSet(doc, "//chapter")
         xpathApply(ch[[2]], "//section/title", xmlValue)

           # To fix the memory leak, we explicitly create a new document for
           # the subtree, perform the query and then free it _when_ we are done
           # with the resulting nodes.
         subDoc = xmlDoc(ch[[2]])
         xpathApply(subDoc, "//section/title", xmlValue)
         free(subDoc)

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.