From f4933a2b59407ab1b16d7d9f31b5ae33a7dcaef5 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 7 Mar 2020 16:34:10 +0000 Subject: [PATCH] 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 --- .../openrs2/deob/ast/transform/GlConstantTransformer.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlConstantTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlConstantTransformer.kt index 371fe8b2f4..6577842187 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlConstantTransformer.kt +++ b/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.body.BodyDeclaration 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.expr.BinaryExpr import com.github.javaparser.ast.expr.Expression @@ -37,6 +38,10 @@ class GlConstantTransformer : Transformer() { return } + if (unit.primaryType.flatMap(TypeDeclaration<*>::getFullyQualifiedName).orElse(null) == JAGGL_CLASS) { + return + } + unit.walk { expr: MethodCallExpr -> if (!expr.nameAsString.startsWith("gl")) { return@walk @@ -49,7 +54,7 @@ class GlConstantTransformer : Transformer() { } val name = type.asReferenceType().qualifiedName - if (name == GL_CLASS) { + if (name == GL_CLASS || name == JAGGL_CLASS) { transformCall(unit, expr) } } @@ -200,6 +205,7 @@ class GlConstantTransformer : Transformer() { private val logger = InlineLogger() private const val GL_CLASS_UNQUALIFIED = "GL" 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 VENDORS = setOf("ARB", "EXT")