當前位置: 首頁>>代碼示例>>Python>>正文


Python ext_c_parser.GnuCParser類代碼示例

本文整理匯總了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;未經允許,請勿轉載。