Skip to content

Commit 5f10266

Browse files
authored
Use gen_struct_info for more things in library_sdl.js (#22626)
It looks like the hardcoded values here were actually wrong.
1 parent 32801b3 commit 5f10266

File tree

4 files changed

+59
-4
lines changed

4 files changed

+59
-4
lines changed

src/library_sdl.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,19 +2668,19 @@ var LibrarySDL = {
26682668

26692669
#if USE_SDL == 2
26702670
if (rwops === undefined) {
2671-
var type = {{{ makeGetValue('rwopsID', 20 /*type*/, 'i32') }}};
2671+
var type = {{{ makeGetValue('rwopsID', C_STRUCTS.SDL_RWops.type, 'i32') }}};
26722672

26732673
if (type === 2/*SDL_RWOPS_STDFILE*/) {
2674-
var fp = {{{ makeGetValue('rwopsID', 28 /*hidden.stdio.fp*/, 'i32') }}};
2674+
var fp = {{{ makeGetValue('rwopsID', C_STRUCTS.SDL_RWops.hidden.stdio.fp, 'i32') }}};
26752675
var fd = _fileno(fp);
26762676
var stream = FS.getStream(fd);
26772677
if (stream) {
26782678
rwops = { filename: stream.path };
26792679
}
26802680
}
26812681
else if (type === 4/*SDL_RWOPS_MEMORY*/ || type === 5/*SDL_RWOPS_MEMORY_RO*/) {
2682-
var base = {{{ makeGetValue('rwopsID', 24 /*hidden.mem.base*/, 'i32') }}};
2683-
var stop = {{{ makeGetValue('rwopsID', 32 /*hidden.mem.stop*/, 'i32') }}};
2682+
var base = {{{ makeGetValue('rwopsID', C_STRUCTS.SDL_RWops.hidden.mem.base, 'i32') }}};
2683+
var stop = {{{ makeGetValue('rwopsID', C_STRUCTS.SDL_RWops.hidden.mem.stop, 'i32') }}};
26842684

26852685
rwops = { bytes: base, count: stop - base };
26862686
}

src/struct_info.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,29 @@
705705
]
706706
}
707707
},
708+
{
709+
"file": "SDL/SDL_rwops.h",
710+
"structs": {
711+
"SDL_RWops": [
712+
"type",
713+
{
714+
"hidden": [
715+
{
716+
"mem": [
717+
"base",
718+
"stop"
719+
]
720+
},
721+
{
722+
"stdio": [
723+
"fp"
724+
]
725+
}
726+
]
727+
}
728+
]
729+
}
730+
},
708731
{
709732
"file": "uuid/uuid.h",
710733
"defines": [

src/struct_info_generated.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,22 @@
744744
"format": 0,
745745
"palette": 4
746746
},
747+
"SDL_RWops": {
748+
"__size__": 32,
749+
"hidden": {
750+
"__size__": 12,
751+
"mem": {
752+
"__size__": 12,
753+
"base": 20,
754+
"stop": 28
755+
},
756+
"stdio": {
757+
"__size__": 8,
758+
"fp": 24
759+
}
760+
},
761+
"type": 16
762+
},
747763
"SDL_Rect": {
748764
"__size__": 16,
749765
"h": 12,

src/struct_info_generated_wasm64.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,22 @@
744744
"format": 0,
745745
"palette": 8
746746
},
747+
"SDL_RWops": {
748+
"__size__": 64,
749+
"hidden": {
750+
"__size__": 24,
751+
"mem": {
752+
"__size__": 24,
753+
"base": 40,
754+
"stop": 56
755+
},
756+
"stdio": {
757+
"__size__": 16,
758+
"fp": 48
759+
}
760+
},
761+
"type": 32
762+
},
747763
"SDL_Rect": {
748764
"__size__": 16,
749765
"h": 12,

0 commit comments

Comments
 (0)