Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors several library files (including libglemu.js, libglew.js, libglfw.js, libsdl.js, and libwebgl.js) to replace hardcoded magic numbers with symbolic constants defined in struct_info.json. However, in libglfw.js, several GLFW constants (such as GLFW_CURSOR and GLFW_RED_BITS) are accessed directly instead of through the cDefs object, which will lead to runtime ReferenceErrors. These constants must be prefixed with cDefs. to be correctly resolved.
fad7194 to
1625de3
Compare
There was a problem hiding this comment.
Code Review
This pull request replaces hardcoded numeric literals with symbolic constant names for GL, GLEW, GLFW, and SDL across several Emscripten JS library files, and updates the corresponding struct info metadata. However, the reviewer noted that referencing these constants directly in the JS scope will cause runtime ReferenceErrors and introduce runtime overhead. To resolve this, the reviewer recommends using compile-time preprocessor expansion (e.g., {{{ cDefs.CONSTANT_NAME }}}) to safely inline the constant values at compile-time.
In particular, make use of computed property names where possible.
1625de3 to
4ed74f9
Compare
| break; | ||
| } | ||
| case 0x00033002: { // GLFW_STICKY_KEYS | ||
| case GLFW_STICKY_KEYS: { |
There was a problem hiding this comment.
This constant differs between glfw and glfw3:
system/include/GLFW/glfw3.h:#define GLFW_STICKY_KEYS 0x00033002
system/include/GL/glfw.h:#define GLFW_STICKY_KEYS 0x00030002
Which should it be here? It looks like it is right in struct_info, but I am a little unsure?
| @@ -1,7 +1,7 @@ | |||
| { | |||
| "a.out.js": 272465, | |||
| "a.out.js": 272483, | |||
There was a problem hiding this comment.
Any idea why closure doesn't turn [5]:3 into 5:3?
Perhaps it is worth doing {{{ .. }}}: 3 in these cases to avoid a regression?
In particular, make use of computed property names where possible.
The small code size increase in WebGL builds (10 bytes in WebGL 1, 18
bytes in WebGL 2) is due to
colorChannelsInGlTextureFormatusingcomputed property names (
[GL_RGB - GL_DEPTH_COMPONENT]: 3), whichClosure folds to
[5]:3rather than5:3(2 extra bytes per entry).