def parse_attributes(class_value, doxygen_index): attributes = {} private_attributes = {} all_xml_attributes = { False: class_value.xpath( "sectiondef[@kind='public-attrib']/memberdef[@kind='variable']"), True: class_value.xpath( "sectiondef[@kind='public-static-attrib']/memberdef[@kind='variable']" ), } for is_static, xml_attributes in all_xml_attributes.items(): for xml_attribute in xml_attributes: attribute_name = get_content(xml_attribute.find("name")) # Ignore unions if attribute_name.startswith("@"): continue attribute_type = parse_real_type(xml_attribute, doxygen_index) attribute_desc = get_content( xml_attribute.find("briefdescription")) initializer = get_content_if(xml_attribute.find("initializer")) qualifiers = QualifiersModel(static=is_static) flags = parse_obidog_flags(xml_attribute) templated = False visibility = ItemVisibility(xml_attribute.attrib["prot"]) attribute_dest = attributes if visibility != ItemVisibility.Public: attribute_dest = private_attributes if xml_attribute.find("templateparamlist") is not None: templated = True definition = get_content(xml_attribute.find("definition")) identifier = parse_definition(definition)[1] if " " in identifier: identifier = identifier.split(" ")[0] namespace = "::".join(identifier.split("::")[:-2]) if not templated: attribute_dest[attribute_name] = AttributeModel( name=attribute_name, namespace=namespace, type=attribute_type, qualifiers=qualifiers, initializer=initializer, description=attribute_desc, flags=flags, location=parse_doxygen_location(xml_attribute), visibility=visibility, ) return attributes, private_attributes
def parse_global_from_xml(xml_global, doxygen_index): description = get_content(xml_global.find("detaileddescription")) if not description: description = get_content(xml_global.find("briefdescription")) CONFLICTS.append(get_content(xml_global.find("name")), xml_global) flags = parse_obidog_flags(xml_global) return GlobalModel( name=get_content(xml_global.find("name")), definition=get_content(xml_global.find("definition")), type=parse_real_type(xml_global, doxygen_index), initializer=get_content_if(xml_global.find("initializer")), flags=flags, location=parse_doxygen_location(xml_global), description=description, )
def parse_enum_from_xml(xml_enum): enum_name = get_content(xml_enum.find("name")) enum_description = get_content(xml_enum.find("briefdescription")) enum_values = [] for enum_value in xml_enum.xpath("enumvalue"): enum_values.append( EnumValueModel( name=get_content(enum_value.find("name")), description=get_content(enum_value.find("briefdescription")), ) ) CONFLICTS.append(enum_name, xml_enum) return EnumModel( name=enum_name, values=enum_values, flags=parse_obidog_flags(xml_enum), description=enum_description, location=parse_doxygen_location(xml_enum), )
def parse_typedef_from_xml(namespace_name, xml_typedef, doxygen_index): typedef_name = get_content(xml_typedef.find("name")) typedef_type = parse_real_type(xml_typedef, doxygen_index) typedef_type = rebuild_incomplete_type(typedef_type, namespace_name, doxygen_index) typedef_description = get_content_if( xml_typedef.find("briefdescription").find("para") ) typedef_definition = get_content(xml_typedef.find("definition")) CONFLICTS.append(typedef_name, xml_typedef) return TypedefModel( name=typedef_name, namespace=namespace_name, definition=typedef_definition, type=typedef_type, flags=parse_obidog_flags(xml_typedef), description=typedef_description, location=parse_doxygen_location(xml_typedef), )
def parse_class_from_xml(class_value, doxygen_index) -> ClassModel: nobind = False class_name = extract_xml_value(class_value, "compoundname") namespace_name, class_name = ( "::".join(class_name.split("::")[:-1:]), class_name.split("::")[-1], ) # Ignore template classes if class_value.xpath("templateparamlist"): nobind = True abstract = False if "abstract" in class_value.attrib and class_value.attrib[ "abstract"] == "yes": abstract = True # Fetching parents base_classes_id = [ item.attrib["refid"] for item in class_value.xpath( 'inheritancegraph/node[@id = 1]/childnode[@relation="public-inheritance"]' ) ] bases = [] if base_classes_id: for base_class_id in base_classes_id: base = class_value.xpath( f"inheritancegraph/node[@id = {base_class_id}]")[0] # TODO: resolve with refid first (for inner types) bases.append( rebuild_incomplete_type( get_content(base).strip(), f"{namespace_name}::{class_name}", doxygen_index, )) description = extract_xml_value(class_value, "briefdescription/para") methods, constructors, destructor, private_methods = parse_methods( class_name, class_value, doxygen_index) attributes, private_attributes = parse_attributes(class_value, doxygen_index) for attribute in list(attributes.values()) + list( private_attributes.values()): attribute.from_class = class_name flags = parse_obidog_flags(class_value, symbol_name="::".join( [namespace_name, class_name])) flags.nobind = flags.nobind or nobind CONFLICTS.append(class_name, class_value) class_model = ClassModel( name=class_name, namespace=namespace_name, abstract=abstract, bases=bases, attributes=attributes, constructors=constructors, destructor=destructor, methods=methods, private_methods=private_methods, private_attributes=private_attributes, flags=flags, description=description, location=parse_doxygen_location(class_value), ) if is_class_non_copyable(class_model): class_model.flags.meta.add(MetaTag.NonCopyable.value) return class_model