diff options
Diffstat (limited to 'opengl/tools/glgen/src')
-rw-r--r-- | opengl/tools/glgen/src/.gitignore | 1 | ||||
-rw-r--r-- | opengl/tools/glgen/src/CFunc.java | 171 | ||||
-rw-r--r-- | opengl/tools/glgen/src/CType.java | 107 | ||||
-rw-r--r-- | opengl/tools/glgen/src/CodeEmitter.java | 23 | ||||
-rw-r--r-- | opengl/tools/glgen/src/GLESCodeEmitter.java | 56 | ||||
-rw-r--r-- | opengl/tools/glgen/src/GenerateGL.java | 182 | ||||
-rw-r--r-- | opengl/tools/glgen/src/GenerateGLES.java | 114 | ||||
-rw-r--r-- | opengl/tools/glgen/src/JFunc.java | 169 | ||||
-rw-r--r-- | opengl/tools/glgen/src/JType.java | 174 | ||||
-rw-r--r-- | opengl/tools/glgen/src/JniCodeEmitter.java | 1180 | ||||
-rw-r--r-- | opengl/tools/glgen/src/Jsr239CodeEmitter.java | 90 | ||||
-rw-r--r-- | opengl/tools/glgen/src/ParameterChecker.java | 43 |
12 files changed, 0 insertions, 2310 deletions
diff --git a/opengl/tools/glgen/src/.gitignore b/opengl/tools/glgen/src/.gitignore deleted file mode 100644 index 6b468b6..0000000 --- a/opengl/tools/glgen/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/opengl/tools/glgen/src/CFunc.java b/opengl/tools/glgen/src/CFunc.java deleted file mode 100644 index 4847694..0000000 --- a/opengl/tools/glgen/src/CFunc.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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. - */ - -import java.util.*; - -public class CFunc { - - String original; - - CType ftype; - String fname; - - List<String> argNames = new ArrayList<String>(); - List<CType> argTypes = new ArrayList<CType>(); - - boolean hasPointerArg = false; - boolean hasTypedPointerArg = false; - - public CFunc(String original) { - this.original = original; - } - - public String getOriginal() { - return original; - } - - public void setName(String fname) { - this.fname = fname; - } - - public String getName() { - return fname; - } - - public void setType(CType ftype) { - this.ftype = ftype; - } - - public CType getType() { - return ftype; - } - - public void addArgument(String argName, CType argType) { - argNames.add(argName); - argTypes.add(argType); - - if (argType.isPointer()) { - hasPointerArg = true; - } - if (argType.isTypedPointer()) { - hasTypedPointerArg = true; - } - } - - public int getNumArgs() { - return argNames.size(); - } - - public int getArgIndex(String name) { - int len = argNames.size(); - for (int i = 0; i < len; i++) { - if (name.equals(argNames.get(i))) { - return i; - } - } - return -1; - } - - public String getArgName(int index) { - return argNames.get(index); - } - - public CType getArgType(int index) { - return argTypes.get(index); - } - - public boolean hasPointerArg() { - return hasPointerArg; - } - - public boolean hasTypedPointerArg() { - return hasTypedPointerArg; - } - - @Override - public String toString() { - String s = "Function " + fname + " returns " + ftype + ": "; - for (int i = 0; i < argNames.size(); i++) { - if (i > 0) { - s += ", "; - } - s += argTypes.get(i) + " " + argNames.get(i); - } - return s; - } - - public static CFunc parseCFunc(String s) { - CFunc cfunc = new CFunc(s); - String[] tokens = s.split("\\s"); - - int i = 0; - CType ftype = new CType(); - String ftypeName = tokens[i++]; - if (ftypeName.equals("const")) { - ftype.setIsConst(true); - ftypeName = tokens[i++]; - } - ftype.setBaseType(ftypeName); - - String fname = tokens[i++]; - if (fname.equals("*")) { - ftype.setIsPointer(true); - fname = tokens[i++]; - } - - cfunc.setName(fname); - cfunc.setType(ftype); - - while (i < tokens.length) { - String tok = tokens[i++]; - - if (tok.equals("(")) { - continue; - } - if (tok.equals(")")) { - break; - } - - CType argType = new CType(); - - String argTypeName = tok; - String argName = ""; - - if (argTypeName.equals("const")) { - argType.setIsConst(true); - argTypeName = tokens[i++]; - } - argType.setBaseType(argTypeName); - - if (argTypeName.equals("void")) { - break; - } - - argName = tokens[i++]; - if (argName.startsWith("*")) { - argType.setIsPointer(true); - argName = argName.substring(1, argName.length()); - } - if (argName.endsWith(",")) { - argName = argName.substring(0, argName.length() - 1); - } - - cfunc.addArgument(argName, argType); - } - - return cfunc; - } -} diff --git a/opengl/tools/glgen/src/CType.java b/opengl/tools/glgen/src/CType.java deleted file mode 100644 index e0f0ca6..0000000 --- a/opengl/tools/glgen/src/CType.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - */ - -public class CType { - - String baseType; - boolean isConst; - boolean isPointer; - - public CType() { - } - - public CType(String baseType) { - setBaseType(baseType); - } - - public CType(String baseType, boolean isConst, boolean isPointer) { - setBaseType(baseType); - setIsConst(isConst); - setIsPointer(isPointer); - } - - public String getDeclaration() { - return baseType + (isPointer ? " *" : ""); - } - - public void setIsConst(boolean isConst) { - this.isConst = isConst; - } - - public boolean isConst() { - return isConst; - } - - public void setIsPointer(boolean isPointer) { - this.isPointer = isPointer; - } - - public boolean isPointer() { - return isPointer; - } - - boolean isVoid() { - String baseType = getBaseType(); - return baseType.equals("GLvoid") || - baseType.equals("void"); - } - - public boolean isConstCharPointer() { - return isConst && isPointer && baseType.equals("char"); - } - - public boolean isTypedPointer() { - return isPointer() && !isVoid() && !isConstCharPointer(); - } - - public void setBaseType(String baseType) { - this.baseType = baseType; - } - - public String getBaseType() { - return baseType; - } - - @Override - public String toString() { - String s = ""; - if (isConst()) { - s += "const "; - } - s += baseType; - if (isPointer()) { - s += "*"; - } - - return s; - } - - @Override - public int hashCode() { - return baseType.hashCode() ^ (isPointer ? 2 : 0) ^ (isConst ? 1 : 0); - } - - @Override - public boolean equals(Object o) { - if (o != null && o instanceof CType) { - CType c = (CType)o; - return baseType.equals(c.baseType) && - isPointer() == c.isPointer() && - isConst() == c.isConst(); - } - return false; - } -} diff --git a/opengl/tools/glgen/src/CodeEmitter.java b/opengl/tools/glgen/src/CodeEmitter.java deleted file mode 100644 index 3a4834e..0000000 --- a/opengl/tools/glgen/src/CodeEmitter.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ - -public interface CodeEmitter { - - void setVersion(int version, boolean ext, boolean pack); - void emitCode(CFunc cfunc, String original); - void addNativeRegistration(String fname); - void emitNativeRegistration(); -} diff --git a/opengl/tools/glgen/src/GLESCodeEmitter.java b/opengl/tools/glgen/src/GLESCodeEmitter.java deleted file mode 100644 index d138250..0000000 --- a/opengl/tools/glgen/src/GLESCodeEmitter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - */ - -import java.io.PrintStream; - -/** - * Emits a Java interface and Java & C implementation for a C function. - * - * <p> The Java interface will have Buffer and array variants for functions that - * have a typed pointer argument. The array variant will convert a single "<type> *data" - * argument to a pair of arguments "<type>[] data, int offset". - */ -public class GLESCodeEmitter extends JniCodeEmitter { - - PrintStream mJavaImplStream; - PrintStream mCStream; - - PrintStream mJavaInterfaceStream; - - /** - */ - public GLESCodeEmitter(String classPathName, - ParameterChecker checker, - PrintStream javaImplStream, - PrintStream cStream) { - mClassPathName = classPathName; - mChecker = checker; - - mJavaImplStream = javaImplStream; - mCStream = cStream; - mUseContextPointer = false; - mUseStaticMethods = true; - } - - public void emitCode(CFunc cfunc, String original) { - emitCode(cfunc, original, null, mJavaImplStream, - mCStream); - } - - public void emitNativeRegistration(String nativeRegistrationName) { - emitNativeRegistration(nativeRegistrationName, mCStream); - } -} diff --git a/opengl/tools/glgen/src/GenerateGL.java b/opengl/tools/glgen/src/GenerateGL.java deleted file mode 100644 index 500cf0b..0000000 --- a/opengl/tools/glgen/src/GenerateGL.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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. - */ - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintStream; - -public class GenerateGL { - - static void copy(String filename, PrintStream out) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(filename)); - String s; - while ((s = br.readLine()) != null) { - out.println(s); - } - } - - private static void emit(int version, boolean ext, boolean pack, - CodeEmitter emitter, - BufferedReader specReader, - PrintStream glStream, - PrintStream glImplStream, - PrintStream cStream) throws Exception { - String s = null; - while ((s = specReader.readLine()) != null) { - if (s.trim().startsWith("//")) { - continue; - } - - CFunc cfunc = CFunc.parseCFunc(s); - - String fname = cfunc.getName(); - File f = new File("stubs/jsr239/" + fname + - ".java-1" + version + "-if"); - if (f.exists()) { - System.out.println("Special-casing function " + fname); - copy("stubs/jsr239/" + fname + - ".java-1" + version + "-if", glStream); - copy("stubs/jsr239/" + fname + ".java-impl", glImplStream); - copy("stubs/jsr239/" + fname + ".cpp", cStream); - - // Register native function names - // This should be improved to require fewer discrete files - String filename = "stubs/jsr239/" + fname + ".nativeReg"; - BufferedReader br = - new BufferedReader(new FileReader(filename)); - String nfunc; - while ((nfunc = br.readLine()) != null) { - emitter.addNativeRegistration(nfunc); - } - } else { - emitter.setVersion(version, ext, pack); - emitter.emitCode(cfunc, s); - } - } - } - - public static void main(String[] args) throws Exception { - String classPathName = "com/google/android/gles_jni/GLImpl"; - boolean useContextPointer = true; - - int aidx = 0; - while (args[aidx].charAt(0) == '-') { - switch (args[aidx].charAt(1)) { - case 'c': - useContextPointer = false; - break; - - default: - System.err.println("Unknown flag: " + args[aidx]); - System.exit(1); - } - - aidx++; - } - - System.out.println("useContextPointer = " + useContextPointer); - - BufferedReader spec10Reader = - new BufferedReader(new FileReader(args[aidx++])); - BufferedReader spec10ExtReader = - new BufferedReader(new FileReader(args[aidx++])); - BufferedReader spec11Reader = - new BufferedReader(new FileReader(args[aidx++])); - BufferedReader spec11ExtReader = - new BufferedReader(new FileReader(args[aidx++])); - BufferedReader spec11ExtPackReader = - new BufferedReader(new FileReader(args[aidx++])); - BufferedReader checksReader = - new BufferedReader(new FileReader(args[aidx++])); - - String gl10Filename = "javax/microedition/khronos/opengles/GL10.java"; - String gl10ExtFilename = - "javax/microedition/khronos/opengles/GL10Ext.java"; - String gl11Filename = "javax/microedition/khronos/opengles/GL11.java"; - String gl11ExtFilename = - "javax/microedition/khronos/opengles/GL11Ext.java"; - String gl11ExtPackFilename = - "javax/microedition/khronos/opengles/GL11ExtensionPack.java"; - String glImplFilename = "com/google/android/gles_jni/GLImpl.java"; - String cFilename = "com_google_android_gles_jni_GLImpl.cpp"; - - PrintStream gl10Stream = - new PrintStream(new FileOutputStream("out/" + gl10Filename)); - PrintStream gl10ExtStream = - new PrintStream(new FileOutputStream("out/" + gl10ExtFilename)); - PrintStream gl11Stream = - new PrintStream(new FileOutputStream("out/" + gl11Filename)); - PrintStream gl11ExtStream = - new PrintStream(new FileOutputStream("out/" + gl11ExtFilename)); - PrintStream gl11ExtPackStream = - new PrintStream(new FileOutputStream("out/" + gl11ExtPackFilename)); - PrintStream glImplStream = - new PrintStream(new FileOutputStream("out/" + glImplFilename)); - PrintStream cStream = - new PrintStream(new FileOutputStream("out/" + cFilename)); - - ParameterChecker checker = new ParameterChecker(checksReader); - - CodeEmitter emitter = - new Jsr239CodeEmitter(classPathName, - checker, - gl10Stream, gl10ExtStream, - gl11Stream, gl11ExtStream, gl11ExtPackStream, - glImplStream, cStream, - useContextPointer); - - gl10Stream.println("/* //device/java/android/" + gl10Filename); - gl10ExtStream.println("/* //device/java/android/" + gl10ExtFilename); - gl11Stream.println("/* //device/java/android/" + gl11Filename); - gl11ExtStream.println("/* //device/java/android/" + gl11ExtFilename); - gl11ExtPackStream.println("/* //device/java/android/" + - gl11ExtPackFilename); - glImplStream.println("/* //device/java/android/" + glImplFilename); - cStream.println("/* //device/libs/android_runtime/" + cFilename); - - copy("stubs/jsr239/GL10Header.java-if", gl10Stream); - copy("stubs/jsr239/GL10ExtHeader.java-if", gl10ExtStream); - copy("stubs/jsr239/GL11Header.java-if", gl11Stream); - copy("stubs/jsr239/GL11ExtHeader.java-if", gl11ExtStream); - copy("stubs/jsr239/GL11ExtensionPackHeader.java-if", gl11ExtPackStream); - copy("stubs/jsr239/GLImplHeader.java-impl", glImplStream); - copy("stubs/jsr239/GLCHeader.cpp", cStream); - - emit(0, false, false, - emitter, spec10Reader, gl10Stream, glImplStream, cStream); - emit(0, true, false, - emitter, spec10ExtReader, gl10ExtStream, glImplStream, cStream); - emit(1, false, false, - emitter, spec11Reader, gl11Stream, glImplStream, cStream); - emit(1, true, false, - emitter, spec11ExtReader, gl11ExtStream, glImplStream, cStream); - emit(1, true, true, - emitter, spec11ExtPackReader, gl11ExtPackStream, glImplStream, - cStream); - - emitter.emitNativeRegistration(); - - gl10Stream.println("}"); - gl10ExtStream.println("}"); - gl11Stream.println("}"); - gl11ExtStream.println("}"); - gl11ExtPackStream.println("}"); - glImplStream.println("}"); - } -} diff --git a/opengl/tools/glgen/src/GenerateGLES.java b/opengl/tools/glgen/src/GenerateGLES.java deleted file mode 100644 index 6468957..0000000 --- a/opengl/tools/glgen/src/GenerateGLES.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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. - */ - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintStream; - -public class GenerateGLES { - - static void copy(String filename, PrintStream out) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(filename)); - String s; - while ((s = br.readLine()) != null) { - out.println(s); - } - } - - private static void emit(GLESCodeEmitter emitter, - BufferedReader specReader, - PrintStream glStream, - PrintStream cStream) throws Exception { - String s = null; - while ((s = specReader.readLine()) != null) { - if (s.trim().startsWith("//")) { - continue; - } - - CFunc cfunc = CFunc.parseCFunc(s); - - String fname = cfunc.getName(); - String stubRoot = "stubs/gles11/" + fname; - String javaPath = stubRoot + ".java"; - File f = new File(javaPath); - if (f.exists()) { - System.out.println("Special-casing function " + fname); - copy(javaPath, glStream); - copy(stubRoot + ".cpp", cStream); - - // Register native function names - // This should be improved to require fewer discrete files - String filename = stubRoot + ".nativeReg"; - BufferedReader br = - new BufferedReader(new FileReader(filename)); - String nfunc; - while ((nfunc = br.readLine()) != null) { - emitter.addNativeRegistration(nfunc); - } - } else { - emitter.emitCode(cfunc, s); - } - } - } - - public static void main(String[] args) throws Exception { - int aidx = 0; - while ((aidx < args.length) && (args[aidx].charAt(0) == '-')) { - switch (args[aidx].charAt(1)) { - default: - System.err.println("Unknown flag: " + args[aidx]); - System.exit(1); - } - - aidx++; - } - - BufferedReader checksReader = - new BufferedReader(new FileReader("specs/gles11/checks.spec")); - ParameterChecker checker = new ParameterChecker(checksReader); - - // Generate files - for(String suffix: new String[] {"GLES10", "GLES10Ext", - "GLES11", "GLES11Ext", "GLES20"}) - { - BufferedReader spec11Reader = - new BufferedReader(new FileReader("specs/gles11/" - + suffix + ".spec")); - String gl11Filename = "android/opengl/" + suffix + ".java"; - String gl11cFilename = "android_opengl_" + suffix + ".cpp"; - PrintStream gl11Stream = - new PrintStream(new FileOutputStream("out/" + gl11Filename)); - PrintStream gl11cStream = - new PrintStream(new FileOutputStream("out/" + gl11cFilename)); - gl11Stream.println("/*"); - gl11cStream.println("/*"); - copy("stubs/gles11/" + suffix + "Header.java-if", gl11Stream); - copy("stubs/gles11/" + suffix + "cHeader.cpp", gl11cStream); - GLESCodeEmitter emitter = new GLESCodeEmitter( - "android/opengl/" + suffix, - checker, gl11Stream, gl11cStream); - emit(emitter, spec11Reader, gl11Stream, gl11cStream); - emitter.emitNativeRegistration("register_android_opengl_jni_" - + suffix); - gl11Stream.println("}"); - gl11Stream.close(); - gl11cStream.close(); - } - } -} diff --git a/opengl/tools/glgen/src/JFunc.java b/opengl/tools/glgen/src/JFunc.java deleted file mode 100644 index e3d73b6..0000000 --- a/opengl/tools/glgen/src/JFunc.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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. - */ - -import java.util.ArrayList; -import java.util.List; - -public class JFunc { - - String className = "com.google.android.gles_jni.GL11Impl"; - - CFunc cfunc; - JType ftype; - String fname; - - List<String> argNames = new ArrayList<String>(); - List<JType> argTypes = new ArrayList<JType>(); - List<Integer> argCIndices = new ArrayList<Integer>(); - - boolean hasBufferArg = false; - boolean hasTypedBufferArg = false; - ArrayList<String> bufferArgNames = new ArrayList<String>(); - - public JFunc(CFunc cfunc) { - this.cfunc = cfunc; - } - - public CFunc getCFunc() { - return cfunc; - } - - public void setName(String fname) { - this.fname = fname; - } - - public String getName() { - return fname; - } - - public void setType(JType ftype) { - this.ftype = ftype; - } - - public JType getType() { - return ftype; - } - - public void setClassName(String className) { - this.className = className; - } - - public String getClassName() { - return className; - } - - public boolean hasBufferArg() { - return hasBufferArg; - } - - public boolean hasTypedBufferArg() { - return hasTypedBufferArg; - } - - public String getBufferArgName(int index) { - return bufferArgNames.get(index); - } - - public void addArgument(String argName, JType argType, int cindex) { - argNames.add(argName); - argTypes.add(argType); - argCIndices.add(new Integer(cindex)); - - if (argType.isBuffer()) { - hasBufferArg = true; - bufferArgNames.add(argName); - } - if (argType.isTypedBuffer()) { - hasTypedBufferArg = true; - bufferArgNames.add(argName); - } - } - - public int getNumArgs() { - return argNames.size(); - } - - public int getArgIndex(String name) { - int len = argNames.size(); - for (int i = 0; i < len; i++) { - if (name.equals(argNames.get(i))) { - return i; - } - } - return -1; - } - - public String getArgName(int index) { - return argNames.get(index); - } - - public JType getArgType(int index) { - return argTypes.get(index); - } - - public int getArgCIndex(int index) { - return argCIndices.get(index).intValue(); - } - - public static JFunc convert(CFunc cfunc, boolean useArray) { - try { - JFunc jfunc = new JFunc(cfunc); - jfunc.setName(cfunc.getName()); - jfunc.setType(JType.convert(cfunc.getType(), false)); - - int numArgs = cfunc.getNumArgs(); - int numOffsets = 0; - for (int i = 0; i < numArgs; i++) { - CType cArgType = cfunc.getArgType(i); - if (cArgType.isTypedPointer() && useArray) { - ++numOffsets; - } - } - - for (int i = 0; i < numArgs; i++) { - String cArgName = cfunc.getArgName(i); - CType cArgType = cfunc.getArgType(i); - - jfunc.addArgument(cArgName, JType.convert(cArgType, useArray), i); - if (cArgType.isTypedPointer() && useArray) { - if (numOffsets > 1) { - jfunc.addArgument(cArgName + "Offset", new JType("int"), i); - } else { - jfunc.addArgument("offset", new JType("int"), i); - } - } - } - - return jfunc; - } catch (RuntimeException e) { - System.err.println("Failed to convert function " + cfunc); - throw e; - } - } - - @Override - public String toString() { - String s = "Function " + fname + " returns " + ftype + ": "; - for (int i = 0; i < argNames.size(); i++) { - if (i > 0) { - s += ", "; - } - s += argTypes.get(i) + " " + argNames.get(i); - } - return s; - } - -} diff --git a/opengl/tools/glgen/src/JType.java b/opengl/tools/glgen/src/JType.java deleted file mode 100644 index deb2f01..0000000 --- a/opengl/tools/glgen/src/JType.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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. - */ - -import java.util.HashMap; - -public class JType { - - String baseType; - boolean isArray; - boolean isClass; - boolean isString; - - static HashMap<CType,JType> typeMapping = new HashMap<CType,JType>(); - static HashMap<CType,JType> arrayTypeMapping = new HashMap<CType,JType>(); - - static { - // Primitive types - typeMapping.put(new CType("GLbitfield"), new JType("int")); - typeMapping.put(new CType("GLboolean"), new JType("boolean")); - typeMapping.put(new CType("GLclampf"), new JType("float")); - typeMapping.put(new CType("GLclampx"), new JType("int")); - typeMapping.put(new CType("GLenum"), new JType("int")); - typeMapping.put(new CType("GLfloat"), new JType("float")); - typeMapping.put(new CType("GLfixed"), new JType("int")); - typeMapping.put(new CType("GLint"), new JType("int")); - typeMapping.put(new CType("GLintptr"), new JType("int")); - typeMapping.put(new CType("GLshort"), new JType("short")); - typeMapping.put(new CType("GLsizei"), new JType("int")); - typeMapping.put(new CType("GLsizeiptr"), new JType("int")); - typeMapping.put(new CType("GLubyte"), new JType("byte")); - typeMapping.put(new CType("GLuint"), new JType("int")); - typeMapping.put(new CType("void"), new JType("void")); - typeMapping.put(new CType("GLubyte", true, true), new JType("String", false, false)); - typeMapping.put(new CType("char", false, true), new JType("byte")); - typeMapping.put(new CType("char", true, true), new JType("String", false, false)); - typeMapping.put(new CType("int"), new JType("int")); - - // Untyped pointers map to untyped Buffers - typeMapping.put(new CType("GLvoid", true, true), - new JType("java.nio.Buffer", true, false)); - typeMapping.put(new CType("GLvoid", false, true), - new JType("java.nio.Buffer", true, false)); - typeMapping.put(new CType("void", false, true), - new JType("java.nio.Buffer", true, false)); - typeMapping.put(new CType("GLeglImageOES", false, false), - new JType("java.nio.Buffer", true, false)); - - // Typed pointers map to typed Buffers - typeMapping.put(new CType("GLboolean", false, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLenum", false, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLfixed", false, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLfixed", true, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLfloat", false, true), - new JType("java.nio.FloatBuffer", true, false)); - typeMapping.put(new CType("GLfloat", true, true), - new JType("java.nio.FloatBuffer", true, false)); - typeMapping.put(new CType("GLint", false, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLint", true, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLsizei", false, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLuint", false, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLuint", true, true), - new JType("java.nio.IntBuffer", true, false)); - typeMapping.put(new CType("GLshort", true, true), - new JType("java.nio.ShortBuffer", true, false)); - - // Typed pointers map to arrays + offsets - arrayTypeMapping.put(new CType("char", false, true), - new JType("byte", false, true)); - arrayTypeMapping.put(new CType("GLboolean", false, true), - new JType("boolean", false, true)); - arrayTypeMapping.put(new CType("GLenum", false, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLfixed", true, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLfixed", false, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLfloat", false, true), new JType("float", false, true)); - arrayTypeMapping.put(new CType("GLfloat", true, true), new JType("float", false, true)); - arrayTypeMapping.put(new CType("GLint", false, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLint", true, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLshort", true, true), new JType("short", false, true)); - arrayTypeMapping.put(new CType("GLsizei", false, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLsizei", true, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLuint", false, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLuint", true, true), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLintptr"), new JType("int", false, true)); - arrayTypeMapping.put(new CType("GLsizeiptr"), new JType("int", false, true)); - } - - public JType() { - } - - public JType(String primitiveTypeName) { - this.baseType = primitiveTypeName; - this.isClass = false; - this.isArray = false; - } - - public JType(String primitiveTypeName, boolean isClass, boolean isArray) { - this.baseType = primitiveTypeName; - this.isClass = isClass; - this.isArray = isArray; - } - - public String getBaseType() { - return baseType; - } - - @Override - public String toString() { - return baseType + (isArray ? "[]" : ""); - } - - public boolean isArray() { - return isArray; - } - - public boolean isClass() { - return isClass; - } - - public boolean isString() { - return baseType.equals("String"); - } - - public boolean isPrimitive() { - return !isClass() && !isArray(); - } - - public boolean isVoid() { - return baseType.equals("void"); - } - - public boolean isBuffer() { - return baseType.indexOf("Buffer") != -1; - } - - public boolean isTypedBuffer() { - return !baseType.equals("java.nio.Buffer") && - (baseType.indexOf("Buffer") != -1); - } - - public static JType convert(CType ctype, boolean useArray) { - JType javaType = null; - if (useArray) { - javaType = arrayTypeMapping.get(ctype); - } - if (javaType == null) { - javaType = typeMapping.get(ctype); - } - if (javaType == null) { - throw new RuntimeException("Unsupported C type: " + ctype); - } - return javaType; - } -} diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java deleted file mode 100644 index 9fa2b74..0000000 --- a/opengl/tools/glgen/src/JniCodeEmitter.java +++ /dev/null @@ -1,1180 +0,0 @@ -/* - * 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. - */ - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -public class JniCodeEmitter { - - static final boolean mUseCPlusPlus = true; - protected boolean mUseContextPointer = true; - protected boolean mUseStaticMethods = false; - protected String mClassPathName; - protected ParameterChecker mChecker; - protected List<String> nativeRegistrations = new ArrayList<String>(); - boolean needsExit; - protected static String indent = " "; - HashSet<String> mFunctionsEmitted = new HashSet<String>(); - - public static String getJniName(JType jType) { - String jniName = ""; - if (jType.isClass()) { - return "L" + jType.getBaseType() + ";"; - } else if (jType.isArray()) { - jniName = "["; - } - - String baseType = jType.getBaseType(); - if (baseType.equals("int")) { - jniName += "I"; - } else if (baseType.equals("float")) { - jniName += "F"; - } else if (baseType.equals("boolean")) { - jniName += "Z"; - } else if (baseType.equals("short")) { - jniName += "S"; - } else if (baseType.equals("long")) { - jniName += "L"; - } else if (baseType.equals("byte")) { - jniName += "B"; - } else if (baseType.equals("String")) { - jniName += "Ljava/lang/String;"; - } else if (baseType.equals("void")) { - // nothing. - } else { - throw new RuntimeException("Unknown primitive basetype " + baseType); - } - return jniName; - } - - - public void emitCode(CFunc cfunc, String original, - PrintStream javaInterfaceStream, - PrintStream javaImplStream, - PrintStream cStream) { - JFunc jfunc; - String signature; - boolean duplicate; - - if (cfunc.hasTypedPointerArg()) { - jfunc = JFunc.convert(cfunc, true); - - // Don't emit duplicate functions - // These may appear because they are defined in multiple - // Java interfaces (e.g., GL11/GL11ExtensionPack) - signature = jfunc.toString(); - duplicate = false; - if (mFunctionsEmitted.contains(signature)) { - duplicate = true; - } else { - mFunctionsEmitted.add(signature); - } - - if (!duplicate) { - emitNativeDeclaration(jfunc, javaImplStream); - emitJavaCode(jfunc, javaImplStream); - } - if (javaInterfaceStream != null) { - emitJavaInterfaceCode(jfunc, javaInterfaceStream); - } - if (!duplicate) { - emitJniCode(jfunc, cStream); - } - } - - jfunc = JFunc.convert(cfunc, false); - - signature = jfunc.toString(); - duplicate = false; - if (mFunctionsEmitted.contains(signature)) { - duplicate = true; - } else { - mFunctionsEmitted.add(signature); - } - - if (!duplicate) { - emitNativeDeclaration(jfunc, javaImplStream); - } - if (javaInterfaceStream != null) { - emitJavaInterfaceCode(jfunc, javaInterfaceStream); - } - if (!duplicate) { - emitJavaCode(jfunc, javaImplStream); - emitJniCode(jfunc, cStream); - } - } - - public void emitNativeDeclaration(JFunc jfunc, PrintStream out) { - out.println(" // C function " + jfunc.getCFunc().getOriginal()); - out.println(); - - emitFunction(jfunc, out, true, false); - } - - public void emitJavaInterfaceCode(JFunc jfunc, PrintStream out) { - emitFunction(jfunc, out, false, true); - } - - public void emitJavaCode(JFunc jfunc, PrintStream out) { - emitFunction(jfunc, out, false, false); - } - - boolean isPointerFunc(JFunc jfunc) { - String name = jfunc.getName(); - return (name.endsWith("Pointer") || name.endsWith("PointerOES")) - && jfunc.getCFunc().hasPointerArg(); - } - - void emitFunctionCall(JFunc jfunc, PrintStream out, String iii, boolean grabArray) { - boolean isVoid = jfunc.getType().isVoid(); - boolean isPointerFunc = isPointerFunc(jfunc); - - if (!isVoid) { - out.println(iii + - jfunc.getType() + " _returnValue;"); - } - out.println(iii + - (isVoid ? "" : "_returnValue = ") + - jfunc.getName() + - (isPointerFunc ? "Bounds" : "" ) + - "("); - - int numArgs = jfunc.getNumArgs(); - for (int i = 0; i < numArgs; i++) { - String argName = jfunc.getArgName(i); - JType argType = jfunc.getArgType(i); - - if (grabArray && argType.isTypedBuffer()) { - String typeName = argType.getBaseType(); - typeName = typeName.substring(9, typeName.length() - 6); - out.println(iii + indent + "get" + typeName + "Array(" + argName + "),"); - out.print(iii + indent + "getOffset(" + argName + ")"); - } else { - out.print(iii + indent + argName); - } - if (i == numArgs - 1) { - if (isPointerFunc) { - out.println(","); - out.println(iii + indent + argName + ".remaining()"); - } else { - out.println(); - } - } else { - out.println(","); - } - } - - out.println(iii + ");"); - } - - void printIfcheckPostamble(PrintStream out, boolean isBuffer, boolean emitExceptionCheck, - String iii) { - printIfcheckPostamble(out, isBuffer, emitExceptionCheck, - "offset", "_remaining", iii); - } - - void printIfcheckPostamble(PrintStream out, boolean isBuffer, boolean emitExceptionCheck, - String offset, String remaining, String iii) { - out.println(iii + " default:"); - out.println(iii + " _needed = 0;"); - out.println(iii + " break;"); - out.println(iii + "}"); - - out.println(iii + "if (" + remaining + " < _needed) {"); - if (emitExceptionCheck) { - out.println(iii + indent + "_exception = 1;"); - } - 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 + "}"); - } - - boolean isNullAllowed(CFunc cfunc) { - String[] checks = mChecker.getChecks(cfunc.getName()); - int index = 1; - if (checks != null) { - while (index < checks.length) { - if (checks[index].equals("return")) { - index += 2; - } else if (checks[index].startsWith("check")) { - index += 3; - } else if (checks[index].equals("ifcheck")) { - index += 5; - } else if (checks[index].equals("unsupported")) { - index += 1; - } else if (checks[index].equals("requires")) { - index += 2; - } else if (checks[index].equals("nullAllowed")) { - return true; - } else { - System.out.println("Error: unknown keyword \"" + - checks[index] + "\""); - System.exit(0); - } - } - } - return false; - } - - String getErrorReturnValue(CFunc cfunc) { - CType returnType = cfunc.getType(); - boolean isVoid = returnType.isVoid(); - if (isVoid) { - return null; - } - - String[] checks = mChecker.getChecks(cfunc.getName()); - - int index = 1; - if (checks != null) { - while (index < checks.length) { - if (checks[index].equals("return")) { - return checks[index + 1]; - } else if (checks[index].startsWith("check")) { - index += 3; - } else if (checks[index].equals("ifcheck")) { - index += 5; - } else if (checks[index].equals("unsupported")) { - index += 1; - } else if (checks[index].equals("requires")) { - index += 2; - } else if (checks[index].equals("nullAllowed")) { - index += 1; - } else { - System.out.println("Error: unknown keyword \"" + - checks[index] + "\""); - System.exit(0); - } - } - } - - return null; - } - - boolean isUnsupportedFunc(CFunc cfunc) { - String[] checks = mChecker.getChecks(cfunc.getName()); - int index = 1; - if (checks != null) { - while (index < checks.length) { - if (checks[index].equals("unsupported")) { - return true; - } else if (checks[index].equals("requires")) { - index += 2; - } else if (checks[index].equals("return")) { - index += 2; - } else if (checks[index].startsWith("check")) { - index += 3; - } else if (checks[index].equals("ifcheck")) { - index += 5; - } else if (checks[index].equals("nullAllowed")) { - index += 1; - } else { - System.out.println("Error: unknown keyword \"" + - checks[index] + "\""); - System.exit(0); - } - } - } - return false; - } - - String isRequiresFunc(CFunc cfunc) { - String[] checks = mChecker.getChecks(cfunc.getName()); - int index = 1; - if (checks != null) { - while (index < checks.length) { - if (checks[index].equals("unsupported")) { - index += 1; - } else if (checks[index].equals("requires")) { - return checks[index+1]; - } else if (checks[index].equals("return")) { - index += 2; - } else if (checks[index].startsWith("check")) { - index += 3; - } else if (checks[index].equals("ifcheck")) { - index += 5; - } else if (checks[index].equals("nullAllowed")) { - index += 1; - } else { - System.out.println("Error: unknown keyword \"" + - checks[index] + "\""); - System.exit(0); - } - } - } - 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 = "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) { - 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 + "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;"); - - 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) { - for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) { - int idx = nonPrimitiveArgs.get(i).intValue(); - int cIndex = jfunc.getArgCIndex(idx); - if (jfunc.getArgType(idx).isArray()) { - if (!cfunc.getArgType(cIndex).isConst()) { - return true; - } - } else if (jfunc.getArgType(idx).isBuffer()) { - if (!cfunc.getArgType(cIndex).isConst()) { - return true; - } - } - } - } - - return false; - } - - /** - * Emit a function in several variants: - * - * if nativeDecl: public native <returntype> func(args); - * - * if !nativeDecl: - * if interfaceDecl: public <returntype> func(args); - * if !interfaceDecl: public <returntype> func(args) { body } - */ - void emitFunction(JFunc jfunc, PrintStream out, boolean nativeDecl, boolean interfaceDecl) { - boolean isPointerFunc = isPointerFunc(jfunc); - - if (!nativeDecl && !interfaceDecl && !isPointerFunc) { - // If it's not a pointer function, we've already emitted it - // with nativeDecl == true - return; - } - - String maybeStatic = mUseStaticMethods ? "static " : ""; - - if (isPointerFunc) { - out.println(indent + - (nativeDecl ? "private " + maybeStatic +"native " : - (interfaceDecl ? "" : "public ") + maybeStatic) + - jfunc.getType() + " " + - jfunc.getName() + - (nativeDecl ? "Bounds" : "") + - "("); - } else { - out.println(indent + - (nativeDecl ? "public " + maybeStatic +"native " : - (interfaceDecl ? "" : "public ") + maybeStatic) + - jfunc.getType() + " " + - jfunc.getName() + - "("); - } - - int numArgs = jfunc.getNumArgs(); - for (int i = 0; i < numArgs; i++) { - String argName = jfunc.getArgName(i); - JType argType = jfunc.getArgType(i); - - out.print(indent + indent + argType + " " + argName); - if (i == numArgs - 1) { - if (isPointerFunc && nativeDecl) { - out.println(","); - out.println(indent + indent + "int remaining"); - } else { - out.println(); - } - } else { - out.println(","); - } - } - - if (nativeDecl || interfaceDecl) { - out.println(indent + ");"); - } else { - out.println(indent + ") {"); - - String iii = indent + indent; - - // emitBoundsChecks(jfunc, out, iii); - emitFunctionCall(jfunc, out, iii, false); - - // Set the pointer after we call the native code, so that if - // the native code throws an exception we don't modify the - // pointer. We assume that the native code is written so that - // if an exception is thrown, then the underlying glXXXPointer - // function will not have been called. - - String fname = jfunc.getName(); - if (isPointerFunc) { - // TODO - deal with VBO variants - if (fname.equals("glColorPointer")) { - out.println(iii + "if ((size == 4) &&"); - out.println(iii + " ((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_UNSIGNED_BYTE) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_colorPointer = pointer;"); - out.println(iii + "}"); - } else if (fname.equals("glNormalPointer")) { - out.println(iii + "if (((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_BYTE) ||"); - out.println(iii + " (type == GL_SHORT) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_normalPointer = pointer;"); - out.println(iii + "}"); - } else if (fname.equals("glTexCoordPointer")) { - out.println(iii + "if (((size == 2) ||"); - out.println(iii + " (size == 3) ||"); - out.println(iii + " (size == 4)) &&"); - out.println(iii + " ((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_BYTE) ||"); - out.println(iii + " (type == GL_SHORT) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_texCoordPointer = pointer;"); - out.println(iii + "}"); - } else if (fname.equals("glVertexPointer")) { - out.println(iii + "if (((size == 2) ||"); - out.println(iii + " (size == 3) ||"); - out.println(iii + " (size == 4)) &&"); - out.println(iii + " ((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_BYTE) ||"); - out.println(iii + " (type == GL_SHORT) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_vertexPointer = pointer;"); - out.println(iii + "}"); - } else if (fname.equals("glPointSizePointerOES")) { - out.println(iii + "if (((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_pointSizePointerOES = pointer;"); - out.println(iii + "}"); - } else if (fname.equals("glMatrixIndexPointerOES")) { - out.println(iii + "if (((size == 2) ||"); - out.println(iii + " (size == 3) ||"); - out.println(iii + " (size == 4)) &&"); - out.println(iii + " ((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_BYTE) ||"); - out.println(iii + " (type == GL_SHORT) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_matrixIndexPointerOES = pointer;"); - out.println(iii + "}"); - } else if (fname.equals("glWeightPointer")) { - out.println(iii + "if (((size == 2) ||"); - out.println(iii + " (size == 3) ||"); - out.println(iii + " (size == 4)) &&"); - out.println(iii + " ((type == GL_FLOAT) ||"); - out.println(iii + " (type == GL_BYTE) ||"); - out.println(iii + " (type == GL_SHORT) ||"); - out.println(iii + " (type == GL_FIXED)) &&"); - out.println(iii + " (stride >= 0)) {"); - out.println(iii + indent + "_weightPointerOES = pointer;"); - out.println(iii + "}"); - } - } - - boolean isVoid = jfunc.getType().isVoid(); - - if (!isVoid) { - out.println(indent + indent + "return _returnValue;"); - } - out.println(indent + "}"); - } - out.println(); - } - - public void addNativeRegistration(String s) { - nativeRegistrations.add(s); - } - - public void emitNativeRegistration(String registrationFunctionName, - PrintStream cStream) { - cStream.println("static const char *classPathName = \"" + - mClassPathName + - "\";"); - cStream.println(); - - cStream.println("static JNINativeMethod methods[] = {"); - - cStream.println("{\"_nativeClassInit\", \"()V\", (void*)nativeClassInit },"); - - Iterator<String> i = nativeRegistrations.iterator(); - while (i.hasNext()) { - cStream.println(i.next()); - } - - cStream.println("};"); - cStream.println(); - - - cStream.println("int " + registrationFunctionName + "(JNIEnv *_env)"); - cStream.println("{"); - cStream.println(indent + - "int err;"); - - cStream.println(indent + - "err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));"); - - cStream.println(indent + "return err;"); - cStream.println("}"); - } - - public JniCodeEmitter() { - super(); - } - - String getJniType(JType jType) { - if (jType.isVoid()) { - return "void"; - } - - String baseType = jType.getBaseType(); - if (jType.isPrimitive()) { - if (baseType.equals("String")) { - return "jstring"; - } else { - return "j" + baseType; - } - } else if (jType.isArray()) { - return "j" + baseType + "Array"; - } else { - return "jobject"; - } - } - - String getJniMangledName(String name) { - name = name.replaceAll("_", "_1"); - name = name.replaceAll(";", "_2"); - name = name.replaceAll("\\[", "_3"); - return name; - } - - public void emitJniCode(JFunc jfunc, PrintStream out) { - CFunc cfunc = jfunc.getCFunc(); - - // Emit comment identifying original C function - // - // Example: - // - // /* void glClipPlanef ( GLenum plane, const GLfloat *equation ) */ - // - out.println("/* " + cfunc.getOriginal() + " */"); - - // Emit JNI signature (name) - // - // Example: - // - // void - // android_glClipPlanef__I_3FI - // - - String outName = "android_" + jfunc.getName(); - boolean isPointerFunc = isPointerFunc(jfunc); - boolean isVBOPointerFunc = (outName.endsWith("Pointer") || - outName.endsWith("PointerOES") || - outName.endsWith("DrawElements") || outName.endsWith("VertexAttribPointer")) && - !jfunc.getCFunc().hasPointerArg(); - if (isPointerFunc) { - outName += "Bounds"; - } - - out.print("static "); - out.println(getJniType(jfunc.getType())); - out.print(outName); - - String rsignature = getJniName(jfunc.getType()); - - String signature = ""; - int numArgs = jfunc.getNumArgs(); - for (int i = 0; i < numArgs; i++) { - JType argType = jfunc.getArgType(i); - signature += getJniName(argType); - } - if (isPointerFunc) { - signature += "I"; - } - - // Append signature to function name - String sig = getJniMangledName(signature).replace('.', '_').replace('/', '_'); - out.print("__" + sig); - outName += "__" + sig; - - signature = signature.replace('.', '/'); - rsignature = rsignature.replace('.', '/'); - - out.println(); - if (rsignature.length() == 0) { - rsignature = "V"; - } - - String s = "{\"" + - jfunc.getName() + - (isPointerFunc ? "Bounds" : "") + - "\", \"(" + signature +")" + - rsignature + - "\", (void *) " + - outName + - " },"; - nativeRegistrations.add(s); - - List<Integer> nonPrimitiveArgs = new ArrayList<Integer>(); - List<Integer> stringArgs = new ArrayList<Integer>(); - int numBufferArgs = 0; - List<String> bufferArgNames = new ArrayList<String>(); - - // Emit JNI signature (arguments) - // - // Example: - // - // (JNIEnv *_env, jobject this, jint plane, jfloatArray equation_ref, jint offset) { - // - out.print(" (JNIEnv *_env, jobject _this"); - for (int i = 0; i < numArgs; i++) { - out.print(", "); - JType argType = jfunc.getArgType(i); - String suffix; - if (!argType.isPrimitive()) { - if (argType.isArray()) { - suffix = "_ref"; - } else { - suffix = "_buf"; - } - nonPrimitiveArgs.add(new Integer(i)); - if (jfunc.getArgType(i).isBuffer()) { - int cIndex = jfunc.getArgCIndex(i); - String cname = cfunc.getArgName(cIndex); - bufferArgNames.add(cname); - numBufferArgs++; - } - } else { - suffix = ""; - } - if (argType.isString()) { - stringArgs.add(new Integer(i)); - } - - out.print(getJniType(argType) + " " + jfunc.getArgName(i) + suffix); - } - if (isPointerFunc) { - out.print(", jint remaining"); - } - out.println(") {"); - - int numArrays = 0; - int numBuffers = 0; - int numStrings = 0; - for (int i = 0; i < nonPrimitiveArgs.size(); i++) { - int idx = nonPrimitiveArgs.get(i).intValue(); - JType argType = jfunc.getArgType(idx); - if (argType.isArray()) { - ++numArrays; - } - if (argType.isBuffer()) { - ++numBuffers; - } - if (argType.isString()) { - ++numStrings; - } - } - - // Emit method body - - // Emit local variable declarations for _exception and _returnValue - // - // Example: - // - // android::gl::ogles_context_t *ctx; - // - // jint _exception; - // GLenum _returnValue; - // - CType returnType = cfunc.getType(); - boolean isVoid = returnType.isVoid(); - - boolean isUnsupported = isUnsupportedFunc(cfunc); - if (isUnsupported) { - out.println(indent + - "jniThrowException(_env, \"java/lang/UnsupportedOperationException\","); - out.println(indent + - " \"" + cfunc.getName() + "\");"); - if (!isVoid) { - String retval = getErrorReturnValue(cfunc); - out.println(indent + "return " + retval + ";"); - } - out.println("}"); - out.println(); - return; - } - - String requiresExtension = isRequiresFunc(cfunc); - if (requiresExtension != null) { - out.println(indent + - "if (! supportsExtension(_env, _this, have_" + requiresExtension + "ID)) {"); - out.println(indent + indent + - "jniThrowException(_env, \"java/lang/UnsupportedOperationException\","); - out.println(indent + indent + - " \"" + cfunc.getName() + "\");"); - if (isVoid) { - out.println(indent + indent + " return;"); - } else { - String retval = getErrorReturnValue(cfunc); - out.println(indent + indent + " return " + retval + ";"); - } - out.println(indent + "}"); - } - if (mUseContextPointer) { - out.println(indent + - "android::gl::ogles_context_t *ctx = getContext(_env, _this);"); - } - - boolean initializeReturnValue = stringArgs.size() > 0; - - boolean emitExceptionCheck = (numArrays > 0 || numBuffers > 0 || numStrings > 0) && - hasNonConstArg(jfunc, cfunc, nonPrimitiveArgs); - // mChecker.getChecks(cfunc.getName()) != null - - // Emit an _exeption variable if there will be error checks - if (emitExceptionCheck) { - out.println(indent + "jint _exception = 0;"); - } - - // Emit a single _array or multiple _XXXArray variables - if (numBufferArgs == 1) { - out.println(indent + "jarray _array = (jarray) 0;"); - } else { - for (int i = 0; i < numBufferArgs; i++) { - out.println(indent + "jarray _" + bufferArgNames.get(i) + - "Array = (jarray) 0;"); - } - } - if (!isVoid) { - String retval = getErrorReturnValue(cfunc); - if (retval != null) { - out.println(indent + returnType.getDeclaration() + - " _returnValue = " + retval + ";"); - } else if (initializeReturnValue) { - out.println(indent + returnType.getDeclaration() + - " _returnValue = 0;"); - } else { - out.println(indent + returnType.getDeclaration() + - " _returnValue;"); - } - } - - // Emit local variable declarations for pointer arguments - // - // Example: - // - // GLfixed *eqn_base; - // GLfixed *eqn; - // - String offset = "offset"; - String remaining = "_remaining"; - if (nonPrimitiveArgs.size() > 0) { - for (int i = 0; i < nonPrimitiveArgs.size(); i++) { - int idx = nonPrimitiveArgs.get(i).intValue(); - int cIndex = jfunc.getArgCIndex(idx); - String cname = cfunc.getArgName(cIndex); - - CType type = cfunc.getArgType(jfunc.getArgCIndex(idx)); - String decl = type.getDeclaration(); - if (jfunc.getArgType(idx).isArray()) { - out.println(indent + - decl + - (decl.endsWith("*") ? "" : " ") + - jfunc.getArgName(idx) + - "_base = (" + decl + ") 0;"); - } - remaining = ((numArrays + numBuffers) <= 1) ? "_remaining" : - "_" + cname + "Remaining"; - out.println(indent + - "jint " + remaining + ";"); - out.println(indent + - decl + - (decl.endsWith("*") ? "" : " ") + - jfunc.getArgName(idx) + - " = (" + decl + ") 0;"); - } - - out.println(); - } - - // Emit local variable declaration for strings - if (stringArgs.size() > 0) { - for (int i = 0; i < stringArgs.size(); i++) { - int idx = stringArgs.get(i).intValue(); - int cIndex = jfunc.getArgCIndex(idx); - String cname = cfunc.getArgName(cIndex); - - out.println(indent + "const char* _native" + cname + " = 0;"); - } - - out.println(); - } - - // Null pointer checks and GetStringUTFChars - if (stringArgs.size() > 0) { - for (int i = 0; i < stringArgs.size(); i++) { - int idx = stringArgs.get(i).intValue(); - int cIndex = jfunc.getArgCIndex(idx); - String cname = cfunc.getArgName(cIndex); - - CType type = cfunc.getArgType(jfunc.getArgCIndex(idx)); - String decl = type.getDeclaration(); - out.println(indent + "if (!" + cname + ") {"); - out.println(indent + " jniThrowException(_env, " + - "\"java/lang/IllegalArgumentException\", \"" + cname + " == null\");"); - out.println(indent + " goto exit;"); - needsExit = true; - out.println(indent + "}"); - - out.println(indent + "_native" + cname + " = _env->GetStringUTFChars(" + cname + ", 0);"); - } - - out.println(); - } - - // Emit 'GetPrimitiveArrayCritical' for arrays - // Emit 'GetPointer' calls for Buffer pointers - int bufArgIdx = 0; - if (nonPrimitiveArgs.size() > 0) { - for (int i = 0; i < nonPrimitiveArgs.size(); i++) { - int idx = nonPrimitiveArgs.get(i).intValue(); - int cIndex = jfunc.getArgCIndex(idx); - - String cname = cfunc.getArgName(cIndex); - offset = numArrays <= 1 ? "offset" : - cname + "Offset"; - remaining = ((numArrays + numBuffers) <= 1) ? "_remaining" : - "_" + cname + "Remaining"; - - if (jfunc.getArgType(idx).isArray()) { - out.println(indent + - "if (!" + - cname + - "_ref) {"); - if (emitExceptionCheck) { - out.println(indent + indent + "_exception = 1;"); - } - out.println(indent + " jniThrowException(_env, " + - "\"java/lang/IllegalArgumentException\", " + - "\"" + cname + " == null\");"); - out.println(indent + " goto exit;"); - needsExit = true; - out.println(indent + "}"); - - out.println(indent + "if (" + offset + " < 0) {"); - if (emitExceptionCheck) { - out.println(indent + indent + "_exception = 1;"); - } - out.println(indent + " jniThrowException(_env, " + - "\"java/lang/IllegalArgumentException\", \"" + offset + " < 0\");"); - out.println(indent + " goto exit;"); - needsExit = true; - out.println(indent + "}"); - - out.println(indent + remaining + " = " + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->GetArrayLength(" + - (mUseCPlusPlus ? "" : "_env, ") + - cname + "_ref) - " + offset + ";"); - - emitNativeBoundsChecks(cfunc, cname, out, false, - emitExceptionCheck, - offset, remaining, " "); - - out.println(indent + - cname + - "_base = (" + - cfunc.getArgType(cIndex).getDeclaration() + - ")"); - out.println(indent + " " + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->GetPrimitiveArrayCritical(" + - (mUseCPlusPlus ? "" : "_env, ") + - jfunc.getArgName(idx) + - "_ref, (jboolean *)0);"); - out.println(indent + - cname + " = " + cname + "_base + " + offset + - ";"); - out.println(); - } else { - String array = numBufferArgs <= 1 ? "_array" : - "_" + bufferArgNames.get(bufArgIdx++) + "Array"; - - boolean nullAllowed = isNullAllowed(cfunc) || isPointerFunc; - if (nullAllowed) { - out.println(indent + "if (" + cname + "_buf) {"); - out.print(indent); - } - - if (isPointerFunc) { - out.println(indent + - cname + - " = (" + - cfunc.getArgType(cIndex).getDeclaration() + - ") getDirectBufferPointer(_env, " + - cname + "_buf);"); - String iii = " "; - out.println(iii + indent + "if ( ! " + cname + " ) {"); - out.println(iii + iii + indent + "return;"); - out.println(iii + indent + "}"); - } else { - out.println(indent + - cname + - " = (" + - cfunc.getArgType(cIndex).getDeclaration() + - ")getPointer(_env, " + - cname + - "_buf, &" + array + ", &" + remaining + - ");"); - } - - emitNativeBoundsChecks(cfunc, cname, out, true, - emitExceptionCheck, - offset, remaining, nullAllowed ? " " : " "); - - if (nullAllowed) { - out.println(indent + "}"); - } - } - } - } - - if (!isVoid) { - out.print(indent + "_returnValue = "); - } else { - out.print(indent); - } - String name = cfunc.getName(); - - if (mUseContextPointer) { - name = name.substring(2, name.length()); // Strip off 'gl' prefix - name = name.substring(0, 1).toLowerCase() + - name.substring(1, name.length()); - out.print("ctx->procs."); - } - - out.print(name + (isPointerFunc ? "Bounds" : "") + "("); - - numArgs = cfunc.getNumArgs(); - if (numArgs == 0) { - if (mUseContextPointer) { - out.println("ctx);"); - } else { - out.println(");"); - } - } else { - if (mUseContextPointer) { - out.println("ctx,"); - } else { - out.println(); - } - for (int i = 0; i < numArgs; i++) { - String typecast; - if (i == numArgs - 1 && isVBOPointerFunc) { - typecast = "const GLvoid *"; - } else { - typecast = cfunc.getArgType(i).getDeclaration(); - } - out.print(indent + indent + - "(" + - typecast + - ")"); - if (cfunc.getArgType(i).isConstCharPointer()) { - out.print("_native"); - } - out.print(cfunc.getArgName(i)); - - if (i == numArgs - 1) { - if (isPointerFunc) { - out.println(","); - out.println(indent + indent + "(GLsizei)remaining"); - } else { - out.println(); - } - } else { - out.println(","); - } - } - out.println(indent + ");"); - } - - if (needsExit) { - out.println(); - out.println("exit:"); - needsExit = false; - } - - bufArgIdx = 0; - if (nonPrimitiveArgs.size() > 0) { - for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) { - int idx = nonPrimitiveArgs.get(i).intValue(); - - int cIndex = jfunc.getArgCIndex(idx); - if (jfunc.getArgType(idx).isArray()) { - - // If the argument is 'const', GL will not write to it. - // In this case, we can use the 'JNI_ABORT' flag to avoid - // the need to write back to the Java array - out.println(indent + - "if (" + jfunc.getArgName(idx) + "_base) {"); - out.println(indent + indent + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ReleasePrimitiveArrayCritical(" + - (mUseCPlusPlus ? "" : "_env, ") + - jfunc.getArgName(idx) + "_ref, " + - cfunc.getArgName(cIndex) + - "_base,"); - out.println(indent + indent + indent + - (cfunc.getArgType(cIndex).isConst() ? - "JNI_ABORT" : - "_exception ? JNI_ABORT: 0") + - ");"); - out.println(indent + "}"); - } else if (jfunc.getArgType(idx).isBuffer()) { - if (! isPointerFunc) { - String array = numBufferArgs <= 1 ? "_array" : - "_" + bufferArgNames.get(bufArgIdx++) + "Array"; - out.println(indent + "if (" + array + ") {"); - out.println(indent + indent + - "releasePointer(_env, " + array + ", " + - cfunc.getArgName(cIndex) + - ", " + - (cfunc.getArgType(cIndex).isConst() ? - "JNI_FALSE" : "_exception ? JNI_FALSE :" + - " JNI_TRUE") + - ");"); - out.println(indent + "}"); - } - } - } - } - - // Emit local variable declaration for strings - if (stringArgs.size() > 0) { - for (int i = 0; i < stringArgs.size(); i++) { - int idx = stringArgs.get(i).intValue(); - int cIndex = jfunc.getArgCIndex(idx); - String cname = cfunc.getArgName(cIndex); - - out.println(indent + "if (_native" + cname + ") {"); - out.println(indent + " _env->ReleaseStringUTFChars(" + cname + ", _native" + cname + ");"); - out.println(indent + "}"); - } - - out.println(); - } - - - if (!isVoid) { - out.println(indent + "return _returnValue;"); - } - - out.println("}"); - out.println(); - } - -} diff --git a/opengl/tools/glgen/src/Jsr239CodeEmitter.java b/opengl/tools/glgen/src/Jsr239CodeEmitter.java deleted file mode 100644 index c10efe3..0000000 --- a/opengl/tools/glgen/src/Jsr239CodeEmitter.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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. - */ - -import java.io.PrintStream; - -/** - * Emits a Java interface and Java & C implementation for a C function. - * - * <p> The Java interface will have Buffer and array variants for functions that - * have a typed pointer argument. The array variant will convert a single "<type> *data" - * argument to a pair of arguments "<type>[] data, int offset". - */ -public class Jsr239CodeEmitter extends JniCodeEmitter implements CodeEmitter { - - PrintStream mJava10InterfaceStream; - PrintStream mJava10ExtInterfaceStream; - PrintStream mJava11InterfaceStream; - PrintStream mJava11ExtInterfaceStream; - PrintStream mJava11ExtPackInterfaceStream; - PrintStream mJavaImplStream; - PrintStream mCStream; - - PrintStream mJavaInterfaceStream; - - /** - * @param java10InterfaceStream the PrintStream to which to emit the Java interface for GL 1.0 functions - * @param java10ExtInterfaceStream the PrintStream to which to emit the Java interface for GL 1.0 extension functions - * @param java11InterfaceStream the PrintStream to which to emit the Java interface for GL 1.1 functions - * @param java11ExtInterfaceStream the PrintStream to which to emit the Java interface for GL 1.1 Extension functions - * @param java11ExtPackInterfaceStream the PrintStream to which to emit the Java interface for GL 1.1 Extension Pack functions - * @param javaImplStream the PrintStream to which to emit the Java implementation - * @param cStream the PrintStream to which to emit the C implementation - */ - public Jsr239CodeEmitter(String classPathName, - ParameterChecker checker, - PrintStream java10InterfaceStream, - PrintStream java10ExtInterfaceStream, - PrintStream java11InterfaceStream, - PrintStream java11ExtInterfaceStream, - PrintStream java11ExtPackInterfaceStream, - PrintStream javaImplStream, - PrintStream cStream, - boolean useContextPointer) { - mClassPathName = classPathName; - mChecker = checker; - mJava10InterfaceStream = java10InterfaceStream; - mJava10ExtInterfaceStream = java10ExtInterfaceStream; - mJava11InterfaceStream = java11InterfaceStream; - mJava11ExtInterfaceStream = java11ExtInterfaceStream; - mJava11ExtPackInterfaceStream = java11ExtPackInterfaceStream; - mJavaImplStream = javaImplStream; - mCStream = cStream; - mUseContextPointer = useContextPointer; - } - - public void setVersion(int version, boolean ext, boolean pack) { - if (version == 0) { - mJavaInterfaceStream = ext ? mJava10ExtInterfaceStream : - mJava10InterfaceStream; - } else if (version == 1) { - mJavaInterfaceStream = ext ? - (pack ? mJava11ExtPackInterfaceStream : - mJava11ExtInterfaceStream) : - mJava11InterfaceStream; - } else { - throw new RuntimeException("Bad version: " + version); - } - } - - public void emitCode(CFunc cfunc, String original) { - emitCode(cfunc, original, mJavaInterfaceStream, mJavaImplStream, mCStream); - } - - public void emitNativeRegistration() { - emitNativeRegistration("register_com_google_android_gles_jni_GLImpl", mCStream); - } -} diff --git a/opengl/tools/glgen/src/ParameterChecker.java b/opengl/tools/glgen/src/ParameterChecker.java deleted file mode 100644 index bff6d86..0000000 --- a/opengl/tools/glgen/src/ParameterChecker.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -import java.io.BufferedReader; -import java.util.HashMap; - -public class ParameterChecker { - - HashMap<String,String[]> map = new HashMap<String,String[]>(); - - public ParameterChecker(BufferedReader reader) throws Exception { - String s; - while ((s = reader.readLine()) != null) { - String[] tokens = s.split("\\s"); - map.put(tokens[0], tokens); - } - } - - public String[] getChecks(String functionName) { - String[] checks = map.get(functionName); - if (checks == null && - (functionName.endsWith("fv") || - functionName.endsWith("xv") || - functionName.endsWith("iv"))) { - functionName = functionName.substring(0, functionName.length() - 2); - checks = map.get(functionName); - } - return checks; - } -} |