Skip to content

Commit f8f2fab

Browse files
committed
Use int to represent webidl long type
The webidl `long` type is defined to be a 32-bit type: https://webidl.spec.whatwg.org/#idl-long https://webidl.spec.whatwg.org/#idl-unsigned-long Using `long` on the native side works find for wasm32 but breaks under wasm64 where `long` is 64-bit. Using `int` instead means the type is the same under wasm32 and wasm64 which more accurately represents the html5/webidl type. See emscripten-core#20276
1 parent 992d1e9 commit f8f2fab

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

system/include/emscripten/html5.h

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ extern "C" {
100100

101101
typedef struct EmscriptenKeyboardEvent {
102102
double timestamp;
103-
unsigned long location;
103+
unsigned int location;
104104
EM_BOOL ctrlKey;
105105
EM_BOOL shiftKey;
106106
EM_BOOL altKey;
107107
EM_BOOL metaKey;
108108
EM_BOOL repeat;
109-
unsigned long charCode;
110-
unsigned long keyCode;
111-
unsigned long which;
109+
unsigned int charCode;
110+
unsigned int keyCode;
111+
unsigned int which;
112112
EM_UTF8 key[EM_HTML5_SHORT_STRING_LEN_BYTES];
113113
EM_UTF8 code[EM_HTML5_SHORT_STRING_LEN_BYTES];
114114
EM_UTF8 charValue[EM_HTML5_SHORT_STRING_LEN_BYTES];
@@ -123,24 +123,24 @@ EMSCRIPTEN_RESULT emscripten_set_keyup_callback_on_thread(const char *target __a
123123

124124
typedef struct EmscriptenMouseEvent {
125125
double timestamp;
126-
long screenX;
127-
long screenY;
128-
long clientX;
129-
long clientY;
126+
int screenX;
127+
int screenY;
128+
int clientX;
129+
int clientY;
130130
EM_BOOL ctrlKey;
131131
EM_BOOL shiftKey;
132132
EM_BOOL altKey;
133133
EM_BOOL metaKey;
134134
unsigned short button;
135135
unsigned short buttons;
136-
long movementX;
137-
long movementY;
138-
long targetX;
139-
long targetY;
136+
int movementX;
137+
int movementY;
138+
int targetX;
139+
int targetY;
140140
// canvasX and canvasY are deprecated - there no longer exists a Module['canvas'] object, so canvasX/Y are no longer reported (register a listener on canvas directly to get canvas coordinates, or translate manually)
141-
long canvasX;
142-
long canvasY;
143-
long padding;
141+
int canvasX;
142+
int canvasY;
143+
int padding;
144144
} EmscriptenMouseEvent;
145145

146146

@@ -166,15 +166,15 @@ typedef struct EmscriptenWheelEvent {
166166
double deltaX;
167167
double deltaY;
168168
double deltaZ;
169-
unsigned long deltaMode;
169+
unsigned int deltaMode;
170170
} EmscriptenWheelEvent;
171171

172172

173173
typedef EM_BOOL (*em_wheel_callback_func)(int eventType, const EmscriptenWheelEvent *wheelEvent __attribute__((nonnull)), void *userData);
174174
EMSCRIPTEN_RESULT emscripten_set_wheel_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_wheel_callback_func callback, pthread_t targetThread);
175175

176176
typedef struct EmscriptenUiEvent {
177-
long detail;
177+
int detail;
178178
int documentBodyClientWidth;
179179
int documentBodyClientHeight;
180180
int windowInnerWidth;
@@ -345,20 +345,20 @@ EMSCRIPTEN_RESULT emscripten_get_visibility_status(EmscriptenVisibilityChangeEve
345345

346346
typedef struct EmscriptenTouchPoint
347347
{
348-
long identifier;
349-
long screenX;
350-
long screenY;
351-
long clientX;
352-
long clientY;
353-
long pageX;
354-
long pageY;
348+
int identifier;
349+
int screenX;
350+
int screenY;
351+
int clientX;
352+
int clientY;
353+
int pageX;
354+
int pageY;
355355
EM_BOOL isChanged;
356356
EM_BOOL onTarget;
357-
long targetX;
358-
long targetY;
357+
int targetX;
358+
int targetY;
359359
// canvasX and canvasY are deprecated - there no longer exists a Module['canvas'] object, so canvasX/Y are no longer reported (register a listener on canvas directly to get canvas coordinates, or translate manually)
360-
long canvasX;
361-
long canvasY;
360+
int canvasX;
361+
int canvasY;
362362
} EmscriptenTouchPoint;
363363

364364
typedef struct EmscriptenTouchEvent {
@@ -387,7 +387,7 @@ typedef struct EmscriptenGamepadEvent {
387387
double analogButton[64];
388388
EM_BOOL digitalButton[64];
389389
EM_BOOL connected;
390-
long index;
390+
int index;
391391
EM_UTF8 id[EM_HTML5_MEDIUM_STRING_LEN_BYTES];
392392
EM_UTF8 mapping[EM_HTML5_MEDIUM_STRING_LEN_BYTES];
393393
} EmscriptenGamepadEvent;

0 commit comments

Comments
 (0)