• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ext_c_parser.GnuCParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pycparserext.ext_c_parser.GnuCParser的典型用法代码示例。如果您正苦于以下问题:Python GnuCParser类的具体用法?Python GnuCParser怎么用?Python GnuCParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了GnuCParser类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_array_ptr_decl_attribute

def test_array_ptr_decl_attribute():
    src = """
    int* __attribute__((weak)) array[256];
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:9,代码来源:test_pycparserext.py


示例2: test_gnu_statement_expression

def test_gnu_statement_expression():
    src = """
      int func(int a) {
        return (int)({; ; *(int*)&a;});
     }
    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:10,代码来源:test_pycparserext.py


示例3: test_funky_header_code_5

def test_funky_header_code_5():
    src=""" void  do_foo(void) __asm(__STRING(do_foo));"""

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:10,代码来源:test_pycparserext.py


示例4: test_func_ret_ptr_decl_attribute

def test_func_ret_ptr_decl_attribute():
    src = """
    extern void* memcpy(const void* src, const void *dst, int len) __attribute__((unused));
    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:11,代码来源:test_pycparserext.py


示例5: test_asm_volatile_2

def test_asm_volatile_2():
    src = """
    void read_tsc(void) {
        long val;
        asm volatile("rdtsc" : "=A" (val));
    }    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print GnuCGenerator().visit(ast)
开发者ID:pombredanne,项目名称:pycparserext,代码行数:13,代码来源:test_pycparserext.py


示例6: test_empty_struct_declaration

def test_empty_struct_declaration():
    src = """
        typedef struct Foo {
        } Foo_t;
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:13,代码来源:test_pycparserext.py


示例7: test_array_attributes

def test_array_attributes():
    src = """
        int x[10] __attribute__((unused));
        int y[20] __attribute((aligned(10)));
        """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:13,代码来源:test_pycparserext.py


示例8: test_asm_volatile_3

def test_asm_volatile_3():
    src = """
    void read_tsc(void) {
        long fpenv;
        asm("mtfsf 255,%0" :: "f" (fpenv));
    }    """
    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print GnuCGenerator().visit(ast)
开发者ID:pombredanne,项目名称:pycparserext,代码行数:13,代码来源:test_pycparserext.py


示例9: test_lvalue_gnu_statement_expression

def test_lvalue_gnu_statement_expression():
    src = """
      int func(int a) {
        int ret=(int)({; ; *(int*)&a;});
        return ret;
     }
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:15,代码来源:test_pycparserext.py


示例10: test_func_decl_attribute

def test_func_decl_attribute():
    src = """
    extern void int happy(void) __attribute__((unused));
    int main()
    {
    }
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:15,代码来源:test_pycparserext.py


示例11: test_funky_header_code

def test_funky_header_code():
    src = """
        extern __inline int __attribute__ ((__nothrow__)) __signbitf (float __x)
         {
           int __m;
           __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x));
           return __m & 0x8;
         }
        """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)

    from pycparserext.ext_c_generator import GnuCGenerator
    print GnuCGenerator().visit(ast)
开发者ID:nrfulton,项目名称:pycparserext,代码行数:16,代码来源:test_pycparserext.py


示例12: test_empty_gnu_statement_expression

def test_empty_gnu_statement_expression():
    # Incase, ASSERTS turn out to be empty statements
    src = """
      int func(int a) {
              ({
                    ; ;
                         });
                }
    """

    from pycparserext.ext_c_parser import GnuCParser
    p = GnuCParser()
    ast = p.parse(src)
    ast.show()

    from pycparserext.ext_c_generator import GnuCGenerator
    print(GnuCGenerator().visit(ast))
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:17,代码来源:test_pycparserext.py


示例13: GnuCParser

from pycparserext.ext_c_parser import GnuCParser
p = GnuCParser()
src="""
typedef int wchar_t;
extern wchar_t *wcscpy (wchar_t *restrict __dest,
const wchar_t *__restrict __src) __attribute ((nothrow , leaf));

"""
p.parse(src).show()
开发者ID:h4ck3rm1k3,项目名称:pycparserext,代码行数:9,代码来源:test.py


示例14: visit_AttributeSpecifier

    def visit_AttributeSpecifier(self, n):
        return ' __attribute__((' + self.visit(n.exprlist) + '))'

####################################################################################################

class MyCGenerator(AsmAndAttributesMixin, CGenerator):
    pass

####################################################################################################

file_path = 'fitz-from-cpp.h'
with open(file_path, 'r') as f:
    source = f.read()

parser = GnuCParser()
ast = parser.parse(source)

# ast.show()

# generator = FunctionDeclarationGenerator()
generator = MyCGenerator()
source = generator.visit(ast)
# print(source)

print('\nStructs:')
for name in generator.structs:
    if name and name.startswith('fz_'):
        print(name)

print('\nFunctions:')
开发者ID:FabriceSalvaire,项目名称:Biblio,代码行数:30,代码来源:test-pycparserext.py



注:本文中的pycparserext.ext_c_parser.GnuCParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python aes.AES类代码示例发布时间:2022-05-25
下一篇:
Python pycparser.parse_file函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap