How to use pygccxml - 10 common examples

To help you get started, we’ve selected a few pygccxml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gccxml / pygccxml / unittests / complex_types_tester.py View on Github external
# Copyright 2014-2016 Insight Software Consortium.
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt

import os
import unittest
import parser_test_case
from pygccxml import parser


class Test(parser_test_case.parser_test_case_t):
    COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE

    def __init__(self, *args):
        parser_test_case.parser_test_case_t.__init__(self, *args)
        self.header = 'complex_types.hpp'
        self.declarations = None

    def setUp(self):
        if not self.declarations:
            self.declarations = parser.parse([self.header], self.config)

    def test(self):
        """
        This test tests presence of complex long double, float within
        FUNDAMENTAL_TYPES map
        """
        pass
github gccxml / pygccxml / unittests / text_reader_tester.py View on Github external
def test(self):
        fconfig = parser.file_configuration_t(
            data='int i;',
            start_with_declarations=None,
            content_type=parser.file_configuration_t.CONTENT_TYPE.TEXT)

        prj_reader = parser.project_reader_t(self.config)
        decls = prj_reader.read_files(
            [fconfig],
            compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)

        var_i = declarations.find_declaration(
            decls, decl_type=declarations.variable_t, name='i')
        self.assertTrue(var_i, "Variable i has not been found.")
github gccxml / pygccxml / unittests / attributes_tester.py View on Github external
def test(self):

        numeric = self.global_ns.class_('numeric_t')
        do_nothing = numeric.mem_fun('do_nothing')
        arg = do_nothing.arguments[0]

        if "CastXML" in utils.xml_generator:
            if utils.xml_output_version >= 1.137:
                # This works since:
                # https://github.com/CastXML/CastXML/issues/25
                # https://github.com/CastXML/CastXML/pull/26
                # https://github.com/CastXML/CastXML/pull/27
                # The version bump to 1.137 came way later but this is the
                # only way to make sure the test is running correctly
                self.assertTrue("annotate(sealed)" == numeric.attributes)
                self.assertTrue("annotate(no throw)" == do_nothing.attributes)
                self.assertTrue("annotate(out)" == arg.attributes)
        else:
            self.assertTrue("gccxml(no throw)" == do_nothing.attributes)
            self.assertTrue("gccxml(out)" == arg.attributes)
github gccxml / pygccxml / unittests / test_pattern_parser.py View on Github external
self.assertEqual(args, l)

            l = [p1, p2]
            name, args = declarations.templates.split(
                "myClass0b<" + ", ".join(l) + ">")
            self.assertEqual(name, "myClass0b")
            self.assertEqual(args, l)

            l = [p1, p2, p2]
            name, args = declarations.templates.split(
                "myClass0c<" + ", ".join(l) + ">")
            self.assertEqual(name, "myClass0c")
            self.assertEqual(args, l)

            l = [p1 + " (" + arg + ")"]
            name, args = declarations.templates.split(
                "myClass1<" + ", ".join(l) + ">")
            self.assertEqual(name, "myClass1")
            self.assertEqual(args, l)

            l = [p1 + " (" + arg + ", " + arg + ")"]
            name, args = declarations.templates.split(
                "myClass2<" + ", ".join(l) + ">")
            self.assertEqual(name, "myClass2")
            self.assertEqual(args, l)

            l = [p2 + " (" + arg + ", " + arg + ")"]
            name, args = declarations.templates.split(
                "myClass3<" + ", ".join(l) + ">")
            self.assertEqual(name, "myClass3")
            self.assertEqual(args, l)
github gccxml / pygccxml / unittests / text_reader_tester.py View on Github external
def test(self):
        fconfig = parser.file_configuration_t(
            data='int i;',
            start_with_declarations=None,
            content_type=parser.file_configuration_t.CONTENT_TYPE.TEXT)

        prj_reader = parser.project_reader_t(self.config)
        decls = prj_reader.read_files(
            [fconfig],
            compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)

        var_i = declarations.find_declaration(
            decls, decl_type=declarations.variable_t, name='i')
        self.assertTrue(var_i, "Variable i has not been found.")
github gccxml / pygccxml / unittests / type_traits_tester.py View on Github external
};

            typedef C<b> easy;
            typedef D Deasy;

            inline void instantiate(){
                int val = sizeof(easy);
            }

            }
        """

        global_ns = parser.parse_string(
            code,
            autoconfig.cxx_parsers_cfg.gccxml)
        global_ns = declarations.get_global_namespace(global_ns)
        easy = global_ns.typedef('easy')
        declarations.class_traits.get_declaration(easy)
        deasy = global_ns.typedef('Deasy')
        d_a = declarations.class_traits.get_declaration(deasy)
        self.assertTrue(isinstance(d_a, declarations.class_types))
</b>
github gccxml / pygccxml / unittests / type_as_exception_bug_tester.py View on Github external
def setUp(self):
        if not Test.global_ns:
            decls = parser.parse([self.header], self.config)
            Test.global_ns = declarations.get_global_namespace(decls)
            Test.global_ns.init_optimizer()
github gccxml / pygccxml / unittests / filters_tester.py View on Github external
def setUp(self):
        if not Test.global_ns:
            decls = parser.parse([self.header], self.config)
            Test.global_ns = declarations.get_global_namespace(decls)
            Test.global_ns.init_optimizer()
            Test.xml_generator_from_xml_file = \
                self.config.xml_generator_from_xml_file
        self.global_ns = Test.global_ns
        self.xml_generator_from_xml_file = Test.xml_generator_from_xml_file
github gccxml / pygccxml / unittests / has_binary_operator_traits_tester.py View on Github external
# Copyright 2014-2016 Insight Software Consortium.
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt

import unittest
import parser_test_case

from pygccxml import parser
from pygccxml import declarations


class Test(parser_test_case.parser_test_case_t):
    COMPILATION_MODE = parser.COMPILATION_MODE.ALL_AT_ONCE
    global_ns = None

    def __init__(self, *args):
        parser_test_case.parser_test_case_t.__init__(self, *args)
        self.header = 'has_public_binary_operator_traits.hpp'
        self.global_ns = None

    def setUp(self):
        if not Test.global_ns:
            decls = parser.parse([self.header], self.config)
            Test.global_ns = declarations.get_global_namespace(decls)
        self.global_ns = Test.global_ns

    def test_yes(self):
        yes_ns = self.global_ns.namespace('yes')
        for typedef in yes_ns.typedefs():
github gccxml / pygccxml / unittests / algorithms_cache_tester.py View on Github external
def setUp(self):
        decls = parser.parse([self.header], self.config)
        self.xml_generator_from_xml_file = \
            self.config.xml_generator_from_xml_file
        self.global_ns = declarations.get_global_namespace(decls)