예제 #1
0
 def visit_enum(self, en):
     return ch_basic.CHType(name=en.name,
                            namespace=en.namespace,
                            is_enum=True,
                            is_const=False,
                            ref_type=None,
                            header_with_def=en.header,
                            container_type=None)
예제 #2
0
 def visit_recursive_type(self, rt: generic.RecursiveType):
     return ch_basic.CHType(name=rt.name,
                            namespace=rt.namespace,
                            is_enum=False,
                            is_const=False,
                            ref_type=None,
                            header_with_def=None,
                            container_type=None,
                            alias=rt.original_typedef)
예제 #3
0
 def visit_primitive_type(self, pt: generic.PrimitiveType):
     return ch_basic.CHType(name=pt.name,
                            namespace=None,
                            is_enum=False,
                            is_const=False,
                            ref_type=None,
                            header_with_def=None,
                            container_type=None,
                            alias=pt.original_typedef)
예제 #4
0
    def visit_declared_class(self, dcc: generic.DeclaredClass):
        if dcc.template_args:
            fst_tmpl_arg = dcc.template_args[0]
            type_info = fst_tmpl_arg.accept_visitor(self)
            type_info.set_container(
                utils.create_full_container(dcc.name, dcc.namespace))
        else:
            type_info = ch_basic.CHType(name=dcc.name,
                                        namespace=dcc.namespace,
                                        is_enum=False,
                                        is_const=False,
                                        ref_type=None,
                                        header_with_def=dcc.header,
                                        container_type=None)

        if dcc.original_typedef:
            type_info.set_alias(dcc.original_typedef)

        return type_info
예제 #5
0
def get_type_info(input_type, tu, scf_path):
    base_type, reference_type = _get_pointed_type(input_type)
    base_type_node = base_type.get_declaration()
    is_const = base_type.is_const_qualified()

    if is_primitive(base_type):
        return _create_primitive_type(base_type, reference_type, is_const), None, None

    container, container_namespace = get_template_class(base_type_node)
    aliased_node = _resolve_typedefs(base_type_node)

    final_type, reference_type_new = _get_pointed_type(
        aliased_node.underlying_typedef_type if aliased_node.kind == CursorKind.TYPE_ALIAS_DECL
        else aliased_node.type
    )

    if is_primitive(final_type):
        return _create_primitive_type(final_type, reference_type if reference_type else reference_type_new, is_const),\
               None, None

    if container:
        template_arg_type = container.type.get_template_argument_type(0)
        if is_primitive(template_arg_type):
            return _create_primitive_type(template_arg_type, reference_type if reference_type else reference_type_new,
                                          is_const, create_full_container(container.spelling, container_namespace)),\
                   None, container
        ending_node = template_arg_type.get_declaration()
    else:
        ending_node = final_type.get_declaration()

    return (ch_basic.CHType(
        name=ending_node.spelling,
        namespace=get_namespace(ending_node),
        header_with_def=get_header(ending_node, tu, scf_path) if tu and scf_path else None,
        container_type=create_full_container(container.spelling if container else None, container_namespace),
        is_enum=ending_node.type.kind == TypeKind.ENUM,
        is_const=is_const,
        ref_type=reference_type if reference_type else reference_type_new
    ), ending_node, container)
예제 #6
0
def _create_primitive_type(resolved_type, reference_type, is_const, container=None):
    return ch_basic.CHType(
        name = get_primitive_type(resolved_type), namespace=None, container_type=container,
        is_const = is_const, ref_type=reference_type
    )