def interfaces(iface): interfaces = [] while iface.base: interfaces.append(iface) iface = iface.idl.getName(xpidl.TypeId(iface.base), iface.location) interfaces.append(iface) interfaces.reverse() return interfaces
def testAttribute(self): i = self.p.parse("""[uuid(abc)] interface foo { attribute long bar; };""", filename='f') self.assertTrue(isinstance(i, xpidl.IDL)) self.assertTrue(isinstance(i.productions[0], xpidl.Interface)) iface = i.productions[0] a = iface.members[0] self.assertTrue(isinstance(a, xpidl.Attribute)) self.assertEqual("bar", a.name) self.assertEqual(xpidl.TypeId("long"), a.type)
def testMethod(self): i = self.p.parse("""[uuid(abc)] interface foo { void bar(); };""", filename='f') self.assertTrue(isinstance(i, xpidl.IDL)) self.assertTrue(isinstance(i.productions[0], xpidl.Interface)) iface = i.productions[0] m = iface.members[0] self.assertTrue(isinstance(m, xpidl.Method)) self.assertEqual("bar", m.name) self.assertEqual(xpidl.TypeId("void"), m.type)
def testMethodParams(self): i = self.p.parse("""[uuid(abc)] interface foo { long bar(in long a, in float b, [array] in long c); };""", filename='f') i.resolve([], self.p, {}) self.assertTrue(isinstance(i, xpidl.IDL)) self.assertTrue(isinstance(i.productions[0], xpidl.Interface)) iface = i.productions[0] m = iface.members[0] self.assertTrue(isinstance(m, xpidl.Method)) self.assertEqual("bar", m.name) self.assertEqual(xpidl.TypeId("long"), m.type) self.assertEqual(3, len(m.params)) self.assertEqual(xpidl.TypeId("long"), m.params[0].type) self.assertEqual("in", m.params[0].paramtype) self.assertEqual(xpidl.TypeId("float"), m.params[1].type) self.assertEqual("in", m.params[1].paramtype) self.assertEqual(xpidl.TypeId("long"), m.params[2].type) self.assertEqual("in", m.params[2].paramtype) self.assertTrue(isinstance(m.params[2].realtype, xpidl.LegacyArray)) self.assertEqual("long", m.params[2].realtype.type.name)