app/src/main/assets/python/app_packages/rubicon/java/api.py
def convert_args(args, type_names):
    """Convert a list of arguments to be in a format compliant with the JNI signature.
    This means:
     * casting primitives into the apprpriate jXXX ctypes objects,
     * Strings into Java string objects, and
     * JavaInstance/JavaProxy objects into their JNI references.
    """
    converted = []
    for type_name, arg in zip(type_names, args):
        if isinstance(arg, jboolean):
            converted.append(arg)
        elif isinstance(arg, bool):
            converted.append(jboolean(arg))
        elif isinstance(arg, jbyte):
            converted.append(arg)
        elif isinstance(arg, jchar):
            converted.append(arg)
        elif isinstance(arg, jshort):
            converted.append(arg)
        elif isinstance(arg, jint):
            converted.append(arg)
        elif isinstance(arg, int):
            if type_name == b'I':
                converted.append(jint(arg))
            elif type_name == b'J':
                converted.append(jlong(arg))
            elif type_name == b'S':
                converted.append(jshort(arg))
            else:
                raise ValueError("Unexpected type name for int argument.")
        elif isinstance(arg, jlong):
            converted.append(arg)
        elif isinstance(arg, jfloat):
            converted.append(jdouble(arg.value))
        elif isinstance(arg, float):
            # The JNI method uses VA_ARGS, and VA_ARGS transparently
            # converts floats to doubles; so regardless of whether the
            # argument is F or D, cast to jdouble.
            converted.append(jdouble(arg))
        elif isinstance(arg, jdouble):
            converted.append(arg)
        elif isinstance(arg, bytes):
            jarg = java.NewByteArray(len(arg))
            java.SetByteArrayRegion(jarg, 0, len(arg), (jbyte * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[Z':
            jarg = java.NewBooleanArray(len(arg))
            java.SetBooleanArrayRegion(jarg, 0, len(arg), (jboolean * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[I':
            jarg = java.NewIntArray(len(arg))
            java.SetIntArrayRegion(jarg, 0, len(arg), (jint * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[F':
            jarg = java.NewFloatArray(len(arg))
            java.SetFloatArrayRegion(jarg, 0, len(arg), (jfloat * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[D':
            jarg = java.NewDoubleArray(len(arg))
            java.SetDoubleArrayRegion(jarg, 0, len(arg), (jdouble * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, str):
            converted.append(java.NewStringUTF(arg.encode('utf-8')))
        elif isinstance(arg, (JavaInstance, JavaProxy)):
            converted.append(arg.__jni__)
        else:
            raise ValueError("Unknown argument type", arg, type(arg))

    return converted
Convert a list of arguments to be in a format compliant with the JNI signature.
    This means:
     * casting primitives into the apprpriate jXXX ctypes objects,
     * Strings into Java string objects, and
     * JavaInstance/JavaProxy objects into their JNI references.
    
Convert a list of arguments to be in a format compliant with the JNI signature.
This means:
casting primitives into the apprpriate jXXX ctypes objects,
Strings into Java string objects, and
JavaInstance/JavaProxy objects into their JNI references.
Convert a list of arguments to be in a format compliant with the JNI signature . This means : casting primitives into the apprpriate jXXX ctypes objects Strings into Java string objects and JavaInstance / JavaProxy objects into their JNI references .
def convert_args(args, type_names):
    converted = []
    for type_name, arg in zip(type_names, args):
        if isinstance(arg, jboolean):
            converted.append(arg)
        elif isinstance(arg, bool):
            converted.append(jboolean(arg))
        elif isinstance(arg, jbyte):
            converted.append(arg)
        elif isinstance(arg, jchar):
            converted.append(arg)
        elif isinstance(arg, jshort):
            converted.append(arg)
        elif isinstance(arg, jint):
            converted.append(arg)
        elif isinstance(arg, int):
            if type_name == b'I':
                converted.append(jint(arg))
            elif type_name == b'J':
                converted.append(jlong(arg))
            elif type_name == b'S':
                converted.append(jshort(arg))
            else:
                raise ValueError("Unexpected type name for int argument.")
        elif isinstance(arg, jlong):
            converted.append(arg)
        elif isinstance(arg, jfloat):
            converted.append(jdouble(arg.value))
        elif isinstance(arg, float):
            converted.append(jdouble(arg))
        elif isinstance(arg, jdouble):
            converted.append(arg)
        elif isinstance(arg, bytes):
            jarg = java.NewByteArray(len(arg))
            java.SetByteArrayRegion(jarg, 0, len(arg), (jbyte * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[Z':
            jarg = java.NewBooleanArray(len(arg))
            java.SetBooleanArrayRegion(jarg, 0, len(arg), (jboolean * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[I':
            jarg = java.NewIntArray(len(arg))
            java.SetIntArrayRegion(jarg, 0, len(arg), (jint * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[F':
            jarg = java.NewFloatArray(len(arg))
            java.SetFloatArrayRegion(jarg, 0, len(arg), (jfloat * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, Sequence) and type_name == b'[D':
            jarg = java.NewDoubleArray(len(arg))
            java.SetDoubleArrayRegion(jarg, 0, len(arg), (jdouble * len(arg))(*arg))
            converted.append(jarg)
        elif isinstance(arg, str):
            converted.append(java.NewStringUTF(arg.encode('utf-8')))
        elif isinstance(arg, (JavaInstance, JavaProxy)):
            converted.append(arg.__jni__)
        else:
            raise ValueError("Unknown argument type", arg, type(arg))
    return converted
def convert_args ( args , type_names ) : converted = [ ] for type_name , arg in zip ( type_names , args ) : if isinstance ( arg , jboolean ) : converted . append ( arg ) elif isinstance ( arg , bool ) : converted . append ( jboolean ( arg ) ) elif isinstance ( arg , jbyte ) : converted . append ( arg ) elif isinstance ( arg , jchar ) : converted . append ( arg ) elif isinstance ( arg , jshort ) : converted . append ( arg ) elif isinstance ( arg , jint ) : converted . append ( arg ) elif isinstance ( arg , int ) : if type_name == b'I' : converted . append ( jint ( arg ) ) elif type_name == b'J' : converted . append ( jlong ( arg ) ) elif type_name == b'S' : converted . append ( jshort ( arg ) ) else : raise ValueError ( "Unexpected type name for int argument." ) elif isinstance ( arg , jlong ) : converted . append ( arg ) elif isinstance ( arg , jfloat ) : converted . append ( jdouble ( arg . value ) ) elif isinstance ( arg , float ) : converted . append ( jdouble ( arg ) ) elif isinstance ( arg , jdouble ) : converted . append ( arg ) elif isinstance ( arg , bytes ) : jarg = java . NewByteArray ( len ( arg ) ) java . SetByteArrayRegion ( jarg , 0 , len ( arg ) , ( jbyte * len ( arg ) ) ( * arg ) ) converted . append ( jarg ) elif isinstance ( arg , Sequence ) and type_name == b'[Z' : jarg = java . NewBooleanArray ( len ( arg ) ) java . SetBooleanArrayRegion ( jarg , 0 , len ( arg ) , ( jboolean * len ( arg ) ) ( * arg ) ) converted . append ( jarg ) elif isinstance ( arg , Sequence ) and type_name == b'[I' : jarg = java . NewIntArray ( len ( arg ) ) java . SetIntArrayRegion ( jarg , 0 , len ( arg ) , ( jint * len ( arg ) ) ( * arg ) ) converted . append ( jarg ) elif isinstance ( arg , Sequence ) and type_name == b'[F' : jarg = java . NewFloatArray ( len ( arg ) ) java . SetFloatArrayRegion ( jarg , 0 , len ( arg ) , ( jfloat * len ( arg ) ) ( * arg ) ) converted . append ( jarg ) elif isinstance ( arg , Sequence ) and type_name == b'[D' : jarg = java . NewDoubleArray ( len ( arg ) ) java . SetDoubleArrayRegion ( jarg , 0 , len ( arg ) , ( jdouble * len ( arg ) ) ( * arg ) ) converted . append ( jarg ) elif isinstance ( arg , str ) : converted . append ( java . NewStringUTF ( arg . encode ( 'utf-8' ) ) ) elif isinstance ( arg , ( JavaInstance , JavaProxy ) ) : converted . append ( arg . __jni__ ) else : raise ValueError ( "Unknown argument type" , arg , type ( arg ) ) return converted
Convert a list of arguments to be in a format compliant with the JNI signature.
Convert a list of arguments to be in a format compliant with the JNI signature .
"""Convert a list of arguments to be in a format compliant with the JNI signature.
    This means:
     * casting primitives into the apprpriate jXXX ctypes objects,
     * Strings into Java string objects, and
     * JavaInstance/JavaProxy objects into their JNI references.
    """ # The JNI method uses VA_ARGS, and VA_ARGS transparently # converts floats to doubles; so regardless of whether the # argument is F or D, cast to jdouble.
args
type_names