Beispiel #1
0
    def test_full_name(self):
        root = Namespace()
        child = root.get_child("A::B")
        cls = Class("ClsA")
        cls.context = child

        self.assertEqual(cls.get_full_name(), "A::B::ClsA")
        self.assertEqual(cls.get_full_name("_"), "A_B_ClsA")
Beispiel #2
0
    def parse_class(self, xml_node):
        ctx = xml_node.find('Context')
        cls = Class(xml_node.get('name'))
        cls.context = self.parse_context(ctx)
        cls.location = self.parse_source_location(ctx)
        cls.access = AccessSpecifier.from_string(xml_node.get('access'))
        cls.bases = [i.get('id') for i in xml_node.findall('Base')]
        cls.dynamic = xml_node.get('dynamic') == '1'

        cls.members = [self.parse_member(i) for i in xml_node.findall('Field')]

        methods = defaultdict(list)
        for i in xml_node.findall('Method'):
            sig = self.parse_function_signature(i)
            if sig.constructor:
                sig.context = cls
                cls.constructors.append(sig)
            elif sig.destructor:
                sig.context = cls
                cls.destructor = sig
            else:
                methods[i.get('name')].append(sig)

        cls.methods = []
        for name, signatures in methods.items():
            method = Method(name, signatures, cls)
            for sig in signatures:
                sig.context = method
            cls.methods.append(method)
        cls.determine_abstractness()

        for child_node in xml_node.findall('Class'):
            self.parse_class(child_node)
        for child_node in xml_node.findall('Enum'):
            self.parse_enumeration(child_node)

        self.nodes[xml_node.get('id')] = cls
        self.classes.append(cls)
        return cls