Add support for translating gl calls on the jaggl.opengl object

This picks up a glGetString(GL_EXTENSIONS) constant.

Don't translate gl calls within the jaggl.opengl class itself. This
causes failures as there are native methods with 0 and 1 suffixes. These
methods don't exist in the OpenGL registry, causing the transformer to
throw an exception.

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent 0564bc29b0
commit f4933a2b59
  1. 8
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlConstantTransformer.kt

@ -4,6 +4,7 @@ import com.github.javaparser.ast.CompilationUnit
import com.github.javaparser.ast.NodeList import com.github.javaparser.ast.NodeList
import com.github.javaparser.ast.body.BodyDeclaration import com.github.javaparser.ast.body.BodyDeclaration
import com.github.javaparser.ast.body.FieldDeclaration import com.github.javaparser.ast.body.FieldDeclaration
import com.github.javaparser.ast.body.TypeDeclaration
import com.github.javaparser.ast.body.VariableDeclarator import com.github.javaparser.ast.body.VariableDeclarator
import com.github.javaparser.ast.expr.BinaryExpr import com.github.javaparser.ast.expr.BinaryExpr
import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.Expression
@ -37,6 +38,10 @@ class GlConstantTransformer : Transformer() {
return return
} }
if (unit.primaryType.flatMap(TypeDeclaration<*>::getFullyQualifiedName).orElse(null) == JAGGL_CLASS) {
return
}
unit.walk { expr: MethodCallExpr -> unit.walk { expr: MethodCallExpr ->
if (!expr.nameAsString.startsWith("gl")) { if (!expr.nameAsString.startsWith("gl")) {
return@walk return@walk
@ -49,7 +54,7 @@ class GlConstantTransformer : Transformer() {
} }
val name = type.asReferenceType().qualifiedName val name = type.asReferenceType().qualifiedName
if (name == GL_CLASS) { if (name == GL_CLASS || name == JAGGL_CLASS) {
transformCall(unit, expr) transformCall(unit, expr)
} }
} }
@ -200,6 +205,7 @@ class GlConstantTransformer : Transformer() {
private val logger = InlineLogger() private val logger = InlineLogger()
private const val GL_CLASS_UNQUALIFIED = "GL" private const val GL_CLASS_UNQUALIFIED = "GL"
private const val GL_CLASS = "javax.media.opengl.$GL_CLASS_UNQUALIFIED" private const val GL_CLASS = "javax.media.opengl.$GL_CLASS_UNQUALIFIED"
private const val JAGGL_CLASS = "jaggl.opengl"
private val REGISTRY = GlRegistry.parse() private val REGISTRY = GlRegistry.parse()
private val VENDORS = setOf("ARB", "EXT") private val VENDORS = setOf("ARB", "EXT")

Loading…
Cancel
Save