Skip to content

Use int to represent webidl long type #20290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

3.1.47 (in development)
-----------------------
- Value types in `emscripten/html5.h` that correspond the WebIDL `long` type are
now represented as `int` rather than `long` types so that they are 32-bit wide
on both wasm32 and wasm64. (#20290)
- `EM_JS` and `EM_ASM` that are present in side module now have their syntax
validated at build time. (#20258)
- `MAIN_THREAD_EM_ASM_PTR` macro added for code that returns a pointer. This
Expand Down
124 changes: 62 additions & 62 deletions src/generated_struct_info64.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,53 +514,53 @@
"scaleMode": 0
},
"EmscriptenGamepadEvent": {
"__size__": 1440,
"__size__": 1432,
"analogButton": 528,
"axis": 16,
"connected": 1296,
"digitalButton": 1040,
"id": 1312,
"index": 1304,
"mapping": 1376,
"id": 1304,
"index": 1300,
"mapping": 1368,
"numAxes": 8,
"numButtons": 12,
"timestamp": 0
},
"EmscriptenKeyboardEvent": {
"__size__": 192,
"altKey": 24,
"charCode": 40,
"charValue": 128,
"code": 96,
"ctrlKey": 16,
"key": 64,
"keyCode": 48,
"locale": 160,
"__size__": 176,
"altKey": 20,
"charCode": 32,
"charValue": 108,
"code": 76,
"ctrlKey": 12,
"key": 44,
"keyCode": 36,
"locale": 140,
"location": 8,
"metaKey": 28,
"repeat": 32,
"shiftKey": 20,
"metaKey": 24,
"repeat": 28,
"shiftKey": 16,
"timestamp": 0,
"which": 56
"which": 40
},
"EmscriptenMouseEvent": {
"__size__": 120,
"altKey": 48,
"button": 56,
"buttons": 58,
"canvasX": 96,
"canvasY": 104,
"clientX": 24,
"clientY": 32,
"ctrlKey": 40,
"metaKey": 52,
"movementX": 64,
"movementY": 72,
"__size__": 72,
"altKey": 32,
"button": 40,
"buttons": 42,
"canvasX": 60,
"canvasY": 64,
"clientX": 16,
"clientY": 20,
"ctrlKey": 24,
"metaKey": 36,
"movementX": 44,
"movementY": 48,
"screenX": 8,
"screenY": 16,
"shiftKey": 44,
"targetX": 80,
"targetY": 88,
"screenY": 12,
"shiftKey": 28,
"targetX": 52,
"targetY": 56,
"timestamp": 0
},
"EmscriptenOrientationChangeEvent": {
Expand All @@ -575,42 +575,42 @@
"nodeName": 4
},
"EmscriptenTouchEvent": {
"__size__": 3104,
"__size__": 1696,
"altKey": 20,
"ctrlKey": 12,
"metaKey": 24,
"numTouches": 8,
"shiftKey": 16,
"timestamp": 0,
"touches": 32
"touches": 28
},
"EmscriptenTouchPoint": {
"__size__": 96,
"canvasX": 80,
"canvasY": 88,
"clientX": 24,
"clientY": 32,
"__size__": 52,
"canvasX": 44,
"canvasY": 48,
"clientX": 12,
"clientY": 16,
"identifier": 0,
"isChanged": 56,
"onTarget": 60,
"pageX": 40,
"pageY": 48,
"screenX": 8,
"screenY": 16,
"targetX": 64,
"targetY": 72
"isChanged": 28,
"onTarget": 32,
"pageX": 20,
"pageY": 24,
"screenX": 4,
"screenY": 8,
"targetX": 36,
"targetY": 40
},
"EmscriptenUiEvent": {
"__size__": 40,
"__size__": 36,
"detail": 0,
"documentBodyClientHeight": 12,
"documentBodyClientWidth": 8,
"scrollLeft": 36,
"scrollTop": 32,
"windowInnerHeight": 20,
"windowInnerWidth": 16,
"windowOuterHeight": 28,
"windowOuterWidth": 24
"documentBodyClientHeight": 8,
"documentBodyClientWidth": 4,
"scrollLeft": 32,
"scrollTop": 28,
"windowInnerHeight": 16,
"windowInnerWidth": 12,
"windowOuterHeight": 24,
"windowOuterWidth": 20
},
"EmscriptenVisibilityChangeEvent": {
"__size__": 8,
Expand All @@ -635,11 +635,11 @@
"stencil": 8
},
"EmscriptenWheelEvent": {
"__size__": 152,
"deltaMode": 144,
"deltaX": 120,
"deltaY": 128,
"deltaZ": 136,
"__size__": 104,
"deltaMode": 96,
"deltaX": 72,
"deltaY": 80,
"deltaZ": 88,
"mouse": 0
},
"SDL_AudioSpec": {
Expand Down
58 changes: 29 additions & 29 deletions system/include/emscripten/html5.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ extern "C" {

typedef struct EmscriptenKeyboardEvent {
double timestamp;
unsigned long location;
unsigned int location;
EM_BOOL ctrlKey;
EM_BOOL shiftKey;
EM_BOOL altKey;
EM_BOOL metaKey;
EM_BOOL repeat;
unsigned long charCode;
unsigned long keyCode;
unsigned long which;
unsigned int charCode;
unsigned int keyCode;
unsigned int which;
EM_UTF8 key[EM_HTML5_SHORT_STRING_LEN_BYTES];
EM_UTF8 code[EM_HTML5_SHORT_STRING_LEN_BYTES];
EM_UTF8 charValue[EM_HTML5_SHORT_STRING_LEN_BYTES];
Expand All @@ -123,24 +123,24 @@ EMSCRIPTEN_RESULT emscripten_set_keyup_callback_on_thread(const char *target __a

typedef struct EmscriptenMouseEvent {
double timestamp;
long screenX;
long screenY;
long clientX;
long clientY;
int screenX;
int screenY;
int clientX;
int clientY;
EM_BOOL ctrlKey;
EM_BOOL shiftKey;
EM_BOOL altKey;
EM_BOOL metaKey;
unsigned short button;
unsigned short buttons;
long movementX;
long movementY;
long targetX;
long targetY;
int movementX;
int movementY;
int targetX;
int targetY;
// 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)
long canvasX;
long canvasY;
long padding;
int canvasX;
int canvasY;
int padding;
} EmscriptenMouseEvent;


Expand All @@ -166,15 +166,15 @@ typedef struct EmscriptenWheelEvent {
double deltaX;
double deltaY;
double deltaZ;
unsigned long deltaMode;
unsigned int deltaMode;
} EmscriptenWheelEvent;


typedef EM_BOOL (*em_wheel_callback_func)(int eventType, const EmscriptenWheelEvent *wheelEvent __attribute__((nonnull)), void *userData);
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);

typedef struct EmscriptenUiEvent {
long detail;
int detail;
int documentBodyClientWidth;
int documentBodyClientHeight;
int windowInnerWidth;
Expand Down Expand Up @@ -345,20 +345,20 @@ EMSCRIPTEN_RESULT emscripten_get_visibility_status(EmscriptenVisibilityChangeEve

typedef struct EmscriptenTouchPoint
{
long identifier;
long screenX;
long screenY;
long clientX;
long clientY;
long pageX;
long pageY;
int identifier;
int screenX;
int screenY;
int clientX;
int clientY;
int pageX;
int pageY;
EM_BOOL isChanged;
EM_BOOL onTarget;
long targetX;
long targetY;
int targetX;
int targetY;
// 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)
long canvasX;
long canvasY;
int canvasX;
int canvasY;
} EmscriptenTouchPoint;

typedef struct EmscriptenTouchEvent {
Expand Down Expand Up @@ -387,7 +387,7 @@ typedef struct EmscriptenGamepadEvent {
double analogButton[64];
EM_BOOL digitalButton[64];
EM_BOOL connected;
long index;
int index;
EM_UTF8 id[EM_HTML5_MEDIUM_STRING_LEN_BYTES];
EM_UTF8 mapping[EM_HTML5_MEDIUM_STRING_LEN_BYTES];
} EmscriptenGamepadEvent;
Expand Down
2 changes: 1 addition & 1 deletion test/test_gamepad.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const char *emscripten_result_to_string(EMSCRIPTEN_RESULT result) {

EM_BOOL gamepad_callback(int eventType, const EmscriptenGamepadEvent *e, void *userData)
{
printf("%s: timeStamp: %g, connected: %d, index: %ld, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"\n",
printf("%s: timeStamp: %g, connected: %d, index: %d, numAxes: %d, numButtons: %d, id: \"%s\", mapping: \"%s\"\n",
eventType != 0 ? emscripten_event_type_to_string(eventType) : "Gamepad state", e->timestamp, e->connected, e->index,
e->numAxes, e->numButtons, e->id, e->mapping);

Expand Down
10 changes: 5 additions & 5 deletions test/test_html5_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const char *emscripten_result_to_string(EMSCRIPTEN_RESULT result) {
// Returning 0 signals that the event was not consumed by the code, and will allow the event to pass on and bubble up normally.
EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData)
{
printf("%s, key: \"%s\", code: \"%s\", location: %lu,%s%s%s%s repeat: %d, locale: \"%s\", char: \"%s\", charCode: %lu, keyCode: %lu, which: %lu, timestamp: %lf\n",
printf("%s, key: \"%s\", code: \"%s\", location: %u,%s%s%s%s repeat: %d, locale: \"%s\", char: \"%s\", charCode: %u, keyCode: %u, which: %u, timestamp: %lf\n",
emscripten_event_type_to_string(eventType), e->key, e->code, e->location,
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "",
e->repeat, e->locale, e->charValue, e->charCode, e->keyCode, e->which,
Expand Down Expand Up @@ -91,7 +91,7 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user

EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData)
{
printf("%s, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, movement: (%ld,%ld), canvas: (%ld,%ld), timestamp: %lf\n",
printf("%s, screen: (%d,%d), client: (%d,%d),%s%s%s%s button: %hu, buttons: %hu, movement: (%d,%d), canvas: (%d,%d), timestamp: %lf\n",
emscripten_event_type_to_string(eventType), e->screenX, e->screenY, e->clientX, e->clientY,
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "",
e->button, e->buttons, e->movementX, e->movementY, e->canvasX, e->canvasY,
Expand All @@ -102,7 +102,7 @@ EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userD

EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData)
{
printf("%s, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, canvas: (%ld,%ld), delta:(%g,%g,%g), deltaMode:%lu, timestamp: %lf\n",
printf("%s, screen: (%d,%d), client: (%d,%d),%s%s%s%s button: %hu, buttons: %hu, canvas: (%d,%d), delta:(%g,%g,%g), deltaMode:%u, timestamp: %lf\n",
emscripten_event_type_to_string(eventType), e->mouse.screenX, e->mouse.screenY, e->mouse.clientX, e->mouse.clientY,
e->mouse.ctrlKey ? " CTRL" : "", e->mouse.shiftKey ? " SHIFT" : "", e->mouse.altKey ? " ALT" : "", e->mouse.metaKey ? " META" : "",
e->mouse.button, e->mouse.buttons, e->mouse.canvasX, e->mouse.canvasY,
Expand All @@ -114,7 +114,7 @@ EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userD

EM_BOOL uievent_callback(int eventType, const EmscriptenUiEvent *e, void *userData)
{
printf("%s, detail: %ld, document.body.client size: (%d,%d), window.inner size: (%d,%d), scrollPos: (%d, %d)\n",
printf("%s, detail: %d, document.body.client size: (%d,%d), window.inner size: (%d,%d), scrollPos: (%d, %d)\n",
emscripten_event_type_to_string(eventType), e->detail, e->documentBodyClientWidth, e->documentBodyClientHeight,
e->windowInnerWidth, e->windowInnerHeight, e->scrollTop, e->scrollLeft);

Expand Down Expand Up @@ -187,7 +187,7 @@ EM_BOOL touch_callback(int eventType, const EmscriptenTouchEvent *e, void *userD
for(int i = 0; i < e->numTouches; ++i)
{
const EmscriptenTouchPoint *t = &e->touches[i];
printf(" %ld: screen: (%ld,%ld), client: (%ld,%ld), page: (%ld,%ld), isChanged: %d, onTarget: %d, canvas: (%ld, %ld)\n",
printf(" %d: screen: (%d,%d), client: (%d,%d), page: (%d,%d), isChanged: %d, onTarget: %d, canvas: (%d, %d)\n",
t->identifier, t->screenX, t->screenY, t->clientX, t->clientY, t->pageX, t->pageY, t->isChanged, t->onTarget, t->canvasX, t->canvasY);
}

Expand Down
4 changes: 2 additions & 2 deletions test/test_html5_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void instruction()

EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData)
{
printf("%s, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, movement: (%ld,%ld), target: (%ld, %ld)\n",
printf("%s, screen: (%d,%d), client: (%d,%d),%s%s%s%s button: %hu, buttons: %hu, movement: (%d,%d), target: (%d, %d)\n",
emscripten_event_type_to_string(eventType), e->screenX, e->screenY, e->clientX, e->clientY,
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "",
e->button, e->buttons, e->movementX, e->movementY, e->targetX, e->targetY);
Expand All @@ -96,7 +96,7 @@ EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userD

EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData)
{
printf("%s, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, target: (%ld, %ld), delta:(%g,%g,%g), deltaMode:%lu\n",
printf("%s, screen: (%d,%d), client: (%d,%d),%s%s%s%s button: %hu, buttons: %hu, target: (%d, %d), delta:(%g,%g,%g), deltaMode:%u\n",
emscripten_event_type_to_string(eventType), e->mouse.screenX, e->mouse.screenY, e->mouse.clientX, e->mouse.clientY,
e->mouse.ctrlKey ? " CTRL" : "", e->mouse.shiftKey ? " SHIFT" : "", e->mouse.altKey ? " ALT" : "", e->mouse.metaKey ? " META" : "",
e->mouse.button, e->mouse.buttons, e->mouse.targetX, e->mouse.targetY,
Expand Down