Skip to content

Commit

Permalink
feat(api): [opengl] do not seal classes
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Jan 9, 2025
1 parent 6a9522c commit da23cbf
Show file tree
Hide file tree
Showing 21 changed files with 19 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class InstanceDowncall(
var constructorCode: String? = null
var customCode: String? = null
private val extends = mutableListOf<String>()
private val permits = mutableListOf<String>()
private val fields = mutableListOf<InstanceDowncallField>()
val handleFields = mutableListOf<InstanceDowncallField>()
val pfnFields = mutableListOf<InstanceDowncallField>()
Expand All @@ -48,10 +47,6 @@ class InstanceDowncall(
extends.add(name)
}

fun permits(name: String) {
permits.add(name)
}

fun field(field: InstanceDowncallField) {
if (fields.none { it.name == field.name })
fields.add(field)
Expand Down Expand Up @@ -88,10 +83,6 @@ class InstanceDowncall(
sb.append(" extends ")
sb.append(extends.joinToString(", "))
}
if (permits.isNotEmpty()) {
sb.append(" permits ")
sb.append(permits.joinToString(", "))
}
sb.appendLine(" {")

// fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,6 @@ val featureExtends = mapOf(
"4.5" to "44",
"4.6" to "45",
)
val featurePermits = mapOf(
"1.0" to "11",
"1.1" to "12",
"1.2" to "13",
"1.3" to "14",
"1.4" to "15",
"1.5" to "20",
"2.0" to "21",
"2.1" to "30",
"3.0" to "31",
"3.1" to "32",
"3.2" to "33",
"3.3" to "40",
"4.0" to "41",
"4.1" to "42",
"4.2" to "43",
"4.3" to "44",
"4.4" to "45",
"4.5" to "46",
"4.6" to "",
)

private fun useStack(code: String): String =
"try (var __stack = MemoryStack.pushLocal()) { $code }"
Expand Down Expand Up @@ -671,9 +650,7 @@ fun main() {
val featureAddedCommands = mutableListOf<String>()
features.forEach { feature ->
InstanceDowncall(openglPackage, "GL${feature.number.replace(".", "")}") {
modifier = "sealed"
featureExtends[feature.number]?.also { extends("GL${it}") }
featurePermits[feature.number]?.also { permits("GL${it}") }
constructorParam = "GLLoadFunc func"
constructorCode = buildString {
if (feature.number != "1.0") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL10 permits GL11 {
public class GL10 {
public static final int GL_DEPTH_BUFFER_BIT = 0x00000100;
public static final int GL_STENCIL_BUFFER_BIT = 0x00000400;
public static final int GL_COLOR_BUFFER_BIT = 0x00004000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL11 extends GL10 permits GL12 {
public class GL11 extends GL10 {
public static final int GL_COLOR_LOGIC_OP = 0x0BF2;
public static final int GL_POLYGON_OFFSET_UNITS = 0x2A00;
public static final int GL_POLYGON_OFFSET_POINT = 0x2A01;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL12 extends GL11 permits GL13 {
public class GL12 extends GL11 {
public static final int GL_UNSIGNED_BYTE_3_3_2 = 0x8032;
public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL13 extends GL12 permits GL14 {
public class GL13 extends GL12 {
public static final int GL_TEXTURE0 = 0x84C0;
public static final int GL_TEXTURE1 = 0x84C1;
public static final int GL_TEXTURE2 = 0x84C2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL14 extends GL13 permits GL15 {
public class GL14 extends GL13 {
public static final int GL_BLEND_DST_RGB = 0x80C8;
public static final int GL_BLEND_SRC_RGB = 0x80C9;
public static final int GL_BLEND_DST_ALPHA = 0x80CA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL15 extends GL14 permits GL20 {
public class GL15 extends GL14 {
public static final int GL_BUFFER_SIZE = 0x8764;
public static final int GL_BUFFER_USAGE = 0x8765;
public static final int GL_QUERY_COUNTER_BITS = 0x8864;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL20 extends GL15 permits GL21 {
public class GL20 extends GL15 {
public static final int GL_BLEND_EQUATION_RGB = 0x8009;
public static final int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
public static final int GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL21 extends GL20 permits GL30 {
public class GL21 extends GL20 {
public static final int GL_PIXEL_PACK_BUFFER = 0x88EB;
public static final int GL_PIXEL_UNPACK_BUFFER = 0x88EC;
public static final int GL_PIXEL_PACK_BUFFER_BINDING = 0x88ED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL30 extends GL21 permits GL31 {
public class GL30 extends GL21 {
public static final int GL_COMPARE_REF_TO_TEXTURE = 0x884E;
public static final int GL_CLIP_DISTANCE0 = 0x3000;
public static final int GL_CLIP_DISTANCE1 = 0x3001;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL31 extends GL30 permits GL32 {
public class GL31 extends GL30 {
public static final int GL_SAMPLER_2D_RECT = 0x8B63;
public static final int GL_SAMPLER_2D_RECT_SHADOW = 0x8B64;
public static final int GL_SAMPLER_BUFFER = 0x8DC2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL32 extends GL31 permits GL33 {
public class GL32 extends GL31 {
public static final int GL_CONTEXT_CORE_PROFILE_BIT = 0x00000001;
public static final int GL_CONTEXT_COMPATIBILITY_PROFILE_BIT = 0x00000002;
public static final int GL_LINES_ADJACENCY = 0x000A;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL33 extends GL32 permits GL40 {
public class GL33 extends GL32 {
public static final int GL_VERTEX_ATTRIB_ARRAY_DIVISOR = 0x88FE;
public static final int GL_SRC1_COLOR = 0x88F9;
public static final int GL_ONE_MINUS_SRC1_COLOR = 0x88FA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL40 extends GL33 permits GL41 {
public class GL40 extends GL33 {
public static final int GL_SAMPLE_SHADING = 0x8C36;
public static final int GL_MIN_SAMPLE_SHADING_VALUE = 0x8C37;
public static final int GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET = 0x8E5E;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL41 extends GL40 permits GL42 {
public class GL41 extends GL40 {
public static final int GL_FIXED = 0x140C;
public static final int GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A;
public static final int GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL42 extends GL41 permits GL43 {
public class GL42 extends GL41 {
public static final int GL_COPY_READ_BUFFER_BINDING = 0x8F36;
public static final int GL_COPY_WRITE_BUFFER_BINDING = 0x8F37;
public static final int GL_TRANSFORM_FEEDBACK_ACTIVE = 0x8E24;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL43 extends GL42 permits GL44 {
public class GL43 extends GL42 {
public static final int GL_NUM_SHADING_LANGUAGE_VERSIONS = 0x82E9;
public static final int GL_VERTEX_ATTRIB_ARRAY_LONG = 0x874E;
public static final int GL_COMPRESSED_RGB8_ETC2 = 0x9274;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL44 extends GL43 permits GL45 {
public class GL44 extends GL43 {
public static final int GL_MAX_VERTEX_ATTRIB_STRIDE = 0x82E5;
public static final int GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED = 0x8221;
public static final int GL_TEXTURE_BUFFER_BINDING = 0x8C2A;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL45 extends GL44 permits GL46 {
public class GL45 extends GL44 {
public static final int GL_CONTEXT_LOST = 0x0507;
public static final int GL_NEGATIVE_ONE_TO_ONE = 0x935E;
public static final int GL_ZERO_TO_ONE = 0x935F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import overrungl.internal.RuntimeHelper;
import overrungl.util.*;

public sealed class GL46 extends GL45 permits GL {
public class GL46 extends GL45 {
public static final int GL_SHADER_BINARY_FORMAT_SPIR_V = 0x9551;
public static final int GL_SPIR_V_BINARY = 0x9552;
public static final int GL_PARAMETER_BUFFER = 0x80EE;
Expand Down

0 comments on commit da23cbf

Please sign in to comment.