The Ravel library is written in C++, and compiled to Javascript via
the emscripten
compiler. There are some
limitations with the Javascript interface generated by the current
emscripten implementation:
- C++ objects created by the system must be explicitly deleted by
calling their
delete method, otherwise a memory leak
results. Unfortunately, Javascript has no concept of finaliser
that is present in other garbage collected languages that would help
here.
- C++ methods returning complex data types will generate a new C++
object, that needs to be deleted as well. Strings are an exception, in
that they are simply converted into Javascript strings. In the following
documentation, it will be noted if the returned object needs to be
deleted.
- C++ methods returning a reference do not return a reference
object back to Javascript, but instead create a new C++ object that is
a copy. Because of this, special reference members are added into
containing objects that can be adjusted to point to desired
object. Ravel::Handle is an example.
- Method overloading is not supported in Javascript. Overloaded
C++ methods must have different names in Javascript (even if the
number of arguments differ). In particular, this means that
getter/setter methods need distinct names, so we use the get/set Attribute convention here, even if the C++ equivalents are just the
attribute name with setter/getter functionality distinguished by argument.
- All C++ classes and other objects are created in the Module namespace.
Subsections
Ravelation Pty Ldt