Skip to content

Commit c2ad9bc

Browse files
committed
Fix use of makeGetValue in library_sdl.js. NFC
1 parent 77e24ae commit c2ad9bc

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

src/library_sdl.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ var LibrarySDL = {
291291
},
292292
loadRect(rect) {
293293
return {
294-
x: {{{ makeGetValue('rect + ' + C_STRUCTS.SDL_Rect.x, '0', 'i32') }}},
295-
y: {{{ makeGetValue('rect + ' + C_STRUCTS.SDL_Rect.y, '0', 'i32') }}},
296-
w: {{{ makeGetValue('rect + ' + C_STRUCTS.SDL_Rect.w, '0', 'i32') }}},
297-
h: {{{ makeGetValue('rect + ' + C_STRUCTS.SDL_Rect.h, '0', 'i32') }}}
294+
x: {{{ makeGetValue('rect', C_STRUCTS.SDL_Rect.x, 'i32') }}},
295+
y: {{{ makeGetValue('rect', C_STRUCTS.SDL_Rect.y, 'i32') }}},
296+
w: {{{ makeGetValue('rect', C_STRUCTS.SDL_Rect.w, 'i32') }}},
297+
h: {{{ makeGetValue('rect', C_STRUCTS.SDL_Rect.h, 'i32') }}}
298298
};
299299
},
300300

@@ -331,11 +331,11 @@ var LibrarySDL = {
331331

332332
// Load SDL color into a CSS-style color specification
333333
loadColorToCSSRGB(color) {
334-
var rgba = {{{ makeGetValue('color', '0', 'i32') }}};
334+
var rgba = {{{ makeGetValue('color', 0, 'i32') }}};
335335
return 'rgb(' + (rgba&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba >> 16)&255) + ')';
336336
},
337337
loadColorToCSSRGBA(color) {
338-
var rgba = {{{ makeGetValue('color', '0', 'i32') }}};
338+
var rgba = {{{ makeGetValue('color', 0, 'i32') }}};
339339
return 'rgba(' + (rgba&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba >> 16)&255) + ',' + (((rgba >> 24)&255)/255) + ')';
340340
},
341341

@@ -466,16 +466,16 @@ var LibrarySDL = {
466466
for (var y = startY; y < endY; ++y) {
467467
var base = y * fullWidth;
468468
for (var x = startX; x < endX; ++x) {
469-
data32[base + x] = colors32[{{{ makeGetValue('buffer + base + x', '0', 'u8') }}}];
469+
data32[base + x] = colors32[{{{ makeGetValue('buffer', 'base + x', 'u8') }}}];
470470
}
471471
}
472472
},
473473

474474
freeSurface(surf) {
475475
var refcountPointer = surf + {{{ C_STRUCTS.SDL_Surface.refcount }}};
476-
var refcount = {{{ makeGetValue('refcountPointer', '0', 'i32') }}};
476+
var refcount = {{{ makeGetValue('refcountPointer', 0, 'i32') }}};
477477
if (refcount > 1) {
478-
{{{ makeSetValue('refcountPointer', '0', 'refcount - 1', 'i32') }}};
478+
{{{ makeSetValue('refcountPointer', 0, 'refcount - 1', 'i32') }}};
479479
return;
480480
}
481481

@@ -1351,9 +1351,9 @@ var LibrarySDL = {
13511351
SDL_Linked_Version: () => {
13521352
if (SDL.version === null) {
13531353
SDL.version = _malloc({{{ C_STRUCTS.SDL_version.__size__ }}});
1354-
{{{ makeSetValue('SDL.version + ' + C_STRUCTS.SDL_version.major, '0', '1', 'i8') }}};
1355-
{{{ makeSetValue('SDL.version + ' + C_STRUCTS.SDL_version.minor, '0', '3', 'i8') }}};
1356-
{{{ makeSetValue('SDL.version + ' + C_STRUCTS.SDL_version.patch, '0', '0', 'i8') }}};
1354+
{{{ makeSetValue('SDL.version', C_STRUCTS.SDL_version.major, '1', 'i8') }}};
1355+
{{{ makeSetValue('SDL.version', C_STRUCTS.SDL_version.minor, '3', 'i8') }}};
1356+
{{{ makeSetValue('SDL.version', C_STRUCTS.SDL_version.patch, '0', 'i8') }}};
13571357
}
13581358
return SDL.version;
13591359
},
@@ -1693,7 +1693,7 @@ var LibrarySDL = {
16931693
var base = y*width*4;
16941694
for (var x = 0; x < width; x++) {
16951695
// See comment above about signs
1696-
var val = {{{ makeGetValue('s++', '0', 'u8') }}} * 4;
1696+
var val = {{{ makeGetValue('s++', 0, 'u8') }}} * 4;
16971697
var start = base + x*4;
16981698
data[start] = colors[val];
16991699
data[start+1] = colors[val+1];
@@ -1769,8 +1769,8 @@ var LibrarySDL = {
17691769

17701770
SDL_GetMouseState__proxy: 'sync',
17711771
SDL_GetMouseState: (x, y) => {
1772-
if (x) {{{ makeSetValue('x', '0', 'Browser.mouseX', 'i32') }}};
1773-
if (y) {{{ makeSetValue('y', '0', 'Browser.mouseY', 'i32') }}};
1772+
if (x) {{{ makeSetValue('x', 0, 'Browser.mouseX', 'i32') }}};
1773+
if (y) {{{ makeSetValue('y', 0, 'Browser.mouseY', 'i32') }}};
17741774
return SDL.buttonState;
17751775
},
17761776

@@ -2094,13 +2094,13 @@ var LibrarySDL = {
20942094
SDL.checkPixelFormat(fmt);
20952095
// We assume the machine is little-endian.
20962096
if (r) {
2097-
{{{ makeSetValue('r', '0', 'pixel&0xff', 'i8') }}};
2097+
{{{ makeSetValue('r', 0, 'pixel&0xff', 'i8') }}};
20982098
}
20992099
if (g) {
2100-
{{{ makeSetValue('g', '0', '(pixel>>8)&0xff', 'i8') }}};
2100+
{{{ makeSetValue('g', 0, '(pixel>>8)&0xff', 'i8') }}};
21012101
}
21022102
if (b) {
2103-
{{{ makeSetValue('b', '0', '(pixel>>16)&0xff', 'i8') }}};
2103+
{{{ makeSetValue('b', 0, '(pixel>>16)&0xff', 'i8') }}};
21042104
}
21052105
},
21062106

@@ -2109,16 +2109,16 @@ var LibrarySDL = {
21092109
SDL.checkPixelFormat(fmt);
21102110
// We assume the machine is little-endian.
21112111
if (r) {
2112-
{{{ makeSetValue('r', '0', 'pixel&0xff', 'i8') }}};
2112+
{{{ makeSetValue('r', 0, 'pixel&0xff', 'i8') }}};
21132113
}
21142114
if (g) {
2115-
{{{ makeSetValue('g', '0', '(pixel>>8)&0xff', 'i8') }}};
2115+
{{{ makeSetValue('g', 0, '(pixel>>8)&0xff', 'i8') }}};
21162116
}
21172117
if (b) {
2118-
{{{ makeSetValue('b', '0', '(pixel>>16)&0xff', 'i8') }}};
2118+
{{{ makeSetValue('b', 0, '(pixel>>16)&0xff', 'i8') }}};
21192119
}
21202120
if (a) {
2121-
{{{ makeSetValue('a', '0', '(pixel>>24)&0xff', 'i8') }}};
2121+
{{{ makeSetValue('a', 0, '(pixel>>24)&0xff', 'i8') }}};
21222122
}
21232123
},
21242124

@@ -2668,19 +2668,19 @@ var LibrarySDL = {
26682668

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

26732673
if (type === 2/*SDL_RWOPS_STDFILE*/) {
2674-
var fp = {{{ makeGetValue('rwopsID + ' + 28 /*hidden.stdio.fp*/, '0', 'i32') }}};
2674+
var fp = {{{ makeGetValue('rwopsID', 28 /*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*/, '0', 'i32') }}};
2683-
var stop = {{{ makeGetValue('rwopsID + ' + 32 /*hidden.mem.stop*/, '0', 'i32') }}};
2682+
var base = {{{ makeGetValue('rwopsID', 24 /*hidden.mem.base*/, 'i32') }}};
2683+
var stop = {{{ makeGetValue('rwopsID', 32 /*hidden.mem.stop*/, 'i32') }}};
26842684

26852685
rwops = { bytes: base, count: stop - base };
26862686
}
@@ -3129,10 +3129,10 @@ var LibrarySDL = {
31293129
TTF_SizeText: (font, text, w, h) => {
31303130
var fontData = SDL.fonts[font];
31313131
if (w) {
3132-
{{{ makeSetValue('w', '0', 'SDL.estimateTextWidth(fontData, UTF8ToString(text))', 'i32') }}};
3132+
{{{ makeSetValue('w', 0, 'SDL.estimateTextWidth(fontData, UTF8ToString(text))', 'i32') }}};
31333133
}
31343134
if (h) {
3135-
{{{ makeSetValue('h', '0', 'fontData.size', 'i32') }}};
3135+
{{{ makeSetValue('h', 0, 'fontData.size', 'i32') }}};
31363136
}
31373137
return 0;
31383138
},
@@ -3143,19 +3143,19 @@ var LibrarySDL = {
31433143
var width = SDL.estimateTextWidth(fontData, String.fromCharCode(ch));
31443144

31453145
if (advance) {
3146-
{{{ makeSetValue('advance', '0', 'width', 'i32') }}};
3146+
{{{ makeSetValue('advance', 0, 'width', 'i32') }}};
31473147
}
31483148
if (minx) {
3149-
{{{ makeSetValue('minx', '0', '0', 'i32') }}};
3149+
{{{ makeSetValue('minx', 0, '0', 'i32') }}};
31503150
}
31513151
if (maxx) {
3152-
{{{ makeSetValue('maxx', '0', 'width', 'i32') }}};
3152+
{{{ makeSetValue('maxx', 0, 'width', 'i32') }}};
31533153
}
31543154
if (miny) {
3155-
{{{ makeSetValue('miny', '0', '0', 'i32') }}};
3155+
{{{ makeSetValue('miny', 0, '0', 'i32') }}};
31563156
}
31573157
if (maxy) {
3158-
{{{ makeSetValue('maxy', '0', 'fontData.size', 'i32') }}};
3158+
{{{ makeSetValue('maxy', 0, 'fontData.size', 'i32') }}};
31593159
}
31603160
},
31613161

@@ -3302,7 +3302,7 @@ var LibrarySDL = {
33023302
abort('Unknown SDL GL attribute (' + attr + '). Please check if your SDL version is supported.');
33033303
}
33043304

3305-
if (value) {{{ makeSetValue('value', '0', 'SDL.glAttributes[attr]', 'i32') }}};
3305+
if (value) {{{ makeSetValue('value', 0, 'SDL.glAttributes[attr]', 'i32') }}};
33063306

33073307
return 0;
33083308
},
@@ -3356,8 +3356,8 @@ var LibrarySDL = {
33563356
SDL_GetWindowSize: (window, width, height) => {
33573357
var w = Module['canvas'].width;
33583358
var h = Module['canvas'].height;
3359-
if (width) {{{ makeSetValue('width', '0', 'w', 'i32') }}};
3360-
if (height) {{{ makeSetValue('height', '0', 'h', 'i32') }}};
3359+
if (width) {{{ makeSetValue('width', 0, 'w', 'i32') }}};
3360+
if (height) {{{ makeSetValue('height', 0, 'h', 'i32') }}};
33613361
},
33623362

33633363
SDL_LogSetOutputFunction: (callback, userdata) => {},

0 commit comments

Comments
 (0)