From 784ad9900eda0608653a995b9aca4d05912fe019 Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 10 Mar 2020 20:53:58 +0000 Subject: [PATCH] Always use GL_ constants without vendor suffixes where possible It's actually hard to determine whether to use a vendor suffix or not. For example, the client sometimes uses a bunch of *ARB functions with _ARB constants. However, it uses the non-_ARB constant with glGetFloat. It's very hard to fix this inconsistency while still using vendor suffixes. It seems much easier to just use the constants without the suffixes all the time. Signed-off-by: Graham --- .../ast/transform/GlConstantTransformer.kt | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) 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 a46e43e3d6..ead84d9a2f 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 @@ -21,7 +21,6 @@ import com.github.javaparser.resolution.types.ResolvedType import com.github.michaelbull.logging.InlineLogger import dev.openrs2.deob.ast.gl.GlCommand import dev.openrs2.deob.ast.gl.GlEnum -import dev.openrs2.deob.ast.gl.GlGroup import dev.openrs2.deob.ast.gl.GlParameter import dev.openrs2.deob.ast.gl.GlRegistry import dev.openrs2.deob.ast.util.checkedAsInt @@ -185,20 +184,6 @@ class GlConstantTransformer : Transformer() { } } - private val GlCommand.vendor: String? - get() = VENDORS.firstOrNull { name.endsWith(it) } - - private fun GlGroup.firstEnumOrNull(value: Int, vendor: String?): GlEnum? { - if (vendor != null) { - val enum = enums.filter { it.name.endsWith("_$vendor") }.firstOrNull { it.value == value.toLong() } - if (enum != null) { - return enum - } - } - - return enums.firstOrNull { it.value == value.toLong() } - } - private fun GlEnum.toExpr(): Expression { return FieldAccessExpr(NameExpr(GL_CLASS_UNQUALIFIED), name) } @@ -240,7 +225,6 @@ class GlConstantTransformer : Transformer() { expr: Expression ) { var value = expr.asIntegerLiteralExpr().checkedAsInt() - val vendor = command.vendor val group = parameter.group ?: return if (parameter.bitfield) { @@ -256,7 +240,7 @@ class GlConstantTransformer : Transformer() { continue } - val enum = group.firstEnumOrNull(bit, vendor) + val enum = group.enums.firstOrNull { it.value == bit.toLong() } if (enum != null) { bitfieldEnums += enum value = value and bit.inv() @@ -283,7 +267,7 @@ class GlConstantTransformer : Transformer() { expr.replace(orExpr) } } else { - val enum = group.firstEnumOrNull(value, vendor) + val enum = group.enums.firstOrNull { it.value == value.toLong() } if (enum != null) { unit.addImport(GL_CLASS) enums += enum @@ -303,7 +287,6 @@ class GlConstantTransformer : Transformer() { private const val JAGGL_CLASS = "jaggl.opengl" private val GL_CLASSES = setOf(GL_CLASS, JAGGL_CLASS) private val REGISTRY = GlRegistry.parse() - private val VENDORS = setOf("ARB", "EXT") private val FIELD_METHOD_COMPARATOR = Comparator> { a, b -> when {