diff --git a/ChangeLog.md b/ChangeLog.md index 0c0772d6f56c..517817a41a36 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 3.1.69 (in development) ----------------------- +- The usage of `EM_BOOL` in the emscripten API has been replaced with C/C++ + bool. This change should not be observable since `EM_BOOL` has been + equivalent to `bool` since #22157. (#22155) 3.1.68 - 09/30/24 ----------------- diff --git a/site/source/docs/api_reference/html5.h.rst b/site/source/docs/api_reference/html5.h.rst index 6e087a20a230..c8aa19e01e9a 100644 --- a/site/source/docs/api_reference/html5.h.rst +++ b/site/source/docs/api_reference/html5.h.rst @@ -53,7 +53,7 @@ The typical format of registration functions is as follows (some methods may omi EMSCRIPTEN_RESULT emscripten_set_some_callback( const char *target, // ID of the target HTML element. void *userData, // User-defined data to be passed to the callback. - EM_BOOL useCapture, // Whether or not to use capture. + bool useCapture, // Whether or not to use capture. em_someevent_callback_func callback // Callback function. ); @@ -96,7 +96,7 @@ Callback functions When the event occurs the callback is invoked with the relevant event "type" (for example :c:data:`EMSCRIPTEN_EVENT_CLICK`), a ``struct`` containing the details of the event that occurred, and the ``userData`` that was originally passed to the registration function. The general format of the callback function is: :: - typedef EM_BOOL (*em_someevent_callback_func) // Callback function. Return true if event is "consumed". + typedef bool (*em_someevent_callback_func) // Callback function. Return true if event is "consumed". ( int eventType, // The type of event. const EmscriptenSomeEvent *someEvent, // Information about the event. @@ -106,7 +106,7 @@ When the event occurs the callback is invoked with the relevant event "type" (fo .. _callback-handler-return-em_bool-html5-api: -Callback handlers that return an :c:data:`EM_BOOL` may specify ``true`` to signal that the handler *consumed* the event (this suppresses the default action for that event by calling its ``.preventDefault();`` member). Returning ``false`` indicates that the event was not consumed — the default browser event action is carried out and the event is allowed to pass on/bubble up as normal. +Callback handlers that return an :c:data:`bool` may specify ``true`` to signal that the handler *consumed* the event (this suppresses the default action for that event by calling its ``.preventDefault();`` member). Returning ``false`` indicates that the event was not consumed — the default browser event action is carried out and the event is allowed to pass on/bubble up as normal. Calling a registration function with a ``null`` pointer for the callback causes a de-registration of that callback from the given ``target`` element. All event handlers are also automatically unregistered when the C ``exit()`` function is invoked during the ``atexit`` handler pass. Either use the function :c:func:`emscripten_set_main_loop` or set ``Module.noExitRuntime = true;`` to make sure that leaving ``main()`` will not immediately cause an ``exit()`` and clean up the event handlers. @@ -140,26 +140,11 @@ General types ============= -.. c:macro:: EM_BOOL - - This is the Emscripten type for a ``bool``. - Possible values: - - .. c:macro:: EM_TRUE - - This is the Emscripten value for ``true``. - - .. c:macro:: EM_FALSE - - This is the Emscripten value for ``false``. - - .. c:macro:: EM_UTF8 This is the Emscripten type for a UTF8 string (maps to a ``char``). This is used for node names, element ids, etc. - Function result values ====================== @@ -263,14 +248,14 @@ Struct Indicates the location of the key on the keyboard. One of the :c:data:`DOM_KEY_LOCATION ` values. - .. c:member:: EM_BOOL ctrlKey - EM_BOOL shiftKey - EM_BOOL altKey - EM_BOOL metaKey + .. c:member:: bool ctrlKey + bool shiftKey + bool altKey + bool metaKey Specifies which modifiers were active during the key event. - .. c:member:: EM_BOOL repeat + .. c:member:: bool repeat Specifies if this keyboard event represents a repeated press. @@ -317,29 +302,29 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_key_callback_func)(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData); + typedef bool (*em_key_callback_func)(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData); :param int eventType: The type of :c:data:`key event `. :param keyEvent: Information about the key event that occurred. :type keyEvent: const EmscriptenKeyboardEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_keypress_callback(const char *target, void *userData, EM_BOOL useCapture, em_key_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_keydown_callback(const char *target, void *userData, EM_BOOL useCapture, em_key_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_keyup_callback(const char *target, void *userData, EM_BOOL useCapture, em_key_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_keypress_callback(const char *target, void *userData, bool useCapture, em_key_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_keydown_callback(const char *target, void *userData, bool useCapture, em_key_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_keyup_callback(const char *target, void *userData, bool useCapture, em_key_callback_func callback) Registers a callback function for receiving browser-generated keyboard input events. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_key_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -390,10 +375,10 @@ Struct The coordinates relative to the viewport associated with the event. - .. c:member:: EM_BOOL ctrlKey - EM_BOOL shiftKey - EM_BOOL altKey - EM_BOOL metaKey + .. c:member:: bool ctrlKey + bool shiftKey + bool altKey + bool metaKey Specifies which modifiers were active during the mouse event. @@ -444,34 +429,34 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_mouse_callback_func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); + typedef bool (*em_mouse_callback_func)(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData); :param int eventType: The type of :c:data:`mouse event `. :param mouseEvent: Information about the mouse event that occurred. :type mouseEvent: const EmscriptenMouseEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_click_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_mousedown_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_mouseup_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_dblclick_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_mousemove_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_mouseenter_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_mouseleave_callback(const char *target, void *userData, EM_BOOL useCapture, em_mouse_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_click_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_mousedown_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_mouseup_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_dblclick_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_mousemove_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_mouseenter_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_mouseleave_callback(const char *target, void *userData, bool useCapture, em_mouse_callback_func callback) Registers a callback function for receiving browser-generated `mouse input events `_. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_mouse_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -546,28 +531,28 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_wheel_callback_func)(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData); + typedef bool (*em_wheel_callback_func)(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData); :param int eventType: The type of wheel event (:c:data:`EMSCRIPTEN_EVENT_WHEEL`). :param wheelEvent: Information about the wheel event that occurred. :type wheelEvent: const EmscriptenWheelEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_wheel_callback(const char *target, void *userData, EM_BOOL useCapture, em_wheel_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_wheel_callback(const char *target, void *userData, bool useCapture, em_wheel_callback_func callback) Registers a callback function for receiving browser-generated `mousewheel events `_. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_wheel_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -628,21 +613,21 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_ui_callback_func)(int eventType, const EmscriptenUiEvent *uiEvent, void *userData); + typedef bool (*em_ui_callback_func)(int eventType, const EmscriptenUiEvent *uiEvent, void *userData); :param int eventType: The type of UI event (:c:data:`EMSCRIPTEN_EVENT_RESIZE`). :param uiEvent: Information about the UI event that occurred. :type uiEvent: const EmscriptenUiEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_resize_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_scroll_callback(const char *target, void *userData, EM_BOOL useCapture, em_ui_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_resize_callback(const char *target, void *userData, bool useCapture, em_ui_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_scroll_callback(const char *target, void *userData, bool useCapture, em_ui_callback_func callback) Registers a callback function for receiving DOM element `resize `_ and `scroll `_ events. @@ -654,7 +639,7 @@ Functions :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_ui_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -706,31 +691,31 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_focus_callback_func)(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData); + typedef bool (*em_focus_callback_func)(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData); :param int eventType: The type of focus event (:c:data:`EMSCRIPTEN_EVENT_BLUR`). :param focusEvent: Information about the focus event that occurred. :type focusEvent: const EmscriptenFocusEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_blur_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_focus_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_focusin_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_focusout_callback(const char *target, void *userData, EM_BOOL useCapture, em_focus_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_blur_callback(const char *target, void *userData, bool useCapture, em_focus_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_focus_callback(const char *target, void *userData, bool useCapture, em_focus_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_focusin_callback(const char *target, void *userData, bool useCapture, em_focus_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_focusout_callback(const char *target, void *userData, bool useCapture, em_focus_callback_func callback) Registers a callback function for receiving DOM element `blur `_, `focus `_, `focusin `_ and `focusout `_ events. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_focus_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -772,7 +757,7 @@ Struct :alt: Image of device showing X, Y, Z axes - .. c:member:: EM_BOOL absolute + .. c:member:: bool absolute If ``false``, the orientation is only relative to some other base orientation, not to the fixed coordinate frame. @@ -786,26 +771,26 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_deviceorientation_callback_func)(int eventType, const EmscriptenDeviceOrientationEvent *deviceOrientationEvent, void *userData); + typedef bool (*em_deviceorientation_callback_func)(int eventType, const EmscriptenDeviceOrientationEvent *deviceOrientationEvent, void *userData); :param int eventType: The type of orientation event (:c:data:`EMSCRIPTEN_EVENT_DEVICEORIENTATION`). :param deviceOrientationEvent: Information about the orientation event that occurred. :type deviceOrientationEvent: const EmscriptenDeviceOrientationEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_deviceorientation_callback(void *userData, EM_BOOL useCapture, em_deviceorientation_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_deviceorientation_callback(void *userData, bool useCapture, em_deviceorientation_callback_func callback) Registers a callback function for receiving the `deviceorientation `_ event. :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_deviceorientation_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -877,14 +862,14 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_devicemotion_callback_func)(int eventType, const EmscriptenDeviceMotionEvent *deviceMotionEvent, void *userData); + typedef bool (*em_devicemotion_callback_func)(int eventType, const EmscriptenDeviceMotionEvent *deviceMotionEvent, void *userData); :param int eventType: The type of devicemotion event (:c:data:`EMSCRIPTEN_EVENT_DEVICEMOTION`). :param deviceMotionEvent: Information about the devicemotion event that occurred. :type deviceMotionEvent: const EmscriptenDeviceMotionEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool @@ -892,12 +877,12 @@ Callback functions Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_devicemotion_callback(void *userData, EM_BOOL useCapture, em_devicemotion_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_devicemotion_callback(void *userData, bool useCapture, em_devicemotion_callback_func callback) Registers a callback function for receiving the `devicemotion `_ event. :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_devicemotion_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -976,25 +961,25 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_orientationchange_callback_func)(int eventType, const EmscriptenOrientationChangeEvent *orientationChangeEvent, void *userData); + typedef bool (*em_orientationchange_callback_func)(int eventType, const EmscriptenOrientationChangeEvent *orientationChangeEvent, void *userData); :param int eventType: The type of orientationchange event (:c:data:`EMSCRIPTEN_EVENT_ORIENTATIONCHANGE`). :param orientationChangeEvent: Information about the orientationchange event that occurred. :type orientationChangeEvent: const EmscriptenOrientationChangeEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_orientationchange_callback(void *userData, EM_BOOL useCapture, em_orientationchange_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_orientationchange_callback(void *userData, bool useCapture, em_orientationchange_callback_func callback) Registers a callback function for receiving the `orientationchange `_ event. :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_orientationchange_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1105,12 +1090,12 @@ Struct The event structure passed in the `fullscreenchange `_ event. - .. c:member:: EM_BOOL isFullscreen + .. c:member:: bool isFullscreen Specifies whether an element on the browser page is currently fullscreen. - .. c:member:: EM_BOOL fullscreenEnabled + .. c:member:: bool fullscreenEnabled Specifies if the current page has the ability to display elements fullscreen. @@ -1176,28 +1161,28 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_fullscreenchange_callback_func)(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData); + typedef bool (*em_fullscreenchange_callback_func)(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData); :param int eventType: The type of fullscreen event (:c:data:`EMSCRIPTEN_EVENT_FULLSCREENCHANGE`). :param fullscreenChangeEvent: Information about the fullscreen event that occurred. :type fullscreenChangeEvent: const EmscriptenFullscreenChangeEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_fullscreenchange_callback(const char *target, void *userData, EM_BOOL useCapture, em_fullscreenchange_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_fullscreenchange_callback(const char *target, void *userData, bool useCapture, em_fullscreenchange_callback_func callback) Registers a callback function for receiving the `fullscreenchange `_ event. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_fullscreenchange_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1213,7 +1198,7 @@ Functions :rtype: |EMSCRIPTEN_RESULT| -.. c:function:: EMSCRIPTEN_RESULT emscripten_request_fullscreen(const char *target, EM_BOOL deferUntilInEventHandler) +.. c:function:: EMSCRIPTEN_RESULT emscripten_request_fullscreen(const char *target, bool deferUntilInEventHandler) Requests the given target element to transition to full screen mode. @@ -1223,12 +1208,12 @@ Functions :param target: |target-parameter-doc| :type target: const char* - :param EM_BOOL deferUntilInEventHandler: If ``true`` requests made outside of a user-generated event handler are automatically deferred until the user next presses a keyboard or mouse button. If ``false`` the request will fail if called outside of a user-generated event handler. + :param bool deferUntilInEventHandler: If ``true`` requests made outside of a user-generated event handler are automatically deferred until the user next presses a keyboard or mouse button. If ``false`` the request will fail if called outside of a user-generated event handler. :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: **EMSCRIPTEN_RESULT** -.. c:function:: EMSCRIPTEN_RESULT emscripten_request_fullscreen_strategy(const char *target, EM_BOOL deferUntilInEventHandler, const EmscriptenFullscreenStrategy *fullscreenStrategy) +.. c:function:: EMSCRIPTEN_RESULT emscripten_request_fullscreen_strategy(const char *target, bool deferUntilInEventHandler, const EmscriptenFullscreenStrategy *fullscreenStrategy) Requests the given target element to transition to full screen mode, using a custom presentation mode for the element. This function is otherwise the same as :c:func:`emscripten_request_fullscreen`, but this function adds options to control how resizing and aspect ratio, and ensures that the behavior is consistent across browsers. @@ -1278,7 +1263,7 @@ Struct The event structure passed in the `pointerlockchange `_ event. - .. c:member:: EM_BOOL isActive + .. c:member:: bool isActive Specifies whether an element on the browser page currently has pointer lock enabled. @@ -1304,14 +1289,14 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_pointerlockchange_callback_func)(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent, void *userData); + typedef bool (*em_pointerlockchange_callback_func)(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent, void *userData); :param int eventType: The type of pointerlockchange event (:c:data:`EMSCRIPTEN_EVENT_POINTERLOCKCHANGE`). :param pointerlockChangeEvent: Information about the pointerlockchange event that occurred. :type pointerlockChangeEvent: const EmscriptenPointerlockChangeEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool .. c:type:: em_pointerlockerror_callback_func @@ -1319,20 +1304,20 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_pointerlockerror_callback_func)(int eventType, const void *reserved, void *userData); + typedef bool (*em_pointerlockerror_callback_func)(int eventType, const void *reserved, void *userData); :param int eventType: The type of pointerlockerror event (:c:data:`EMSCRIPTEN_EVENT_POINTERLOCKERROR`). :param const void* reserved: Reserved for future use; pass in 0. :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_pointerlockchange_callback(const char *target, void *userData, EM_BOOL useCapture, em_pointerlockchange_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_pointerlockchange_callback(const char *target, void *userData, bool useCapture, em_pointerlockchange_callback_func callback) Registers a callback function for receiving the `pointerlockchange `_ event. @@ -1341,21 +1326,21 @@ Functions :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_pointerlockchange_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_pointerlockerror_callback(const char *target, void *userData, EM_BOOL useCapture, em_pointerlockerror_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_pointerlockerror_callback(const char *target, void *userData, bool useCapture, em_pointerlockerror_callback_func callback) Registers a callback function for receiving the `pointerlockerror `_ event. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_pointerlockerror_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1371,7 +1356,7 @@ Functions :rtype: |EMSCRIPTEN_RESULT| -.. c:function:: EMSCRIPTEN_RESULT emscripten_request_pointerlock(const char *target, EM_BOOL deferUntilInEventHandler) +.. c:function:: EMSCRIPTEN_RESULT emscripten_request_pointerlock(const char *target, bool deferUntilInEventHandler) Requests the given target element to grab pointerlock. @@ -1380,7 +1365,7 @@ Functions :param target: |target-parameter-doc| :type target: const char* - :param EM_BOOL deferUntilInEventHandler: If ``true`` requests made outside of a user-generated event handler are automatically deferred until the user next presses a keyboard or mouse button. If ``false`` the request will fail if called outside of a user-generated event handler. + :param bool deferUntilInEventHandler: If ``true`` requests made outside of a user-generated event handler are automatically deferred until the user next presses a keyboard or mouse button. If ``false`` the request will fail if called outside of a user-generated event handler. :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1428,7 +1413,7 @@ Struct The event structure passed in the `visibilitychange `__ event. - .. c:member:: EM_BOOL hidden + .. c:member:: bool hidden If true, the current browser page is now hidden. @@ -1447,25 +1432,25 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_visibilitychange_callback_func)(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent, void *userData); + typedef bool (*em_visibilitychange_callback_func)(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent, void *userData); :param int eventType: The type of ``visibilitychange`` event (:c:data:`EMSCRIPTEN_VISIBILITY_HIDDEN`). :param visibilityChangeEvent: Information about the ``visibilitychange`` event that occurred. :type visibilityChangeEvent: const EmscriptenVisibilityChangeEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_visibilitychange_callback(void *userData, EM_BOOL useCapture, em_visibilitychange_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_visibilitychange_callback(void *userData, bool useCapture, em_visibilitychange_callback_func callback) Registers a callback function for receiving the `visibilitychange `_ event. :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_visibilitychange_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1521,11 +1506,11 @@ Struct The touch coordinate relative to the viewport, in pixels, and including any scroll offset. - .. c:member:: EM_BOOL isChanged + .. c:member:: bool isChanged Specifies whether the touch point changed during this event. - .. c:member:: EM_BOOL onTarget + .. c:member:: bool onTarget Specifies whether this touch point is still above the original target on which it was initially pressed. @@ -1554,10 +1539,10 @@ Struct The number of valid elements in the touches array. - .. c:member:: EM_BOOL ctrlKey - EM_BOOL shiftKey - EM_BOOL altKey - EM_BOOL metaKey + .. c:member:: bool ctrlKey + bool shiftKey + bool altKey + bool metaKey Specifies which modifiers were active during the touch event. @@ -1577,31 +1562,31 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_touch_callback_func)(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData); + typedef bool (*em_touch_callback_func)(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData); :param int eventType: The type of touch event (:c:data:`EMSCRIPTEN_EVENT_TOUCHSTART`). :param touchEvent: Information about the touch event that occurred. :type touchEvent: const EmscriptenTouchEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_touchstart_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_touchend_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_touchmove_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_touchcancel_callback(const char *target, void *userData, EM_BOOL useCapture, em_touch_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_touchstart_callback(const char *target, void *userData, bool useCapture, em_touch_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_touchend_callback(const char *target, void *userData, bool useCapture, em_touch_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_touchmove_callback(const char *target, void *userData, bool useCapture, em_touch_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_touchcancel_callback(const char *target, void *userData, bool useCapture, em_touch_callback_func callback) Registers a callback function for receiving `touch events `__ : `touchstart `_, `touchend `_, `touchmove `_ and `touchcancel `_. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_touch_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1650,11 +1635,11 @@ Struct The analog state of the gamepad buttons, in the range [0, 1]. - .. c:member:: EM_BOOL digitalButton[64] + .. c:member:: bool digitalButton[64] The digital state of the gamepad buttons, either 0 or 1. - .. c:member:: EM_BOOL connected + .. c:member:: bool connected Specifies whether this gamepad is connected to the browser page. @@ -1685,27 +1670,27 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_gamepad_callback_func)(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) + typedef bool (*em_gamepad_callback_func)(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) :param int eventType: The type of gamepad event (:c:data:`EMSCRIPTEN_EVENT_GAMEPADCONNECTED`). :param gamepadEvent: Information about the gamepad event that occurred. :type gamepadEvent: const EmscriptenGamepadEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_gamepadconnected_callback(void *userData, EM_BOOL useCapture, em_gamepad_callback_func callback) - EMSCRIPTEN_RESULT emscripten_set_gamepaddisconnected_callback(void *userData, EM_BOOL useCapture, em_gamepad_callback_func callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_gamepadconnected_callback(void *userData, bool useCapture, em_gamepad_callback_func callback) + EMSCRIPTEN_RESULT emscripten_set_gamepaddisconnected_callback(void *userData, bool useCapture, em_gamepad_callback_func callback) Registers a callback function for receiving the gamepad_ events: `gamepadconnected `_ and `gamepaddisconnected `_. :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_gamepad_callback_func callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| @@ -1793,7 +1778,7 @@ Struct Current battery level, on a scale of 0 to 1.0. - .. c:member:: EM_BOOL charging; + .. c:member:: bool charging; ``true`` if the battery is charging, ``false`` otherwise. @@ -1807,14 +1792,14 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_battery_callback_func)(int eventType, const EmscriptenBatteryEvent *batteryEvent, void *userData); + typedef bool (*em_battery_callback_func)(int eventType, const EmscriptenBatteryEvent *batteryEvent, void *userData); :param int eventType: The type of ``batterymanager`` event (:c:data:`EMSCRIPTEN_EVENT_BATTERYCHARGINGCHANGE`). :param batteryEvent: Information about the ``batterymanager`` event that occurred. :type batteryEvent: const EmscriptenBatteryEvent* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool @@ -1940,29 +1925,29 @@ Struct Specifies `WebGL context creation parameters `_. - .. c:member:: EM_BOOL alpha + .. c:member:: bool alpha If ``true``, request an alpha channel for the context. If you create an alpha channel, you can blend the canvas rendering with the underlying web page contents. Default value: ``true``. - .. c:member:: EM_BOOL depth + .. c:member:: bool depth If ``true``, request a depth buffer of at least 16 bits. If ``false``, no depth buffer will be initialized. Default value: ``true``. - .. c:member:: EM_BOOL stencil + .. c:member:: bool stencil If ``true``, request a stencil buffer of at least 8 bits. If ``false``, no stencil buffer will be initialized. Default value: ``false``. - .. c:member:: EM_BOOL antialias + .. c:member:: bool antialias If ``true``, antialiasing will be initialized with a browser-specified algorithm and quality level. If ``false``, antialiasing is disabled. Default value: ``true``. - .. c:member:: EM_BOOL premultipliedAlpha + .. c:member:: bool premultipliedAlpha If ``true``, the alpha channel of the rendering context will be treated as representing premultiplied alpha values. If ``false``, the alpha channel represents non-premultiplied alpha. Default value: ``true``. - .. c:member:: EM_BOOL preserveDrawingBuffer + .. c:member:: bool preserveDrawingBuffer If ``true``, the contents of the drawing buffer are preserved between consecutive ``requestAnimationFrame()`` calls. If ``false``, color, depth and stencil are cleared at the beginning of each ``requestAnimationFrame()``. Generally setting this to ``false`` gives better performance. Default value: ``false``. @@ -1971,7 +1956,7 @@ Struct Specifies a hint to the WebGL canvas implementation to how it should choose the use of available GPU resources. One of EM_WEBGL_POWER_PREFERENCE_DEFAULT, EM_WEBGL_POWER_PREFERENCE_LOW_POWER, EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE. - .. c:member:: EM_BOOL failIfMajorPerformanceCaveat + .. c:member:: bool failIfMajorPerformanceCaveat If ``true``, requests context creation to abort if the browser is only able to create a context that does not give good hardware-accelerated performance. Default value: ``false``. @@ -1986,26 +1971,26 @@ Struct Default value: ``majorVersion=1``, ``minorVersion=0`` - .. c:member:: EM_BOOL enableExtensionsByDefault + .. c:member:: bool enableExtensionsByDefault If ``true``, all GLES2-compatible non-performance-impacting WebGL extensions will automatically be enabled for you after the context has been created. If ``false``, no extensions are enabled by default, and you need to manually call :c:func:`emscripten_webgl_enable_extension` to enable each extension that you want to use. Default value: ``true``. - .. c:member:: EM_BOOL explicitSwapControl + .. c:member:: bool explicitSwapControl By default, when ``explicitSwapControl`` is in its default state ``false``, rendered WebGL content is implicitly presented (displayed to the user) on the canvas when the event handler that renders with WebGL returns back to the browser event loop. If ``explicitSwapControl`` is set to ``true``, rendered content will not be displayed on screen automatically when event handler function finishes, but the control of swapping is given to the user to manage, via the ``emscripten_webgl_commit_frame()`` function. In order to be able to set ``explicitSwapControl==true``, support for it must explicitly be enabled either 1) via adding the ``-sOFFSCREEN_FRAMEBUFFER`` Emscripten linker flag, and enabling ``renderViaOffscreenBackBuffer==1``, or 2) via adding the linker flag ``-sOFFSCREENCANVAS_SUPPORT``, and running in a browser that supports OffscreenCanvas. - .. c:member:: EM_BOOL renderViaOffscreenBackBuffer + .. c:member:: bool renderViaOffscreenBackBuffer If ``true``, an extra intermediate backbuffer (offscreen render target) is allocated to the created WebGL context, and rendering occurs to this backbuffer instead of directly onto the WebGL "default backbuffer". This is required to be enabled if 1) ``explicitSwapControl==true`` and the browser does not support OffscreenCanvas, 2) when performing WebGL rendering in a worker thread and the browser does not support OffscreenCanvas, and 3) when performing WebGL context accesses from multiple threads simultaneously (independent of whether OffscreenCanvas is supported or not). Because supporting offscreen framebuffer adds some amount of extra code to the compiled output, support for it must explicitly be enabled via the ``-sOFFSCREEN_FRAMEBUFFER`` Emscripten linker flag. When building simultaneously with both ``-sOFFSCREEN_FRAMEBUFFER`` and ``-sOFFSCREENCANVAS_SUPPORT`` linker flags enabled, offscreen backbuffer can be used as a polyfill-like compatibility fallback to enable rendering WebGL from a pthread when the browser does not support the OffscreenCanvas API. - .. c:member:: EM_BOOL proxyContextToMainThread + .. c:member:: bool proxyContextToMainThread This member specifies the threading model that will be used for the created WebGL context, when the WebGL context is created in a pthread. Three values are possible: ``EMSCRIPTEN_WEBGL_CONTEXT_PROXY_DISALLOW``, ``EMSCRIPTEN_WEBGL_CONTEXT_PROXY_FALLBACK`` or ``EMSCRIPTEN_WEBGL_CONTEXT_PROXY_ALWAYS``. If ``EMSCRIPTEN_WEBGL_CONTEXT_PROXY_DISALLOW`` is specified, the WebGLRenderingContext object will be created inside the pthread that is calling the ``emscripten_webgl_create_context()`` function as an OffscreenCanvas-based rendering context. This is only possible if 1) current browser supports OffscreenCanvas specification, 2) code was compiled with ``-sOFFSCREENCANVAS_SUPPORT`` linker flag enabled, 3) the Canvas object that the context is being created on was transferred over to the calling pthread with function ``emscripten_pthread_attr_settransferredcanvases()`` when the pthread was originally created, and 4) no OffscreenCanvas-based context already exists from the given Canvas at the same time. @@ -2027,14 +2012,14 @@ Callback functions .. code-block:: cpp - typedef EM_BOOL (*em_webgl_context_callback)(int eventType, const void *reserved, void *userData); + typedef bool (*em_webgl_context_callback)(int eventType, const void *reserved, void *userData); :param int eventType: The type of :c:data:`WebGL context event `. :param reserved: Reserved for future use; pass in 0. :type reserved: const void* :param void* userData: The ``userData`` originally passed to the registration function. :returns: |callback-handler-return-value-doc| - :rtype: |EM_BOOL| + :rtype: bool @@ -2042,28 +2027,28 @@ Functions --------- -.. c:function:: EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback(const char *target, void *userData, EM_BOOL useCapture, em_webgl_context_callback callback) - EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback(const char *target, void *userData, EM_BOOL useCapture, em_webgl_context_callback callback) +.. c:function:: EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback(const char *target, void *userData, bool useCapture, em_webgl_context_callback callback) + EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback(const char *target, void *userData, bool useCapture, em_webgl_context_callback callback) Registers a callback function for the canvas `WebGL context`_ events: ``webglcontextlost`` and ``webglcontextrestored``. :param target: |target-parameter-doc| :type target: const char* :param void* userData: |userData-parameter-doc| - :param EM_BOOL useCapture: |useCapture-parameter-doc| + :param bool useCapture: |useCapture-parameter-doc| :param em_webgl_context_callback callback: |callback-function-parameter-doc| :returns: :c:data:`EMSCRIPTEN_RESULT_SUCCESS`, or one of the other result values. :rtype: |EMSCRIPTEN_RESULT| -.. c:function:: EM_BOOL emscripten_is_webgl_context_lost(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context) +.. c:function:: bool emscripten_is_webgl_context_lost(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context) Queries the given WebGL context if it is in a lost context state. :param target: Specifies a handle to the context to test. :type target: EMSCRIPTEN_WEBGL_CONTEXT_HANDLE :returns: ``true`` if the WebGL context is in a lost state (or the context does not exist) - :rtype: |EM_BOOL| + :rtype: bool .. c:function:: void emscripten_webgl_init_context_attributes(EmscriptenWebGLContextAttributes *attributes) @@ -2148,15 +2133,15 @@ Functions :rtype: |EMSCRIPTEN_RESULT| -.. c:function:: EM_BOOL emscripten_webgl_enable_extension(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context, const char *extension) +.. c:function:: bool emscripten_webgl_enable_extension(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context, const char *extension) Enables the given extension on the given context. :param EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context: The WebGL context on which the extension is to be enabled. :param extension: A string identifying the `WebGL extension `_. For example "OES_texture_float". :type extension: const char* - :returns: EM_TRUE if the given extension is supported by the context, and EM_FALSE if the extension was not available. - :rtype: |EM_BOOL| + :returns: true if the given extension is supported by the context, and false if the extension was not available. + :rtype: bool .. c:function:: EMSCRIPTEN_RESULT emscripten_set_canvas_element_size(const char *target, int width, int height) @@ -2216,7 +2201,6 @@ Functions .. COMMENT (not rendered): The replace function return values with links (not created automatically) .. |EMSCRIPTEN_RESULT| replace:: :c:type:`EMSCRIPTEN_RESULT` -.. |EM_BOOL| replace:: :c:type:`EM_BOOL` .. |EMSCRIPTEN_WEBGL_CONTEXT_HANDLE| replace:: :c:type:`EMSCRIPTEN_WEBGL_CONTEXT_HANDLE` @@ -2259,10 +2243,10 @@ Functions :param setTimeoutId: An ID returned by function :c:func:`emscripten_set_timeout()`. -.. c:function:: void emscripten_set_timeout_loop(EM_BOOL (*cb)(double time, void *userData), double intervalMsecs, void *userData) +.. c:function:: void emscripten_set_timeout_loop(bool (*cb)(double time, void *userData), double intervalMsecs, void *userData) Initializes a ``setTimeout()`` loop on the given function on the calling thread. The specified callback - function 'cb' needs to keep returning ``EM_TRUE`` as long as the animation loop should continue to run. + function 'cb' needs to keep returning ``true`` as long as the animation loop should continue to run. When the function returns false, the ``setTimeout()`` loop will stop. Note: The loop will start immediately with a 0 msecs delay - the passed in intervalMsecs time specifies the interval that the consecutive callback calls should fire at. @@ -2272,7 +2256,7 @@ Functions :param userData: Specifies a pointer sized field of custom data that will be passed in to the callback function. -.. c:function:: long emscripten_request_animation_frame(EM_BOOL (*cb)(double time, void *userData), void *userData) +.. c:function:: long emscripten_request_animation_frame(bool (*cb)(double time, void *userData), void *userData) Performs a single ``requestAnimationFrame()`` callback call on the given function on the calling thread. @@ -2293,10 +2277,10 @@ Functions :param requestAnimationFrameId: An ID returned by function :c:func:`emscripten_request_animation_frame()`. -.. c:function:: void emscripten_request_animation_frame_loop(EM_BOOL (*cb)(double time, void *userData), void *userData) +.. c:function:: void emscripten_request_animation_frame_loop(bool (*cb)(double time, void *userData), void *userData) Initializes a ``requestAnimationFrame()`` loop on the given function on the calling thread. The specified - callback function 'cb' needs to keep returning ``EM_TRUE`` as long as the animation loop should continue + callback function 'cb' needs to keep returning ``true`` as long as the animation loop should continue to run. When the function returns false, the animation frame loop will stop. :param cb: The callback function to call. This function will receive the current high precision timer value @@ -2324,10 +2308,10 @@ Functions :param setImmediateId: An ID returned by function :c:func:`emscripten_set_immediate()`. -.. c:function:: void emscripten_set_immediate_loop(EM_BOOL (*cb)(void *userData), void *userData) +.. c:function:: void emscripten_set_immediate_loop(bool (*cb)(void *userData), void *userData) Initializes a ``setImmediate()`` loop on the given function on the calling thread. The specified callback - function 'cb' needs to keep returning ``EM_TRUE`` as long as the loop should continue to run. + function 'cb' needs to keep returning ``true`` as long as the loop should continue to run. When the function returns false, the ``setImmediate()`` loop will stop. TODO: Currently the polyfill of ``setImmediate()`` only works in the main browser thread, but not in pthreads. diff --git a/site/source/docs/api_reference/wasm_audio_worklets.rst b/site/source/docs/api_reference/wasm_audio_worklets.rst index e2587bf58b37..b7a24dc4f02d 100644 --- a/site/source/docs/api_reference/wasm_audio_worklets.rst +++ b/site/source/docs/api_reference/wasm_audio_worklets.rst @@ -95,7 +95,7 @@ own noise generator AudioWorkletProcessor node type: .. code-block:: cpp - void AudioThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) + void AudioThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { if (!success) return; // Check browser console in a debug build for detailed errors WebAudioWorkletProcessorCreateOptions opts = { @@ -110,7 +110,7 @@ which resumes the audio context when the user clicks on the DOM Canvas element t .. code-block:: cpp - void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) + void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { if (!success) return; // Check browser console in a debug build for detailed errors @@ -137,13 +137,13 @@ which resumes the audio context when the user clicks on the DOM Canvas element t .. code-block:: cpp - EM_BOOL OnCanvasClick(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) + bool OnCanvasClick(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) { EMSCRIPTEN_WEBAUDIO_T audioContext = (EMSCRIPTEN_WEBAUDIO_T)userData; if (emscripten_audio_context_state(audioContext) != AUDIO_CONTEXT_STATE_RUNNING) { emscripten_resume_audio_context_sync(audioContext); } - return EM_FALSE; + return false; } 5. Finally we can implement the audio callback that is to generate the noise: @@ -152,7 +152,7 @@ which resumes the audio context when the user clicks on the DOM Canvas element t #include - EM_BOOL GenerateNoise(int numInputs, const AudioSampleFrame *inputs, + bool GenerateNoise(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) @@ -161,7 +161,7 @@ which resumes the audio context when the user clicks on the DOM Canvas element t for(int j = 0; j < 128*outputs[i].numberOfChannels; ++j) outputs[i].data[j] = emscripten_random() * 0.2 - 0.1; // Warning: scale down audio volume by factor of 0.2, raw noise can be really loud otherwise - return EM_TRUE; // Keep the graph output going + return true; // Keep the graph output going } And that's it! Compile the code with the linker flags ``-sAUDIO_WORKLET=1 -sWASM_WORKERS=1`` to enable targeting AudioWorklets. diff --git a/site/source/docs/porting/emscripten-runtime-environment.rst b/site/source/docs/porting/emscripten-runtime-environment.rst index 2a8e41776ba1..6010e3ce7d20 100644 --- a/site/source/docs/porting/emscripten-runtime-environment.rst +++ b/site/source/docs/porting/emscripten-runtime-environment.rst @@ -73,11 +73,11 @@ Typically you will have a small section with ``#ifdef __EMSCRIPTEN__`` for the t // Our "main loop" function. This callback receives the current time as // reported by the browser, and the user data we provide in the call to // emscripten_request_animation_frame_loop(). - EM_BOOL one_iter(double time, void* userData) { + bool one_iter(double time, void* userData) { // Can render to the screen here, etc. puts("one iteration"); // Return true to keep the loop running. - return EM_TRUE; + return true; } int main() { diff --git a/system/include/emscripten/em_types.h b/system/include/emscripten/em_types.h index ae9aca239a1a..3479002746d9 100644 --- a/system/include/emscripten/em_types.h +++ b/system/include/emscripten/em_types.h @@ -5,6 +5,8 @@ * found in the LICENSE file. */ +#include + #pragma once #include @@ -31,9 +33,11 @@ typedef void (*em_callback_func)(void); typedef void (*em_arg_callback_func)(void*); typedef void (*em_str_callback_func)(const char *); +/* Legacy EM_BOOL type. Emscripten no longer uses this */ #define EM_BOOL bool -#define EM_TRUE 1 -#define EM_FALSE 0 +#define EM_TRUE true +#define EM_FALSE false + #define EM_UTF8 char #define EMSCRIPTEN_RESULT int diff --git a/system/include/emscripten/eventloop.h b/system/include/emscripten/eventloop.h index 74c2ca1a0ee4..4f706f9acf63 100644 --- a/system/include/emscripten/eventloop.h +++ b/system/include/emscripten/eventloop.h @@ -17,18 +17,18 @@ void emscripten_unwind_to_js_event_loop(void) __attribute__((__noreturn__)); int emscripten_set_timeout(void (*cb)(void *user_data) __attribute__((nonnull)), double msecs, void *user_data); void emscripten_clear_timeout(int id); -void emscripten_set_timeout_loop(EM_BOOL (*cb)(double time, void *user_data) __attribute__((nonnull)), double interval_ms, void *user_data); +void emscripten_set_timeout_loop(bool (*cb)(double time, void *user_data) __attribute__((nonnull)), double interval_ms, void *user_data); int emscripten_set_immediate(void (*cb)(void *user_data) __attribute__((nonnull)), void *user_data); void emscripten_clear_immediate(int id); -void emscripten_set_immediate_loop(EM_BOOL (*cb)(void *user_data), void *user_data); +void emscripten_set_immediate_loop(bool (*cb)(void *user_data), void *user_data); int emscripten_set_interval(void (*cb)(void *user_data) __attribute__((nonnull)), double interval_ms, void *user_data); void emscripten_clear_interval(int id); void emscripten_runtime_keepalive_push(void); void emscripten_runtime_keepalive_pop(void); -EM_BOOL emscripten_runtime_keepalive_check(void); +bool emscripten_runtime_keepalive_check(void); #ifdef __cplusplus } diff --git a/system/include/emscripten/fetch.h b/system/include/emscripten/fetch.h index 9099491c7387..38bf43c14f00 100644 --- a/system/include/emscripten/fetch.h +++ b/system/include/emscripten/fetch.h @@ -8,9 +8,10 @@ #pragma once #include +#include #include #include -#include +#include #ifdef __cplusplus extern "C" { @@ -88,7 +89,7 @@ typedef struct emscripten_fetch_attr_t { // Indicates whether cross-site access control requests should be made using // credentials. - EM_BOOL withCredentials; + bool withCredentials; // Specifies the destination path in IndexedDB where to store the downloaded // content body. If this is empty, the transfer is not stored to IndexedDB at diff --git a/system/include/emscripten/html5.h b/system/include/emscripten/html5.h index 99af09666040..178f05e4d991 100644 --- a/system/include/emscripten/html5.h +++ b/system/include/emscripten/html5.h @@ -88,11 +88,11 @@ extern "C" { typedef struct EmscriptenKeyboardEvent { double timestamp; unsigned int location; - EM_BOOL ctrlKey; - EM_BOOL shiftKey; - EM_BOOL altKey; - EM_BOOL metaKey; - EM_BOOL repeat; + bool ctrlKey; + bool shiftKey; + bool altKey; + bool metaKey; + bool repeat; unsigned int charCode; unsigned int keyCode; unsigned int which; @@ -103,10 +103,10 @@ typedef struct EmscriptenKeyboardEvent { } EmscriptenKeyboardEvent; -typedef EM_BOOL (*em_key_callback_func)(int eventType, const EmscriptenKeyboardEvent *keyEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_keypress_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_key_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_keydown_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_key_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_keyup_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_key_callback_func callback, pthread_t targetThread); +typedef bool (*em_key_callback_func)(int eventType, const EmscriptenKeyboardEvent *keyEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_keypress_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_key_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_keydown_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_key_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_keyup_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_key_callback_func callback, pthread_t targetThread); typedef struct EmscriptenMouseEvent { double timestamp; @@ -114,10 +114,10 @@ typedef struct EmscriptenMouseEvent { int screenY; int clientX; int clientY; - EM_BOOL ctrlKey; - EM_BOOL shiftKey; - EM_BOOL altKey; - EM_BOOL metaKey; + bool ctrlKey; + bool shiftKey; + bool altKey; + bool metaKey; unsigned short button; unsigned short buttons; int movementX; @@ -131,16 +131,16 @@ typedef struct EmscriptenMouseEvent { } EmscriptenMouseEvent; -typedef EM_BOOL (*em_mouse_callback_func)(int eventType, const EmscriptenMouseEvent *mouseEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_click_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mousedown_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mouseup_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_dblclick_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mousemove_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mouseenter_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mouseleave_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mouseover_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_mouseout_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_mouse_callback_func callback, pthread_t targetThread); +typedef bool (*em_mouse_callback_func)(int eventType, const EmscriptenMouseEvent *mouseEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_click_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mousedown_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mouseup_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_dblclick_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mousemove_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mouseenter_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mouseleave_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mouseover_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_mouseout_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_mouse_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_mouse_status(EmscriptenMouseEvent *mouseState __attribute__((nonnull))); @@ -157,8 +157,8 @@ typedef struct EmscriptenWheelEvent { } 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 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, bool useCapture, em_wheel_callback_func callback, pthread_t targetThread); typedef struct EmscriptenUiEvent { int detail; @@ -173,31 +173,31 @@ typedef struct EmscriptenUiEvent { } EmscriptenUiEvent; -typedef EM_BOOL (*em_ui_callback_func)(int eventType, const EmscriptenUiEvent *uiEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_resize_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_ui_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_scroll_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_ui_callback_func callback, pthread_t targetThread); +typedef bool (*em_ui_callback_func)(int eventType, const EmscriptenUiEvent *uiEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_resize_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_ui_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_scroll_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_ui_callback_func callback, pthread_t targetThread); typedef struct EmscriptenFocusEvent { EM_UTF8 nodeName[EM_HTML5_LONG_STRING_LEN_BYTES]; EM_UTF8 id[EM_HTML5_LONG_STRING_LEN_BYTES]; } EmscriptenFocusEvent; -typedef EM_BOOL (*em_focus_callback_func)(int eventType, const EmscriptenFocusEvent *focusEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_blur_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_focus_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_focus_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_focus_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_focusin_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_focus_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_focusout_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_focus_callback_func callback, pthread_t targetThread); +typedef bool (*em_focus_callback_func)(int eventType, const EmscriptenFocusEvent *focusEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_blur_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_focus_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_focus_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_focus_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_focusin_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_focus_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_focusout_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_focus_callback_func callback, pthread_t targetThread); typedef struct EmscriptenDeviceOrientationEvent { double alpha; double beta; double gamma; - EM_BOOL absolute; + bool absolute; } EmscriptenDeviceOrientationEvent; -typedef EM_BOOL (*em_deviceorientation_callback_func)(int eventType, const EmscriptenDeviceOrientationEvent *deviceOrientationEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_deviceorientation_callback_on_thread(void *userData, EM_BOOL useCapture, em_deviceorientation_callback_func callback, pthread_t targetThread); +typedef bool (*em_deviceorientation_callback_func)(int eventType, const EmscriptenDeviceOrientationEvent *deviceOrientationEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_deviceorientation_callback_on_thread(void *userData, bool useCapture, em_deviceorientation_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_deviceorientation_status(EmscriptenDeviceOrientationEvent *orientationState __attribute__((nonnull))); @@ -219,8 +219,8 @@ typedef struct EmscriptenDeviceMotionEvent { } EmscriptenDeviceMotionEvent; -typedef EM_BOOL (*em_devicemotion_callback_func)(int eventType, const EmscriptenDeviceMotionEvent *deviceMotionEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_devicemotion_callback_on_thread(void *userData, EM_BOOL useCapture, em_devicemotion_callback_func callback, pthread_t targetThread); +typedef bool (*em_devicemotion_callback_func)(int eventType, const EmscriptenDeviceMotionEvent *deviceMotionEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_devicemotion_callback_on_thread(void *userData, bool useCapture, em_devicemotion_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_devicemotion_status(EmscriptenDeviceMotionEvent *motionState __attribute__((nonnull))); @@ -236,16 +236,16 @@ typedef struct EmscriptenOrientationChangeEvent { } EmscriptenOrientationChangeEvent; -typedef EM_BOOL (*em_orientationchange_callback_func)(int eventType, const EmscriptenOrientationChangeEvent *orientationChangeEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_orientationchange_callback_on_thread(void *userData, EM_BOOL useCapture, em_orientationchange_callback_func callback, pthread_t targetThread); +typedef bool (*em_orientationchange_callback_func)(int eventType, const EmscriptenOrientationChangeEvent *orientationChangeEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_orientationchange_callback_on_thread(void *userData, bool useCapture, em_orientationchange_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_orientation_status(EmscriptenOrientationChangeEvent *orientationStatus __attribute__((nonnull))); EMSCRIPTEN_RESULT emscripten_lock_orientation(int allowedOrientations); EMSCRIPTEN_RESULT emscripten_unlock_orientation(void); typedef struct EmscriptenFullscreenChangeEvent { - EM_BOOL isFullscreen; - EM_BOOL fullscreenEnabled; + bool isFullscreen; + bool fullscreenEnabled; EM_UTF8 nodeName[EM_HTML5_LONG_STRING_LEN_BYTES]; EM_UTF8 id[EM_HTML5_LONG_STRING_LEN_BYTES]; int elementWidth; @@ -255,8 +255,8 @@ typedef struct EmscriptenFullscreenChangeEvent { } EmscriptenFullscreenChangeEvent; -typedef EM_BOOL (*em_fullscreenchange_callback_func)(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_fullscreenchange_callback_on_thread(const char *target, void *userData, EM_BOOL useCapture, em_fullscreenchange_callback_func callback, pthread_t targetThread); +typedef bool (*em_fullscreenchange_callback_func)(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_fullscreenchange_callback_on_thread(const char *target, void *userData, bool useCapture, em_fullscreenchange_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_fullscreen_status(EmscriptenFullscreenChangeEvent *fullscreenStatus __attribute__((nonnull))); @@ -276,7 +276,7 @@ EMSCRIPTEN_RESULT emscripten_get_fullscreen_status(EmscriptenFullscreenChangeEve #define EMSCRIPTEN_FULLSCREEN_FILTERING_NEAREST 1 #define EMSCRIPTEN_FULLSCREEN_FILTERING_BILINEAR 2 -typedef EM_BOOL (*em_canvasresized_callback_func)(int eventType, const void *reserved, void *userData); +typedef bool (*em_canvasresized_callback_func)(int eventType, const void *reserved, void *userData); typedef struct EmscriptenFullscreenStrategy { EMSCRIPTEN_FULLSCREEN_SCALE scaleMode; @@ -287,8 +287,8 @@ typedef struct EmscriptenFullscreenStrategy { pthread_t canvasResizedCallbackTargetThread; } EmscriptenFullscreenStrategy; -EMSCRIPTEN_RESULT emscripten_request_fullscreen(const char *target __attribute__((nonnull)), EM_BOOL deferUntilInEventHandler); -EMSCRIPTEN_RESULT emscripten_request_fullscreen_strategy(const char *target __attribute__((nonnull)), EM_BOOL deferUntilInEventHandler, const EmscriptenFullscreenStrategy *fullscreenStrategy __attribute__((nonnull))); +EMSCRIPTEN_RESULT emscripten_request_fullscreen(const char *target __attribute__((nonnull)), bool deferUntilInEventHandler); +EMSCRIPTEN_RESULT emscripten_request_fullscreen_strategy(const char *target __attribute__((nonnull)), bool deferUntilInEventHandler, const EmscriptenFullscreenStrategy *fullscreenStrategy __attribute__((nonnull))); EMSCRIPTEN_RESULT emscripten_exit_fullscreen(void); @@ -297,21 +297,21 @@ EMSCRIPTEN_RESULT emscripten_enter_soft_fullscreen(const char *target __attribut EMSCRIPTEN_RESULT emscripten_exit_soft_fullscreen(void); typedef struct EmscriptenPointerlockChangeEvent { - EM_BOOL isActive; + bool isActive; EM_UTF8 nodeName[EM_HTML5_LONG_STRING_LEN_BYTES]; EM_UTF8 id[EM_HTML5_LONG_STRING_LEN_BYTES]; } EmscriptenPointerlockChangeEvent; -typedef EM_BOOL (*em_pointerlockchange_callback_func)(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_pointerlockchange_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_pointerlockchange_callback_func callback, pthread_t targetThread); +typedef bool (*em_pointerlockchange_callback_func)(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_pointerlockchange_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_pointerlockchange_callback_func callback, pthread_t targetThread); -typedef EM_BOOL (*em_pointerlockerror_callback_func)(int eventType, const void *reserved, void *userData); -EMSCRIPTEN_RESULT emscripten_set_pointerlockerror_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_pointerlockerror_callback_func callback, pthread_t targetThread); +typedef bool (*em_pointerlockerror_callback_func)(int eventType, const void *reserved, void *userData); +EMSCRIPTEN_RESULT emscripten_set_pointerlockerror_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_pointerlockerror_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_pointerlock_status(EmscriptenPointerlockChangeEvent *pointerlockStatus __attribute__((nonnull))); -EMSCRIPTEN_RESULT emscripten_request_pointerlock(const char *target __attribute__((nonnull)), EM_BOOL deferUntilInEventHandler); +EMSCRIPTEN_RESULT emscripten_request_pointerlock(const char *target __attribute__((nonnull)), bool deferUntilInEventHandler); EMSCRIPTEN_RESULT emscripten_exit_pointerlock(void); @@ -321,12 +321,12 @@ EMSCRIPTEN_RESULT emscripten_exit_pointerlock(void); #define EMSCRIPTEN_VISIBILITY_UNLOADED 3 typedef struct EmscriptenVisibilityChangeEvent { - EM_BOOL hidden; + bool hidden; int visibilityState; } EmscriptenVisibilityChangeEvent; -typedef EM_BOOL (*em_visibilitychange_callback_func)(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_visibilitychange_callback_on_thread(void *userData, EM_BOOL useCapture, em_visibilitychange_callback_func callback, pthread_t targetThread); +typedef bool (*em_visibilitychange_callback_func)(int eventType, const EmscriptenVisibilityChangeEvent *visibilityChangeEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_visibilitychange_callback_on_thread(void *userData, bool useCapture, em_visibilitychange_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_get_visibility_status(EmscriptenVisibilityChangeEvent *visibilityStatus __attribute__((nonnull))); @@ -340,8 +340,8 @@ typedef struct EmscriptenTouchPoint int clientY; int pageX; int pageY; - EM_BOOL isChanged; - EM_BOOL onTarget; + bool isChanged; + bool onTarget; 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) @@ -352,19 +352,19 @@ typedef struct EmscriptenTouchPoint typedef struct EmscriptenTouchEvent { double timestamp; int numTouches; - EM_BOOL ctrlKey; - EM_BOOL shiftKey; - EM_BOOL altKey; - EM_BOOL metaKey; + bool ctrlKey; + bool shiftKey; + bool altKey; + bool metaKey; EmscriptenTouchPoint touches[32]; } EmscriptenTouchEvent; -typedef EM_BOOL (*em_touch_callback_func)(int eventType, const EmscriptenTouchEvent *touchEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_touchstart_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_touch_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_touchend_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_touch_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_touchmove_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_touch_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_touchcancel_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_touch_callback_func callback, pthread_t targetThread); +typedef bool (*em_touch_callback_func)(int eventType, const EmscriptenTouchEvent *touchEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_touchstart_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_touch_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_touchend_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_touch_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_touchmove_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_touch_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_touchcancel_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_touch_callback_func callback, pthread_t targetThread); typedef struct EmscriptenGamepadEvent { @@ -373,17 +373,17 @@ typedef struct EmscriptenGamepadEvent { int numButtons; double axis[64]; double analogButton[64]; - EM_BOOL digitalButton[64]; - EM_BOOL connected; + bool digitalButton[64]; + bool connected; int index; EM_UTF8 id[EM_HTML5_MEDIUM_STRING_LEN_BYTES]; EM_UTF8 mapping[EM_HTML5_MEDIUM_STRING_LEN_BYTES]; } EmscriptenGamepadEvent; -typedef EM_BOOL (*em_gamepad_callback_func)(int eventType, const EmscriptenGamepadEvent *gamepadEvent __attribute__((nonnull)), void *userData); -EMSCRIPTEN_RESULT emscripten_set_gamepadconnected_callback_on_thread(void *userData, EM_BOOL useCapture, em_gamepad_callback_func callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_gamepaddisconnected_callback_on_thread(void *userData, EM_BOOL useCapture, em_gamepad_callback_func callback, pthread_t targetThread); +typedef bool (*em_gamepad_callback_func)(int eventType, const EmscriptenGamepadEvent *gamepadEvent __attribute__((nonnull)), void *userData); +EMSCRIPTEN_RESULT emscripten_set_gamepadconnected_callback_on_thread(void *userData, bool useCapture, em_gamepad_callback_func callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_gamepaddisconnected_callback_on_thread(void *userData, bool useCapture, em_gamepad_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_sample_gamepad_data(void); int emscripten_get_num_gamepads(void); @@ -393,10 +393,10 @@ typedef struct EmscriptenBatteryEvent { double chargingTime; double dischargingTime; double level; - EM_BOOL charging; + bool charging; } EmscriptenBatteryEvent; -typedef EM_BOOL (*em_battery_callback_func)(int eventType, const EmscriptenBatteryEvent *batteryEvent __attribute__((nonnull)), void *userData); +typedef bool (*em_battery_callback_func)(int eventType, const EmscriptenBatteryEvent *batteryEvent __attribute__((nonnull)), void *userData); EMSCRIPTEN_RESULT emscripten_set_batterychargingchange_callback_on_thread(void *userData, em_battery_callback_func callback, pthread_t targetThread); EMSCRIPTEN_RESULT emscripten_set_batterylevelchange_callback_on_thread(void *userData, em_battery_callback_func callback, pthread_t targetThread); @@ -462,9 +462,9 @@ void emscripten_html5_remove_all_event_listeners(void); #define emscripten_set_batterylevelchange_callback(userData, callback) emscripten_set_batterylevelchange_callback_on_thread( (userData), (callback), EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD) #define emscripten_set_beforeunload_callback(userData, callback) emscripten_set_beforeunload_callback_on_thread( (userData), (callback), EM_CALLBACK_THREAD_CONTEXT_MAIN_RUNTIME_THREAD) -int emscripten_request_animation_frame(EM_BOOL (*cb)(double time, void *userData), void *userData); +int emscripten_request_animation_frame(bool (*cb)(double time, void *userData), void *userData); void emscripten_cancel_animation_frame(int requestAnimationFrameId); -void emscripten_request_animation_frame_loop(EM_BOOL (*cb)(double time, void *userData), void *userData); +void emscripten_request_animation_frame_loop(bool (*cb)(double time, void *userData), void *userData); double emscripten_date_now(void); double emscripten_performance_now(void); diff --git a/system/include/emscripten/html5_webgl.h b/system/include/emscripten/html5_webgl.h index 5c7e4421ffe8..4cfbe7ff6cea 100644 --- a/system/include/emscripten/html5_webgl.h +++ b/system/include/emscripten/html5_webgl.h @@ -27,22 +27,22 @@ typedef int EM_WEBGL_POWER_PREFERENCE; #define EM_WEBGL_POWER_PREFERENCE_HIGH_PERFORMANCE 2 typedef struct EmscriptenWebGLContextAttributes { - EM_BOOL alpha; - EM_BOOL depth; - EM_BOOL stencil; - EM_BOOL antialias; - EM_BOOL premultipliedAlpha; - EM_BOOL preserveDrawingBuffer; + bool alpha; + bool depth; + bool stencil; + bool antialias; + bool premultipliedAlpha; + bool preserveDrawingBuffer; EM_WEBGL_POWER_PREFERENCE powerPreference; - EM_BOOL failIfMajorPerformanceCaveat; + bool failIfMajorPerformanceCaveat; int majorVersion; int minorVersion; - EM_BOOL enableExtensionsByDefault; - EM_BOOL explicitSwapControl; + bool enableExtensionsByDefault; + bool explicitSwapControl; EMSCRIPTEN_WEBGL_CONTEXT_PROXY_MODE proxyContextToMainThread; - EM_BOOL renderViaOffscreenBackBuffer; + bool renderViaOffscreenBackBuffer; } EmscriptenWebGLContextAttributes; void emscripten_webgl_init_context_attributes(EmscriptenWebGLContextAttributes *attributes __attribute__((nonnull))); @@ -59,35 +59,35 @@ EMSCRIPTEN_RESULT emscripten_webgl_get_context_attributes(EMSCRIPTEN_WEBGL_CONTE EMSCRIPTEN_RESULT emscripten_webgl_destroy_context(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_extension(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context, const char *extension __attribute__((nonnull))); +bool emscripten_webgl_enable_extension(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context, const char *extension __attribute__((nonnull))); -EM_BOOL emscripten_webgl_enable_ANGLE_instanced_arrays(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_ANGLE_instanced_arrays(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_OES_vertex_array_object(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_OES_vertex_array_object(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_WEBGL_draw_buffers(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_draw_buffers(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_draw_instanced_base_vertex_base_instance(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_WEBGL_multi_draw(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_multi_draw(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_multi_draw_instanced_base_vertex_base_instance(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_EXT_polygon_offset_clamp(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_EXT_polygon_offset_clamp(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_EXT_clip_control(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_EXT_clip_control(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -EM_BOOL emscripten_webgl_enable_WEBGL_polygon_mode(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_polygon_mode(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); -typedef EM_BOOL (*em_webgl_context_callback)(int eventType, const void *reserved, void *userData); -EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_webgl_context_callback callback, pthread_t targetThread); -EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, EM_BOOL useCapture, em_webgl_context_callback callback, pthread_t targetThread); +typedef bool (*em_webgl_context_callback)(int eventType, const void *reserved, void *userData); +EMSCRIPTEN_RESULT emscripten_set_webglcontextlost_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_webgl_context_callback callback, pthread_t targetThread); +EMSCRIPTEN_RESULT emscripten_set_webglcontextrestored_callback_on_thread(const char *target __attribute__((nonnull)), void *userData, bool useCapture, em_webgl_context_callback callback, pthread_t targetThread); -EM_BOOL emscripten_is_webgl_context_lost(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_is_webgl_context_lost(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); EMSCRIPTEN_RESULT emscripten_webgl_commit_frame(void); -EM_BOOL emscripten_supports_offscreencanvas(void); +bool emscripten_supports_offscreencanvas(void); // Returns function pointers to WebGL 1 functions. Please avoid using this function ever - all WebGL1/GLES2 functions, even those for WebGL1 extensions, are available to user code via static linking. Calling GL functions // via function pointers obtained here is slow, and using this function can greatly increase resulting compiled program size. This functionality is available only for easier program code porting purposes, but be aware diff --git a/system/include/emscripten/wasm_worker.h b/system/include/emscripten/wasm_worker.h index 3fdace54d342..21bf1a82dfd5 100644 --- a/system/include/emscripten/wasm_worker.h +++ b/system/include/emscripten/wasm_worker.h @@ -56,10 +56,10 @@ void emscripten_terminate_wasm_worker(emscripten_wasm_worker_t id); // (-sWASM_WORKERS=0) void emscripten_terminate_all_wasm_workers(void); -// Returns EM_TRUE if the current thread is executing a Wasm Worker, EM_FALSE +// Returns true if the current thread is executing a Wasm Worker, false // otherwise. Note that calling this function can be relatively slow as it // incurs a Wasm->JS transition, so avoid calling it in hot paths. -EM_BOOL emscripten_current_thread_is_wasm_worker(void); +bool emscripten_current_thread_is_wasm_worker(void); // Returns a unique ID that identifies the calling Wasm Worker. Similar to // pthread_self(). The main browser thread will return 0 as the ID. First Wasm @@ -120,17 +120,17 @@ int emscripten_atomics_is_lock_free(int byteWidth); void emscripten_lock_init(emscripten_lock_t *lock __attribute__((nonnull))); // Attempts to acquire the specified lock. If the lock is free, then this -// function acquires the lock and immediately returns EM_TRUE. If the lock is +// function acquires the lock and immediately returns true. If the lock is // not free at the time of the call, the calling thread is set to synchronously // sleep for at most maxWaitNanoseconds long, until another thread releases the // lock. If the lock is acquired within that period, the function returns -// EM_TRUE. If the lock is not acquired within the specified period, then the -// wait times out and EM_FALSE is returned. +// true. If the lock is not acquired within the specified period, then the +// wait times out and false is returned. // NOTE: This function can be only called in a Worker, and not on the main // browser thread, because the main browser thread cannot synchronously // sleep to wait for locks. -EM_BOOL emscripten_lock_wait_acquire(emscripten_lock_t *lock __attribute__((nonnull)), int64_t maxWaitNanoseconds); +bool emscripten_lock_wait_acquire(emscripten_lock_t *lock __attribute__((nonnull)), int64_t maxWaitNanoseconds); // Similar to emscripten_lock_wait_acquire(), but instead of waiting for at most // a specified timeout value, the thread will wait indefinitely long until the @@ -153,7 +153,7 @@ void emscripten_lock_waitinf_acquire(emscripten_lock_t *lock __attribute__((nonn // reasonable max wait value, or otherwise a "slow script dialog" // notification can pop up, and can cause the browser to stop executing // the page. -EM_BOOL emscripten_lock_busyspin_wait_acquire(emscripten_lock_t *lock __attribute__((nonnull)), double maxWaitMilliseconds); +bool emscripten_lock_busyspin_wait_acquire(emscripten_lock_t *lock __attribute__((nonnull)), double maxWaitMilliseconds); // Similar to emscripten_lock_wait_acquire(), but instead of placing the calling // thread to sleep until the lock can be acquired, this function will burn CPU @@ -188,11 +188,11 @@ void emscripten_lock_async_acquire(emscripten_lock_t *lock __attribute__((nonnul void *userData, double maxWaitMilliseconds); -// Attempts to acquire a lock, returning EM_TRUE if successful. If the lock is +// Attempts to acquire a lock, returning true if successful. If the lock is // already held, this function will not sleep to wait until the lock is -// released, but immediately returns EM_FALSE. +// released, but immediately returns false. // This function can be called on both main thread and in Workers. -EM_BOOL emscripten_lock_try_acquire(emscripten_lock_t *lock __attribute__((nonnull))); +bool emscripten_lock_try_acquire(emscripten_lock_t *lock __attribute__((nonnull))); // Unlocks the specified lock for another thread to access. Note that locks are // extremely lightweight, there is no "lock owner" tracking: this function does @@ -262,10 +262,10 @@ void emscripten_condvar_waitinf(emscripten_condvar_t *condvar __attribute__((non // Same as the above, except that an attempt to wait for the condition variable // to become true is only performed for a maximum duration. -// On success (no timeout), this function will return EM_TRUE. If the wait times -// out, this function will return EM_FALSE. In this case, +// On success (no timeout), this function will return true. If the wait times +// out, this function will return false. In this case, // the calling thread will not try to reacquire the lock. -EM_BOOL emscripten_condvar_wait(emscripten_condvar_t *condvar __attribute__((nonnull)), emscripten_lock_t *lock __attribute__((nonnull)), int64_t maxWaitNanoseconds); +bool emscripten_condvar_wait(emscripten_condvar_t *condvar __attribute__((nonnull)), emscripten_lock_t *lock __attribute__((nonnull)), int64_t maxWaitNanoseconds); // Asynchronously wait for the given condition variable to signal. ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t *condvar __attribute__((nonnull)), diff --git a/system/include/emscripten/webaudio.h b/system/include/emscripten/webaudio.h index 5f9108c12769..a3261c47ac1d 100644 --- a/system/include/emscripten/webaudio.h +++ b/system/include/emscripten/webaudio.h @@ -47,7 +47,7 @@ void emscripten_resume_audio_context_sync(EMSCRIPTEN_WEBAUDIO_T audioContext); // Returns the current AudioContext state. AUDIO_CONTEXT_STATE emscripten_audio_context_state(EMSCRIPTEN_WEBAUDIO_T audioContext); -typedef void (*EmscriptenStartWebAudioWorkletCallback)(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData2); +typedef void (*EmscriptenStartWebAudioWorkletCallback)(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData2); // Calls .suspend() on the given AudioContext and releases the JS object table // reference to the given audio context. The specified handle is invalid @@ -89,7 +89,7 @@ typedef struct WebAudioWorkletProcessorCreateOptions const WebAudioParamDescriptor *audioParamDescriptors; } WebAudioWorkletProcessorCreateOptions; -typedef void (*EmscriptenWorkletProcessorCreatedCallback)(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData3); +typedef void (*EmscriptenWorkletProcessorCreatedCallback)(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData3); // Creates a new AudioWorkletProcessor with the given name and specified set of control parameters. // userData3: A custom userdata pointer to pass to the callback function. This value will be passed on to the call to the given EmscriptenWorkletProcessorCreatedCallback callback function. @@ -113,7 +113,7 @@ typedef struct AudioParamFrame float *data; } AudioParamFrame; -typedef EM_BOOL (*EmscriptenWorkletNodeProcessCallback)(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData4); +typedef bool (*EmscriptenWorkletNodeProcessCallback)(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData4); typedef struct EmscriptenAudioWorkletNodeCreateOptions { @@ -129,10 +129,10 @@ typedef struct EmscriptenAudioWorkletNodeCreateOptions // userData4: A custom userdata pointer to pass to the callback function. This value will be passed on to the call to the given EmscriptenWorkletNodeProcessCallback callback function. EMSCRIPTEN_AUDIO_WORKLET_NODE_T emscripten_create_wasm_audio_worklet_node(EMSCRIPTEN_WEBAUDIO_T audioContext, const char *name, const EmscriptenAudioWorkletNodeCreateOptions *options, EmscriptenWorkletNodeProcessCallback processCallback, void *userData4); -// Returns EM_TRUE if the current thread is executing a Wasm AudioWorklet, EM_FALSE otherwise. +// Returns true if the current thread is executing a Wasm AudioWorklet, false otherwise. // Note that calling this function can be relatively slow as it incurs a Wasm->JS transition, // so avoid calling it in hot paths. -EM_BOOL emscripten_current_thread_is_audio_worklet(void); +bool emscripten_current_thread_is_audio_worklet(void); #define EMSCRIPTEN_AUDIO_MAIN_THREAD 0 diff --git a/system/include/emscripten/websocket.h b/system/include/emscripten/websocket.h index 11cf8a402429..f07615dcd154 100644 --- a/system/include/emscripten/websocket.h +++ b/system/include/emscripten/websocket.h @@ -45,34 +45,34 @@ typedef struct EmscriptenWebSocketOpenEvent { EMSCRIPTEN_WEBSOCKET_T socket; } EmscriptenWebSocketOpenEvent; -typedef EM_BOOL (*em_websocket_open_callback_func)(int eventType, const EmscriptenWebSocketOpenEvent *websocketEvent __attribute__((nonnull)), void *userData); +typedef bool (*em_websocket_open_callback_func)(int eventType, const EmscriptenWebSocketOpenEvent *websocketEvent __attribute__((nonnull)), void *userData); EMSCRIPTEN_RESULT emscripten_websocket_set_onopen_callback_on_thread(EMSCRIPTEN_WEBSOCKET_T socket, void *userData, em_websocket_open_callback_func callback, pthread_t targetThread); typedef struct EmscriptenWebSocketMessageEvent { EMSCRIPTEN_WEBSOCKET_T socket; uint8_t *data; uint32_t numBytes; - EM_BOOL isText; + bool isText; } EmscriptenWebSocketMessageEvent; -typedef EM_BOOL (*em_websocket_message_callback_func)(int eventType, const EmscriptenWebSocketMessageEvent *websocketEvent __attribute__((nonnull)), void *userData); +typedef bool (*em_websocket_message_callback_func)(int eventType, const EmscriptenWebSocketMessageEvent *websocketEvent __attribute__((nonnull)), void *userData); EMSCRIPTEN_RESULT emscripten_websocket_set_onmessage_callback_on_thread(EMSCRIPTEN_WEBSOCKET_T socket, void *userData, em_websocket_message_callback_func callback, pthread_t targetThread); typedef struct EmscriptenWebSocketErrorEvent { EMSCRIPTEN_WEBSOCKET_T socket; } EmscriptenWebSocketErrorEvent; -typedef EM_BOOL (*em_websocket_error_callback_func)(int eventType, const EmscriptenWebSocketErrorEvent *websocketEvent __attribute__((nonnull)), void *userData); +typedef bool (*em_websocket_error_callback_func)(int eventType, const EmscriptenWebSocketErrorEvent *websocketEvent __attribute__((nonnull)), void *userData); EMSCRIPTEN_RESULT emscripten_websocket_set_onerror_callback_on_thread(EMSCRIPTEN_WEBSOCKET_T socket, void *userData, em_websocket_error_callback_func callback, pthread_t targetThread); typedef struct EmscriptenWebSocketCloseEvent { EMSCRIPTEN_WEBSOCKET_T socket; - EM_BOOL wasClean; + bool wasClean; unsigned short code; char reason[512]; // WebSockets spec enforces this can be max 123 characters, so as UTF-8 at most 123*4 bytes < 512. } EmscriptenWebSocketCloseEvent; -typedef EM_BOOL (*em_websocket_close_callback_func)(int eventType, const EmscriptenWebSocketCloseEvent *websocketEvent __attribute__((nonnull)), void *userData); +typedef bool (*em_websocket_close_callback_func)(int eventType, const EmscriptenWebSocketCloseEvent *websocketEvent __attribute__((nonnull)), void *userData); EMSCRIPTEN_RESULT emscripten_websocket_set_onclose_callback_on_thread(EMSCRIPTEN_WEBSOCKET_T socket, void *userData, em_websocket_close_callback_func callback, pthread_t targetThread); #define emscripten_websocket_set_onopen_callback(socket, userData, callback) emscripten_websocket_set_onopen_callback_on_thread( (socket), (userData), (callback), EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD) @@ -93,14 +93,14 @@ typedef struct EmscriptenWebSocketCreateAttributes { // pthread that you create the socket, set createOnMainThread to true. If the created WebSocket only needs to be accessible on the thread // that created it, and the creating thread is an event based thread (meaning it regularly yields back to the browser event loop), then // it is more efficient to set this to false. - EM_BOOL createOnMainThread; + bool createOnMainThread; } EmscriptenWebSocketCreateAttributes; //extern void emscripten_websocket_init_create_attributes(EmscriptenWebSocketCreateAttributes *attributes); #define emscripten_websocket_init_create_attributes(attributes) do { memset((attributes), 0, sizeof(EmscriptenWebSocketCreateAttributes)); } while(0) // Returns true if WebSockets are supported by the current browser -EM_BOOL emscripten_websocket_is_supported(void); +bool emscripten_websocket_is_supported(void); // Creates a new WebSocket and connects it to the given remote host. // If the return value of this function is > 0, the function has succeeded and the return value represents a handle to the WebSocket object. diff --git a/system/include/webgl/webgl1_ext.h b/system/include/webgl/webgl1_ext.h index a5268a375988..fdf2ea935d2a 100644 --- a/system/include/webgl/webgl1_ext.h +++ b/system/include/webgl/webgl1_ext.h @@ -78,7 +78,7 @@ #ifndef EMSCRIPTEN_GL_OES_vertex_array_object #define EMSCRIPTEN_GL_OES_vertex_array_object 1 // To enable: call -EM_BOOL emscripten_webgl_enable_OES_vertex_array_object(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_OES_vertex_array_object(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "OES_vertex_array_object"); #define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 @@ -155,7 +155,7 @@ WEBGL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES(GLuint array); #ifndef EMSCRIPTEN_GL_WEBGL_draw_buffers #define EMSCRIPTEN_GL_WEBGL_draw_buffers 1 // To enable: call -EM_BOOL emscripten_webgl_enable_WEBGL_draw_buffers(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_draw_buffers(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "WEBGL_draw_buffers"); #define GL_COLOR_ATTACHMENT0_WEBGL 0x8CE0 @@ -200,7 +200,7 @@ WEBGL_APICALL void GL_APIENTRY glDrawBuffersWEBGL(GLsizei n, const GLenum *buffe #ifndef EMSCRIPTEN_GL_ANGLE_instanced_arrays #define EMSCRIPTEN_GL_ANGLE_instanced_arrays 1 // To enable: call -EM_BOOL emscripten_webgl_enable_ANGLE_instanced_arrays(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_ANGLE_instanced_arrays(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "ANGLE_instanced_arrays"); #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE @@ -412,7 +412,7 @@ WEBGL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT(GLuint id, GLenum pname, #ifndef EMSCRIPTEN_GL_WEBGL_multi_draw #define EMSCRIPTEN_GL_WEBGL_multi_draw 1 // To enable: call -EM_BOOL emscripten_webgl_enable_WEBGL_multi_draw(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_multi_draw(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "WEBGL_multi_draw"); WEBGL_APICALL void GL_APIENTRY emscripten_glMultiDrawArraysWEBGL(GLenum mode, @@ -493,7 +493,7 @@ WEBGL_APICALL void GL_APIENTRY glMultiDrawElementsInstancedWEBGL(GLenum mode, #ifndef EMSCRIPTEN_GL_EXT_polygon_offset_clamp #define EMSCRIPTEN_GL_EXT_polygon_offset_clamp 1 // To enable: call -EM_BOOL emscripten_webgl_enable_EXT_polygon_offset_clamp(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_EXT_polygon_offset_clamp(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "EXT_polygon_offset_clamp"); #define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B @@ -505,7 +505,7 @@ WEBGL_APICALL void GL_APIENTRY glPolygonOffsetClampEXT(GLfloat factor, GLfloat u #ifndef EMSCRIPTEN_GL_EXT_clip_control #define EMSCRIPTEN_GL_EXT_clip_control 1 // To enable: call -EM_BOOL emscripten_webgl_enable_EXT_clip_control(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_EXT_clip_control(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "EXT_clip_control"); #define GL_LOWER_LEFT_EXT 0x8CA1 @@ -530,7 +530,7 @@ WEBGL_APICALL void GL_APIENTRY glClipControlEXT(GLenum origin, GLenum depth); #ifndef EMSCRIPTEN_GL_WEBGL_polygon_mode #define EMSCRIPTEN_GL_WEBGL_polygon_mode 1 // To enable: call -EM_BOOL emscripten_webgl_enable_WEBGL_polygon_mode(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); +bool emscripten_webgl_enable_WEBGL_polygon_mode(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); // or link with -sGL_SUPPORT_SIMPLE_ENABLE_EXTENSIONS=1 and // call emscripten_webgl_enable_extension(ctx, "WEBGL_polygon_mode"); #define GL_POLYGON_MODE_WEBGL 0x0B40 diff --git a/system/lib/gl/webgl1.c b/system/lib/gl/webgl1.c index 5368d57a7638..a2abde8b9f6b 100644 --- a/system/lib/gl/webgl1.c +++ b/system/lib/gl/webgl1.c @@ -77,7 +77,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_create_context(const char *targ if (attributes->proxyContextToMainThread == EMSCRIPTEN_WEBGL_CONTEXT_PROXY_ALWAYS || (attributes->proxyContextToMainThread == EMSCRIPTEN_WEBGL_CONTEXT_PROXY_FALLBACK && !emscripten_supports_offscreencanvas())) { EmscriptenWebGLContextAttributes attrs = *attributes; - attrs.renderViaOffscreenBackBuffer = EM_TRUE; + attrs.renderViaOffscreenBackBuffer = true; return (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emscripten_sync_run_in_main_runtime_thread_ptr(EM_FUNC_SIG_PPP, &emscripten_webgl_do_create_context, target, &attrs); } else { return emscripten_webgl_do_create_context(target, attributes); diff --git a/system/lib/gl/webgl_internal.h b/system/lib/gl/webgl_internal.h index 8e25acc9790e..533845239911 100644 --- a/system/lib/gl/webgl_internal.h +++ b/system/lib/gl/webgl_internal.h @@ -10,7 +10,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_do_get_current_context(void); EMSCRIPTEN_WEBGL_CONTEXT_HANDLE emscripten_webgl_do_create_context(const char *target, const EmscriptenWebGLContextAttributes *attributes); EMSCRIPTEN_RESULT emscripten_webgl_make_context_current_calling_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); EMSCRIPTEN_RESULT emscripten_webgl_do_commit_frame(void); -EM_BOOL emscripten_supports_offscreencanvas(void); +bool emscripten_supports_offscreencanvas(void); void _emscripten_proxied_gl_context_activated_from_main_browser_thread(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context); #if defined(__EMSCRIPTEN_PTHREADS__) && defined(__EMSCRIPTEN_OFFSCREEN_FRAMEBUFFER__) diff --git a/system/lib/html5/callback.c b/system/lib/html5/callback.c index 1bec1ea78347..4d426feb55a9 100644 --- a/system/lib/html5/callback.c +++ b/system/lib/html5/callback.c @@ -9,7 +9,7 @@ #include "emscripten_internal.h" -typedef EM_BOOL (*event_callback)(int event_type, void *event_data __attribute__((nonnull)), void *user_data); +typedef bool (*event_callback)(int event_type, void *event_data __attribute__((nonnull)), void *user_data); typedef struct callback_args_t { event_callback callback; diff --git a/system/lib/wasm_worker/library_wasm_worker.c b/system/lib/wasm_worker/library_wasm_worker.c index e61c6fc0831a..360bceb051f6 100644 --- a/system/lib/wasm_worker/library_wasm_worker.c +++ b/system/lib/wasm_worker/library_wasm_worker.c @@ -85,19 +85,19 @@ void emscripten_lock_init(emscripten_lock_t *lock) emscripten_atomic_store_u32((void*)lock, EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER); } -EM_BOOL emscripten_lock_wait_acquire(emscripten_lock_t *lock, int64_t maxWaitNanoseconds) +bool emscripten_lock_wait_acquire(emscripten_lock_t *lock, int64_t maxWaitNanoseconds) { emscripten_lock_t val = emscripten_atomic_cas_u32((void*)lock, 0, 1); - if (!val) return EM_TRUE; + if (!val) return true; int64_t waitEnd = (int64_t)(emscripten_performance_now() * 1e6) + maxWaitNanoseconds; while(maxWaitNanoseconds > 0) { emscripten_atomic_wait_u32((int32_t*)lock, val, maxWaitNanoseconds); val = emscripten_atomic_cas_u32((void*)lock, 0, 1); - if (!val) return EM_TRUE; + if (!val) return true; maxWaitNanoseconds = waitEnd - (int64_t)(emscripten_performance_now() * 1e6); } - return EM_FALSE; + return false; } void emscripten_lock_waitinf_acquire(emscripten_lock_t *lock) @@ -111,20 +111,20 @@ void emscripten_lock_waitinf_acquire(emscripten_lock_t *lock) } while(val); } -EM_BOOL emscripten_lock_busyspin_wait_acquire(emscripten_lock_t *lock, double maxWaitMilliseconds) +bool emscripten_lock_busyspin_wait_acquire(emscripten_lock_t *lock, double maxWaitMilliseconds) { emscripten_lock_t val = emscripten_atomic_cas_u32((void*)lock, 0, 1); - if (!val) return EM_TRUE; + if (!val) return true; double t = emscripten_performance_now(); double waitEnd = t + maxWaitMilliseconds; while(t < waitEnd) { val = emscripten_atomic_cas_u32((void*)lock, 0, 1); - if (!val) return EM_TRUE; + if (!val) return true; t = emscripten_performance_now(); } - return EM_FALSE; + return false; } void emscripten_lock_busyspin_waitinf_acquire(emscripten_lock_t *lock) @@ -136,7 +136,7 @@ void emscripten_lock_busyspin_waitinf_acquire(emscripten_lock_t *lock) } while(val); } -EM_BOOL emscripten_lock_try_acquire(emscripten_lock_t *lock) +bool emscripten_lock_try_acquire(emscripten_lock_t *lock) { emscripten_lock_t val = emscripten_atomic_cas_u32((void*)lock, 0, 1); return !val; @@ -219,13 +219,13 @@ void emscripten_condvar_waitinf(emscripten_condvar_t *condvar, emscripten_lock_t emscripten_lock_waitinf_acquire(lock); } -EM_BOOL emscripten_condvar_wait(emscripten_condvar_t *condvar, emscripten_lock_t *lock, int64_t maxWaitNanoseconds) +bool emscripten_condvar_wait(emscripten_condvar_t *condvar, emscripten_lock_t *lock, int64_t maxWaitNanoseconds) { int val = emscripten_atomic_load_u32((void*)condvar); emscripten_lock_release(lock); int waitValue = emscripten_atomic_wait_u32((int32_t*)condvar, val, maxWaitNanoseconds); if (waitValue == ATOMICS_WAIT_TIMED_OUT) - return EM_FALSE; + return false; return emscripten_lock_wait_acquire(lock, maxWaitNanoseconds); } diff --git a/system/lib/wasm_worker/library_wasm_worker_stub.c b/system/lib/wasm_worker/library_wasm_worker_stub.c index 27693fec493e..cf062300baaa 100644 --- a/system/lib/wasm_worker/library_wasm_worker_stub.c +++ b/system/lib/wasm_worker/library_wasm_worker_stub.c @@ -22,22 +22,22 @@ void emscripten_wasm_worker_sleep(int64_t nsecs) { void emscripten_lock_init(emscripten_lock_t *lock) { } -EM_BOOL emscripten_lock_wait_acquire(emscripten_lock_t *lock, int64_t maxWaitNanoseconds) { - return EM_TRUE; +bool emscripten_lock_wait_acquire(emscripten_lock_t *lock, int64_t maxWaitNanoseconds) { + return true; } void emscripten_lock_waitinf_acquire(emscripten_lock_t *lock) { } -EM_BOOL emscripten_lock_busyspin_wait_acquire(emscripten_lock_t *lock, double maxWaitMilliseconds) { - return EM_TRUE; +bool emscripten_lock_busyspin_wait_acquire(emscripten_lock_t *lock, double maxWaitMilliseconds) { + return true; } void emscripten_lock_busyspin_waitinf_acquire(emscripten_lock_t *lock) { } -EM_BOOL emscripten_lock_try_acquire(emscripten_lock_t *lock) { - return EM_TRUE; +bool emscripten_lock_try_acquire(emscripten_lock_t *lock) { + return true; } void emscripten_lock_release(emscripten_lock_t *lock) { @@ -72,8 +72,8 @@ void emscripten_condvar_init(emscripten_condvar_t *condvar) { void emscripten_condvar_waitinf(emscripten_condvar_t *condvar, emscripten_lock_t *lock) { } -EM_BOOL emscripten_condvar_wait(emscripten_condvar_t *condvar, emscripten_lock_t *lock, int64_t maxWaitNanoseconds) { - return EM_TRUE; +bool emscripten_condvar_wait(emscripten_condvar_t *condvar, emscripten_lock_t *lock, int64_t maxWaitNanoseconds) { + return true; } ATOMICS_WAIT_TOKEN_T emscripten_condvar_wait_async(emscripten_condvar_t *condvar, diff --git a/system/lib/websocket/websocket_to_posix_socket.c b/system/lib/websocket/websocket_to_posix_socket.c index a7ff7b061f4b..589ca6169693 100644 --- a/system/lib/websocket/websocket_to_posix_socket.c +++ b/system/lib/websocket/websocket_to_posix_socket.c @@ -153,13 +153,13 @@ static void wait_for_call_result(PosixSocketCallResult *b) { #endif } -static EM_BOOL +static bool bridge_socket_on_message(int eventType, const EmscriptenWebSocketMessageEvent* websocketEvent, void* userData) { if (websocketEvent->numBytes < sizeof(SocketCallResultHeader)) { emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK, "Received corrupt WebSocket result message with size %d, not enough space for header, at least %d bytes!\n", (int)websocketEvent->numBytes, (int)sizeof(SocketCallResultHeader)); - return EM_TRUE; + return true; } SocketCallResultHeader *header = (SocketCallResultHeader *)websocketEvent->data; @@ -172,13 +172,13 @@ bridge_socket_on_message(int eventType, if (!b) { emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK, "Received WebSocket result message to unknown call ID %d!\n", (int)header->callId); // TODO: Craft a socket result that signifies a failure, and wake the listening thread - return EM_TRUE; + return true; } if (websocketEvent->numBytes < b->bytes) { emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK, "Received corrupt WebSocket result message with size %d, expected at least %d bytes!\n", (int)websocketEvent->numBytes, b->bytes); // TODO: Craft a socket result that signifies a failure, and wake the listening thread - return EM_TRUE; + return true; } b->bytes = websocketEvent->numBytes; @@ -186,7 +186,7 @@ bridge_socket_on_message(int eventType, if (!b->data) { emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK, "Out of memory, tried to allocate %d bytes!\n", websocketEvent->numBytes); - return EM_TRUE; + return true; } if (b->operationCompleted != 0) { @@ -196,7 +196,7 @@ bridge_socket_on_message(int eventType, b->operationCompleted = 1; emscripten_futex_wake(&b->operationCompleted, INT_MAX); - return EM_TRUE; + return true; } EMSCRIPTEN_WEBSOCKET_T emscripten_init_websocket_to_posix_socket_bridge(const char *bridgeUrl) { diff --git a/test/atomic/test_wait32_notify.c b/test/atomic/test_wait32_notify.c index e471fcdd557d..52840c17621e 100644 --- a/test/atomic/test_wait32_notify.c +++ b/test/atomic/test_wait32_notify.c @@ -64,7 +64,7 @@ void* thread_main(void* arg) { #endif -EM_BOOL main_loop(double time, void *userData) { +bool main_loop(double time, void *userData) { if (addr == 3) { // Burn one second to make sure worker finishes its test. emscripten_out("main: seen worker running"); @@ -79,9 +79,9 @@ EM_BOOL main_loop(double time, void *userData) { pthread_join(t, NULL); #endif - return EM_FALSE; + return false; } - return EM_TRUE; + return true; } int main() { diff --git a/test/atomic/test_wait64_notify.c b/test/atomic/test_wait64_notify.c index d6b93cfc5aa1..9a885cf3a48f 100644 --- a/test/atomic/test_wait64_notify.c +++ b/test/atomic/test_wait64_notify.c @@ -65,7 +65,7 @@ void* thread_main(void* arg) { #endif -EM_BOOL main_loop(double time, void *userData) { +bool main_loop(double time, void *userData) { if (addr == 0x300000000ull) { // Burn one second to make sure worker finishes its test. emscripten_out("main: seen worker running"); @@ -80,9 +80,9 @@ EM_BOOL main_loop(double time, void *userData) { pthread_join(t, NULL); #endif - return EM_FALSE; + return false; } - return EM_TRUE; + return true; } int main() { diff --git a/test/browser/async_iostream.cpp b/test/browser/async_iostream.cpp index 054bb0557b80..2e6c263a0e34 100644 --- a/test/browser/async_iostream.cpp +++ b/test/browser/async_iostream.cpp @@ -12,7 +12,7 @@ using namespace std; int seen = 0; -EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void* userData) { +bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void* userData) { cout << "mouse_callback+" << endl; seen++; return 0; diff --git a/test/browser/test_keydown_preventdefault_proxy.c b/test/browser/test_keydown_preventdefault_proxy.c index 86a81e062b9f..00efc4d34ed6 100644 --- a/test/browser/test_keydown_preventdefault_proxy.c +++ b/test/browser/test_keydown_preventdefault_proxy.c @@ -19,7 +19,7 @@ static int result = 1; // Therefore where we expect the keypress callback to be prevented for '\b' // but not for 'A'. -EM_BOOL keydown_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keydown_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { printf("got keydown: %d\n", e->keyCode); if ((e->keyCode == 'A') || (e->keyCode == '\b')) { result *= 2; @@ -30,7 +30,7 @@ EM_BOOL keydown_callback(int eventType, const EmscriptenKeyboardEvent *e, void * return 0; } -EM_BOOL keypress_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keypress_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { printf("got keypress: %d\n", e->keyCode); // preventDefault should have been set for the backspace key so we should // never get that here. @@ -39,7 +39,7 @@ EM_BOOL keypress_callback(int eventType, const EmscriptenKeyboardEvent *e, void return 0; } -EM_BOOL keyup_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keyup_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { printf("got keyup: %d\n", e->keyCode); if ((e->keyCode == 'A') || (e->keyCode == '\b')) { result *= 5; diff --git a/test/browser/test_sdl_togglefullscreen.c b/test/browser/test_sdl_togglefullscreen.c index 3b3edae224b5..935fabe64ed7 100644 --- a/test/browser/test_sdl_togglefullscreen.c +++ b/test/browser/test_sdl_togglefullscreen.c @@ -32,7 +32,7 @@ static void fail(const char *msg) { emscripten_force_exit(1); } -static EM_BOOL mouseup(int eventType, +static bool mouseup(int eventType, const EmscriptenMouseEvent *keyEvent, void *userData) { if (eventType == EMSCRIPTEN_EVENT_MOUSEUP) { switch (state) { diff --git a/test/browser/test_webgl_no_auto_init_extensions.c b/test/browser/test_webgl_no_auto_init_extensions.c index 4e497a5821b3..6e1b8db10b86 100644 --- a/test/browser/test_webgl_no_auto_init_extensions.c +++ b/test/browser/test_webgl_no_auto_init_extensions.c @@ -15,7 +15,7 @@ int main() EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); emscripten_webgl_make_context_current(ctx); - EM_BOOL hasVaos = emscripten_webgl_enable_extension(ctx, "OES_vertex_array_object"); + bool hasVaos = emscripten_webgl_enable_extension(ctx, "OES_vertex_array_object"); if (hasVaos) { GLuint vao = 0; diff --git a/test/browser/webgl_create_context.cpp b/test/browser/webgl_create_context.cpp index 8d7a6278c050..02ddcf97d8c7 100644 --- a/test/browser/webgl_create_context.cpp +++ b/test/browser/webgl_create_context.cpp @@ -114,7 +114,7 @@ int main() { std::vector exts = split(extensions, ' '); for(size_t i = 0; i < exts.size(); ++i) { - EM_BOOL supported = emscripten_webgl_enable_extension(context, exts[i].c_str()); + bool supported = emscripten_webgl_enable_extension(context, exts[i].c_str()); printf("%s\n", exts[i].c_str()); assert(supported); } diff --git a/test/browser/webgl_destroy_context.cpp b/test/browser/webgl_destroy_context.cpp index cee7e1b11afe..e9e4eab3008f 100644 --- a/test/browser/webgl_destroy_context.cpp +++ b/test/browser/webgl_destroy_context.cpp @@ -21,13 +21,13 @@ void finish(void*) { report_result(0); } -EM_BOOL context_lost(int eventType, const void *reserved, void *userData) { +bool context_lost(int eventType, const void *reserved, void *userData) { printf("C code received a signal for WebGL context lost! This should not happen!\n"); report_result(1); return 0; } -EM_BOOL context_restored(int eventType, const void *reserved, void *userData) { +bool context_restored(int eventType, const void *reserved, void *userData) { printf("C code received a signal for WebGL context restored! This should not happen!\n"); report_result(1); return 0; diff --git a/test/browser/webgl_parallel_shader_compile.cpp b/test/browser/webgl_parallel_shader_compile.cpp index 629056bbe51c..4a0a78f1acb6 100644 --- a/test/browser/webgl_parallel_shader_compile.cpp +++ b/test/browser/webgl_parallel_shader_compile.cpp @@ -50,7 +50,7 @@ std::vector > pendingLinks; int parallel_shader_compile_is_working = 0; -EM_BOOL tick(double, void*) +bool tick(double, void*) { for(size_t i = 0; i < pendingLinks.size(); ++i) { @@ -77,7 +77,7 @@ EM_BOOL tick(double, void*) } ++numRafFramesElapsed; - return EM_TRUE; + return true; } int main() @@ -88,7 +88,7 @@ int main() EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); emscripten_webgl_make_context_current(ctx); - EM_BOOL supported = emscripten_webgl_enable_extension(ctx, "KHR_parallel_shader_compile"); + bool supported = emscripten_webgl_enable_extension(ctx, "KHR_parallel_shader_compile"); if (!supported) { printf("Skipping test, KHR_parallel_shader_compile WebGL extension is not supported.\n"); diff --git a/test/browser/webgl_unmasked_vendor_webgl.c b/test/browser/webgl_unmasked_vendor_webgl.c index aa17f5b187ab..605f1d6d614e 100644 --- a/test/browser/webgl_unmasked_vendor_webgl.c +++ b/test/browser/webgl_unmasked_vendor_webgl.c @@ -21,7 +21,7 @@ int main() assert(glGetError()); assert(!glGetError()); // One error is enough - EM_BOOL success = emscripten_webgl_enable_extension(ctx, "WEBGL_debug_renderer_info"); + bool success = emscripten_webgl_enable_extension(ctx, "WEBGL_debug_renderer_info"); if (!success) { // Browser does not have WEBGL_debug_renderer_info, skip remainder and return success. diff --git a/test/canvas_animate_resize.c b/test/canvas_animate_resize.c index 844d9b8b0628..d502360391c4 100644 --- a/test/canvas_animate_resize.c +++ b/test/canvas_animate_resize.c @@ -119,7 +119,7 @@ int main() EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); #if TEST_EXPLICIT_CONTEXT_SWAP - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; #endif ctx = emscripten_webgl_create_context("#canvas", &attr); printf("Created context with handle %#lx\n", ctx); diff --git a/test/canvas_focus.c b/test/canvas_focus.c index e45d17bb8d69..178ee65d0f69 100644 --- a/test/canvas_focus.c +++ b/test/canvas_focus.c @@ -11,7 +11,7 @@ #include #include -EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { static int i = 0; printf("key_callback %d\n", i); i++; diff --git a/test/emscripten_hide_mouse.c b/test/emscripten_hide_mouse.c index 349a3bbd72e1..70db3f50d306 100644 --- a/test/emscripten_hide_mouse.c +++ b/test/emscripten_hide_mouse.c @@ -3,7 +3,7 @@ #include #include -EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { +bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { printf("Mouse click on canvas.\n"); emscripten_force_exit(0); return 0; diff --git a/test/emscripten_request_animation_frame.c b/test/emscripten_request_animation_frame.c index 89204449a7d3..7e2b4fb10386 100644 --- a/test/emscripten_request_animation_frame.c +++ b/test/emscripten_request_animation_frame.c @@ -4,9 +4,9 @@ int func1Executed = 0; int func2Executed = 0; -EM_BOOL func1(double time, void *userData); +bool func1(double time, void *userData); -EM_BOOL func2(double time, void *userData) { +bool func2(double time, void *userData) { assert((long)userData == 2); assert(time > 0); ++func2Executed; @@ -24,7 +24,7 @@ EM_BOOL func2(double time, void *userData) { return 0; } -EM_BOOL func1(double time, void *userData) { +bool func1(double time, void *userData) { assert((long)userData == 1); assert(time > 0); ++func1Executed; diff --git a/test/emscripten_request_animation_frame_loop.c b/test/emscripten_request_animation_frame_loop.c index cf1b0f848229..51dea5bf3ad5 100644 --- a/test/emscripten_request_animation_frame_loop.c +++ b/test/emscripten_request_animation_frame_loop.c @@ -11,7 +11,7 @@ void testDone(void *userData) { exit(0); } -EM_BOOL tick(double time, void *userData) { +bool tick(double time, void *userData) { assert(time > previousRafTime); previousRafTime = time; assert((long)userData == 1); diff --git a/test/emscripten_set_immediate_loop.c b/test/emscripten_set_immediate_loop.c index 5f27e0e6eb4e..a4248b16ee68 100644 --- a/test/emscripten_set_immediate_loop.c +++ b/test/emscripten_set_immediate_loop.c @@ -10,7 +10,7 @@ void testDone(void *userData) { exit(0); } -EM_BOOL tick(void *userData) { +bool tick(void *userData) { assert((long)userData == 1); ++funcExecuted; if (funcExecuted == 10) { diff --git a/test/emscripten_set_timeout_loop.c b/test/emscripten_set_timeout_loop.c index 0ce1837a1740..1ddf79c21ecd 100644 --- a/test/emscripten_set_timeout_loop.c +++ b/test/emscripten_set_timeout_loop.c @@ -13,7 +13,7 @@ void testDone(void *userData) { exit(0); } -EM_BOOL tick(double time, void *userData) { +bool tick(double time, void *userData) { assert(time >= previousSetTimeouTime); previousSetTimeouTime = time; assert((long)userData == 1); diff --git a/test/fetch/test_fetch_persist.c b/test/fetch/test_fetch_persist.c index cc3e465d09f3..7f3510d685e5 100644 --- a/test/fetch/test_fetch_persist.c +++ b/test/fetch/test_fetch_persist.c @@ -5,6 +5,7 @@ #include #include +#include #include void downloadSucceeded(emscripten_fetch_t *fetch) { diff --git a/test/fetch/test_fetch_progress.c b/test/fetch/test_fetch_progress.c index cc537366c265..666739cdb0f8 100644 --- a/test/fetch/test_fetch_progress.c +++ b/test/fetch/test_fetch_progress.c @@ -5,6 +5,7 @@ #include #include +#include #include void downloadSucceeded(emscripten_fetch_t *fetch) { diff --git a/test/fetch/test_fetch_stream_async.c b/test/fetch/test_fetch_stream_async.c index 7029c73fa285..500623337cfc 100644 --- a/test/fetch/test_fetch_stream_async.c +++ b/test/fetch/test_fetch_stream_async.c @@ -5,6 +5,7 @@ #include #include +#include #include void downloadSucceeded(emscripten_fetch_t *fetch) { diff --git a/test/fetch/test_fetch_xhr_abort.cpp b/test/fetch/test_fetch_xhr_abort.cpp index 91ba06153d84..d8682dc2b041 100644 --- a/test/fetch/test_fetch_xhr_abort.cpp +++ b/test/fetch/test_fetch_xhr_abort.cpp @@ -7,6 +7,7 @@ #include #include #include +#include void handleSuccess(emscripten_fetch_t *fetch) { assert(false && "Should not succeed"); diff --git a/test/gl_in_mainthread_after_pthread.cpp b/test/gl_in_mainthread_after_pthread.cpp index 529a8d0b592b..6105a40d983e 100644 --- a/test/gl_in_mainthread_after_pthread.cpp +++ b/test/gl_in_mainthread_after_pthread.cpp @@ -25,7 +25,7 @@ void *ThreadMain(void *arg) printf("Thread started. You should see the WebGL canvas fade from black to red.\n"); EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; ctx = emscripten_webgl_create_context("#canvas", &attr); emscripten_webgl_make_context_current(ctx); @@ -100,7 +100,7 @@ void PollThreadExit(void *) EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); #ifdef TEST_MAIN_THREAD_EXPLICIT_COMMIT - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; #endif ctx = emscripten_webgl_create_context("#canvas", &attr); emscripten_webgl_make_context_current(ctx); diff --git a/test/gl_in_pthread.cpp b/test/gl_in_pthread.cpp index 0387277c0ab4..3afad652668c 100644 --- a/test/gl_in_pthread.cpp +++ b/test/gl_in_pthread.cpp @@ -34,7 +34,7 @@ void *ThreadMain(void *arg) } EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; ctx = emscripten_webgl_create_context("#canvas", &attr); emscripten_webgl_make_context_current(ctx); diff --git a/test/gl_in_two_pthreads.cpp b/test/gl_in_two_pthreads.cpp index cb9ae44ffcbf..311e16def00f 100644 --- a/test/gl_in_two_pthreads.cpp +++ b/test/gl_in_two_pthreads.cpp @@ -31,7 +31,7 @@ void *thread_main(void *param) { EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); assert(ctx); @@ -74,7 +74,7 @@ int main() // Create a context EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); assert(ctx); diff --git a/test/gl_only_in_pthread.cpp b/test/gl_only_in_pthread.cpp index 1669840612a3..fa9470591743 100644 --- a/test/gl_only_in_pthread.cpp +++ b/test/gl_only_in_pthread.cpp @@ -26,7 +26,7 @@ void *ThreadMain(void *arg) printf("Thread started. You should see the WebGL canvas fade from black to red.\n"); EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; ctx = emscripten_webgl_create_context("#canvas", &attr); emscripten_webgl_make_context_current(ctx); diff --git a/test/html5_callbacks_on_calling_thread.c b/test/html5_callbacks_on_calling_thread.c index 07308ce2d439..602a8da576f6 100644 --- a/test/html5_callbacks_on_calling_thread.c +++ b/test/html5_callbacks_on_calling_thread.c @@ -12,7 +12,7 @@ void *mainRuntimeThreadId = 0; void *registeringThreadId = 0; -EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { +bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { static int once; void *threadId = pthread_self(); diff --git a/test/html5_event_callback_in_two_threads.c b/test/html5_event_callback_in_two_threads.c index 531a27da68c4..35f575a6e00c 100644 --- a/test/html5_event_callback_in_two_threads.c +++ b/test/html5_event_callback_in_two_threads.c @@ -15,7 +15,7 @@ _Atomic int saw_keydown_event_on_enter_key_on_application_thread = 0; _Atomic int saw_keydown_event_on_enter_key_on_main_runtime_thread = 0; _Atomic int saw_keypress_event_on_enter_key = 0; -EM_BOOL keydown_callback_on_application_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keydown_callback_on_application_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { int dom_pk_code = emscripten_compute_dom_pk_code(e->code); printf("keydown_callback_on_application_thread received on pthread: %p, application_thread_id: %p, dom_pk_code: %s\n", pthread_self(), application_thread_id, emscripten_dom_pk_code_to_string(dom_pk_code)); assert(pthread_self() == application_thread_id); @@ -26,7 +26,7 @@ EM_BOOL keydown_callback_on_application_thread(int eventType, const EmscriptenKe return 0; } -EM_BOOL keydown_callback_on_main_runtime_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keydown_callback_on_main_runtime_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { int dom_pk_code = emscripten_compute_dom_pk_code(e->code); printf("keydown_callback_on_main_runtime_thread received on pthread: %p, main_runtime_thread_id; %p, dom_pk_code: %s\n", pthread_self(), main_runtime_thread_id, emscripten_dom_pk_code_to_string(dom_pk_code)); assert(pthread_self() == main_runtime_thread_id); @@ -48,7 +48,7 @@ EM_BOOL keydown_callback_on_main_runtime_thread(int eventType, const EmscriptenK return dom_pk_code == DOM_PK_ENTER; } -EM_BOOL keypress_callback_on_application_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keypress_callback_on_application_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { int dom_pk_code = emscripten_compute_dom_pk_code(e->code); printf("keypress_callback_on_application_thread received on pthread: %p, application_thread_id; %p, dom_pk_code: %s\n", pthread_self(), application_thread_id, emscripten_dom_pk_code_to_string(dom_pk_code)); assert(pthread_self() == application_thread_id); @@ -61,7 +61,7 @@ EM_BOOL keypress_callback_on_application_thread(int eventType, const EmscriptenK return 0; } -EM_BOOL keyup_callback_on_application_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool keyup_callback_on_application_thread(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { int dom_pk_code = emscripten_compute_dom_pk_code(e->code); printf("keyup_callback_on_application_thread received on pthread: %p, application_thread_id; %p, dom_pk_code: %s\n", pthread_self(), application_thread_id, emscripten_dom_pk_code_to_string(dom_pk_code)); assert(pthread_self() == application_thread_id); diff --git a/test/html5_webgl.c b/test/html5_webgl.c index 07d7757d9e0d..24dbeeec19fa 100644 --- a/test/html5_webgl.c +++ b/test/html5_webgl.c @@ -28,7 +28,7 @@ int main() { emscripten_webgl_init_context_attributes(&attrs); attrs.majorVersion = 2; attrs.proxyContextToMainThread = EMSCRIPTEN_WEBGL_CONTEXT_PROXY_FALLBACK; - attrs.renderViaOffscreenBackBuffer = EM_TRUE; + attrs.renderViaOffscreenBackBuffer = true; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("#canvas", &attrs); emscripten_webgl_make_context_current(context); diff --git a/test/interactive/test_glfw_cursor_disabled.c b/test/interactive/test_glfw_cursor_disabled.c index 23c7b5db6101..46a7cedcccb4 100644 --- a/test/interactive/test_glfw_cursor_disabled.c +++ b/test/interactive/test_glfw_cursor_disabled.c @@ -49,7 +49,7 @@ void render() { #ifdef __EMSCRIPTEN__ -EM_BOOL on_pointerlockchange(int eventType, const EmscriptenPointerlockChangeEvent *event, void *userData) { +bool on_pointerlockchange(int eventType, const EmscriptenPointerlockChangeEvent *event, void *userData) { printf("pointerlockchange, isActive=%d\n", event->isActive); pointerlock_isActive = event->isActive; return 0; diff --git a/test/interactive/test_glfw_get_key_stuck.c b/test/interactive/test_glfw_get_key_stuck.c index 87dd1aa87e90..878778fb324b 100644 --- a/test/interactive/test_glfw_get_key_stuck.c +++ b/test/interactive/test_glfw_get_key_stuck.c @@ -45,7 +45,7 @@ void render() { } #ifdef __EMSCRIPTEN__ -EM_BOOL on_focuspocus(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData) { +bool on_focuspocus(int eventType, const EmscriptenFocusEvent *focusEvent, void *userData) { switch(eventType) { case EMSCRIPTEN_EVENT_BLUR: printf("blur\n"); @@ -78,7 +78,7 @@ EM_BOOL on_focuspocus(int eventType, const EmscriptenFocusEvent *focusEvent, voi printf("focus event %d\n", eventType); break; } - return EM_FALSE; + return false; } #endif @@ -98,10 +98,10 @@ int main() { printf("%d. Press and hold spacebar\n", step); #ifdef __EMSCRIPTEN__ - emscripten_set_blur_callback(NULL, NULL, EM_TRUE, on_focuspocus); - emscripten_set_focus_callback(NULL, NULL, EM_TRUE, on_focuspocus); - emscripten_set_focusin_callback(NULL, NULL, EM_TRUE, on_focuspocus); - emscripten_set_focusout_callback(NULL, NULL, EM_TRUE, on_focuspocus); + emscripten_set_blur_callback(NULL, NULL, true, on_focuspocus); + emscripten_set_focus_callback(NULL, NULL, true, on_focuspocus); + emscripten_set_focusin_callback(NULL, NULL, true, on_focuspocus); + emscripten_set_focusout_callback(NULL, NULL, true, on_focuspocus); emscripten_set_main_loop(render, 0, 1); __builtin_trap(); diff --git a/test/minimal_webgl/main.c b/test/minimal_webgl/main.c index ecf0eaee1d77..a3f8ac05f78c 100644 --- a/test/minimal_webgl/main.c +++ b/test/minimal_webgl/main.c @@ -18,7 +18,7 @@ float mod_dist(float v, float t) return fminf(d, 6.f - d); } // Per-frame animation tick. -EM_BOOL draw_frame(double t, void *unused) +bool draw_frame(double t, void *unused) { static double prevT; double dt = t - prevT; @@ -57,13 +57,13 @@ EM_BOOL draw_frame(double t, void *unused) clamp01(2.f - mod_dist(c, 0.f)), clamp01(2.f - mod_dist(c, 2.f)), clamp01(2.f - mod_dist(c, 4.f)), - 1.f, text[i], 64.f, EM_TRUE); + 1.f, text[i], 64.f, true); } // snow foreground for(int i = NUM_FLAKES/2; i < NUM_FLAKES; ++i) SIM; - return EM_TRUE; + return true; } int main() diff --git a/test/minimal_webgl/webgl.c b/test/minimal_webgl/webgl.c index c5a638763e5d..a38346c41358 100644 --- a/test/minimal_webgl/webgl.c +++ b/test/minimal_webgl/webgl.c @@ -101,14 +101,14 @@ void init_webgl(int width, int height) typedef void (*tick_func)(double t, double dt); -static EM_BOOL tick(double time, void *userData) +static bool tick(double time, void *userData) { static double t0; double dt = time - t0; t0 = time; tick_func f = (tick_func)(userData); f(time, dt); - return EM_TRUE; + return true; } void clear_screen(float r, float g, float b, float a) diff --git a/test/other/test_contrib_ports.cpp b/test/other/test_contrib_ports.cpp index 946f9b492e14..e2825a653049 100644 --- a/test/other/test_contrib_ports.cpp +++ b/test/other/test_contrib_ports.cpp @@ -17,7 +17,7 @@ int main() { GLFWwindow* window = glfwCreateWindow(320, 200, "test_glfw3_port", 0, 0); assert(window != 0); // this call ensures that it uses the right port - assert(emscripten_glfw_is_window_fullscreen(window) == EM_FALSE); + assert(emscripten_glfw_is_window_fullscreen(window) == false); glfwTerminate(); diff --git a/test/other/test_embool.c b/test/other/test_embool.c new file mode 100644 index 000000000000..35cd10dce82f --- /dev/null +++ b/test/other/test_embool.c @@ -0,0 +1,8 @@ +#include +#include + +int main() { + EM_BOOL b = EM_TRUE; + printf("EM_TRUE:%d,EM_FALSE:%d\n", b, EM_FALSE); + return 0; +} diff --git a/test/other/test_embool.out b/test/other/test_embool.out new file mode 100644 index 000000000000..855cd15b93be --- /dev/null +++ b/test/other/test_embool.out @@ -0,0 +1 @@ +EM_TRUE:1,EM_FALSE:0 diff --git a/test/poppler/emscripten_html5.pdf b/test/poppler/emscripten_html5.pdf index b984f67fb809..cdb0478607a9 100644 Binary files a/test/poppler/emscripten_html5.pdf and b/test/poppler/emscripten_html5.pdf differ diff --git a/test/pthread/test_pthread_mutex.c b/test/pthread/test_pthread_mutex.c index 0c6a85b9a746..04ea5fce8c39 100644 --- a/test/pthread/test_pthread_mutex.c +++ b/test/pthread/test_pthread_mutex.c @@ -56,7 +56,7 @@ void CreateThread(int i, int n) { int threadNum = 0; -EM_BOOL WaitToJoin(double time, void *userData) { +bool WaitToJoin(double time, void *userData) { int threadsRunning = 0; // Join all threads. for (int i = 0; i < NUM_THREADS; ++i) { @@ -81,9 +81,9 @@ EM_BOOL WaitToJoin(double time, void *userData) { emscripten_errf("All threads finished, but counter = %d != %d!", counter, numThreadsToCreateTotal); assert(counter == 50); emscripten_force_exit(0); - return EM_FALSE; + return false; } - return EM_TRUE; + return true; } int main() { diff --git a/test/resize_offscreencanvas_from_main_thread.cpp b/test/resize_offscreencanvas_from_main_thread.cpp index 5b1d510149e2..dd9adc9b8b90 100644 --- a/test/resize_offscreencanvas_from_main_thread.cpp +++ b/test/resize_offscreencanvas_from_main_thread.cpp @@ -32,7 +32,7 @@ void thread_local_main_loop() { void *thread_main(void *arg) { EmscriptenWebGLContextAttributes attr; emscripten_webgl_init_context_attributes(&attr); - attr.explicitSwapControl = EM_TRUE; + attr.explicitSwapControl = true; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context("#canvas", &attr); assert(ctx); diff --git a/test/test_gamepad.c b/test/test_gamepad.c index 57b8ae09476f..42482cc30ba2 100644 --- a/test/test_gamepad.c +++ b/test/test_gamepad.c @@ -36,7 +36,7 @@ const char *emscripten_result_to_string(EMSCRIPTEN_RESULT result) { #define TEST_RESULT(x) if (ret != EMSCRIPTEN_RESULT_SUCCESS) printf("%s returned %s.\n", #x, emscripten_result_to_string(ret)); -EM_BOOL gamepad_callback(int eventType, const EmscriptenGamepadEvent *e, void *userData) { +bool gamepad_callback(int eventType, const EmscriptenGamepadEvent *e, void *userData) { 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); diff --git a/test/test_html5_core.c b/test/test_html5_core.c index 3d8e6f6bf4f7..7fbd87802b63 100644 --- a/test/test_html5_core.c +++ b/test/test_html5_core.c @@ -38,7 +38,7 @@ const char *emscripten_result_to_string(EMSCRIPTEN_RESULT result) { // The event handler functions can return 1 to suppress the event and disable the default action. That calls event.preventDefault(); // 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) { +bool key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { 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" : "", @@ -88,7 +88,7 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user return 0; } -EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { +bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { 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" : "", @@ -98,7 +98,7 @@ EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userD return 0; } -EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData) { +bool wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData) { 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" : "", @@ -109,7 +109,7 @@ EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userD return 0; } -EM_BOOL uievent_callback(int eventType, const EmscriptenUiEvent *e, void *userData) { +bool uievent_callback(int eventType, const EmscriptenUiEvent *e, void *userData) { 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); @@ -117,19 +117,19 @@ EM_BOOL uievent_callback(int eventType, const EmscriptenUiEvent *e, void *userDa return 0; } -EM_BOOL focusevent_callback(int eventType, const EmscriptenFocusEvent *e, void *userData) { +bool focusevent_callback(int eventType, const EmscriptenFocusEvent *e, void *userData) { printf("%s, nodeName: \"%s\", id: \"%s\"\n", emscripten_event_type_to_string(eventType), e->nodeName, e->id[0] == '\0' ? "(empty string)" : e->id); return 0; } -EM_BOOL deviceorientation_callback(int eventType, const EmscriptenDeviceOrientationEvent *e, void *userData) { +bool deviceorientation_callback(int eventType, const EmscriptenDeviceOrientationEvent *e, void *userData) { printf("%s, (%g, %g, %g)\n", emscripten_event_type_to_string(eventType), e->alpha, e->beta, e->gamma); return 0; } -EM_BOOL devicemotion_callback(int eventType, const EmscriptenDeviceMotionEvent *e, void *userData) { +bool devicemotion_callback(int eventType, const EmscriptenDeviceMotionEvent *e, void *userData) { printf("%s, accel: (%g, %g, %g), accelInclGravity: (%g, %g, %g), rotationRate: (%g, %g, %g), supportedFields: %s %s %s\n", emscripten_event_type_to_string(eventType), e->accelerationX, e->accelerationY, e->accelerationZ, @@ -142,33 +142,33 @@ EM_BOOL devicemotion_callback(int eventType, const EmscriptenDeviceMotionEvent * return 0; } -EM_BOOL orientationchange_callback(int eventType, const EmscriptenOrientationChangeEvent *e, void *userData) { +bool orientationchange_callback(int eventType, const EmscriptenOrientationChangeEvent *e, void *userData) { printf("%s, orientationAngle: %d, orientationIndex: %d\n", emscripten_event_type_to_string(eventType), e->orientationAngle, e->orientationIndex); return 0; } -EM_BOOL fullscreenchange_callback(int eventType, const EmscriptenFullscreenChangeEvent *e, void *userData) { +bool fullscreenchange_callback(int eventType, const EmscriptenFullscreenChangeEvent *e, void *userData) { printf("%s, isFullscreen: %d, fullscreenEnabled: %d, fs element nodeName: \"%s\", fs element id: \"%s\". New size: %dx%d pixels. Screen size: %dx%d pixels.\n", emscripten_event_type_to_string(eventType), e->isFullscreen, e->fullscreenEnabled, e->nodeName, e->id, e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight); return 0; } -EM_BOOL pointerlockchange_callback(int eventType, const EmscriptenPointerlockChangeEvent *e, void *userData) { +bool pointerlockchange_callback(int eventType, const EmscriptenPointerlockChangeEvent *e, void *userData) { printf("%s, isActive: %d, pointerlock element nodeName: \"%s\", id: \"%s\"\n", emscripten_event_type_to_string(eventType), e->isActive, e->nodeName, e->id); return 0; } -EM_BOOL visibilitychange_callback(int eventType, const EmscriptenVisibilityChangeEvent *e, void *userData) { +bool visibilitychange_callback(int eventType, const EmscriptenVisibilityChangeEvent *e, void *userData) { printf("%s, hidden: %d, visibilityState: %d\n", emscripten_event_type_to_string(eventType), e->hidden, e->visibilityState); return 0; } -EM_BOOL touch_callback(int eventType, const EmscriptenTouchEvent *e, void *userData) { +bool touch_callback(int eventType, const EmscriptenTouchEvent *e, void *userData) { printf("%s, numTouches: %d timestamp: %lf %s%s%s%s\n", emscripten_event_type_to_string(eventType), e->numTouches, e->timestamp, e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : ""); @@ -204,7 +204,7 @@ void formatTime(char *str, int seconds) { } } -EM_BOOL battery_callback(int eventType, const EmscriptenBatteryEvent *e, void *userData) { +bool battery_callback(int eventType, const EmscriptenBatteryEvent *e, void *userData) { char t1[64]; formatTime(t1, (int)e->chargingTime); char t2[64]; @@ -215,7 +215,7 @@ EM_BOOL battery_callback(int eventType, const EmscriptenBatteryEvent *e, void *u return 0; } -EM_BOOL webglcontext_callback(int eventType, const void *reserved, void *userData) { +bool webglcontext_callback(int eventType, const void *reserved, void *userData) { printf("%s.\n", emscripten_event_type_to_string(eventType)); return 0; diff --git a/test/test_html5_emscripten_exit_fullscreen.c b/test/test_html5_emscripten_exit_fullscreen.c index 44ca59027ae0..a416e526e63f 100644 --- a/test/test_html5_emscripten_exit_fullscreen.c +++ b/test/test_html5_emscripten_exit_fullscreen.c @@ -4,9 +4,9 @@ #include #include -EM_BOOL is_fs = EM_FALSE; +bool is_fs = false; -EM_BOOL fullscreen_change(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) { +bool fullscreen_change(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) { is_fs = fullscreenChangeEvent->isFullscreen; printf("%s fullscreen\n", is_fs ? "entered" : "left"); @@ -16,7 +16,7 @@ EM_BOOL fullscreen_change(int eventType, const EmscriptenFullscreenChangeEvent * static int resizes = 0; -EM_BOOL canvas_resize(int eventType, const void *reserved, void *userData) { +bool canvas_resize(int eventType, const void *reserved, void *userData) { double css_w, css_h; emscripten_get_element_css_size("#canvas", &css_w, &css_h); @@ -30,7 +30,7 @@ EM_BOOL canvas_resize(int eventType, const void *reserved, void *userData) { return 0; } -EM_BOOL key_down(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) { +bool key_down(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) { if (keyEvent->keyCode == 0x46/*f*/) { if (is_fs) { emscripten_exit_fullscreen(); diff --git a/test/test_html5_fullscreen.c b/test/test_html5_fullscreen.c index 3399ffd17f23..71abdb23ab5f 100644 --- a/test/test_html5_fullscreen.c +++ b/test/test_html5_fullscreen.c @@ -51,7 +51,7 @@ const char *emscripten_result_to_string(EMSCRIPTEN_RESULT result) { // The event handler functions can return 1 to suppress the event and disable the default action. That calls event.preventDefault(); // 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) +bool key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { if (eventType == EMSCRIPTEN_EVENT_KEYPRESS && (!strcmp(e->key, "f") || e->which == 102)) { EmscriptenFullscreenChangeEvent fsce; @@ -80,7 +80,7 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user int callCount = 0; -EM_BOOL fullscreenchange_callback(int eventType, const EmscriptenFullscreenChangeEvent *e, void *userData) { +bool fullscreenchange_callback(int eventType, const EmscriptenFullscreenChangeEvent *e, void *userData) { printf("%s, isFullscreen: %d, fullscreenEnabled: %d, fs element nodeName: \"%s\", fs element id: \"%s\". New size: %dx%d pixels. Screen size: %dx%d pixels.\n", emscripten_event_type_to_string(eventType), e->isFullscreen, e->fullscreenEnabled, e->nodeName, e->id, e->elementWidth, e->elementHeight, e->screenWidth, e->screenHeight); @@ -99,7 +99,7 @@ EM_BOOL fullscreenchange_callback(int eventType, const EmscriptenFullscreenChang return 0; } -EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { +bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { return 0; } @@ -118,7 +118,7 @@ void draw() { glDrawArrays(GL_TRIANGLES, 0, 3); } -EM_BOOL on_canvassize_changed(int eventType, const void *reserved, void *userData) { +bool on_canvassize_changed(int eventType, const void *reserved, void *userData) { int w, h; emscripten_get_canvas_element_size("#canvas", &w, &h); double cssW, cssH; diff --git a/test/test_html5_mouse.c b/test/test_html5_mouse.c index 3bc99c29840a..056e1dc6a64d 100644 --- a/test/test_html5_mouse.c +++ b/test/test_html5_mouse.c @@ -65,7 +65,7 @@ void instruction() { if (gotClick && gotMouseDown && gotMouseUp && gotDblClick && gotMouseMove && gotWheel) report_result(0); } -EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { +bool mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { 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" : "", @@ -89,7 +89,7 @@ EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userD return 0; } -EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData) { +bool wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData) { 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" : "", diff --git a/test/test_html5_pointerlockerror.c b/test/test_html5_pointerlockerror.c index 222c5684b702..e6c997d1f8b1 100644 --- a/test/test_html5_pointerlockerror.c +++ b/test/test_html5_pointerlockerror.c @@ -38,7 +38,7 @@ const char *emscripten_result_to_string(EMSCRIPTEN_RESULT result) { int gotClick = 0; -EM_BOOL click_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { +bool click_callback(int eventType, const EmscriptenMouseEvent *e, void *userData) { if (e->screenX != 0 && e->screenY != 0 && e->clientX != 0 && e->clientY != 0 && e->canvasX != 0 && e->canvasY != 0 && e->targetX != 0 && e->targetY != 0) { if (eventType == EMSCRIPTEN_EVENT_CLICK && !gotClick) { @@ -56,14 +56,14 @@ EM_BOOL click_callback(int eventType, const EmscriptenMouseEvent *e, void *userD return 0; } -EM_BOOL pointerlockchange_callback(int eventType, const EmscriptenPointerlockChangeEvent *e, void *userData) { +bool pointerlockchange_callback(int eventType, const EmscriptenPointerlockChangeEvent *e, void *userData) { printf("ERROR! received 'pointerlockchange' event\n"); report_result(1); return 0; } -EM_BOOL pointerlockerror_callback(int eventType, const void *reserved, void *userData) { +bool pointerlockerror_callback(int eventType, const void *reserved, void *userData) { if (eventType != EMSCRIPTEN_EVENT_POINTERLOCKERROR) { printf("ERROR! invalid event type for 'pointerlockerror' callback\n"); report_result(1); diff --git a/test/test_html5_unknown_event_target.c b/test/test_html5_unknown_event_target.c index 894d89c072b6..5bc318d72564 100644 --- a/test/test_html5_unknown_event_target.c +++ b/test/test_html5_unknown_event_target.c @@ -8,15 +8,15 @@ #include #include -EM_BOOL wheel_cb(int eventType, const EmscriptenWheelEvent *wheelEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } -EM_BOOL key_cb(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { return EM_TRUE; } -EM_BOOL mouse_cb(int eventType, const EmscriptenMouseEvent *mouseEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } -EM_BOOL ui_cb(int eventType, const EmscriptenUiEvent *uiEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } -EM_BOOL focus_cb(int eventType, const EmscriptenFocusEvent *focusEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } -EM_BOOL fullscreenchange_cb(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } -EM_BOOL pointerlockchange_cb(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } -EM_BOOL pointerlockerror_cb(int eventType, const void *reserved, void *userData) { return EM_TRUE; } -EM_BOOL touch_cb(int eventType, const EmscriptenTouchEvent *touchEvent __attribute__((nonnull)), void *userData) { return EM_TRUE; } +bool wheel_cb(int eventType, const EmscriptenWheelEvent *wheelEvent __attribute__((nonnull)), void *userData) { return true; } +bool key_cb(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { return true; } +bool mouse_cb(int eventType, const EmscriptenMouseEvent *mouseEvent __attribute__((nonnull)), void *userData) { return true; } +bool ui_cb(int eventType, const EmscriptenUiEvent *uiEvent __attribute__((nonnull)), void *userData) { return true; } +bool focus_cb(int eventType, const EmscriptenFocusEvent *focusEvent __attribute__((nonnull)), void *userData) { return true; } +bool fullscreenchange_cb(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent __attribute__((nonnull)), void *userData) { return true; } +bool pointerlockchange_cb(int eventType, const EmscriptenPointerlockChangeEvent *pointerlockChangeEvent __attribute__((nonnull)), void *userData) { return true; } +bool pointerlockerror_cb(int eventType, const void *reserved, void *userData) { return true; } +bool touch_cb(int eventType, const EmscriptenTouchEvent *touchEvent __attribute__((nonnull)), void *userData) { return true; } int main(int argc, char **argv) { diff --git a/test/test_keyboard_codes.c b/test/test_keyboard_codes.c index 98ecbe4cbd86..058933f23fc3 100644 --- a/test/test_keyboard_codes.c +++ b/test/test_keyboard_codes.c @@ -47,7 +47,7 @@ int emscripten_key_event_is_printable_character(const EmscriptenKeyboardEvent *k return number_of_characters_in_utf8_string(keyEvent->key) == 1; } -EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { +bool key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData) { int dom_pk_code = emscripten_compute_dom_pk_code(e->code); printf("%s, key: \"%s\" (printable: %s), code: \"%s\" = %s (%d), location: %lu,%s%s%s%s repeat: %d, locale: \"%s\", char: \"%s\", charCode: %lu (interpreted: %d), keyCode: %s(%lu), which: %lu\n", diff --git a/test/test_other.py b/test/test_other.py index 9111feb6d658..7680a736e649 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15160,3 +15160,6 @@ def test_fp16(self, opts): self.v8_args += ['--no-liftoff'] self.emcc_args = ['-msimd128', '-mfp16', '-sENVIRONMENT=shell'] + opts self.do_runf('test_fp16.c') + + def test_embool(self): + self.do_other_test('test_embool.c') diff --git a/test/third_party/sokol/emsc.h b/test/third_party/sokol/emsc.h index fd54b20342bd..dc0502578ea5 100644 --- a/test/third_party/sokol/emsc.h +++ b/test/third_party/sokol/emsc.h @@ -16,7 +16,7 @@ enum { }; /* track CSS element size changes and update the WebGL canvas size */ -static EM_BOOL _emsc_size_changed(int event_type, const EmscriptenUiEvent* ui_event, void* user_data) { +static bool _emsc_size_changed(int event_type, const EmscriptenUiEvent* ui_event, void* user_data) { (void)event_type; (void)ui_event; (void)user_data; diff --git a/test/wasm_worker/cancel_all_wait_asyncs.c b/test/wasm_worker/cancel_all_wait_asyncs.c index e7345cd27084..71d36a4de92f 100644 --- a/test/wasm_worker/cancel_all_wait_asyncs.c +++ b/test/wasm_worker/cancel_all_wait_asyncs.c @@ -7,7 +7,7 @@ volatile int32_t addr = 1; -EM_BOOL testSucceeded = 1; +bool testSucceeded = 1; void asyncWaitFinishedShouldNotBeCalled(int32_t *ptr, uint32_t val, ATOMICS_WAIT_RESULT_T waitResult, void *userData) { diff --git a/test/wasm_worker/cancel_all_wait_asyncs_at_address.c b/test/wasm_worker/cancel_all_wait_asyncs_at_address.c index 0f4bf7e51de7..b51f3b8a011f 100644 --- a/test/wasm_worker/cancel_all_wait_asyncs_at_address.c +++ b/test/wasm_worker/cancel_all_wait_asyncs_at_address.c @@ -7,7 +7,7 @@ volatile int32_t addr = 1; -EM_BOOL testSucceeded = 1; +bool testSucceeded = 1; void asyncWaitFinishedShouldNotBeCalled(int32_t *ptr, uint32_t val, ATOMICS_WAIT_RESULT_T waitResult, void *userData) { diff --git a/test/wasm_worker/cancel_wait_async.c b/test/wasm_worker/cancel_wait_async.c index 281d10b2fe85..e4f0d8f8223e 100644 --- a/test/wasm_worker/cancel_wait_async.c +++ b/test/wasm_worker/cancel_wait_async.c @@ -7,7 +7,7 @@ volatile int32_t addr = 1; -EM_BOOL testSucceeded = 1; +bool testSucceeded = 1; void asyncWaitFinishedShouldNotBeCalled(int32_t *ptr, uint32_t val, ATOMICS_WAIT_RESULT_T waitResult, void *userData) { diff --git a/test/wasm_worker/lock_async_acquire.c b/test/wasm_worker/lock_async_acquire.c index 6b8ab479f386..f27f52b26cff 100644 --- a/test/wasm_worker/lock_async_acquire.c +++ b/test/wasm_worker/lock_async_acquire.c @@ -12,7 +12,7 @@ emscripten_lock_t lock = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER; volatile int sharedState0 = 0; volatile int sharedState1 = 1; -EM_BOOL testFinished = EM_FALSE; +bool testFinished = false; int numTimesMainThreadAcquiredLock = 0; int numTimesWasmWorkerAcquiredLock = 0; @@ -52,7 +52,7 @@ void work() REPORT_RESULT(0); #endif } - testFinished = EM_TRUE; + testFinished = true; } } } diff --git a/test/wasm_worker/lock_busyspin_wait_acquire.c b/test/wasm_worker/lock_busyspin_wait_acquire.c index e91d50a71883..da33f68c66c8 100644 --- a/test/wasm_worker/lock_busyspin_wait_acquire.c +++ b/test/wasm_worker/lock_busyspin_wait_acquire.c @@ -10,8 +10,8 @@ emscripten_lock_t lock = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER; void test() { - EM_BOOL success = emscripten_lock_busyspin_wait_acquire(&lock, 0); // Expect no contention on free lock. - assert(success == EM_TRUE); + bool success = emscripten_lock_busyspin_wait_acquire(&lock, 0); // Expect no contention on free lock. + assert(success == true); double t0 = emscripten_performance_now(); success = emscripten_lock_busyspin_wait_acquire(&lock, 0); // We already have the lock, and emscripten_lock is not recursive, so this should fail. diff --git a/test/wasm_worker/lock_wait_acquire.c b/test/wasm_worker/lock_wait_acquire.c index 82b8363ca607..73527ee64688 100644 --- a/test/wasm_worker/lock_wait_acquire.c +++ b/test/wasm_worker/lock_wait_acquire.c @@ -10,8 +10,8 @@ emscripten_lock_t lock = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER; void worker_main() { - EM_BOOL success = emscripten_lock_wait_acquire(&lock, 0); // Expect no contention on free lock. - assert(success == EM_TRUE); + bool success = emscripten_lock_wait_acquire(&lock, 0); // Expect no contention on free lock. + assert(success == true); double t0 = emscripten_performance_now(); success = emscripten_lock_wait_acquire(&lock, 0); // We already have the lock, and emscripten_lock is not recursive, so this should fail. diff --git a/test/wasm_worker/lock_wait_acquire2.c b/test/wasm_worker/lock_wait_acquire2.c index 7d14f32216b1..13cd111f1ffd 100644 --- a/test/wasm_worker/lock_wait_acquire2.c +++ b/test/wasm_worker/lock_wait_acquire2.c @@ -11,7 +11,7 @@ emscripten_lock_t lock = EMSCRIPTEN_LOCK_T_STATIC_INITIALIZER; void worker1_main() { emscripten_console_log("worker1 main try_acquiring lock"); - EM_BOOL success = emscripten_lock_try_acquire(&lock); // Expect no contention on free lock. + bool success = emscripten_lock_try_acquire(&lock); // Expect no contention on free lock. emscripten_console_log("worker1 try_acquire lock finished"); assert(success); emscripten_console_log("worker1 try_acquire lock success, sleeping 1000 msecs"); @@ -27,7 +27,7 @@ void worker2_main() emscripten_console_log("worker2 main sleeping 500 msecs"); emscripten_wasm_worker_sleep(500 * 1000000ull); emscripten_console_log("worker2 slept 500 msecs, try_acquiring lock"); - EM_BOOL success = emscripten_lock_try_acquire(&lock); // At this time, the other thread should have the lock. + bool success = emscripten_lock_try_acquire(&lock); // At this time, the other thread should have the lock. emscripten_console_log("worker2 try_acquire lock finished"); assert(!success); diff --git a/test/webaudio/audio_worklet_tone_generator.c b/test/webaudio/audio_worklet_tone_generator.c index 437053cedf25..cfec0dc0ec87 100644 --- a/test/webaudio/audio_worklet_tone_generator.c +++ b/test/webaudio/audio_worklet_tone_generator.c @@ -26,7 +26,7 @@ volatile int audioProcessedCount = 0; #endif // This function will be called for every fixed 128 samples of audio to be processed. -EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) { +bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) { #ifdef REPORT_RESULT ++audioProcessedCount; #endif @@ -49,23 +49,23 @@ EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutpu // Range reduce to keep precision around zero. phase = emscripten_math_fmod(phase, 2.f * PI); - // We generated audio and want to keep this processor going. Return EM_FALSE here to shut down. - return EM_TRUE; + // We generated audio and want to keep this processor going. Return false here to shut down. + return true; } #ifdef REPORT_RESULT -EM_BOOL observe_test_end(double time, void *userData) { +bool observe_test_end(double time, void *userData) { if (audioProcessedCount >= 100) { REPORT_RESULT(0); - return EM_FALSE; + return false; } - return EM_TRUE; + return true; } #endif // This callback will fire after the Audio Worklet Processor has finished being // added to the Worklet global scope. -void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { if (!success) return; // Specify the input and output node configurations for the Wasm Audio @@ -110,7 +110,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL su // This callback will fire when the Wasm Module has been shared to the // AudioWorklet global scope, and is now ready to begin adding Audio Worklet // Processors. -void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { if (!success) return; WebAudioWorkletProcessorCreateOptions opts = { diff --git a/test/webaudio/audioworklet.c b/test/webaudio/audioworklet.c index d4a9d674a801..9240063a8648 100644 --- a/test/webaudio/audioworklet.c +++ b/test/webaudio/audioworklet.c @@ -30,7 +30,7 @@ int lastTlsVariableValueInAudioThread = 1; #endif // This function will be called for every fixed 128 samples of audio to be processed. -EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) { +bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) { #ifdef REPORT_RESULT assert(testTlsVariable == lastTlsVariableValueInAudioThread); ++testTlsVariable; @@ -43,8 +43,8 @@ EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutpu for(int j = 0; j < 128*outputs[i].numberOfChannels; ++j) outputs[i].data[j] = (rand() / (float)RAND_MAX * 2.0f - 1.0f) * 0.3f; - // We generated audio and want to keep this processor going. Return EM_FALSE here to shut down. - return EM_TRUE; + // We generated audio and want to keep this processor going. Return false here to shut down. + return true; } EM_JS(void, InitHtmlUi, (EMSCRIPTEN_WEBAUDIO_T audioContext, EMSCRIPTEN_AUDIO_WORKLET_NODE_T audioWorkletNode), { @@ -68,21 +68,21 @@ EM_JS(void, InitHtmlUi, (EMSCRIPTEN_WEBAUDIO_T audioContext, EMSCRIPTEN_AUDIO_WO }); #ifdef REPORT_RESULT -EM_BOOL main_thread_tls_access(double time, void *userData) { +bool main_thread_tls_access(double time, void *userData) { // Try to mess the TLS variable on the main thread, with the expectation that // it should not change the TLS value on the AudioWorklet thread. testTlsVariable = (int)time; if (lastTlsVariableValueInAudioThread >= 100) { REPORT_RESULT(0); - return EM_FALSE; + return false; } - return EM_TRUE; + return true; } #endif // This callback will fire after the Audio Worklet Processor has finished being // added to the Worklet global scope. -void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { if (!success) return; // Specify the input and output node configurations for the Wasm Audio @@ -109,7 +109,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL su // This callback will fire when the Wasm Module has been shared to the // AudioWorklet global scope, and is now ready to begin adding Audio Worklet // Processors. -void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { if (!success) return; WebAudioWorkletProcessorCreateOptions opts = { diff --git a/test/webaudio/audioworklet_emscripten_futex_wake.cpp b/test/webaudio/audioworklet_emscripten_futex_wake.cpp index 4ae8b34324db..428d9168f4dd 100644 --- a/test/webaudio/audioworklet_emscripten_futex_wake.cpp +++ b/test/webaudio/audioworklet_emscripten_futex_wake.cpp @@ -13,7 +13,7 @@ int futexLocation = 0; int testSuccess = 0; -EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) { +bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) { int supportsAtomicWait = _emscripten_thread_supports_atomics_wait(); printf("supportsAtomicWait: %d\n", supportsAtomicWait); assert(!supportsAtomicWait); @@ -23,7 +23,7 @@ EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutpu emscripten_futex_wait(&futexLocation, 1, /*maxWaitMs=*/2); testSuccess = 1; - return EM_FALSE; + return false; } EM_JS(void, InitHtmlUi, (EMSCRIPTEN_WEBAUDIO_T audioContext, EMSCRIPTEN_AUDIO_WORKLET_NODE_T audioWorkletNode), { @@ -39,25 +39,25 @@ EM_JS(void, InitHtmlUi, (EMSCRIPTEN_WEBAUDIO_T audioContext, EMSCRIPTEN_AUDIO_WO }; }); -EM_BOOL PollTestSuccess(double, void *) { +bool PollTestSuccess(double, void *) { if (testSuccess) { printf("Test success!\n"); #ifdef REPORT_RESULT REPORT_RESULT(0); #endif - return EM_FALSE; + return false; } - return EM_TRUE; + return true; } -void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { int outputChannelCounts[1] = { 1 }; EmscriptenAudioWorkletNodeCreateOptions options = { .numberOfInputs = 0, .numberOfOutputs = 1, .outputChannelCounts = outputChannelCounts }; EMSCRIPTEN_AUDIO_WORKLET_NODE_T wasmAudioWorklet = emscripten_create_wasm_audio_worklet_node(audioContext, "noise-generator", &options, &ProcessAudio, 0); InitHtmlUi(audioContext, wasmAudioWorklet); } -void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { WebAudioWorkletProcessorCreateOptions opts = { .name = "noise-generator" }; emscripten_create_wasm_audio_worklet_processor_async(audioContext, &opts, AudioWorkletProcessorCreated, 0); } diff --git a/test/webaudio/audioworklet_post_function.c b/test/webaudio/audioworklet_post_function.c index 1619fe267364..caabd1f45c59 100644 --- a/test/webaudio/audioworklet_post_function.c +++ b/test/webaudio/audioworklet_post_function.c @@ -25,7 +25,7 @@ void MessageReceivedInAudioWorkletThread(int a, int b) { } // This callback will fire when the audio worklet thread has been initialized. -void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { printf("WebAudioWorkletThreadInitialized\n"); emscripten_audio_worklet_post_function_vii(audioContext, MessageReceivedInAudioWorkletThread, /*a=*/42, /*b=*/9000); } diff --git a/test/webaudio/audioworklet_worker.c b/test/webaudio/audioworklet_worker.c index e010402735de..b7394f86035b 100644 --- a/test/webaudio/audioworklet_worker.c +++ b/test/webaudio/audioworklet_worker.c @@ -33,7 +33,7 @@ void MessageReceivedInAudioWorkletThread() { emscripten_futex_wake(&workletToWorkerFutexLocation, 1); } -void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, EM_BOOL success, void *userData) { +void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) { emscripten_audio_worklet_post_function_v(audioContext, MessageReceivedInAudioWorkletThread); } diff --git a/test/websocket/test_websocket_send.c b/test/websocket/test_websocket_send.c index 4e82b844afa9..a3a01c1d3b69 100644 --- a/test/websocket/test_websocket_send.c +++ b/test/websocket/test_websocket_send.c @@ -8,7 +8,7 @@ EMSCRIPTEN_WEBSOCKET_T sock1; EMSCRIPTEN_WEBSOCKET_T sock2; -EM_BOOL WebSocketOpen(int eventType, const EmscriptenWebSocketOpenEvent *e, void *userData) { +bool WebSocketOpen(int eventType, const EmscriptenWebSocketOpenEvent *e, void *userData) { printf("open(socket=%d, eventType=%d, userData=%p)\n", e->socket, eventType, userData); emscripten_websocket_send_utf8_text(e->socket, "hello on the other side"); @@ -19,7 +19,7 @@ EM_BOOL WebSocketOpen(int eventType, const EmscriptenWebSocketOpenEvent *e, void return 0; } -EM_BOOL WebSocketClose(int eventType, const EmscriptenWebSocketCloseEvent *e, void *userData) { +bool WebSocketClose(int eventType, const EmscriptenWebSocketCloseEvent *e, void *userData) { printf("close(socket=%d, eventType=%d, wasClean=%d, code=%d, reason=%s, userData=%p)\n", e->socket, eventType, e->wasClean, e->code, e->reason, userData); assert(e->wasClean == 1); assert(e->code == 1005 /* No Status Rcvd */); @@ -36,12 +36,12 @@ EM_BOOL WebSocketClose(int eventType, const EmscriptenWebSocketCloseEvent *e, vo return 0; } -EM_BOOL WebSocketError(int eventType, const EmscriptenWebSocketErrorEvent *e, void *userData) { +bool WebSocketError(int eventType, const EmscriptenWebSocketErrorEvent *e, void *userData) { printf("error(socket=%d, eventType=%d, userData=%p)\n", e->socket, eventType, userData); return 0; } -EM_BOOL WebSocketMessage(int eventType, const EmscriptenWebSocketMessageEvent *e, void *userData) { +bool WebSocketMessage(int eventType, const EmscriptenWebSocketMessageEvent *e, void *userData) { printf("message(socket=%d, eventType=%d, userData=%p data=%p, numBytes=%d, isText=%d)\n", e->socket, eventType, userData, e->data, e->numBytes, e->isText); static int text_received = 0; assert(e->socket == sock1 || e->socket == sock2);