def get_unique_name(self, cursor):
        """get the spelling or create a unique name for a cursor"""
        name = ''
        if cursor.kind in [CursorKind.UNEXPOSED_DECL]:
            return ''
        # covers most cases
        name = cursor.spelling
        # if its a record decl or field decl and its type is unnamed
        if cursor.spelling == '':
            # a unnamed object at the root TU
            if (cursor.semantic_parent
                and cursor.semantic_parent.kind == CursorKind.TRANSLATION_UNIT):
                name = self.make_python_name(cursor.get_usr())
                log.debug('get_unique_name: root unnamed type kind %s',cursor.kind)
            elif cursor.kind in [CursorKind.STRUCT_DECL,CursorKind.UNION_DECL,
                                 CursorKind.CLASS_DECL,CursorKind.FIELD_DECL]:
                name = self._make_unknown_name(cursor)
                log.debug('Unnamed cursor type, got name %s',name)
            else:
                log.debug('Unnamed cursor, No idea what to do')
                #import code
                #code.interact(local=locals())
                return ''
        if cursor.kind in [CursorKind.STRUCT_DECL,CursorKind.UNION_DECL,
                                 CursorKind.CLASS_DECL]:
            names= {CursorKind.STRUCT_DECL: 'struct',
                    CursorKind.UNION_DECL: 'union',
                    CursorKind.CLASS_DECL: 'class',
                    CursorKind.TYPE_REF: ''}
            name = '%s_%s'%(names[cursor.kind],name)
        log.debug('get_unique_name: name "%s"',name)
        return name
def get_unique_name ( self , cursor ) : name = '' if cursor . kind in [ CursorKind . UNEXPOSED_DECL ] : return '' name = cursor . spelling if cursor . spelling == '' : if ( cursor . semantic_parent and cursor . semantic_parent . kind == CursorKind . TRANSLATION_UNIT ) : name = self . make_python_name ( cursor . get_usr ( ) ) log . debug ( 'get_unique_name: root unnamed type kind %s' , cursor . kind ) elif cursor . kind in [ CursorKind . STRUCT_DECL , CursorKind . UNION_DECL , CursorKind . CLASS_DECL , CursorKind . FIELD_DECL ] : name = self . _make_unknown_name ( cursor ) log . debug ( 'Unnamed cursor type, got name %s' , name ) else : log . debug ( 'Unnamed cursor, No idea what to do' ) return '' if cursor . kind in [ CursorKind . STRUCT_DECL , CursorKind . UNION_DECL , CursorKind . CLASS_DECL ] : names = { CursorKind . STRUCT_DECL : 'struct' , CursorKind . UNION_DECL : 'union' , CursorKind . CLASS_DECL : 'class' , CursorKind . TYPE_REF : '' } name = '%s_%s' % ( names [ cursor . kind ] , name ) log . debug ( 'get_unique_name: name "%s"' , name ) return name
get the spelling or create a unique name for a cursor