Exemplo n.º 1
0
def p_struct_or_union_specifier(p):
    '''struct_or_union_specifier : struct_or_union gcc_attribs IDENTIFIER '{' struct_declaration_list '}'
         | struct_or_union gcc_attribs TYPE_NAME '{' struct_declaration_list '}'
         | struct_or_union gcc_attribs '{' struct_declaration_list '}'
         | struct_or_union IDENTIFIER '{' struct_declaration_list '}'
         | struct_or_union TYPE_NAME '{' struct_declaration_list '}'
         | struct_or_union '{' struct_declaration_list '}'
         | struct_or_union IDENTIFIER
         | struct_or_union TYPE_NAME
    '''
    # The TYPE_NAME ones are dodgy, needed for Apple headers
    # CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h.
    # CoreServices.framework/Frameworks/OSServices.framework/Headers/Power.h
    packed = False
    if len(p) == 3:  # struct <id/typname>
        p[0] = cdeclarations.StructTypeSpecifier(p[1], False, p[2], None)
    else:
        if type(p[2]) is Attribs:
            attribs = p[2]
            if p[3] == '{':
                tag, decl = '', p[4]
            else:
                tag, decl = p[3], p[5]
        else:
            attribs = Attribs()
            if p[2] == '{':
                tag, decl = '', p[3]
            else:
                tag, decl = p[2], p[4]

        p[0] = cdeclarations.StructTypeSpecifier(p[1], attribs.packed, tag,
                                                 decl)

    p[0].filename = p.slice[0].filename
    p[0].lineno = p.slice[0].lineno
Exemplo n.º 2
0
def p_struct_or_union_specifier(p):
    '''struct_or_union_specifier : struct_or_union IDENTIFIER '{' struct_declaration_list '}'
         | struct_or_union TYPE_NAME '{' struct_declaration_list '}'
         | struct_or_union '{' struct_declaration_list '}'
         | struct_or_union IDENTIFIER
         | struct_or_union TYPE_NAME
    '''
    # The TYPE_NAME ones are dodgy, needed for Apple headers
    # CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h.
    # CoreServices.framework/Frameworks/OSServices.framework/Headers/Power.h
    if len(p) == 3:
        p[0] = cdeclarations.StructTypeSpecifier(p[1], p[2], None)
    elif p[2] == '{':
        p[0] = cdeclarations.StructTypeSpecifier(p[1], '', p[3])
    else:
        p[0] = cdeclarations.StructTypeSpecifier(p[1], p[2], p[4])

    p[0].filename = p.slice[0].filename
    p[0].lineno = p.slice[0].lineno