Skip to content
Merged
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
20 changes: 10 additions & 10 deletions site/source/docs/porting/connecting_cpp_and_javascript/embind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ to enable the closure compiler.
Memory management
=================

The :js:func:`delete()` JavaScript method is provided to manually signal that
The ``delete()`` JavaScript method is provided to manually signal that
a C++ object is no longer needed and can be deleted:

.. code:: javascript
Expand Down Expand Up @@ -284,8 +284,8 @@ mechanism in which multiple handles can be produced for the same underlying
C++ object. Only when all handles have been deleted does the object get
destroyed.

The :js:func:`clone()` JavaScript method returns a new handle. It must
eventually also be disposed with :js:func:`delete()`:
The ``clone()`` JavaScript method returns a new handle. It must
eventually also be disposed with ``delete()``:

.. code:: javascript

Expand Down Expand Up @@ -399,8 +399,8 @@ on the return type of the function. The policies work as follows:
* *default (no argument)* - For return by value and reference a new object will be allocated using the
object's copy constructor. JS then owns the object and is responsible for deleting it. Returning a
pointer is not allowed by default (use an explicit policy below).
* :cpp:type:`return_value_policy::take_ownership` - Ownership is transferred to JS.
* :cpp:type:`return_value_policy::reference` - Reference an existing object but do not take
* ``return_value_policy::take_ownership`` - Ownership is transferred to JS.
* ``return_value_policy::reference`` - Reference an existing object but do not take
ownership. Care must be taken to not delete the object while it is still in use in JS.

More details below:
Expand Down Expand Up @@ -440,8 +440,8 @@ Raw pointers

Because raw pointers have unclear lifetime semantics, *embind* requires
their use to be marked with either :cpp:type:`allow_raw_pointers` or with a
:cpp:type:`return_value_policy`. If the function returns a pointer it is
recommended to use a :cpp:type:`return_value_policy` instead of the general
``return_value_policy``. If the function returns a pointer it is
recommended to use a ``return_value_policy`` instead of the general
:cpp:type:`allow_raw_pointers`.

For example:
Expand Down Expand Up @@ -1194,7 +1194,7 @@ with ``-sWASM=0``).

For convenience, *embind* provides factory functions to register
``std::vector<T, class Allocator=std::allocator<T>>`` (:cpp:func:`register_vector`), ``std::map<K, V, class Compare=std::less<K>, class Allocator=std::allocator<std::pair<const K, V>>>``
(:cpp:func:`register_map`), and ``std::optional<T>`` (:cpp:func:`register_optional`) types:
(:cpp:func:`register_map`), and ``std::optional<T>`` (``register_optional``) types:

.. code:: cpp

Expand Down Expand Up @@ -1320,8 +1320,8 @@ Custom ``val`` Definitions
:cpp:class:`emscripten::val` types are mapped to TypeScript's `any` type by default,
which does not provide much useful information for API's that consume or
produce `val` types. To give better type information, custom `val` types can be
registered using :cpp:func:`EMSCRIPTEN_DECLARE_VAL_TYPE` in combination with
:cpp:class:`emscripten::register_type`. An example below:
registered using ``EMSCRIPTEN_DECLARE_VAL_TYPE`` in combination with
``emscripten::register_type``. An example below:

Two registration forms are supported:

Expand Down
Loading