From 90a131f3a40d991f9aebfabe95525b9e17a927a4 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Sun, 17 Mar 2024 18:18:32 +0100 Subject: [PATCH 1/6] Use enum value from header --- src/generated_struct_info32.json | 5 +++++ src/library_html5.js | 2 +- src/struct_info.json | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/generated_struct_info32.json b/src/generated_struct_info32.json index 7eb3d9def4d15..be71ef7fe9107 100644 --- a/src/generated_struct_info32.json +++ b/src/generated_struct_info32.json @@ -185,6 +185,11 @@ "EMSCRIPTEN_FULLSCREEN_SCALE_CENTER": 3, "EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT": 0, "EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH": 1, + "EMSCRIPTEN_ORIENTATION_LANDSCAPE_PRIMARY": 4, + "EMSCRIPTEN_ORIENTATION_LANDSCAPE_SECONDARY": 8, + "EMSCRIPTEN_ORIENTATION_PORTRAIT_PRIMARY": 1, + "EMSCRIPTEN_ORIENTATION_PORTRAIT_SECONDARY": 2, + "EMSCRIPTEN_ORIENTATION_UNSUPPORTED": 0, "EMSCRIPTEN_RESULT_DEFERRED": 1, "EMSCRIPTEN_RESULT_FAILED": -6, "EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED": -2, diff --git a/src/library_html5.js b/src/library_html5.js index d3932fa9b397e..edacdcba59e9e 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -940,7 +940,7 @@ var LibraryHTML5 = { // alternative selection from OrientationLockType enum var orientationsType2 = ['portrait', 'portrait', 'landscape', 'landscape']; - var orientationIndex = 0; + var orientationIndex = {{{ cDefs.EMSCRIPTEN_ORIENTATION_UNSUPPORTED }}}; var orientationAngle = 0; var screenOrientObj = screenOrientation(); if (typeof screenOrientObj === 'object') { diff --git a/src/struct_info.json b/src/struct_info.json index a01e76abb42aa..a94d5d2f70510 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -785,7 +785,13 @@ "EMSCRIPTEN_DEVICE_MOTION_EVENT_SUPPORTS_ACCELERATION", "EMSCRIPTEN_DEVICE_MOTION_EVENT_SUPPORTS_ACCELERATION_INCLUDING_GRAVITY", - "EMSCRIPTEN_DEVICE_MOTION_EVENT_SUPPORTS_ROTATION_RATE" + "EMSCRIPTEN_DEVICE_MOTION_EVENT_SUPPORTS_ROTATION_RATE", + + "EMSCRIPTEN_ORIENTATION_UNSUPPORTED", + "EMSCRIPTEN_ORIENTATION_PORTRAIT_PRIMARY", + "EMSCRIPTEN_ORIENTATION_PORTRAIT_SECONDARY", + "EMSCRIPTEN_ORIENTATION_LANDSCAPE_PRIMARY", + "EMSCRIPTEN_ORIENTATION_LANDSCAPE_SECONDARY" ], "structs": { "EmscriptenKeyboardEvent": [ From 993bb1406b826b531ad27e25c359e83b55fccb0b Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Mon, 18 Mar 2024 15:52:21 +0100 Subject: [PATCH 2/6] Only add minimum required enum entries --- src/generated_struct_info32.json | 4 ---- src/struct_info.json | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/generated_struct_info32.json b/src/generated_struct_info32.json index be71ef7fe9107..5e35537a8bf5c 100644 --- a/src/generated_struct_info32.json +++ b/src/generated_struct_info32.json @@ -185,10 +185,6 @@ "EMSCRIPTEN_FULLSCREEN_SCALE_CENTER": 3, "EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT": 0, "EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH": 1, - "EMSCRIPTEN_ORIENTATION_LANDSCAPE_PRIMARY": 4, - "EMSCRIPTEN_ORIENTATION_LANDSCAPE_SECONDARY": 8, - "EMSCRIPTEN_ORIENTATION_PORTRAIT_PRIMARY": 1, - "EMSCRIPTEN_ORIENTATION_PORTRAIT_SECONDARY": 2, "EMSCRIPTEN_ORIENTATION_UNSUPPORTED": 0, "EMSCRIPTEN_RESULT_DEFERRED": 1, "EMSCRIPTEN_RESULT_FAILED": -6, diff --git a/src/struct_info.json b/src/struct_info.json index a94d5d2f70510..433105ff1ebcb 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -787,11 +787,7 @@ "EMSCRIPTEN_DEVICE_MOTION_EVENT_SUPPORTS_ACCELERATION_INCLUDING_GRAVITY", "EMSCRIPTEN_DEVICE_MOTION_EVENT_SUPPORTS_ROTATION_RATE", - "EMSCRIPTEN_ORIENTATION_UNSUPPORTED", - "EMSCRIPTEN_ORIENTATION_PORTRAIT_PRIMARY", - "EMSCRIPTEN_ORIENTATION_PORTRAIT_SECONDARY", - "EMSCRIPTEN_ORIENTATION_LANDSCAPE_PRIMARY", - "EMSCRIPTEN_ORIENTATION_LANDSCAPE_SECONDARY" + "EMSCRIPTEN_ORIENTATION_UNSUPPORTED" ], "structs": { "EmscriptenKeyboardEvent": [ From f08ec75f0169bf0e03195ba8005f979fdc3cfde0 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Mon, 18 Mar 2024 16:08:18 +0100 Subject: [PATCH 3/6] Update 64-bit generated info --- src/generated_struct_info64.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/generated_struct_info64.json b/src/generated_struct_info64.json index b61bed8e15bf1..32e312de8b2cd 100644 --- a/src/generated_struct_info64.json +++ b/src/generated_struct_info64.json @@ -185,6 +185,7 @@ "EMSCRIPTEN_FULLSCREEN_SCALE_CENTER": 3, "EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT": 0, "EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH": 1, + "EMSCRIPTEN_ORIENTATION_UNSUPPORTED": 0, "EMSCRIPTEN_RESULT_DEFERRED": 1, "EMSCRIPTEN_RESULT_FAILED": -6, "EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED": -2, From 4a66a135817e7682e08e50241f77670ea1276db0 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Mon, 18 Mar 2024 19:37:34 +0100 Subject: [PATCH 4/6] Error message tested now matches actual error --- test/test_other.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_other.py b/test/test_other.py index 398929543ce9f..54c01eb1edb03 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -14027,13 +14027,13 @@ def test_missing_struct_info(self): {{{ C_STRUCTS.Foo }}} ''') err = self.expect_fail([EMCC, test_file('hello_world.c'), '--js-library=lib.js']) - self.assertContained('Error: Missing C struct Foo! If you just added it to struct_info.json, you need to run ./tools/gen_struct_info.py', err) + self.assertContained('Error: Missing C struct Foo! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)', err) create_file('lib.js', ''' {{{ C_DEFINES.Foo }}} ''') err = self.expect_fail([EMCC, test_file('hello_world.c'), '--js-library=lib.js']) - self.assertContained('Error: Missing C define Foo! If you just added it to struct_info.json, you need to run ./tools/gen_struct_info.py', err) + self.assertContained('Error: Missing C define Foo! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)', err) def run_wasi_test_suite_test(self, name): if not os.path.exists(path_from_root('test/third_party/wasi-test-suite')): From b8c30934fb7a2f565e9e2879d255d4d65692839d Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Tue, 19 Mar 2024 09:35:12 +0100 Subject: [PATCH 5/6] Improved error message --- src/modules.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules.mjs b/src/modules.mjs index 4097b9d37f7f4..e02381e069a52 100644 --- a/src/modules.mjs +++ b/src/modules.mjs @@ -300,7 +300,7 @@ const C_STRUCTS = new Proxy(structs, { get(target, prop, receiver) { if (!(prop in target)) { throw new Error( - `Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/gen_struct_info.py`, + `Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py`, ); } return target[prop]; @@ -311,7 +311,7 @@ const C_DEFINES = new Proxy(defines, { get(target, prop, receiver) { if (!(prop in target)) { throw new Error( - `Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/gen_struct_info.py`, + `Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py`, ); } return target[prop]; From d7ccdcfc3bfb5eb25dd81407fc7158c4c5b4e513 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Tue, 19 Mar 2024 11:05:41 +0100 Subject: [PATCH 6/6] Error message got reverted in the merge --- src/modules.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules.mjs b/src/modules.mjs index e02381e069a52..b8ea88dd78e68 100644 --- a/src/modules.mjs +++ b/src/modules.mjs @@ -300,7 +300,7 @@ const C_STRUCTS = new Proxy(structs, { get(target, prop, receiver) { if (!(prop in target)) { throw new Error( - `Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py`, + `Missing C struct ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`, ); } return target[prop]; @@ -311,7 +311,7 @@ const C_DEFINES = new Proxy(defines, { get(target, prop, receiver) { if (!(prop in target)) { throw new Error( - `Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py`, + `Missing C define ${prop}! If you just added it to struct_info.json, you need to run ./tools/maint/gen_struct_info.py (then run a second time with --wasm64)`, ); } return target[prop];