Ejemplo n.º 1
0
    def __init__(self, intf, dict=None, inst=None):
        # Convert the interfaces
        actualIntf = _convertInterfaces([intf])

        # Verify that one of the options has been selected
        if dict is not None and inst is not None:
            raise RuntimeError("Specify only one of dict and inst")

        if dict is not None:
            # Define the lookup function based for a dict
            def lookup(d, name):
                return d[name]

            # create a proxy
            self.__javaproxy__ = _jpype.PyJPProxy(dict, lookup, actualIntf)
            return

        if inst is not None:
            # Define the lookup function based for a object instance
            def lookup(d, name):
                return getattr(d, name)

            # create a proxy
            self.__javaproxy__ = _jpype.PyJPProxy(inst, lookup, actualIntf)
            return
        raise TypeError("a dict or inst must be specified")
Ejemplo n.º 2
0
 def testProxyNoInterfaces(self):
     with self.assertRaises(TypeError):
         proxy = _jpype.PyJPProxy(None, None, tuple())
Ejemplo n.º 3
0
 def testProxyInitBad3(self):
     with self.assertRaises(TypeError):
         _jpype.PyJPProxy(None, None, tuple([None, None]))
Ejemplo n.º 4
0
 def testProxyInitBad2(self):
     with self.assertRaises(TypeError):
         _jpype.PyJPProxy(None, None, None)
Ejemplo n.º 5
0
 def init2(self, *args, **kwargs):
     self.__javaproxy__ = _jpype.PyJPProxy(self, lookup, actualIntf)