Example #1
0
    def _process_variable(
            self,
            c: Cursor,
            parent: AnyCxxSymbol,
            store_global: bool,
            warn_failed: bool = True) -> (str, Optional[Variable]):
        type = c.type.get_named_type(
        ).spelling  # todo: use self.qualified_name or replace it .
        if not type:
            type = c.type.spelling

        var = Variable(
            name=c.spelling,
            parent=parent,
            location=location_from_cursor(c),
            type=type,
            const=is_const_type(type),
            brief_comment=c.brief_comment,
            access=c.access_specifier.name.lower(),
        )
        literal, value = self._parse_literal_cursor(c, warn_failed)
        var.literal = literal
        var.value = value
        if store_global:
            self.objects[var.full_name] = var
        return var
Example #2
0
 def _process_variable(self,
                       c: Cursor,
                       parent: AnyCxxSymbol,
                       store_global: bool,
                       warn_failed: bool = True) -> (str, Optional[Variable]):
     type = c.type.spelling
     var = Variable(
         name=c.spelling,
         parent=parent,
         location=location_from_cursor(c),
         type=type,
         const=is_const_type(type),
         brief_comment=c.brief_comment,
     )
     literal, value = self._parse_literal_cursor(c, warn_failed)
     var.literal = literal
     var.value = value
     if store_global:
         self.objects[var.full_name] = var
     return var
Example #3
0
 def _process_function(self, c: Cursor, parent: Namespace, store_global: bool):
     func = Function(
         name=c.spelling,
         parent=parent,
         location=location_from_cursor(c),
         ret_type=c.result_type.spelling,
         args=[
             Variable(name=ac.spelling, type=ac.type.spelling)
             for ac in c.get_arguments()
         ],
         brief_comment=c.brief_comment,
     )
     if store_global:
         self.objects[func.full_name] = func
     return func
Example #4
0
def function_pointer_type_info(t: str) -> Function:
    m = _FUNCTION_POINTER_RE.match(t)
    if m:
        ret_type = m.group(1)
        calling_convention = m.group(2)
        args_str = m.group(4)

        func = Function(name=m.group(3),
                        ret_type=ret_type,
                        calling_convention=calling_convention
                        if calling_convention else None)
        func.args = [
            Variable(name='', type=arg.strip(), parent=func)
            for arg in args_str.split(',')
        ]
        return func
Example #5
0
 def _process_enum(self, c: Cursor, parent: AnyCxxSymbol, store_global: bool):
     e = Enum(name=c.spelling,
              parent=parent,
              location=location_from_cursor(c),
              type=c.enum_type.spelling,
              is_strong_typed=c.is_scoped_enum(),
              brief_comment=c.brief_comment,
              )
     for i in list(c.get_children()):
         e.variables[i.spelling] = Variable(
             parent=e,
             name=i.spelling,
             location=location_from_cursor(i),
             type=e.name,
             value=i.enum_value,
             brief_comment=c.brief_comment,
         )
     if store_global:
         self.objects[e.full_name] = e
     return e