Skip to content

Commit 2dc74c8

Browse files
authored
Use C/C++ bool type to implement EM_BOOL (#22157)
This reduces the size of several structs and can result in code size savings in some cases. The reason the code size savings don't show up in trivial examples is (I believe) because this change also increases the use of HEAP8 (where previously some examples only depended on HEAP32). This change is split of from a larger change I have planned to remove the use of EM_BOOL completely: #22155.
1 parent 09b765f commit 2dc74c8

12 files changed

+225
-221
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.62 (in development)
2222
-----------------------
23+
- The `EM_BOOL` type changed from `int/u32` to `bool/u8`. This changes the
24+
layout and size of some structs in the emscripten API. (#22157)
2325
- The `EMSCRIPTEN_FETCH_WAITABLE` flag along with the `emscripten_fetch_wait`
2426
API were marked a deprecated. These feature have not functions for several
2527
years now. (#22138)

src/generated_struct_info32.json

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,15 @@
493493
"nodeName": 0
494494
},
495495
"EmscriptenFullscreenChangeEvent": {
496-
"__size__": 280,
497-
"elementHeight": 268,
498-
"elementWidth": 264,
499-
"fullscreenEnabled": 4,
500-
"id": 136,
496+
"__size__": 276,
497+
"elementHeight": 264,
498+
"elementWidth": 260,
499+
"fullscreenEnabled": 1,
500+
"id": 130,
501501
"isFullscreen": 0,
502-
"nodeName": 8,
503-
"screenHeight": 276,
504-
"screenWidth": 272
502+
"nodeName": 2,
503+
"screenHeight": 272,
504+
"screenWidth": 268
505505
},
506506
"EmscriptenFullscreenStrategy": {
507507
"__size__": 24,
@@ -513,53 +513,53 @@
513513
"scaleMode": 0
514514
},
515515
"EmscriptenGamepadEvent": {
516-
"__size__": 1432,
516+
"__size__": 1240,
517517
"analogButton": 528,
518518
"axis": 16,
519-
"connected": 1296,
519+
"connected": 1104,
520520
"digitalButton": 1040,
521-
"id": 1304,
522-
"index": 1300,
523-
"mapping": 1368,
521+
"id": 1112,
522+
"index": 1108,
523+
"mapping": 1176,
524524
"numAxes": 8,
525525
"numButtons": 12,
526526
"timestamp": 0
527527
},
528528
"EmscriptenKeyboardEvent": {
529-
"__size__": 176,
530-
"altKey": 20,
531-
"charCode": 32,
532-
"charValue": 108,
533-
"code": 76,
529+
"__size__": 160,
530+
"altKey": 14,
531+
"charCode": 20,
532+
"charValue": 96,
533+
"code": 64,
534534
"ctrlKey": 12,
535-
"key": 44,
536-
"keyCode": 36,
537-
"locale": 140,
535+
"key": 32,
536+
"keyCode": 24,
537+
"locale": 128,
538538
"location": 8,
539-
"metaKey": 24,
540-
"repeat": 28,
541-
"shiftKey": 16,
539+
"metaKey": 15,
540+
"repeat": 16,
541+
"shiftKey": 13,
542542
"timestamp": 0,
543-
"which": 40
543+
"which": 28
544544
},
545545
"EmscriptenMouseEvent": {
546-
"__size__": 72,
547-
"altKey": 32,
548-
"button": 40,
549-
"buttons": 42,
550-
"canvasX": 60,
551-
"canvasY": 64,
546+
"__size__": 64,
547+
"altKey": 26,
548+
"button": 28,
549+
"buttons": 30,
550+
"canvasX": 48,
551+
"canvasY": 52,
552552
"clientX": 16,
553553
"clientY": 20,
554554
"ctrlKey": 24,
555-
"metaKey": 36,
556-
"movementX": 44,
557-
"movementY": 48,
555+
"metaKey": 27,
556+
"movementX": 32,
557+
"movementY": 36,
558558
"screenX": 8,
559559
"screenY": 12,
560-
"shiftKey": 28,
561-
"targetX": 52,
562-
"targetY": 56,
560+
"shiftKey": 25,
561+
"targetX": 40,
562+
"targetY": 44,
563563
"timestamp": 0
564564
},
565565
"EmscriptenOrientationChangeEvent": {
@@ -568,36 +568,36 @@
568568
"orientationIndex": 0
569569
},
570570
"EmscriptenPointerlockChangeEvent": {
571-
"__size__": 260,
572-
"id": 132,
571+
"__size__": 257,
572+
"id": 129,
573573
"isActive": 0,
574-
"nodeName": 4
574+
"nodeName": 1
575575
},
576576
"EmscriptenTouchEvent": {
577-
"__size__": 1696,
578-
"altKey": 20,
577+
"__size__": 1552,
578+
"altKey": 14,
579579
"ctrlKey": 12,
580-
"metaKey": 24,
580+
"metaKey": 15,
581581
"numTouches": 8,
582-
"shiftKey": 16,
582+
"shiftKey": 13,
583583
"timestamp": 0,
584-
"touches": 28
584+
"touches": 16
585585
},
586586
"EmscriptenTouchPoint": {
587-
"__size__": 52,
588-
"canvasX": 44,
589-
"canvasY": 48,
587+
"__size__": 48,
588+
"canvasX": 40,
589+
"canvasY": 44,
590590
"clientX": 12,
591591
"clientY": 16,
592592
"identifier": 0,
593593
"isChanged": 28,
594-
"onTarget": 32,
594+
"onTarget": 29,
595595
"pageX": 20,
596596
"pageY": 24,
597597
"screenX": 4,
598598
"screenY": 8,
599-
"targetX": 36,
600-
"targetY": 40
599+
"targetX": 32,
600+
"targetY": 36
601601
},
602602
"EmscriptenUiEvent": {
603603
"__size__": 36,
@@ -617,26 +617,26 @@
617617
"visibilityState": 4
618618
},
619619
"EmscriptenWebGLContextAttributes": {
620-
"__size__": 56,
620+
"__size__": 36,
621621
"alpha": 0,
622-
"antialias": 12,
623-
"depth": 4,
624-
"enableExtensionsByDefault": 40,
625-
"explicitSwapControl": 44,
626-
"failIfMajorPerformanceCaveat": 28,
627-
"majorVersion": 32,
628-
"minorVersion": 36,
629-
"powerPreference": 24,
630-
"premultipliedAlpha": 16,
631-
"preserveDrawingBuffer": 20,
632-
"proxyContextToMainThread": 48,
633-
"renderViaOffscreenBackBuffer": 52,
634-
"stencil": 8
622+
"antialias": 3,
623+
"depth": 1,
624+
"enableExtensionsByDefault": 24,
625+
"explicitSwapControl": 25,
626+
"failIfMajorPerformanceCaveat": 12,
627+
"majorVersion": 16,
628+
"minorVersion": 20,
629+
"powerPreference": 8,
630+
"premultipliedAlpha": 4,
631+
"preserveDrawingBuffer": 5,
632+
"proxyContextToMainThread": 28,
633+
"renderViaOffscreenBackBuffer": 32,
634+
"stencil": 2
635635
},
636636
"EmscriptenWebSocketCloseEvent": {
637-
"__size__": 524,
638-
"code": 8,
639-
"reason": 10,
637+
"__size__": 520,
638+
"code": 6,
639+
"reason": 8,
640640
"wasClean": 4
641641
},
642642
"EmscriptenWebSocketCreateAttributes": {
@@ -650,11 +650,11 @@
650650
"numBytes": 8
651651
},
652652
"EmscriptenWheelEvent": {
653-
"__size__": 104,
654-
"deltaMode": 96,
655-
"deltaX": 72,
656-
"deltaY": 80,
657-
"deltaZ": 88,
653+
"__size__": 96,
654+
"deltaMode": 88,
655+
"deltaX": 64,
656+
"deltaY": 72,
657+
"deltaZ": 80,
658658
"mouse": 0
659659
},
660660
"SDL_AudioSpec": {

0 commit comments

Comments
 (0)