summaryrefslogtreecommitdiffstats
path: root/opengl/tools/glgen/src
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-02-22 19:34:06 -0800
committerMathias Agopian <mathias@google.com>2013-02-25 16:50:51 -0800
commitbf13ba5e77804ca7466acb7100cdaf7c14cc0fb7 (patch)
treec600eac8af2915a39ed2ae0ca8aaeefb8f915a2d /opengl/tools/glgen/src
parentf5c7cb316cc8c8e2d6ae93a659ac771420cbfa2b (diff)
downloadframeworks_native-bf13ba5e77804ca7466acb7100cdaf7c14cc0fb7.zip
frameworks_native-bf13ba5e77804ca7466acb7100cdaf7c14cc0fb7.tar.gz
frameworks_native-bf13ba5e77804ca7466acb7100cdaf7c14cc0fb7.tar.bz2
add some missing parameter validation in GLES java bindings
- added support for comments in checks.spec - added most missing checks - added and commented with // special-cased functions - added and commented with # functions that are still missing validation checks - moved glGet* to a special case and updated all the "pnames" from the khronos spec - changed ifcheck to default to 1 value. this allows us to simplify the checks.spec file and handle unknown pnames automatically (they'll be validated against 1 value, if it happens to need more, the call will go through but the validation will not happen). - refactored the cpp headers in to a common header + GLES version specific header Bug: 7402895 Change-Id: Ib5c68ca0ca416407b4cfa36e3a21901b2d6263ab
Diffstat (limited to 'opengl/tools/glgen/src')
-rw-r--r--opengl/tools/glgen/src/GenerateGLES.java4
-rw-r--r--opengl/tools/glgen/src/JniCodeEmitter.java46
-rw-r--r--opengl/tools/glgen/src/ParameterChecker.java17
3 files changed, 39 insertions, 28 deletions
diff --git a/opengl/tools/glgen/src/GenerateGLES.java b/opengl/tools/glgen/src/GenerateGLES.java
index 6468957..6f9da5d 100644
--- a/opengl/tools/glgen/src/GenerateGLES.java
+++ b/opengl/tools/glgen/src/GenerateGLES.java
@@ -42,7 +42,6 @@ public class GenerateGLES {
}
CFunc cfunc = CFunc.parseCFunc(s);
-
String fname = cfunc.getName();
String stubRoot = "stubs/gles11/" + fname;
String javaPath = stubRoot + ".java";
@@ -96,10 +95,9 @@ public class GenerateGLES {
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);
+ copy("stubs/gles11/common.cpp", gl11cStream);
GLESCodeEmitter emitter = new GLESCodeEmitter(
"android/opengl/" + suffix,
checker, gl11Stream, gl11cStream);
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
index 774f40c..01c5c48 100644
--- a/opengl/tools/glgen/src/JniCodeEmitter.java
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -197,30 +197,30 @@ public class JniCodeEmitter {
void printIfcheckPostamble(PrintStream out, boolean isBuffer, boolean emitExceptionCheck,
String iii) {
- printIfcheckPostamble(out, isBuffer, emitExceptionCheck,
- "offset", "_remaining", 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) {");
- out.println(iii + indent + "_exception = 1;");
- out.println(iii + indent +
- "_exceptionType = \"java/lang/IllegalArgumentException\";");
- out.println(iii + indent +
- "_exceptionMessage = \"" +
- (isBuffer ? "remaining()" : "length - " + offset) +
- " < needed\";");
- out.println(iii + indent + "goto exit;");
- out.println(iii + "}");
-
- needsExit = true;
- }
+ out.println(iii + " default:");
+ out.println(iii + " _needed = 1;");
+ out.println(iii + " break;");
+ out.println(iii + "}");
+
+ out.println(iii + "if (" + remaining + " < _needed) {");
+ out.println(iii + indent + "_exception = 1;");
+ out.println(iii + indent +
+ "_exceptionType = \"java/lang/IllegalArgumentException\";");
+ out.println(iii + indent +
+ "_exceptionMessage = \"" +
+ (isBuffer ? "remaining()" : "length - " + offset) +
+ " < needed\";");
+ out.println(iii + indent + "goto exit;");
+ out.println(iii + "}");
+
+ needsExit = true;
+ }
boolean isNullAllowed(CFunc cfunc) {
String[] checks = mChecker.getChecks(cfunc.getName());
@@ -932,8 +932,8 @@ public class JniCodeEmitter {
// Emit an _exeption variable if there will be error checks
if (emitExceptionCheck) {
out.println(indent + "jint _exception = 0;");
- out.println(indent + "const char * _exceptionType;");
- out.println(indent + "const char * _exceptionMessage;");
+ out.println(indent + "const char * _exceptionType = NULL;");
+ out.println(indent + "const char * _exceptionMessage = NULL;");
}
// Emit a single _array or multiple _XXXArray variables
diff --git a/opengl/tools/glgen/src/ParameterChecker.java b/opengl/tools/glgen/src/ParameterChecker.java
index bff6d86..fbc47fb 100644
--- a/opengl/tools/glgen/src/ParameterChecker.java
+++ b/opengl/tools/glgen/src/ParameterChecker.java
@@ -22,8 +22,21 @@ 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 line;
+ while ((line = reader.readLine()) != null) {
+ String s = line.trim();
+
+ // skip empty lines
+ if (s.isEmpty()) {
+ continue;
+ }
+
+ // skip single-line comments
+ if (s.startsWith("//") ||
+ s.startsWith("#")) {
+ continue;
+ }
+
String[] tokens = s.split("\\s");
map.put(tokens[0], tokens);
}