Beispiel #1
0
def dump_type(type):
    visitor = type_dumper_t(type)
    algorithm.apply_visitor(visitor, type)
    # XXX: RECT becomes tagRECT somehow
    if visitor.result == 'tagRECT':
        return 'RECT'
    return visitor.result
Beispiel #2
0
def dump_type(type):
    visitor = type_dumper_t(type)
    algorithm.apply_visitor(visitor, type)
    # XXX: RECT becomes tagRECT somehow
    if visitor.result == 'tagRECT':
        return 'RECT'
    return visitor.result
Beispiel #3
0
def dump_decl(decl):
    visitor = decl_dumper_t(decl)
    algorithm.apply_visitor(visitor, decl)
    return visitor.result
Beispiel #4
0
def main():
    defines = []
    includes = []
    cxxflags = [
        '-Wno-unknown-attributes',
        '-Wno-unused-value',
        '-Wno-macro-redefined',
    ]
    compiler = 'g++'

    args = sys.argv[1:]
    while args and args[0].startswith('-'):
        arg = args.pop(0)
        if arg.startswith('-I'):
            include = arg[2:]
            includes.append(include)
        elif arg.startswith('-D'):
            define = arg[2:]
            defines.append(define)
        else:
            sys.stderr.write('error: unknown option %r\n' % arg)
            sys.exit(1)

    winsdk = True
    if winsdk:
        # Set up Clang compiler flags to use MinGW runtime
        # http://stackoverflow.com/a/19839946
        p = subprocess.Popen(
            ["x86_64-w64-mingw32-g++", "-x", "c++", "-E", "-Wp,-v", '-', '-fsyntax-only'],
            stdin=open(os.devnull, 'rt'),
            stdout=open(os.devnull, 'wt'),
            stderr=subprocess.PIPE)
        includes.append('/usr/share/castxml/clang/include')
        for line in p.stderr:
            if line.startswith(' '):
                include = line.strip()
                if os.path.isdir(include):
                    if os.path.exists(os.path.join(include, 'ia32intrin.h')):
                        # XXX: We must use Clang's intrinsic headers
                        continue
                    includes.append(os.path.normpath(include))

        winver = 0x0602

        defines += [
            # emulate MinGW
            '__MINGW32__',
            '_WIN32',
            '_WIN64',
            '__declspec(x)=',
            # Avoid namespace pollution when including windows.h
            # http://support.microsoft.com/kb/166474
            'WIN32_LEAN_AND_MEAN',
            # Set Windows version to 8.1
            '_WIN32_WINNT=0x%04X' % winver,
            'WINVER=0x%04X' % winver,
            'NTDDI_VERSION=0x%04X0000' % winver,
            # Prevent headers from requiring a rpcndr.h version beyond MinGW's
            '__REQUIRED_RPCNDR_H_VERSION__=475',
            # Avoid C++ helper classes
            'D3D10_NO_HELPERS',
            'D3D11_NO_HELPERS',
            'D3D11_VIDEO_NO_HELPERS',
        ]

        # XXX: Change compiler?
        #compiler = 'cl'

        # XXX: This doesn't seem to work well
        cxxflags += [
            #'-m32',
            #'-target', 'x86_64-pc-mingw32',
        ]

    sys.stderr.write('Include path:\n')
    for include in includes:
        sys.stderr.write('  %s\n' % include)
    sys.stderr.write('Definitions:\n')
    for define in defines:
        sys.stderr.write('  %s\n' % define)

    import logging
    utils.loggers.set_level(logging.DEBUG)

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

    # Configure the xml generator
    config = parser.xml_generator_configuration_t(
        xml_generator_path=generator_path,
        xml_generator=generator_name,
        define_symbols = defines,
        include_paths = includes,
        cflags = ' '.join(cxxflags),
        compiler = compiler,
        #keep_xml = True,
    )

    script_dir = os.path.dirname(__file__)
    headers = [
        os.path.join(script_dir, '..', '..', 'compat', 'winsdk_compat.h'),
        os.path.join(script_dir, 'cxx2api.h'),
    ]
    main_header = args[0]
    headers.append(main_header)

    decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)
    global_ns = declarations.get_global_namespace(decls)

    def decl_filter(decl):
        location = decl.location
        if location is None:
            return False
        return os.path.basename(location.file_name) in map(os.path.basename, args)

    module, _ = os.path.splitext(main_header)
    visitor = decl2_dumper_t(module)
    visitor.start()
    for decl in global_ns.declarations:
        if not decl_filter(decl):
            continue

        if sys.stdout.isatty():
            print('# ' + str(decl))

        visitor.decl = decl
        algorithm.apply_visitor(visitor, decl)
    visitor.finish()
Beispiel #5
0
def dump_decl(instance, decl):
    dumper = decl_dumper_t(instance, decl)
    algorithm.apply_visitor(dumper, decl)
Beispiel #6
0
def dump_type(instance, type_):
    type_ = type_traits.remove_alias(type_)
    visitor = type_dumper_t(instance, type_)
    algorithm.apply_visitor(visitor, type_)
Beispiel #7
0
def dump_decl(decl):
    visitor = decl_dumper_t(decl)
    algorithm.apply_visitor(visitor, decl)
    return visitor.result
Beispiel #8
0
def main():
    defines = []
    includes = []
    cxxflags = [
        '-Wno-unknown-attributes',
        '-Wno-unused-value',
        '-Wno-macro-redefined',
    ]
    compiler = 'g++'

    args = sys.argv[1:]
    while args and args[0].startswith('-'):
        arg = args.pop(0)
        if arg.startswith('-I'):
            include = arg[2:]
            includes.append(include)
        elif arg.startswith('-D'):
            define = arg[2:]
            defines.append(define)
        else:
            sys.stderr.write('error: unknown option %r\n' % arg)
            sys.exit(1)

    winsdk = True
    if winsdk:
        # Set up Clang compiler flags to use MinGW runtime
        if 0:
            # XXX: This doesn't work
            # http://stackoverflow.com/a/19839946
            p = subprocess.Popen([
                "x86_64-w64-mingw32-g++", "-x", "c++", "-E", "-Wp,-v", '-',
                '-fsyntax-only'
            ],
                                 stdin=open(os.devnull, 'rt'),
                                 stdout=open(os.devnull, 'wt'),
                                 stderr=subprocess.PIPE)
            includes.append('/usr/share/castxml/clang/include')
            for line in p.stderr:
                if line.startswith(' '):
                    include = line.strip()
                    if os.path.isdir(include):
                        includes.append(os.path.normpath(include))
        elif 0:
            # XXX: This matches what wclang does, but doensn't work neither
            cxxflags += [
                "-target",
                "x86_64-w64-mingw32",
                "-nostdinc",
                "-isystem",
                "/usr/lib/clang/3.6.0/include",
                "-isystem",
                "/usr/x86_64-w64-mingw32/include",
                "-isystem",
                "/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++",
                "-isystem",
                "/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++/x86_64-w64-mingw32",
            ]
        else:
            # This works somehow, but seems brittle
            includes += [
                '/usr/x86_64-w64-mingw32/include',
                '/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++',
                '/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++/x86_64-w64-mingw32',
            ]

        winver = 0x0602

        defines += [
            # emulate MinGW
            '__MINGW32__',
            '_WIN32',
            '_WIN64',
            '__declspec(x)=',
            # Avoid namespace pollution when including windows.h
            # http://support.microsoft.com/kb/166474
            'WIN32_LEAN_AND_MEAN',
            # Set Windows version to 8.1
            '_WIN32_WINNT=0x%04X' % winver,
            'WINVER=0x%04X' % winver,
            'NTDDI_VERSION=0x%04X0000' % winver,
            # Avoid C++ helper classes
            'D3D10_NO_HELPERS',
            'D3D11_NO_HELPERS',
            'D3D11_VIDEO_NO_HELPERS',
        ]

        # XXX: Change compiler?
        #compiler = 'cl'

        # XXX: This doesn't seem to work well
        cxxflags += [
            #'-m32',
            #'-target', 'x86_64-pc-mingw32',
        ]

    sys.stderr.write('Include path:\n')
    for include in includes:
        sys.stderr.write('  %s\n' % include)
    sys.stderr.write('Definitions:\n')
    for define in defines:
        sys.stderr.write('  %s\n' % define)

    import logging
    utils.loggers.set_level(logging.DEBUG)

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

    # Configure the xml generator
    config = parser.xml_generator_configuration_t(
        xml_generator_path=generator_path,
        xml_generator=generator_name,
        define_symbols=defines,
        include_paths=includes,
        cflags=' '.join(cxxflags),
        compiler=compiler,
        #keep_xml = True,
    )

    script_dir = os.path.dirname(__file__)
    headers = [
        os.path.join(script_dir, '..', '..', 'compat', 'winsdk_compat.h'),
        os.path.join(script_dir, 'cxx2api.h'),
    ]
    main_header = args[0]
    headers.append(main_header)

    decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)
    global_ns = declarations.get_global_namespace(decls)

    def decl_filter(decl):
        location = decl.location
        if location is None:
            return False
        return os.path.basename(location.file_name) in args

    module, _ = os.path.splitext(main_header)
    visitor = decl2_dumper_t(module)
    visitor.start()
    for decl in global_ns.declarations:
        if not decl_filter(decl):
            continue
        visitor.decl = decl
        algorithm.apply_visitor(visitor, decl)
    visitor.finish()
Beispiel #9
0
def dump_decl(instance, decl):
    dumper = decl_dumper_t(instance, decl)
    algorithm.apply_visitor(dumper, decl)
Beispiel #10
0
def dump_type(instance, type_):
    type_ = type_traits.remove_alias(type_)
    visitor = type_dumper_t(instance, type_)
    algorithm.apply_visitor(visitor, type_)
Beispiel #11
0
def main():
    defines = []
    includes = []
    cxxflags = ["-Wno-unknown-attributes", "-Wno-unused-value", "-Wno-macro-redefined"]
    compiler = "g++"

    args = sys.argv[1:]
    while args and args[0].startswith("-"):
        arg = args.pop(0)
        if arg.startswith("-I"):
            include = arg[2:]
            includes.append(include)
        elif arg.startswith("-D"):
            define = arg[2:]
            defines.append(define)
        else:
            sys.stderr.write("error: unknown option %r\n" % arg)
            sys.exit(1)

    winsdk = True
    if winsdk:
        # Set up Clang compiler flags to use MinGW runtime
        if 0:
            # XXX: This doesn't work
            # http://stackoverflow.com/a/19839946
            p = subprocess.Popen(
                ["x86_64-w64-mingw32-g++", "-x", "c++", "-E", "-Wp,-v", "-", "-fsyntax-only"],
                stdin=open(os.devnull, "rt"),
                stdout=open(os.devnull, "wt"),
                stderr=subprocess.PIPE,
            )
            includes.append("/usr/share/castxml/clang/include")
            for line in p.stderr:
                if line.startswith(" "):
                    include = line.strip()
                    if os.path.isdir(include):
                        includes.append(os.path.normpath(include))
        elif 0:
            # XXX: This matches what wclang does, but doensn't work neither
            cxxflags += [
                "-target",
                "x86_64-w64-mingw32",
                "-nostdinc",
                "-isystem",
                "/usr/lib/clang/3.6.0/include",
                "-isystem",
                "/usr/x86_64-w64-mingw32/include",
                "-isystem",
                "/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++",
                "-isystem",
                "/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++/x86_64-w64-mingw32",
            ]
        else:
            # This works somehow, but seems brittle
            includes += [
                "/usr/x86_64-w64-mingw32/include",
                "/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++",
                "/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/include/c++/x86_64-w64-mingw32",
            ]

        winver = 0x0602

        defines += [
            # emulate MinGW
            "__MINGW32__",
            "_WIN32",
            "_WIN64",
            "__declspec(x)=",
            # Avoid namespace pollution when including windows.h
            # http://support.microsoft.com/kb/166474
            "WIN32_LEAN_AND_MEAN",
            # Set Windows version to 8.1
            "_WIN32_WINNT=0x%04X" % winver,
            "WINVER=0x%04X" % winver,
            "NTDDI_VERSION=0x%04X0000" % winver,
            # Avoid C++ helper classes
            "D3D10_NO_HELPERS",
            "D3D11_NO_HELPERS",
            "D3D11_VIDEO_NO_HELPERS",
        ]

        # XXX: Change compiler?
        # compiler = 'cl'

        # XXX: This doesn't seem to work well
        cxxflags += [
            #'-m32',
            #'-target', 'x86_64-pc-mingw32',
        ]

    sys.stderr.write("Include path:\n")
    for include in includes:
        sys.stderr.write("  %s\n" % include)
    sys.stderr.write("Definitions:\n")
    for define in defines:
        sys.stderr.write("  %s\n" % define)

    import logging

    utils.loggers.set_level(logging.DEBUG)

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

    # Configure the xml generator
    config = parser.xml_generator_configuration_t(
        xml_generator_path=generator_path,
        xml_generator=generator_name,
        define_symbols=defines,
        include_paths=includes,
        cflags=" ".join(cxxflags),
        compiler=compiler,
        # keep_xml = True,
    )

    script_dir = os.path.dirname(__file__)
    headers = [os.path.join(script_dir, "..", "..", "compat", "winsdk_compat.h"), os.path.join(script_dir, "cxx2api.h")]
    main_header = args[0]
    headers.append(main_header)

    decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)
    global_ns = declarations.get_global_namespace(decls)

    def decl_filter(decl):
        location = decl.location
        if location is None:
            return False
        return os.path.basename(location.file_name) in args

    module, _ = os.path.splitext(main_header)
    visitor = decl2_dumper_t(module)
    visitor.start()
    for decl in global_ns.declarations:
        if not decl_filter(decl):
            continue
        visitor.decl = decl
        algorithm.apply_visitor(visitor, decl)
    visitor.finish()