Example #1
0
def generate_pxd():
    """
    Uses cwrap (https://github.com/geggo/cwrap)

    and

    c_defines_to_pxd_enum.py (hacked for this example)
    """
    from cwrap.config import Config, File
    import sys
    import os
    import glob

    # Run cwrap (output in CWRAP_OUT)
    # if not LLVM_BIN_PATH in sys.path:
    #     sys.path.append(LLVM_BIN_PATH)
    if not os.path.exists(CWRAP_OUT):
        os.makedirs(CWRAP_OUT)
    umfpack_headers = glob.glob(os.path.join(
        SUITESPARSE_INC, 'umfpack*'))
    cwrap_header_files = list(map(File, umfpack_headers))
    config_clang = Config('clang', files=cwrap_header_files,
                          save_dir = CWRAP_OUT,
                          include_dirs = [SUITESPARSE_INC]
                          )
    config_clang.generate()

    # Extract #define style enums (output to PXD_ENUM_OUT)
    import c_defines_to_pxd_enum
    if not os.path.exists(PXD_ENUM_OUT):
        os.makedirs(PXD_ENUM_OUT)
    c_defines_to_pxd_enum.main(umfpack_headers, PXD_ENUM_OUT)

    # Join resp. pxd files in cython_umfpack/
    for cwrap_pxd in glob.glob(os.path.join(
        CWRAP_OUT, '*.pxd')):
        pxd_basename = os.path.basename(cwrap_pxd)

        sources = [cwrap_pxd]
        enum_pxd = os.path.join(PXD_ENUM_OUT, pxd_basename)
        if os.path.isfile(enum_pxd):
            sources.append(enum_pxd)
        dest_basename = pxd_basename[1:] if pxd_basename.startswith('_') else pxd_basename
        dest = os.path.join('./cython_umfpack', dest_basename)
        cat(sources, dest)
Example #2
0
 def convert(self, filename):
     files = [File(filename)]
     config = Config('clang', files=files)
     asts = self.frontend.generate_asts(config)
     print '\n\n\nvmx: asts:\n', asts, '\n\n\n\n\n'
     ast_renderer = renderer.ASTRenderer()
     for ast_container in asts:
         mod_node = ast_container.module
         code = ast_renderer.render(mod_node)
         output = []
         for line in code.splitlines():
             if line.startswith('#') or not line.strip():
                 continue
             output.append(line.strip())
         return output
Example #3
0
from cwrap.config import Config, File
import sys

print(sys.argv)
if len(sys.argv) > 1:
    files = [File(f) for f in sys.argv[1:]]
else:
    files = [File('test.h')]

if __name__ == '__main__':
    #config = Config('gccxml', files=files, save_dir = 'tests/result_gccxml')
    #config.generate()

    print('------------------------')
    print()

    config_clang = Config(
        'clang',
        files=files,
        save_dir='tests/result_clang',
        #include_dirs = [], #/usr/include/c++/4.2.1
        #extern_name = '',
        #implementation_name = '',
        #language = 'c++',
    )
    config_clang.generate()
Example #4
0
from cwrap.config import Config, File

if __name__ == '__main__':
    config = Config('gccxml', files=[File('test.h')])
    config.generate()
Example #5
0
from cwrap.config import Config, File

if __name__ == '__main__':
    config = Config('gccxml', 
                    files = [File('mvDeviceManager/Include/mvDeviceManager.h')],
                    include_dirs = ['.',])
    config.generate()

    config = Config('gccxml', 
                    files = [File('DriverBase/Include/mvDriverBaseEnums.h')],
                    include_dirs = ['.',])
    config.generate()

    config = Config('gccxml', 
                    files = [File('mvPropHandling/Include/mvPropHandlingDatatypes.h')],
                    include_dirs = ['.',])
    config.generate()
    
   
Example #6
0
# -*- coding: utf-8 -*-
#
#   pyflycapture2 - python bindings for libflycapture2_c
#   Copyright (C) 2012 Robert Jordens <*****@*****.**>
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

from cwrap.config import Config, File

if __name__ == '__main__':
    config = Config('gccxml',
                    files=[
                        File('FlyCapture2Defs_C.h'),
                        File('FlyCapture2_C.h'),
                    ])
    config.generate()
Example #7
0
from cwrap.config import Config, File
import sys

print sys.argv
if len(sys.argv) > 1:
    files = [File(f) for f in sys.argv[1:]]
else:
    files = [File('test.h')]

if __name__ == '__main__':
    #config = Config('gccxml', files=files, save_dir = 'tests/result_gccxml')
    #config.generate()
    
    print '------------------------'
    print

    config_clang = Config('clang', files=files, 
                          save_dir = 'tests/result_clang',
                          #include_dirs = [], #/usr/include/c++/4.2.1
                          #extern_name = '',
                          #implementation_name = '',
                          #language = 'c++',
                          )
    config_clang.generate()