Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d61378ff authored by Elliott Hughes's avatar Elliott Hughes Committed by Android (Google) Code Review
Browse files

Merge "Kill the global references in the OpenGL wrappers."

parents 09a75f33 98757505
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ mkdir -p out/android/util
echo "package android.graphics;" > out/android/graphics/Canvas.java
echo "package android.graphics;" > out/android/graphics/Canvas.java
echo "public interface Canvas {}" >> out/android/graphics/Canvas.java
echo "public interface Canvas {}" >> out/android/graphics/Canvas.java


echo "package android.app; import android.content.pm.IPackageManager; public class ActivityThread { public static final ActivityThread currentActivityThread() { return null; } public static final String currentPackageName(){ return null; } public static IPackageManager getPackageManager() { return null;} }" > out/android/app/ActivityThread.java
echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java
# echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java
# echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java
echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java
echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java
echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java
echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java
+89 −117
Original line number Original line Diff line number Diff line
@@ -58,7 +58,7 @@ public class JniCodeEmitter {
        } else if (baseType.equals("void")) {
        } else if (baseType.equals("void")) {
            // nothing.
            // nothing.
        } else {
        } else {
            throw new RuntimeException("Uknown primitive basetype " + baseType);
            throw new RuntimeException("Unknown primitive basetype " + baseType);
        }
        }
        return jniName;
        return jniName;
    }
    }
@@ -200,15 +200,9 @@ public class JniCodeEmitter {
                if (emitExceptionCheck) {
                if (emitExceptionCheck) {
                    out.println(iii + indent + "_exception = 1;");
                    out.println(iii + indent + "_exception = 1;");
                }
                }
                out.println(iii + indent +
                out.println(iii + indent + "jniThrowException(_env, " +
                            (mUseCPlusPlus ? "_env" : "(*_env)") +
                        "\"java/lang/IllegalArgumentException\", " +
                            "->ThrowNew(" +
                        "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < needed\");");
                            (mUseCPlusPlus ? "" : "_env, ") +
                            "IAEClass, " +
                            "\"" +
                            (isBuffer ?
                             "remaining()" : "length - " + offset) +
                            " < needed\");");
                out.println(iii + indent + "goto exit;");
                out.println(iii + indent + "goto exit;");
                needsExit = true;
                needsExit = true;
                out.println(iii + "}");
                out.println(iii + "}");
@@ -350,30 +344,26 @@ public class JniCodeEmitter {
                        index += 3;
                        index += 3;
                        continue;
                        continue;
                    }
                    }
                            out.println(iii + "if (" + remaining + " < " +
                    out.println(iii + "if (" + remaining + " < " + checks[index + 2] + ") {");
                                        checks[index + 2] +
                                        ") {");
                    if (emitExceptionCheck) {
                    if (emitExceptionCheck) {
                        out.println(iii + indent + "_exception = 1;");
                        out.println(iii + indent + "_exception = 1;");
                    }
                    }
                    String exceptionClassName = "IAEClass";
                    String exceptionClassName = "java/lang/IllegalArgumentException";
                    // If the "check" keyword was of the form
                    // If the "check" keyword was of the form
                    // "check_<class name>", use the class name in the
                    // "check_<class name>", use the class name in the
                    // exception to be thrown
                    // exception to be thrown
                    int underscore = checks[index].indexOf('_');
                    int underscore = checks[index].indexOf('_');
                    if (underscore >= 0) {
                    if (underscore >= 0) {
                    exceptionClassName = checks[index].substring(underscore + 1) + "Class";
                        String abbr = checks[index].substring(underscore + 1);
                        if (abbr.equals("AIOOBE")) {
                            exceptionClassName = "java/lang/ArrayIndexOutOfBoundsException";
                        } else {
                            throw new RuntimeException("unknown exception abbreviation: " + abbr);
                        }
                        }
                            out.println(iii + indent +
                    }
                                        (mUseCPlusPlus ? "_env" : "(*_env)") +
                    out.println(iii + indent + "jniThrowException(_env, " +
                                        "->ThrowNew(" +
                            "\"" + exceptionClassName + "\", " +
                                        (mUseCPlusPlus ? "" : "_env, ") +
                            "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < " + checks[index + 2] + "\");");
                        exceptionClassName + ", " +
                                        "\"" +
                                        (isBuffer ?
                                         "remaining()" : "length - " + offset) +
                                        " < " + checks[index + 2] +
                                        "\");");


                    out.println(iii + indent + "goto exit;");
                    out.println(iii + indent + "goto exit;");
                    needsExit = true;
                    needsExit = true;
@@ -385,26 +375,16 @@ public class JniCodeEmitter {


                    if (!lastWasIfcheck) {
                    if (!lastWasIfcheck) {
                        out.println(iii + "int _needed;");
                        out.println(iii + "int _needed;");
                                out.println(iii +
                        out.println(iii + "switch (" + checks[index + 3] + ") {");
                                            "switch (" +
                                            checks[index + 3] +
                                            ") {");
                    }
                    }


                    for (int i = 0; i < matches.length; i++) {
                    for (int i = 0; i < matches.length; i++) {
                        out.println("#if defined(" + matches[i] + ")");
                        out.println("#if defined(" + matches[i] + ")");
                                out.println(iii +
                        out.println(iii + "    case " + matches[i] + ":");
                                            "    case " +
                                            matches[i] +
                                            ":");
                        out.println("#endif // defined(" + matches[i] + ")");
                        out.println("#endif // defined(" + matches[i] + ")");
                    }
                    }
                            out.println(iii +
                    out.println(iii + "        _needed = " + checks[index + 2] + ";");
                                        "        _needed = " +
                    out.println(iii + "        break;");
                                        checks[index + 2] +
                                        ";");
                            out.println(iii +
                                        "        break;");


                    lastWasIfcheck = true;
                    lastWasIfcheck = true;
                    index += 5;
                    index += 5;
@@ -421,8 +401,7 @@ public class JniCodeEmitter {
                    // ignore
                    // ignore
                    index += 1;
                    index += 1;
                } else {
                } else {
                            System.out.println("Error: unknown keyword \"" +
                    System.out.println("Error: unknown keyword \"" + checks[index] + "\"");
                                               checks[index] + "\"");
                    System.exit(0);
                    System.exit(0);
                }
                }
            }
            }
@@ -817,7 +796,7 @@ public class JniCodeEmitter {
        boolean isUnsupported = isUnsupportedFunc(cfunc);
        boolean isUnsupported = isUnsupportedFunc(cfunc);
        if (isUnsupported) {
        if (isUnsupported) {
            out.println(indent +
            out.println(indent +
                        "_env->ThrowNew(UOEClass,");
                        "jniThrowException(_env, \"java/lang/UnsupportedOperationException\",");
            out.println(indent +
            out.println(indent +
                        "    \"" + cfunc.getName() + "\");");
                        "    \"" + cfunc.getName() + "\");");
            if (!isVoid) {
            if (!isVoid) {
@@ -834,7 +813,7 @@ public class JniCodeEmitter {
            out.println(indent +
            out.println(indent +
                        "if (! supportsExtension(_env, _this, have_" + requiresExtension + "ID)) {");
                        "if (! supportsExtension(_env, _this, have_" + requiresExtension + "ID)) {");
            out.println(indent + indent +
            out.println(indent + indent +
                        "_env->ThrowNew(UOEClass,");
                        "jniThrowException(_env, \"java/lang/UnsupportedOperationException\",");
            out.println(indent + indent +
            out.println(indent + indent +
                        "    \"" + cfunc.getName() + "\");");
                        "    \"" + cfunc.getName() + "\");");
            if (isVoid) {
            if (isVoid) {
@@ -945,7 +924,8 @@ public class JniCodeEmitter {
                CType type = cfunc.getArgType(jfunc.getArgCIndex(idx));
                CType type = cfunc.getArgType(jfunc.getArgCIndex(idx));
                String decl = type.getDeclaration();
                String decl = type.getDeclaration();
                out.println(indent + "if (!" + cname + ") {");
                out.println(indent + "if (!" + cname + ") {");
                out.println(indent + "    _env->ThrowNew(IAEClass, \"" + cname + " == null\");");
                out.println(indent + "    jniThrowException(_env, " +
                        "\"java/lang/IllegalArgumentException\", \"" + cname + " == null\");");
                out.println(indent + "    goto exit;");
                out.println(indent + "    goto exit;");
                needsExit = true;
                needsExit = true;
                out.println(indent + "}");
                out.println(indent + "}");
@@ -978,13 +958,9 @@ public class JniCodeEmitter {
                    if (emitExceptionCheck) {
                    if (emitExceptionCheck) {
                        out.println(indent + indent + "_exception = 1;");
                        out.println(indent + indent + "_exception = 1;");
                    }
                    }
                    out.println(indent + "    " +
                    out.println(indent + "    jniThrowException(_env, " +
                                (mUseCPlusPlus ? "_env" : "(*_env)") +
                            "\"java/lang/IllegalArgumentException\", " +
                                "->ThrowNew(" +
                            "\"" + cname + " == null\");");
                                (mUseCPlusPlus ? "" : "_env, ") +
                                "IAEClass, " +
                                "\"" + cname +
                                " == null\");");
                    out.println(indent + "    goto exit;");
                    out.println(indent + "    goto exit;");
                    needsExit = true;
                    needsExit = true;
                    out.println(indent + "}");
                    out.println(indent + "}");
@@ -993,12 +969,8 @@ public class JniCodeEmitter {
                    if (emitExceptionCheck) {
                    if (emitExceptionCheck) {
                        out.println(indent + indent + "_exception = 1;");
                        out.println(indent + indent + "_exception = 1;");
                    }
                    }
                    out.println(indent + "    " +
                    out.println(indent + "    jniThrowException(_env, " +
                                (mUseCPlusPlus ? "_env" : "(*_env)") +
                            "\"java/lang/IllegalArgumentException\", \"" + offset + " < 0\");");
                                "->ThrowNew(" +
                                (mUseCPlusPlus ? "" : "_env, ") +
                                "IAEClass, " +
                                "\"" + offset + " < 0\");");
                    out.println(indent + "    goto exit;");
                    out.println(indent + "    goto exit;");
                    needsExit = true;
                    needsExit = true;
                    out.println(indent + "}");
                    out.println(indent + "}");
+13 −36
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


// This source file is automatically generated
// This source file is automatically generated


#include "jni.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
#include <utils/misc.h>


@@ -27,10 +29,6 @@ static int initialized = 0;


static jclass nioAccessClass;
static jclass nioAccessClass;
static jclass bufferClass;
static jclass bufferClass;
static jclass OOMEClass;
static jclass UOEClass;
static jclass IAEClass;
static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
static jmethodID getBaseArrayOffsetID;
@@ -41,7 +39,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
/* Cache method IDs each time the class is loaded. */


static void
static void
nativeClassInitBuffer(JNIEnv *_env)
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
{
    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -63,26 +61,6 @@ nativeClassInitBuffer(JNIEnv *_env)
}
}




static void
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
    nativeClassInitBuffer(_env);

    jclass IAEClassLocal =
        _env->FindClass("java/lang/IllegalArgumentException");
    jclass OOMEClassLocal =
         _env->FindClass("java/lang/OutOfMemoryError");
    jclass UOEClassLocal =
         _env->FindClass("java/lang/UnsupportedOperationException");
    jclass AIOOBEClassLocal =
         _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");

    IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
    OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
    UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
    AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
}

static void *
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
{
@@ -122,4 +100,3 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
}
}


// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
+15 −37
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


// This source file is automatically generated
// This source file is automatically generated


#include "jni.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
#include <utils/misc.h>


@@ -40,10 +42,6 @@ static int initialized = 0;


static jclass nioAccessClass;
static jclass nioAccessClass;
static jclass bufferClass;
static jclass bufferClass;
static jclass OOMEClass;
static jclass UOEClass;
static jclass IAEClass;
static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
static jmethodID getBaseArrayOffsetID;
@@ -54,7 +52,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
/* Cache method IDs each time the class is loaded. */


static void
static void
nativeClassInitBuffer(JNIEnv *_env)
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
{
    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -75,26 +73,6 @@ nativeClassInitBuffer(JNIEnv *_env)
        _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
        _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
}
}


static void
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
    nativeClassInitBuffer(_env);

    jclass IAEClassLocal =
        _env->FindClass("java/lang/IllegalArgumentException");
    jclass OOMEClassLocal =
         _env->FindClass("java/lang/OutOfMemoryError");
    jclass UOEClassLocal =
         _env->FindClass("java/lang/UnsupportedOperationException");
    jclass AIOOBEClassLocal =
         _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");

    IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
    OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
    UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
    AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
}

static void *
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
{
@@ -140,7 +118,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
        buf += position << elementSizeShift;
        buf += position << elementSizeShift;
    } else {
    } else {
        _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
        jniThrowException(_env, "java/lang/IllegalArgumentException",
                          "Must use a native order direct Buffer");
    }
    }
    return (void*) buf;
    return (void*) buf;
}
}
@@ -153,4 +132,3 @@ getNumCompressedTextureFormats() {
}
}


// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
+15 −37
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


// This source file is automatically generated
// This source file is automatically generated


#include "jni.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
#include <utils/misc.h>


@@ -36,10 +38,6 @@ static int initialized = 0;


static jclass nioAccessClass;
static jclass nioAccessClass;
static jclass bufferClass;
static jclass bufferClass;
static jclass OOMEClass;
static jclass UOEClass;
static jclass IAEClass;
static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
static jmethodID getBaseArrayOffsetID;
@@ -50,7 +48,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
/* Cache method IDs each time the class is loaded. */


static void
static void
nativeClassInitBuffer(JNIEnv *_env)
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
{
    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
    jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
    nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -72,26 +70,6 @@ nativeClassInitBuffer(JNIEnv *_env)
}
}




static void
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
    nativeClassInitBuffer(_env);

    jclass IAEClassLocal =
        _env->FindClass("java/lang/IllegalArgumentException");
    jclass OOMEClassLocal =
         _env->FindClass("java/lang/OutOfMemoryError");
    jclass UOEClassLocal =
         _env->FindClass("java/lang/UnsupportedOperationException");
    jclass AIOOBEClassLocal =
         _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");

    IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
    OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
    UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
    AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
}

static void *
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
{
@@ -138,9 +116,9 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
        jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
        buf += position << elementSizeShift;
        buf += position << elementSizeShift;
    } else {
    } else {
        _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
        jniThrowException(_env, "java/lang/IllegalArgumentException",
                          "Must use a native order direct Buffer");
    }
    }
    return (void*) buf;
    return (void*) buf;
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
Loading