Skip to content

Commit b61811c

Browse files
committedJul 18, 2014
Use typedefs in html5.h for referring to callback function pointers instead of passing the function pointer types in the function declaration to avoid Sphinx doc parser from getting confused during parsing.
1 parent 2acb8de commit b61811c

File tree

1 file changed

+48
-32
lines changed

1 file changed

+48
-32
lines changed
 

‎system/include/emscripten/html5.h

+48-32
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ typedef struct EmscriptenKeyboardEvent {
168168
* See https://developer.mozilla.org/en/DOM/Event/UIEvent/KeyEvent
169169
* and http://www.javascriptkit.com/jsref/eventkeyboardmouse.shtml
170170
*/
171-
extern EMSCRIPTEN_RESULT emscripten_set_keypress_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData));
172-
extern EMSCRIPTEN_RESULT emscripten_set_keydown_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData));
173-
extern EMSCRIPTEN_RESULT emscripten_set_keyup_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData));
171+
typedef EM_BOOL (*em_key_callback_func)(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData);
172+
extern EMSCRIPTEN_RESULT emscripten_set_keypress_callback(const char *target, void *userData, EM_BOOL useCapture, em_key_callback_func callback);
173+
extern EMSCRIPTEN_RESULT emscripten_set_keydown_callback(const char *target, void *userData, EM_BOOL useCapture, em_key_callback_func callback);
174+
extern EMSCRIPTEN_RESULT emscripten_set_keyup_callback(const char *target, void *userData, EM_BOOL useCapture, em_key_callback_func callback);
174175

175176
/*
176177
* The event structure passed in mouse events click, mousedown, mouseup, dblclick and mousemove.
@@ -209,11 +210,12 @@ typedef struct EmscriptenMouseEvent {
209210
* Registers a callback function for receiving browser-generated mouse input events.
210211
* See https://developer.mozilla.org/en/DOM/MouseEvent
211212
*/
212-
extern EMSCRIPTEN_RESULT emscripten_set_click_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData));
213-
extern EMSCRIPTEN_RESULT emscripten_set_mousedown_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData));
214-
extern EMSCRIPTEN_RESULT emscripten_set_mouseup_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData));
215-
extern EMSCRIPTEN_RESULT emscripten_set_dblclick_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData));
216-
extern EMSCRIPTEN_RESULT emscripten_set_mousemove_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData));
213+
typedef EM_BOOL (*em_mouse_callback_func)(int eventType, const EmscriptenMouseEvent *keyEvent, void *userData);
214+
extern EMSCRIPTEN_RESULT emscripten_set_click_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback);
215+
extern EMSCRIPTEN_RESULT emscripten_set_mousedown_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback);
216+
extern EMSCRIPTEN_RESULT emscripten_set_mouseup_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback);
217+
extern EMSCRIPTEN_RESULT emscripten_set_dblclick_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback);
218+
extern EMSCRIPTEN_RESULT emscripten_set_mousemove_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback);
217219
/*
218220
* Returns the most recently received mouse event state. Note that for this function call to succeed, emscripten_set_xx_callback must have first
219221
* been called with one of the mouse event types and a non-zero callback function pointer to enable the Mouse state capture.
@@ -243,7 +245,8 @@ typedef struct EmscriptenWheelEvent {
243245
* Registers a callback function for receiving browser-generated mouse wheel events.
244246
* See http://www.w3.org/TR/DOM-Level-3-Events/#event-type-wheel
245247
*/
246-
extern EMSCRIPTEN_RESULT emscripten_set_wheel_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData));
248+
typedef EM_BOOL (*em_wheel_callback_func)(int eventType, const EmscriptenWheelEvent *keyEvent, void *userData);
249+
extern EMSCRIPTEN_RESULT emscripten_set_wheel_callback(const char *target, void *userData, EM_BOOL useCapture, em_wheel_callback_func callback);
247250

248251
/*
249252
* The event structure passed in DOM element resize and scroll events.
@@ -273,8 +276,9 @@ typedef struct EmscriptenUiEvent {
273276
* requires that the Window object sends resize events. It is valid to register a resize callback to other DOM elements,
274277
* but the browser is not required to fire resize events on them.
275278
*/
276-
extern EMSCRIPTEN_RESULT emscripten_set_resize_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenUiEvent *uiEvent, void *userData));
277-
extern EMSCRIPTEN_RESULT emscripten_set_scroll_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenUiEvent *uiEvent, void *userData));
279+
typedef EM_BOOL (*em_ui_callback_func)(int eventType, const EmscriptenUiEvent *keyEvent, void *userData);
280+
extern EMSCRIPTEN_RESULT emscripten_set_resize_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback);
281+
extern EMSCRIPTEN_RESULT emscripten_set_scroll_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback);
278282

279283
/*
280284
* The event structure passed in DOM element blur, focus, focusin and focusout events.
@@ -291,10 +295,11 @@ typedef struct EmscriptenFocusEvent {
291295
* Registers a callback function for receiving DOM element blur, focus, focusin and focusout events.
292296
* See https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-blur
293297
*/
294-
extern EMSCRIPTEN_RESULT emscripten_set_blur_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData));
295-
extern EMSCRIPTEN_RESULT emscripten_set_focus_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData));
296-
extern EMSCRIPTEN_RESULT emscripten_set_focusin_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData));
297-
extern EMSCRIPTEN_RESULT emscripten_set_focusout_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData));
298+
typedef EM_BOOL (*em_focus_callback_func)(int eventType, const EmscriptenFocusEvent *keyEvent, void *userData);
299+
extern EMSCRIPTEN_RESULT emscripten_set_blur_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback);
300+
extern EMSCRIPTEN_RESULT emscripten_set_focus_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback);
301+
extern EMSCRIPTEN_RESULT emscripten_set_focusin_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback);
302+
extern EMSCRIPTEN_RESULT emscripten_set_focusout_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback);
298303

299304
/*
300305
* The event structure passed in the deviceorientation event.
@@ -315,7 +320,8 @@ typedef struct EmscriptenDeviceOrientationEvent {
315320
* Registers a callback function for receiving the deviceorientation event.
316321
* See http://dev.w3.org/geo/api/spec-source-orientation.html
317322
*/
318-
extern EMSCRIPTEN_RESULT emscripten_set_deviceorientation_callback(void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenDeviceOrientationEvent *orientationEvent, void *userData));
323+
typedef EM_BOOL (*em_deviceorientation_callback_func)(int eventType, const EmscriptenDeviceOrientationEvent *keyEvent, void *userData);
324+
extern EMSCRIPTEN_RESULT emscripten_set_deviceorientation_callback(void *userData, EM_BOOL useCapture, em_deviceorientation_callback_func callback);
319325
/*
320326
* Returns the most recently received deviceorientation event state. Note that for this function call to succeed, emscripten_set_deviceorientation_callback
321327
* must have first been called with one of the mouse event types and a non-zero callback function pointer to enable the Device Orientation state capture.
@@ -347,7 +353,8 @@ typedef struct EmscriptenDeviceMotionEvent {
347353
* Registers a callback function for receiving the devicemotion event.
348354
* See http://dev.w3.org/geo/api/spec-source-orientation.html
349355
*/
350-
extern EMSCRIPTEN_RESULT emscripten_set_devicemotion_callback(void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenDeviceMotionEvent *motionEvent, void *userData));
356+
typedef EM_BOOL (*em_devicemotion_callback_func)(int eventType, const EmscriptenDeviceMotionEvent *keyEvent, void *userData);
357+
extern EMSCRIPTEN_RESULT emscripten_set_devicemotion_callback(void *userData, EM_BOOL useCapture, em_devicemotion_callback_func callback);
351358
/*
352359
* Returns the most recently received deviceomotion event state. Note that for this function call to succeed, emscripten_set_devicemotion_callback
353360
* must have first been called with one of the mouse event types and a non-zero callback function pointer to enable the Device Motion state capture.
@@ -375,7 +382,8 @@ typedef struct EmscriptenOrientationChangeEvent {
375382
* Registers a callback function for receiving the orientationchange event.
376383
* https://dvcs.w3.org/hg/screen-orientation/raw-file/tip/Overview.html
377384
*/
378-
extern EMSCRIPTEN_RESULT emscripten_set_orientationchange_callback(void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenOrientationChangeEvent *orientationChangeEvent, void *userData));
385+
typedef EM_BOOL (*em_orientationchange_callback_func)(int eventType, const EmscriptenOrientationChangeEvent *keyEvent, void *userData);
386+
extern EMSCRIPTEN_RESULT emscripten_set_orientationchange_callback(void *userData, EM_BOOL useCapture, em_orientationchange_callback_func callback);
379387
/*
380388
* Returns the current device orientation state.
381389
*/
@@ -416,7 +424,8 @@ typedef struct EmscriptenFullscreenChangeEvent {
416424
* Registers a callback function for receiving the fullscreenchange event.
417425
* https://dvcs.w3.org/hg/screen-orientation/raw-file/tip/Overview.html
418426
*/
419-
extern EMSCRIPTEN_RESULT emscripten_set_fullscreenchange_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData));
427+
typedef EM_BOOL (*em_fullscreenchange_callback_func)(int eventType, const EmscriptenFullscreenChangeEvent *keyEvent, void *userData);
428+
extern EMSCRIPTEN_RESULT emscripten_set_fullscreenchange_callback(const char *target, void *userData, EM_BOOL useCapture, em_fullscreenchange_callback_func callback);
420429
/*
421430
* Returns the current page fullscreen state.
422431
*/
@@ -452,7 +461,8 @@ typedef struct EmscriptenPointerlockChangeEvent {
452461
* Pointer lock hides the mouse cursor and exclusively gives the target element relative mouse movement events via the mousemove event.
453462
* http://www.w3.org/TR/pointerlock/
454463
*/
455-
extern EMSCRIPTEN_RESULT emscripten_set_pointerlockchange_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent, void *userData));
464+
typedef EM_BOOL (*em_pointerlockchange_callback_func)(int eventType, const EmscriptenPointerlockChangeEvent *keyEvent, void *userData);
465+
extern EMSCRIPTEN_RESULT emscripten_set_pointerlockchange_callback(const char *target, void *userData, EM_BOOL useCapture, em_pointerlockchange_callback_func callback);
456466
/*
457467
* Returns the current page pointerlock state.
458468
*/
@@ -490,7 +500,8 @@ typedef struct EmscriptenVisibilityChangeEvent {
490500
* Registers a callback function for receiving the visibilitychange event.
491501
* http://www.w3.org/TR/page-visibility/
492502
*/
493-
extern EMSCRIPTEN_RESULT emscripten_set_visibilitychange_callback(void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent, void *userData));
503+
typedef EM_BOOL (*em_visibilitychange_callback_func)(int eventType, const EmscriptenVisibilityChangeEvent *keyEvent, void *userData);
504+
extern EMSCRIPTEN_RESULT emscripten_set_visibilitychange_callback(void *userData, EM_BOOL useCapture, em_visibilitychange_callback_func callback);
494505
/*
495506
* Returns the current page visibility state.
496507
*/
@@ -542,10 +553,11 @@ typedef struct EmscriptenTouchEvent {
542553
* Registers a callback function for receiving the touchstart, touchend, touchmove and touchcancel events.
543554
* http://www.w3.org/TR/touch-events/
544555
*/
545-
extern EMSCRIPTEN_RESULT emscripten_set_touchstart_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData));
546-
extern EMSCRIPTEN_RESULT emscripten_set_touchend_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData));
547-
extern EMSCRIPTEN_RESULT emscripten_set_touchmove_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData));
548-
extern EMSCRIPTEN_RESULT emscripten_set_touchcancel_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData));
556+
typedef EM_BOOL (*em_touch_callback_func)(int eventType, const EmscriptenTouchEvent *keyEvent, void *userData);
557+
extern EMSCRIPTEN_RESULT emscripten_set_touchstart_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback);
558+
extern EMSCRIPTEN_RESULT emscripten_set_touchend_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback);
559+
extern EMSCRIPTEN_RESULT emscripten_set_touchmove_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback);
560+
extern EMSCRIPTEN_RESULT emscripten_set_touchcancel_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback);
549561

550562
/*
551563
* Represents the current snapshot state of a gamepad.
@@ -578,8 +590,9 @@ typedef struct EmscriptenGamepadEvent {
578590
* Registers a callback function for receiving the gamepadconnected and gamepaddisconnected events.
579591
* http://www.w3.org/TR/gamepad/
580592
*/
581-
extern EMSCRIPTEN_RESULT emscripten_set_gamepadconnected_callback(void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData));
582-
extern EMSCRIPTEN_RESULT emscripten_set_gamepaddisconnected_callback(void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData));
593+
typedef EM_BOOL (*em_gamepad_callback_func)(int eventType, const EmscriptenGamepadEvent *keyEvent, void *userData);
594+
extern EMSCRIPTEN_RESULT emscripten_set_gamepadconnected_callback(void *userData, EM_BOOL useCapture, em_gamepad_callback_func callback);
595+
extern EMSCRIPTEN_RESULT emscripten_set_gamepaddisconnected_callback(void *userData, EM_BOOL useCapture, em_gamepad_callback_func callback);
583596

584597
/*
585598
* Returns the number of gamepads connected to the system or EMSCRIPTEN_RESULT_NOT_SUPPORTED if the current browser does not support gamepads.
@@ -606,8 +619,9 @@ typedef struct EmscriptenBatteryEvent {
606619
* Registers a callback function for receiving the battery chargingchange and levelchange events.
607620
* http://www.w3.org/TR/battery-status/
608621
*/
609-
extern EMSCRIPTEN_RESULT emscripten_set_batterychargingchange_callback(void *userData, EM_BOOL (*func)(int eventType, const EmscriptenBatteryEvent *batteryEvent, void *userData));
610-
extern EMSCRIPTEN_RESULT emscripten_set_batterylevelchange_callback(void *userData, EM_BOOL (*func)(int eventType, const EmscriptenBatteryEvent *batteryEvent, void *userData));
622+
typedef EM_BOOL (*em_battery_callback_func)(int eventType, const EmscriptenBatteryEvent *keyEvent, void *userData);
623+
extern EMSCRIPTEN_RESULT emscripten_set_batterychargingchange_callback(void *userData, em_battery_callback_func callback);
624+
extern EMSCRIPTEN_RESULT emscripten_set_batterylevelchange_callback(void *userData, em_battery_callback_func callback);
611625
/*
612626
* Returns the current battery status.
613627
*/
@@ -631,14 +645,16 @@ extern EMSCRIPTEN_RESULT emscripten_vibrate_pattern(int *msecsArray, int numEntr
631645
* Hook onto this event to perform process right prior to page close, and/or display a confirmation notification asking if the user really wants to leave the page.
632646
* http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#beforeunloadevent
633647
*/
634-
extern EMSCRIPTEN_RESULT emscripten_set_beforeunload_callback(void *userData, const char *(*func)(int eventType, const void *reserved, void *userData));
648+
typedef const char *(*em_beforeunload_callback)(int eventType, const void *reserved, void *userData);
649+
extern EMSCRIPTEN_RESULT emscripten_set_beforeunload_callback(void *userData, em_beforeunload_callback callback);
635650

636651
/*
637652
* Registers a callback function for the canvas webgl context webglcontextlost and webglcontextrestored events.
638653
* See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
639654
*/
640-
extern EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const void *reserved, void *userData));
641-
extern EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback(const char *target, void *userData, EM_BOOL useCapture, EM_BOOL (*func)(int eventType, const void *reserved, void *userData));
655+
typedef EM_BOOL (*em_webgl_context_callback)(int eventType, const void *reserved, void *userData);
656+
extern EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback(const char *target, void *userData, EM_BOOL useCapture, em_webgl_context_callback callback);
657+
extern EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback(const char *target, void *userData, EM_BOOL useCapture, em_webgl_context_callback callback);
642658

643659
/*
644660
* Queries the given canvas element for whether its WebGL context is in a lost state.

0 commit comments

Comments
 (0)
Please sign in to comment.