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 test_overridden_signatures(self):
        clsA = Class("ClsA")
        clsB = Class("ClsB")
        clsB.bases.append(clsA)

        methodA = Method("test")
        methodA.signatures.append(FunctionSignature())
        methodA.signatures[0].context = methodA
        methodA.signatures[0].virtual = True
        methodB = Method("test")
        methodB.signatures.append(FunctionSignature())
        methodB.signatures[0].context = methodB

        clsA.methods.append(methodA)
        methodA.context = clsA
        clsB.methods.append(methodB)
        methodB.context = clsB

        self.assertEqual(clsA.get_overridable_signatures(), [[methodA.signatures[0]]])
        self.assertEqual(clsB.get_overridable_signatures(), [])

        methodB.signatures[0].virtual = True
        self.assertEqual(clsB.get_overridable_signatures(), [[methodB.signatures[0]]])

        methodB.signatures[0].const = True
        self.assertEqual(clsB.get_overridable_signatures(), [[methodB.signatures[0], methodA.signatures[0]]])
Beispiel #3
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