static jint android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz,
                                               jbyteArray bArray,
                                               jint off, jint len)
{
    if (bArray == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }

    jsize bLen = env->GetArrayLength(bArray);
    if (off < 0 || off >= bLen || len < 0 || len > bLen || (off+len) > bLen) {
        doThrow(env, "java/lang/IndexOutOfBoundsException");
        return 0;
    }

    jbyte* b = env->GetByteArrayElements(bArray, NULL);
    ResXMLTree* osb = new ResXMLTree(b+off, len, true);
    env->ReleaseByteArrayElements(bArray, b, 0);

    if (osb == NULL || osb->getError() != NO_ERROR) {
        doThrow(env, "java/lang/IllegalArgumentException");
        return 0;
    }

    return (jint)osb;
}
static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
        jobject config, jobject native_window, jintArray attrib_list) {
    if (display == NULL || config == NULL
        || !validAttribList(_env, attrib_list)) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext cnf = getConfig(_env, config);
    Surface* window = 0;
    if (native_window == NULL) {
not_valid_surface:
        doThrow(_env, "java/lang/IllegalArgumentException",
                "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface");
        return 0;
    }
    window = (Surface*)_env->GetIntField(native_window, gSurface_SurfaceFieldID);
    if (window == NULL)
        goto not_valid_surface;

    jint* base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window, base);
    endNativeAttributeList(_env, attrib_list, base);
    return (jint)sur;
}
static void android_content_res_ObbScanner_getObbInfo(JNIEnv* env, jobject clazz, jstring file,
        jobject obbInfo)
{
    const char* filePath = env->GetStringUTFChars(file, JNI_FALSE);

    sp<ObbFile> obb = new ObbFile();
    if (!obb->readFrom(filePath)) {
        env->ReleaseStringUTFChars(file, filePath);
        doThrow(env, "java/io/IOException", "Could not read OBB file");
        return;
    }

    env->ReleaseStringUTFChars(file, filePath);

    const char* packageNameStr = obb->getPackageName().string();

    jstring packageName = env->NewStringUTF(packageNameStr);
    if (packageName == NULL) {
        doThrow(env, "java/io/IOException", "Could not read OBB file");
        return;
    }

    env->SetObjectField(obbInfo, gObbInfoClassInfo.packageName, packageName);
    env->SetIntField(obbInfo, gObbInfoClassInfo.version, obb->getVersion());
    env->SetIntField(obbInfo, gObbInfoClassInfo.flags, obb->getFlags());

    size_t saltLen;
    const unsigned char* salt = obb->getSalt(&saltLen);
    if (saltLen > 0) {
        jbyteArray saltArray = env->NewByteArray(saltLen);
        env->SetByteArrayRegion(saltArray, 0, saltLen, (jbyte*)salt);
        env->SetObjectField(obbInfo, gObbInfoClassInfo.salt, saltArray);
    }
}
예제 #4
0
    static int breakTextC(JNIEnv* env, jobject jpaint, jcharArray jtext,
            int index, int count, float maxWidth, jfloatArray jmeasuredWidth) {
        NPE_CHECK_RETURN_ZERO(env, jpaint);
        NPE_CHECK_RETURN_ZERO(env, jtext);

        SkPaint::TextBufferDirection tbd;
        if (count < 0) {
            tbd = SkPaint::kBackward_TextBufferDirection;
            count = -count;
        }
        else {
            tbd = SkPaint::kForward_TextBufferDirection;
        }

        if ((index < 0) || (index + count > env->GetArrayLength(jtext))) {
            doThrow(env, "java/lang/ArrayIndexOutOfBoundsException");
            return 0;
        }

        SkPaint*     paint = GraphicsJNI::getNativePaint(env, jpaint);
        const jchar* text = env->GetCharArrayElements(jtext, NULL);
        count = breakText(env, *paint, text + index, count, maxWidth,
                          jmeasuredWidth, tbd);
        env->ReleaseCharArrayElements(jtext, const_cast<jchar*>(text),
                                      JNI_ABORT);
        return count;
    }
static jint android_content_XmlBlock_nativeNext(JNIEnv* env, jobject clazz,
                                             jint token)
{
    ResXMLParser* st = (ResXMLParser*)token;
    if (st == NULL) {
        return ResXMLParser::END_DOCUMENT;
    }

    do {
        jint code = (jint)st->next();
        switch (code) {
            case ResXMLParser::START_TAG:
                return 2;
            case ResXMLParser::END_TAG:
                return 3;
            case ResXMLParser::TEXT:
                return 4;
            case ResXMLParser::START_DOCUMENT:
                return 0;
            case ResXMLParser::END_DOCUMENT:
                return 1;
            case ResXMLParser::BAD_DOCUMENT:
                goto bad;
        }
    } while (true);
    
bad:
    doThrow(env, "org/xmlpull/v1/XmlPullParserException",
            "Corrupt XML binary file");
    return ResXMLParser::BAD_DOCUMENT;
}
static jint android_content_XmlBlock_nativeGetAttributeIndex(JNIEnv* env, jobject clazz,
                                                             jint token,
                                                             jstring ns, jstring name)
{
    ResXMLParser* st = (ResXMLParser*)token;
    if (st == NULL || name == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }

    const char16_t* ns16 = NULL;
    jsize nsLen = 0;
    if (ns) {
        ns16 = env->GetStringChars(ns, NULL);
        nsLen = env->GetStringLength(ns);
    }
    
    const char16_t* name16 = env->GetStringChars(name, NULL);
    jsize nameLen = env->GetStringLength(name);

    jint idx = (jint)st->indexOfAttribute(ns16, nsLen, name16, nameLen);

    if (ns) {
        env->ReleaseStringChars(ns, ns16);
    }
    env->ReleaseStringChars(name, name16);

    return idx;
}
static jint jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) {
    if (!(readdraw == EGL_READ) || (readdraw == EGL_DRAW)) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return 0;
    }
    return (jint)eglGetCurrentSurface(readdraw);
}
static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
        jobjectArray configs, jint config_size, jintArray num_config) {
    if (display == NULL || (configs != NULL && _env->GetArrayLength(configs) < config_size)
        || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    jboolean success = JNI_FALSE;
    if (configs == NULL) {
        config_size = 0;
    }
    EGLConfig nativeConfigs[config_size];
    int num;
    success = eglGetConfigs(dpy, configs ? nativeConfigs : 0, config_size, &num);
    if (num_config != NULL) {
        _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num);
    }
    if (success && configs) {
        for (int i=0 ; i<num ; i++) {
            jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]);
            _env->SetObjectArrayElement(configs, i, obj);
        }
    }
    return success;
}
예제 #9
0
long double
AbortExpression::getLongDouble() const
{
    doThrow();
    //not reached.
    return 0;
}
예제 #10
0
long long
AbortExpression::getLongLong() const
{
    doThrow();
    //not reached.
    return 0;
}
예제 #11
0
bool                
AbortExpression::getBool() const
{
    doThrow();
    //not reached.
    return false;
}
예제 #12
0
char_ptr
AbortExpression::getCharPtr() const
{
    doThrow();
    //not reached.
    return operand_->getCharPtr();
}
예제 #13
0
const char *
AbortExpression::getRaw()
{
    doThrow();
    //not reached.
    return NULL;
}
예제 #14
0
bool                
AbortExpression::isNull() const
{
    doThrow();
    //not reached.
    return true;
}
static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) {
    if (display == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    return eglTerminate(dpy);
}
static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_sur,
        jobject display, jobject config, jobject native_pixmap,
        jintArray attrib_list)
{
    if (display == NULL || config == NULL || native_pixmap == NULL
        || !validAttribList(_env, attrib_list)) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLConfig  cnf = getConfig(_env, config);
    jint* base = 0;

    SkBitmap const * nativeBitmap =
            (SkBitmap const *)_env->GetIntField(native_pixmap,
                    gBitmap_NativeBitmapFieldID);
    SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0;
    if (ref == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException", "Bitmap has no PixelRef");
        return;
    }

    ref->safeRef();
    ref->lockPixels();

    egl_native_pixmap_t pixmap;
    pixmap.version = sizeof(pixmap);
    pixmap.width  = nativeBitmap->width();
    pixmap.height = nativeBitmap->height();
    pixmap.stride = nativeBitmap->rowBytes() / nativeBitmap->bytesPerPixel();
    pixmap.format = convertPixelFormat(nativeBitmap->config());
    pixmap.data   = (uint8_t*)ref->pixels();

    base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreatePixmapSurface(dpy, cnf, &pixmap, base);
    endNativeAttributeList(_env, attrib_list, base);

    if (sur != EGL_NO_SURFACE) {
        _env->SetIntField(out_sur, gSurface_EGLSurfaceFieldID, (int)sur);
        _env->SetIntField(out_sur, gSurface_NativePixelRefFieldID, (int)ref);
    } else {
        ref->unlockPixels();
        ref->safeUnref();
    }
}
void* callToThrow(ExecState* exec, Instruction* pc)
{
#if LLINT_SLOW_PATH_TRACING
    VM* vm = &exec->vm();
    dataLog("Throwing exception ", vm->exception(), " (callToThrow).\n");
#endif
    doThrow(exec, pc);
    return LLInt::getCodePtr(llint_throw_during_call_trampoline);
}
Instruction* returnToThrow(ExecState* exec, Instruction* pc)
{
#if LLINT_SLOW_PATH_TRACING
    VM* vm = &exec->vm();
    dataLog("Throwing exception ", vm->exception(), " (returnToThrow).\n");
#endif
    doThrow(exec, pc);
    return LLInt::exceptionInstructions();
}
static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) {
    if (display == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return NULL;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    const char* chars = eglQueryString(dpy, name);
    return _env->NewStringUTF(chars);
}
static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) {
    if (display == NULL || context == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext ctx = getContext(_env, context);
    return eglDestroyContext(dpy, ctx);
}
static jboolean jni_eglCopyBuffers(JNIEnv *_env, jobject _this, jobject display,
        jobject surface, jobject native_pixmap) {
    if (display == NULL || surface == NULL || native_pixmap == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    // TODO: Implement this
    return JNI_FALSE;
}
static jboolean jni_eglSwapBuffers(JNIEnv *_env, jobject _this, jobject display, jobject surface) {
    if (display == NULL || surface == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLSurface sur = getSurface(_env, surface);
    return eglSwapBuffers(dpy, sur);
}
예제 #23
0
static jint android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz,
                                                          jint token)
{
    ResXMLTree* osb = (ResXMLTree*)token;
    if (osb == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }

    ResXMLParser* st = new ResXMLParser(*osb);
    if (st == NULL) {
        doThrow(env, "java/lang/OutOfMemoryError");
        return 0;
    }

    st->restart();

    return (jint)st;
}
예제 #24
0
static jint android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz,
                                                       jint token)
{
    ResXMLTree* osb = (ResXMLTree*)token;
    if (osb == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }

    return (jint)&osb->getStrings();
}
예제 #25
0
static void android_content_XmlBlock_nativeDestroy(JNIEnv* env, jobject clazz,
                                                   jint token)
{
    ResXMLTree* osb = (ResXMLTree*)token;
    if (osb == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return;
    }

    delete osb;
}
예제 #26
0
static void android_content_XmlBlock_nativeDestroyParseState(JNIEnv* env, jobject clazz,
                                                          jint token)
{
    ResXMLParser* st = (ResXMLParser*)token;
    if (st == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return;
    }

    delete st;
}
예제 #27
0
static jint android_content_XmlBlock_nativeGetAttributeStringValue(JNIEnv* env, jobject clazz,
                                                                   jint token, jint idx)
{
    ResXMLParser* st = (ResXMLParser*)token;
    if (st == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }

    return (jint)st->getAttributeValueStringID(idx);
}
예제 #28
0
static jint android_content_XmlBlock_nativeGetLineNumber(JNIEnv* env, jobject clazz,
                                                         jint token)
{
    ResXMLParser* st = (ResXMLParser*)token;
    if (st == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }

    return (jint)st->getLineNumber();
}
static jboolean jni_eglMakeCurrent(JNIEnv *_env, jobject _this, jobject display, jobject draw, jobject read, jobject context) {
    if (display == NULL || draw == NULL || read == NULL || context == NULL) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLSurface sdr = getSurface(_env, draw);
    EGLSurface srd = getSurface(_env, read);
    EGLContext ctx = getContext(_env, context);
    return eglMakeCurrent(dpy, sdr, srd, ctx);
}
예제 #30
0
static jint android_content_XmlBlock_nativeGetClassAttribute(JNIEnv* env, jobject clazz,
                                                             jint token)
{
    ResXMLParser* st = (ResXMLParser*)token;
    if (st == NULL) {
        doThrow(env, "java/lang/NullPointerException");
        return 0;
    }
    
    ssize_t idx = st->indexOfClass();
    return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1;
}