示例#1
0
文件: aura_rt_VM.c 项目: Zubnix/aura
CharArray* Java_aura_rt_VM_newCharArray(Env* env, Class* c, jlong address, jint size) {
    CharArray* array = rvmNewCharArray(env, size);
    if (array) {
        memcpy(array->values, LONG_TO_PTR(address), size * sizeof(jchar));
    }
    return array;
}
示例#2
0
文件: attribute.c 项目: Zubnix/aura
static jboolean parseArrayElementValue(Env* env, void** attributes, Class* arrayClass, Object* classLoader, jvalue* result) {
    jbyte tag = getByte(attributes);
    if (tag != '[') return throwFormatError(env, "Array");

    Class* componentType = arrayClass->componentType;

    jint length = getChar(attributes);
    Array* array = NULL;
    if (CLASS_IS_PRIMITIVE(componentType)) {
        switch (componentType->name[0]) {
        case 'Z':
            array = (Array*) rvmNewBooleanArray(env, length);
            break;
        case 'B':
            array = (Array*) rvmNewByteArray(env, length);
            break;
        case 'S':
            array = (Array*) rvmNewShortArray(env, length);
            break;
        case 'C':
            array = (Array*) rvmNewCharArray(env, length);
            break;
        case 'I':
            array = (Array*) rvmNewIntArray(env, length);
            break;
        case 'J':
            array = (Array*) rvmNewLongArray(env, length);
            break;
        case 'F':
            array = (Array*) rvmNewFloatArray(env, length);
            break;
        case 'D':
            array = (Array*) rvmNewDoubleArray(env, length);
            break;
        }
    } else {
        array = (Array*) rvmNewObjectArray(env, length, NULL, arrayClass, NULL);
    }
    if (!array) return FALSE;

    jint i = 0;
    for (i = 0; i < length; i++) {
        jvalue v;
        if (!parseElementValue(env, attributes, componentType, classLoader, &v)) return FALSE;
        if (CLASS_IS_PRIMITIVE(componentType)) {
            switch (componentType->name[0]) {
            case 'Z':
                ((BooleanArray*) array)->values[i] = v.z;
                break;
            case 'B':
                ((ByteArray*) array)->values[i] = v.b;
                break;
            case 'S':
                ((ShortArray*) array)->values[i] = v.s;
                break;
            case 'C':
                ((CharArray*) array)->values[i] = v.c;
                break;
            case 'I':
                ((IntArray*) array)->values[i] = v.i;
                break;
            case 'J':
                ((LongArray*) array)->values[i] = v.j;
                break;
            case 'F':
                ((FloatArray*) array)->values[i] = v.f;
                break;
            case 'D':
                ((DoubleArray*) array)->values[i] = v.d;
                break;
            }
        } else {
            ((ObjectArray*) array)->values[i] = (Object*) v.l;
        }
    }
    result->l = (jobject) array;
    return result->l ? TRUE : FALSE;
}
示例#3
0
文件: bc.c 项目: SinoJerk/robovm
CharArray* _bcNewCharArray(Env* env, jint length) {
    ENTER;
    CharArray* array = rvmNewCharArray(env, length);
    LEAVE(array);
}
示例#4
0
static jcharArray NewCharArray(JNIEnv* env, jsize len) {
    return (jcharArray) rvmNewCharArray((Env*) env, len);
}