app/src/main/assets/python/app_packages/rubicon/java/api.py
def dispatch(instance, method, args):
    """The mechanism by which Java can invoke methods in Python.
    This method should be invoked with an:
     * an ID for a Python object
     * a string representing a method name, and
     * a (void *) array of arguments. The arguments should be memory
       references to JNI objects.
    The ID is used to look up the instance from the cache of proxy instances
    that have been instantiated; Python method lookup is then used to invoke
    the appropriate method, and provide the arguments (after casting to
    valid Python objects).
    This method returns either `None` or a Python `int`. if the Python callable
    returns a Python `int. It can therefore be used to represent Java interface
    methods returning either `void` or `int` or `java.lang.Integer`.
    """
    val = None
    try:
        # print("PYTHON SIDE DISPATCH", instance, method, args)
        pyinstance = _proxy_cache[instance]
        signatures = pyinstance._methods.get(method)

        if len(signatures) == 1:
            signature = list(signatures)[0]
            if len(signature) != len(args):
                raise RuntimeError("argc provided for dispatch doesn't match registered method.")
            try:
                args = [
                    dispatch_cast(jarg, jtype)
                    for jarg, jtype in zip(args, signature)
                ]
                val = getattr(pyinstance, method)(*args)
            except Exception:
                import traceback
                traceback.print_exc()
        else:
            raise RuntimeError("Can't handle multiple prototypes for same method name (yet!)")
    except KeyError:
        raise RuntimeError("Unknown Python instance %d", instance)
    if isinstance(val, int):
        return val
The mechanism by which Java can invoke methods in Python.
    This method should be invoked with an:
     * an ID for a Python object
     * a string representing a method name, and
     * a (void *) array of arguments. The arguments should be memory
       references to JNI objects.
    The ID is used to look up the instance from the cache of proxy instances
    that have been instantiated; Python method lookup is then used to invoke
    the appropriate method, and provide the arguments (after casting to
    valid Python objects).
    This method returns either `None` or a Python `int`. if the Python callable
    returns a Python `int. It can therefore be used to represent Java interface
    methods returning either `void` or `int` or `java.lang.Integer`.
    
The mechanism by which Java can invoke methods in Python.
This method should be invoked with an:
an ID for a Python object
a string representing a method name, and
a (void *) array of arguments. The arguments should be memory
references to JNI objects.
The ID is used to look up the instance from the cache of proxy instances
that have been instantiated; Python method lookup is then used to invoke
the appropriate method, and provide the arguments (after casting to
valid Python objects).
This method returns either `None` or a Python `int`. if the Python callable
returns a Python `int.
The mechanism by which Java can invoke methods in Python . This method should be invoked with an : an ID for a Python object a string representing a method name and a ( void * ) array of arguments . The arguments should be memory references to JNI objects . The ID is used to look up the instance from the cache of proxy instances that have been instantiated ; Python method lookup is then used to invoke the appropriate method and provide the arguments ( after casting to valid Python objects ) . This method returns either ` None ` or a Python ` int ` . if the Python callable returns a Python ` int .
def dispatch(instance, method, args):
    val = None
    try:
        pyinstance = _proxy_cache[instance]
        signatures = pyinstance._methods.get(method)
        if len(signatures) == 1:
            signature = list(signatures)[0]
            if len(signature) != len(args):
                raise RuntimeError("argc provided for dispatch doesn't match registered method.")
            try:
                args = [
                    dispatch_cast(jarg, jtype)
                    for jarg, jtype in zip(args, signature)
                ]
                val = getattr(pyinstance, method)(*args)
            except Exception:
                import traceback
                traceback.print_exc()
        else:
            raise RuntimeError("Can't handle multiple prototypes for same method name (yet!)")
    except KeyError:
        raise RuntimeError("Unknown Python instance %d", instance)
    if isinstance(val, int):
        return val
def dispatch ( instance , method , args ) : val = None try : pyinstance = _proxy_cache [ instance ] signatures = pyinstance . _methods . get ( method ) if len ( signatures ) == 1 : signature = list ( signatures ) [ 0 ] if len ( signature ) != len ( args ) : raise RuntimeError ( "argc provided for dispatch doesn't match registered method." ) try : args = [ dispatch_cast ( jarg , jtype ) for jarg , jtype in zip ( args , signature ) ] val = getattr ( pyinstance , method ) ( * args ) except Exception : import traceback traceback . print_exc ( ) else : raise RuntimeError ( "Can't handle multiple prototypes for same method name (yet!)" ) except KeyError : raise RuntimeError ( "Unknown Python instance %d" , instance ) if isinstance ( val , int ) : return val
The mechanism by which Java can invoke methods in Python.
The mechanism by which Java can invoke methods in Python .
"""The mechanism by which Java can invoke methods in Python.
    This method should be invoked with an:
     * an ID for a Python object
     * a string representing a method name, and
     * a (void *) array of arguments. The arguments should be memory
       references to JNI objects.
    The ID is used to look up the instance from the cache of proxy instances
    that have been instantiated; Python method lookup is then used to invoke
    the appropriate method, and provide the arguments (after casting to
    valid Python objects).
    This method returns either `None` or a Python `int`. if the Python callable
    returns a Python `int. It can therefore be used to represent Java interface
    methods returning either `void` or `int` or `java.lang.Integer`.
    """ # print("PYTHON SIDE DISPATCH", instance, method, args)
instance
method
args