diff options
Diffstat (limited to 'opengl')
26 files changed, 401 insertions, 578 deletions
diff --git a/opengl/java/android/opengl/GLES10.java b/opengl/java/android/opengl/GLES10.java index 7c0f94953f03..790acbd3395e 100644 --- a/opengl/java/android/opengl/GLES10.java +++ b/opengl/java/android/opengl/GLES10.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES10Ext.java b/opengl/java/android/opengl/GLES10Ext.java index 116ab9dfa574..81fc59e08911 100644 --- a/opengl/java/android/opengl/GLES10Ext.java +++ b/opengl/java/android/opengl/GLES10Ext.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES11.java b/opengl/java/android/opengl/GLES11.java index b24c043e579d..1ca179b573be 100644 --- a/opengl/java/android/opengl/GLES11.java +++ b/opengl/java/android/opengl/GLES11.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES11Ext.java b/opengl/java/android/opengl/GLES11Ext.java index a9a7a22432b7..25d54674ca03 100644 --- a/opengl/java/android/opengl/GLES11Ext.java +++ b/opengl/java/android/opengl/GLES11Ext.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES20.java b/opengl/java/android/opengl/GLES20.java index 700164b6d7e7..635f811e72f6 100644 --- a/opengl/java/android/opengl/GLES20.java +++ b/opengl/java/android/opengl/GLES20.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/com/google/android/gles_jni/GLImpl.java b/opengl/java/com/google/android/gles_jni/GLImpl.java index 50f67601f9b5..090c0cb7c1d9 100644 --- a/opengl/java/com/google/android/gles_jni/GLImpl.java +++ b/opengl/java/com/google/android/gles_jni/GLImpl.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/com/google/android/gles_jni/GLImpl.java +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL.java b/opengl/java/javax/microedition/khronos/opengles/GL.java index d5b60c64413b..3b78f3d2ce7d 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL.java +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ package javax.microedition.khronos.opengles; diff --git a/opengl/java/javax/microedition/khronos/opengles/GL10.java b/opengl/java/javax/microedition/khronos/opengles/GL10.java index f48ecde02d88..4fcfb5206da1 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL10.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL10.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL10.java +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java b/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java index f3252ab0dd64..562b20ad4d75 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL10Ext.java +** +** Copyright 2007, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL11.java b/opengl/java/javax/microedition/khronos/opengles/GL11.java index 943a5be47426..3ba110ccec48 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL11.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL11.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL11.java +** +** Copyright 2006, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java b/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java index 842db7ab7edd..459a1abafe0c 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL11Ext.java +** +** Copyright 2007, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java b/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java index 97d5fd82e764..933c91ef4965 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL11ExtensionPack.java +** +** Copyright 2007, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ // This source file is automatically generated diff --git a/opengl/tools/glgen/gen b/opengl/tools/glgen/gen index 6c1a2318536b..31f41906ff25 100755 --- a/opengl/tools/glgen/gen +++ b/opengl/tools/glgen/gen @@ -21,7 +21,7 @@ mkdir -p out/android/util echo "package android.graphics;" > 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.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 diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java index 9d8c5a061698..9fa2b7418cca 100644 --- a/opengl/tools/glgen/src/JniCodeEmitter.java +++ b/opengl/tools/glgen/src/JniCodeEmitter.java @@ -58,7 +58,7 @@ public class JniCodeEmitter { } else if (baseType.equals("void")) { // nothing. } else { - throw new RuntimeException("Uknown primitive basetype " + baseType); + throw new RuntimeException("Unknown primitive basetype " + baseType); } return jniName; } @@ -200,15 +200,9 @@ public class JniCodeEmitter { if (emitExceptionCheck) { out.println(iii + indent + "_exception = 1;"); } - out.println(iii + indent + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - "IAEClass, " + - "\"" + - (isBuffer ? - "remaining()" : "length - " + offset) + - " < needed\");"); + out.println(iii + indent + "jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", " + + "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < needed\");"); out.println(iii + indent + "goto exit;"); needsExit = true; out.println(iii + "}"); @@ -302,7 +296,7 @@ public class JniCodeEmitter { } return false; } - + String isRequiresFunc(CFunc cfunc) { String[] checks = mChecker.getChecks(cfunc.getName()); int index = 1; @@ -329,109 +323,94 @@ public class JniCodeEmitter { } return null; } - + void emitNativeBoundsChecks(CFunc cfunc, String cname, PrintStream out, boolean isBuffer, boolean emitExceptionCheck, String offset, String remaining, String iii) { - String[] checks = mChecker.getChecks(cfunc.getName()); - - boolean lastWasIfcheck = false; - - int index = 1; - if (checks != null) { - while (index < checks.length) { - if (checks[index].startsWith("check")) { - if (lastWasIfcheck) { - printIfcheckPostamble(out, isBuffer, emitExceptionCheck, - offset, remaining, iii); - } - lastWasIfcheck = false; - if (cname != null && !cname.equals(checks[index + 1])) { - index += 3; - continue; - } - out.println(iii + "if (" + remaining + " < " + - checks[index + 2] + - ") {"); - if (emitExceptionCheck) { - out.println(iii + indent + "_exception = 1;"); - } - String exceptionClassName = "IAEClass"; + String[] checks = mChecker.getChecks(cfunc.getName()); + + boolean lastWasIfcheck = false; + + int index = 1; + if (checks != null) { + while (index < checks.length) { + if (checks[index].startsWith("check")) { + if (lastWasIfcheck) { + printIfcheckPostamble(out, isBuffer, emitExceptionCheck, + offset, remaining, iii); + } + lastWasIfcheck = false; + if (cname != null && !cname.equals(checks[index + 1])) { + index += 3; + continue; + } + out.println(iii + "if (" + remaining + " < " + checks[index + 2] + ") {"); + if (emitExceptionCheck) { + out.println(iii + indent + "_exception = 1;"); + } + String exceptionClassName = "java/lang/IllegalArgumentException"; // If the "check" keyword was of the form // "check_<class name>", use the class name in the // exception to be thrown int underscore = checks[index].indexOf('_'); if (underscore >= 0) { - exceptionClassName = checks[index].substring(underscore + 1) + "Class"; - } - out.println(iii + indent + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - exceptionClassName + ", " + - "\"" + - (isBuffer ? - "remaining()" : "length - " + offset) + - " < " + checks[index + 2] + - "\");"); - - out.println(iii + indent + "goto exit;"); - needsExit = true; - out.println(iii + "}"); - - index += 3; - } else if (checks[index].equals("ifcheck")) { - String[] matches = checks[index + 4].split(","); - - if (!lastWasIfcheck) { - out.println(iii + "int _needed;"); - out.println(iii + - "switch (" + - checks[index + 3] + - ") {"); - } - - for (int i = 0; i < matches.length; i++) { - out.println("#if defined(" + matches[i] + ")"); - out.println(iii + - " case " + - matches[i] + - ":"); - out.println("#endif // defined(" + matches[i] + ")"); - } - out.println(iii + - " _needed = " + - checks[index + 2] + - ";"); - out.println(iii + - " break;"); - - lastWasIfcheck = true; - index += 5; - } else if (checks[index].equals("return")) { - // ignore - index += 2; - } else if (checks[index].equals("unsupported")) { - // ignore - index += 1; - } else if (checks[index].equals("requires")) { - // ignore - index += 2; - } else if (checks[index].equals("nullAllowed")) { - // ignore - index += 1; + String abbr = checks[index].substring(underscore + 1); + if (abbr.equals("AIOOBE")) { + exceptionClassName = "java/lang/ArrayIndexOutOfBoundsException"; } else { - System.out.println("Error: unknown keyword \"" + - checks[index] + "\""); - System.exit(0); + throw new RuntimeException("unknown exception abbreviation: " + abbr); } } - } + out.println(iii + indent + "jniThrowException(_env, " + + "\"" + exceptionClassName + "\", " + + "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < " + checks[index + 2] + "\");"); + + out.println(iii + indent + "goto exit;"); + needsExit = true; + out.println(iii + "}"); + + index += 3; + } else if (checks[index].equals("ifcheck")) { + String[] matches = checks[index + 4].split(","); + + if (!lastWasIfcheck) { + out.println(iii + "int _needed;"); + out.println(iii + "switch (" + checks[index + 3] + ") {"); + } + + for (int i = 0; i < matches.length; i++) { + out.println("#if defined(" + matches[i] + ")"); + out.println(iii + " case " + matches[i] + ":"); + out.println("#endif // defined(" + matches[i] + ")"); + } + out.println(iii + " _needed = " + checks[index + 2] + ";"); + out.println(iii + " break;"); - if (lastWasIfcheck) { - printIfcheckPostamble(out, isBuffer, emitExceptionCheck, iii); + lastWasIfcheck = true; + index += 5; + } else if (checks[index].equals("return")) { + // ignore + index += 2; + } else if (checks[index].equals("unsupported")) { + // ignore + index += 1; + } else if (checks[index].equals("requires")) { + // ignore + index += 2; + } else if (checks[index].equals("nullAllowed")) { + // ignore + index += 1; + } else { + System.out.println("Error: unknown keyword \"" + checks[index] + "\""); + System.exit(0); } } + } + + if (lastWasIfcheck) { + printIfcheckPostamble(out, isBuffer, emitExceptionCheck, iii); + } + } boolean hasNonConstArg(JFunc jfunc, CFunc cfunc, List<Integer> nonPrimitiveArgs) { if (nonPrimitiveArgs.size() > 0) { @@ -817,7 +796,7 @@ public class JniCodeEmitter { boolean isUnsupported = isUnsupportedFunc(cfunc); if (isUnsupported) { out.println(indent + - "_env->ThrowNew(UOEClass,"); + "jniThrowException(_env, \"java/lang/UnsupportedOperationException\","); out.println(indent + " \"" + cfunc.getName() + "\");"); if (!isVoid) { @@ -828,13 +807,13 @@ public class JniCodeEmitter { out.println(); return; } - + String requiresExtension = isRequiresFunc(cfunc); if (requiresExtension != null) { out.println(indent + "if (! supportsExtension(_env, _this, have_" + requiresExtension + "ID)) {"); out.println(indent + indent + - "_env->ThrowNew(UOEClass,"); + "jniThrowException(_env, \"java/lang/UnsupportedOperationException\","); out.println(indent + indent + " \"" + cfunc.getName() + "\");"); if (isVoid) { @@ -945,7 +924,8 @@ public class JniCodeEmitter { CType type = cfunc.getArgType(jfunc.getArgCIndex(idx)); String decl = type.getDeclaration(); 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;"); needsExit = true; out.println(indent + "}"); @@ -978,13 +958,9 @@ public class JniCodeEmitter { if (emitExceptionCheck) { out.println(indent + indent + "_exception = 1;"); } - out.println(indent + " " + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - "IAEClass, " + - "\"" + cname + - " == null\");"); + out.println(indent + " jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", " + + "\"" + cname + " == null\");"); out.println(indent + " goto exit;"); needsExit = true; out.println(indent + "}"); @@ -993,12 +969,8 @@ public class JniCodeEmitter { if (emitExceptionCheck) { out.println(indent + indent + "_exception = 1;"); } - out.println(indent + " " + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - "IAEClass, " + - "\"" + offset + " < 0\");"); + out.println(indent + " jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", \"" + offset + " < 0\");"); out.println(indent + " goto exit;"); needsExit = true; out.println(indent + "}"); diff --git a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp index 294d1ce82e72..5d418d7c4024 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2009, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -27,10 +29,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; static jmethodID getBaseArrayOffsetID; @@ -41,7 +39,7 @@ static jfieldID elementSizeShiftID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); 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 * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -103,13 +81,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -122,4 +100,3 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp index e1c09f4614d6..35a3c333a6a1 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2009, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -40,10 +42,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; static jmethodID getBaseArrayOffsetID; @@ -54,7 +52,7 @@ static jfieldID elementSizeShiftID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal); @@ -75,26 +73,6 @@ nativeClassInitBuffer(JNIEnv *_env) _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 * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -115,13 +93,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -140,7 +118,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) { jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID); buf += position << elementSizeShift; } 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; } @@ -153,4 +132,3 @@ getNumCompressedTextureFormats() { } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp index 2548b32a24c9..9b29a4410920 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2009, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -36,10 +38,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; static jmethodID getBaseArrayOffsetID; @@ -50,7 +48,7 @@ static jfieldID elementSizeShiftID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); 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 * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -112,13 +90,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -138,9 +116,9 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) { jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID); buf += position << elementSizeShift; } 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; } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp index 4c297f786950..823079f39f28 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2009, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -34,10 +36,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; static jmethodID getBaseArrayOffsetID; @@ -48,7 +46,7 @@ static jfieldID elementSizeShiftID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal); @@ -70,26 +68,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 * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -110,13 +88,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -136,10 +114,10 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) { jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID); buf += position << elementSizeShift; } 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; } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp index e451e9ad9023..13a2577c2838 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2009, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -27,10 +29,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; static jmethodID getBaseArrayOffsetID; @@ -41,7 +39,7 @@ static jfieldID elementSizeShiftID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); 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 * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -103,13 +81,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -129,7 +107,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) { jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID); buf += position << elementSizeShift; } 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; } @@ -147,4 +126,3 @@ static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type, } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp b/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp index d92f51598352..ce6ab240443f 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp @@ -1,27 +1,19 @@ -#include <string.h> +#include <stdlib.h> /* void glGetProgramInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */ -static -jstring -android_glGetProgramInfoLog (JNIEnv *_env, jobject _this, jint shader) { +static jstring android_glGetProgramInfoLog(JNIEnv *_env, jobject, jint shader) { GLint infoLen = 0; - jstring _result = 0; - char* buf = 0; glGetProgramiv(shader, GL_INFO_LOG_LENGTH, &infoLen); - if (infoLen) { - char* buf = (char*) malloc(infoLen); - if (buf == 0) { - _env->ThrowNew(IAEClass, "out of memory"); - goto exit; - } - glGetProgramInfoLog(shader, infoLen, NULL, buf); - _result = _env->NewStringUTF(buf); - } else { - _result = _env->NewStringUTF(""); + if (!infoLen) { + return _env->NewStringUTF(""); } -exit: - if (buf) { - free(buf); + char* buf = (char*) malloc(infoLen); + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; } - return _result; -}
\ No newline at end of file + glGetProgramInfoLog(shader, infoLen, NULL, buf); + jstring result = _env->NewStringUTF(buf); + free(buf); + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp b/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp index 5441d66817a0..dd656b60c127 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp @@ -1,27 +1,19 @@ -#include <string.h> +#include <stdlib.h> /* void glGetShaderInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */ -static -jstring -android_glGetShaderInfoLog (JNIEnv *_env, jobject _this, jint shader) { +static jstring android_glGetShaderInfoLog(JNIEnv *_env, jobject, jint shader) { GLint infoLen = 0; - jstring _result = 0; - char* buf = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen); - if (infoLen) { - char* buf = (char*) malloc(infoLen); - if (buf == 0) { - _env->ThrowNew(IAEClass, "out of memory"); - goto exit; - } - glGetShaderInfoLog(shader, infoLen, NULL, buf); - _result = _env->NewStringUTF(buf); - } else { - _result = _env->NewStringUTF(""); + if (!infoLen) { + return _env->NewStringUTF(""); } -exit: - if (buf) { - free(buf); + char* buf = (char*) malloc(infoLen); + if (buf == NULL) { + jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); + return NULL; } - return _result; -}
\ No newline at end of file + glGetShaderInfoLog(shader, infoLen, NULL, buf); + jstring result = _env->NewStringUTF(buf); + free(buf); + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetString.cpp b/opengl/tools/glgen/stubs/gles11/glGetString.cpp index a400859f771f..239fe4ac2e64 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetString.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetString.cpp @@ -1,11 +1,5 @@ -#include <string.h>
-
/* const GLubyte * glGetString ( GLenum name ) */
-static
-jstring
-android_glGetString
- (JNIEnv *_env, jobject _this, jint name) {
- const char * chars = (const char *)glGetString((GLenum)name);
- jstring output = _env->NewStringUTF(chars);
- return output;
+static jstring android_glGetString(JNIEnv* _env, jobject, jint name) {
+ const char* chars = (const char*) glGetString((GLenum) name);
+ return _env->NewStringUTF(chars);
}
diff --git a/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp b/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp index c2741089a6bd..125fd0ff1992 100644 --- a/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp +++ b/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp @@ -6,7 +6,7 @@ android_glShaderSource (JNIEnv *_env, jobject _this, jint shader, jstring string) { if (!string) { - _env->ThrowNew(IAEClass, "string == null"); + jniThrowException(_env, "java/lang/IllegalArgumentException", "string == null"); return; } diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp index c2464b05626e..f7315eefdddf 100644 --- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp +++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp @@ -1,21 +1,23 @@ ** ** Copyright 2006, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ // This source file is automatically generated +#include "jni.h" +#include "JNIHelp.h" #include <android_runtime/AndroidRuntime.h> #include <utils/misc.h> @@ -63,10 +65,6 @@ static int initialized = 0; static jclass nioAccessClass; static jclass bufferClass; -static jclass OOMEClass; -static jclass UOEClass; -static jclass IAEClass; -static jclass AIOOBEClass; static jclass G11ImplClass; static jmethodID getBasePointerID; static jmethodID getBaseArrayID; @@ -84,7 +82,7 @@ static jfieldID have_OES_texture_cube_mapID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInit(JNIEnv *_env, jclass glImplClass) { jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal); @@ -114,26 +112,6 @@ nativeClassInitBuffer(JNIEnv *_env) _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 * getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) { @@ -154,7 +132,7 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) *array = NULL; return (void *) (jint) pointer; } - + *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass, getBaseArrayID, buffer); if (*array == NULL) { @@ -163,7 +141,7 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) offset = _env->CallStaticIntMethod(nioAccessClass, getBaseArrayOffsetID, buffer); data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0); - + return (void *) ((char *) data + offset); } @@ -207,7 +185,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) { releasePointer(_env, array, buf, 0); } } else { - _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + jniThrowException(_env, "java/lang/IllegalArgumentException", + "Must use a native order direct Buffer"); } } return buf; @@ -250,7 +229,7 @@ nextExtension(const GLubyte* pExtensions) { } } } - + static bool checkForExtension(const GLubyte* pExtensions, const GLubyte* pExtension) { for (;*pExtensions != '\0'; pExtensions = nextExtension(pExtensions)) { @@ -279,4 +258,3 @@ supportsExtension(JNIEnv *_env, jobject impl, jfieldID fieldId) { } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl index 372710625e4c..cd730aa95b21 100644 --- a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl +++ b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl @@ -18,7 +18,7 @@ package com.google.android.gles_jni; -import android.app.ActivityThread; +import android.app.AppGlobals; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.os.Build; @@ -64,7 +64,7 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { private static boolean allowIndirectBuffers(String appName) { boolean result = false; int version = 0; - IPackageManager pm = ActivityThread.getPackageManager(); + IPackageManager pm = AppGlobals.getPackageManager(); try { ApplicationInfo applicationInfo = pm.getApplicationInfo(appName, 0); if (applicationInfo != null) { diff --git a/opengl/tools/glgen/stubs/jsr239/glGetString.cpp b/opengl/tools/glgen/stubs/jsr239/glGetString.cpp index a400859f771f..cd6e3f39578a 100644 --- a/opengl/tools/glgen/stubs/jsr239/glGetString.cpp +++ b/opengl/tools/glgen/stubs/jsr239/glGetString.cpp @@ -1,11 +1,5 @@ -#include <string.h>
-
/* const GLubyte * glGetString ( GLenum name ) */
-static
-jstring
-android_glGetString
- (JNIEnv *_env, jobject _this, jint name) {
- const char * chars = (const char *)glGetString((GLenum)name);
- jstring output = _env->NewStringUTF(chars);
- return output;
+static jstring android_glGetString(JNIEnv *_env, jobject, jint name) {
+ const char* chars = (const char*) glGetString((GLenum) name);
+ return _env->NewStringUTF(chars);
}
|