Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,9 @@ See the :c:macro:`emscripten.h docs <EM_ASM_>` for more details.
- See how ``{`` and ``}`` are used here to enclose the code. This is
necessary to differentiate the code from the arguments passed later,
which are the input values (this is how C macros work).
- When using the :c:macro:`EM_ASM` macro, ensure that you only use
single quotes('). Double quotes(") will cause a syntax error that
is not detected by the compiler and is only shown when looking at
a JavaScript console while running the offending code.
- JavaScript string literals inside :c:macro:`EM_ASM` code may use either
single quotes (``'``) or double quotes (``"``). See
`test/core/test_em_asm_2.cpp`_ for examples of both forms.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or no quotes at all right? Maybe we should just drop this block completely?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I misread that context.

Still, since both are allowed why even bother mentioning this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's unconventional in C/C++ to use 'string' for more than a single character, so it's valuable to mention it. The See ... for examples mention also seems useful.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why its useful. if there was an issue with one form or another, that makes sense to mention. If everything just works then why mention this ? Should we also mention the === works, even though it doesn't in C++?

- clang-format may clobber Javascript constructions, such as ``=>``
turning to ``= >``. To avoid this, add to your ``.clang-format``:
``WhitespaceSensitiveMacros: ['EM_ASM', 'EM_JS', 'EM_ASM_INT', 'EM_ASM_DOUBLE', 'EM_ASM_PTR', 'MAIN_THREAD_EM_ASM', 'MAIN_THREAD_EM_ASM_INT', 'MAIN_THREAD_EM_ASM_DOUBLE', 'MAIN_THREAD_EM_ASM_DOUBLE', 'MAIN_THREAD_ASYNC_EM_ASM']``.
Expand Down Expand Up @@ -853,6 +852,7 @@ you can give it a try. See `Emnapi documentation`_ for more details.
.. _test/test_other.py: https://github.com/emscripten-core/emscripten/blob/main/test/test_other.py
.. _test/core/test_utf.c: https://github.com/emscripten-core/emscripten/blob/main/test/core/test_utf.c
.. _test/core/test_getValue_setValue.cpp: https://github.com/emscripten-core/emscripten/blob/main/test/core/test_getValue_setValue.cpp
.. _test/core/test_em_asm_2.cpp: https://github.com/emscripten-core/emscripten/blob/main/test/core/test_em_asm_2.cpp
.. _test/test_core.py: https://github.com/emscripten-core/emscripten/blob/main/test/test_core.py
.. _Box2D: https://github.com/kripken/box2d.js/#box2djs
.. _Bullet: https://github.com/kripken/ammo.js/#ammojs
Expand Down
Loading