Git Product home page Git Product logo

ctypeslib's Introduction

ctypeslib with libclang
-----------------------

2015-01-29:
 master works with libclang-3.7 @227409 + my visit-fields-201501 patch on clang / see python-clang branch visit-fields-201501
 locality doesn't work. (need to find why)



This fork of ctypeslib is mainly about using the libclang1>=3.4 python bindings
to generate python code from C source code.

ctypeslib contains these packages:
 - ``ctypeslib.codegen``       - a code generator
 - ``ctypeslib.contrib``       - various contributed modules
 - ``ctypeslib.util``          - assorted small helper functions
 - ``ctypeslib.test``          - unittests

This fork of ctypeslib is heavily patched for clang.
https://github.com/trolldbois/ctypeslib is based on 
 rev77594 of the original ctypeslib.
git-svn-id: http://svn.python.org/projects/ctypes/trunk/ctypeslib@77594 
 6015fed2-1504-0410-9fe1-9d1591cc4771

The original ctypeslib is written by
author="Thomas Heller",
author_email="[email protected]",

Stable Distribution is available through pypi:
  https://pypi.python.org/pypi/ctypeslib2/
  sudo easy_install ctypeslib2 
  
Usage
-----
usage: clang2py [-h] [--debug] [-c] [-d] [-k TYPEKIND] [-l DLLS] [-o OUTPUT]
                [-r EXPRESSION] [-s SYMBOL] [-v] [-w W] [-m module]
                [--preload DLL] [--show-ids SHOWIDS] [--max-depth N]
                files [files ...]

generate python ABI code from C code

positional arguments:
  files               source filenames

optional arguments:
  -h, --help          show this help message and exit
  --debug             setLevel to DEBUG
  -c                  include source file location in comments
  -d                  include docstrings containing C prototype and source
                      file location
  -k TYPEKIND         kind of type descriptions to include: d = #defines, e =
                      enumerations, f = functions, s = structures, t =
                      typedefs
  -l DLLS             libraries to search for exported functions
  -o OUTPUT           output filename (if not specified, standard output will
                      be used)
  -r EXPRESSION       regular expression for symbols to include (if neither
                      symbols nor expressions are specified,everything will be
                      included)
  -s SYMBOL           symbol to include (if neither symbols nor expressions
                      are specified,everything will be included)
  -v                  verbose output
  -w W                add all standard windows dlls to the searched dlls list
  -m module           Python module(s) containing symbols which will be
                      imported instead of generated
  --preload DLL       dlls to be loaded before all others (to resolve symbols)
  --show-ids SHOWIDS  Don't compute cursor IDs (very slow)
  --max-depth N       Limit cursor expansion to depth N

About clang-args: You can pass modifier to clang after your file name. For
example, try "-target x86_64" or "-target i386-linux" as the last argument to
change the target CPU arch.


Inner workings for memo
-----------------------
clang2py is a script that calls ctypeslib/ctypeslib/clang2py.py
clang2py.py is mostly the old xml2py.py module forked to use libclang.
clang2py.py calls ctypeslib/ctypeslib/codegen/codegenerator.py
codegenerator.py calls ctypeslib/ctypeslib/codegen/clangparser.py
clangparser.py uses libclang's python binding to access the clang internal 
 representation of the C source code. 
 It then translate each child of the AST tree to python objects as listed in 
 typedesc.
codegenerator.py then uses these python object to generate ctypes-based python
 source code.
 
Because clang is capable to handle different target architecture, this fork 
 {is/should be} able to produce cross-platform memory representation if needed.


Setting up clang>=3.4
---------------------
see http://llvm.org/apt/

  sudo apt-add-repository "deb http://llvm.org/apt/raring/ llvm-toolchain-raring main"
  sudo apt-get install libclang1-3.4 libclang-common-3.4-dev
  sudo echo `echo "/usr/lib/llvm-3.4/lib/" >> /etc/ld.so.conf.d/llvm-dev.conf`
  sudo ldconfig -n

Setting up python-clang>=3.4
----------------------------
This are the python bindings, not distributed by llvm as far as I know. 
I made a python package for them.

  sudo easy_install clang







 

ctypeslib's People

Contributors

trolldbois avatar rgov avatar luzfcb avatar

Watchers

James Cloos avatar Philippe Ombredanne avatar

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.