How to use the pycparserext.ext_c_generator function in pycparserext

To help you get started, we’ve selected a few pycparserext 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 inducer / pycparserext / test / test_pycparserext.py View on Github external
def test_no_added_attr():
    src = """
    char* foo() {
        return "";
    }

    int main() {
        return 0;
    }
    """
    import pycparserext.ext_c_parser as ext_c_parser
    import pycparserext.ext_c_generator as ext_c_generator

    parser = ext_c_parser.GnuCParser()
    ast = parser.parse(src)
    gen = ext_c_generator.GnuCGenerator()
    print(gen.visit(ast))
    assert "attr" not in gen.visit(ast)
github inducer / pycparserext / test / test_pycparserext.py View on Github external
src = """
    struct foo {
        const char                      *bar;
        const char                      *baz;
    };

    int main () {
        return 0;
    }
    """
    import pycparserext.ext_c_parser as ext_c_parser
    import pycparserext.ext_c_generator as ext_c_generator

    parser = ext_c_parser.GnuCParser()
    ast = parser.parse(src)
    gen = ext_c_generator.GnuCGenerator()
    print(gen.visit(ast))