コード例 #1
0
ファイル: cursorhandler.py プロジェクト: mindw/ctypeslib
    def TYPEDEF_DECL(self, cursor):
        """
        Handles typedef statements.
        Gets Type from cache if we known it. Add it to cache otherwise.
        # typedef of an enum
        """
        name = self.get_unique_name(cursor)
        # if the typedef is known, get it from cache
        if self.is_registered(name):
            return self.get_registered(name)
        # use the canonical type directly.
        _type = cursor.type.get_canonical()
        log.debug("TYPEDEF_DECL: name:%s", name)
        log.debug("TYPEDEF_DECL: typ.kind.displayname:%s", _type.kind)

        # For all types (array, fundament, pointer, others), get the type
        p_type = self.parse_cursor_type(_type)
        if not isinstance(p_type, typedesc.T):
            log.error('Bad TYPEREF parsing in TYPEDEF_DECL: %s',
                      _type.spelling)
            # import code
            # code.interact(local=locals())
            raise TypeError('Bad TYPEREF parsing in TYPEDEF_DECL: %s' %
                            (_type.spelling))
        # register the type
        obj = self.register(name, typedesc.Typedef(name, p_type))
        self.set_location(obj, cursor)
        self.set_comment(obj, cursor)
        return obj
コード例 #2
0
 def Typedef(self, attrs):
     name = attrs["name"]
     typ = attrs["type"]
     return typedesc.Typedef(name, typ)