Single step JS generation
Separate objects compilation and linking
Libraries are stored using LLVM binary representation
webMain entry point
By convention the method that will be called first on the client side should have the following signature
main function is the traditional
entry point of a C++ program. It also contains the whole program, which terminates after the
main function returns. On a Cheerp application, the
webMain function plays the role of the entry point in a very different manner.
webMain initializes the program, sets up event handlers and returns control to the browser as soon as possible. After returning, the browser notifies the events you registered handlers for.
webMain is absent,
main defaults to it, and in some cases the behaviour may be the same, but what happens for example here?
Try to compile it with a C++ to x86 compiler, and the result should be
Constructor\n and Destructor\n while the Cheerp version’s output will be only
Constructor\n. Basically global objects survives the call to the webMain, that is meant for performing initializations/setting up event listeners.
client is a C++ namespace that contains all browser APIs declared in cheerp/clientlib.h. The
console object represent the console object of the browser. In the example, the
cheerp/clientlib.h contains declarations for the browser APIs. All functions are only declared so that the Cheerp C++ compiler can use them, but they are simply forwarded (with no additional overhead) to the browser at runtime. No implementation of these functions is provided by Cheerp, so that all browser APIs have the semantics provided by the browser you are currently using.
Accessing Web/HTML5/DOM/Browser APIs
Global variables and types that are provided by the browser environment are accessible through the ‘client’ namespace
Of course, being a regular C++ namespace you can reduce code verbosity by
The relevant headers that defines client interfaces are
Accessing DOM properties
In a similar way you can bind to any other DOM event
Properties of DOM objects are always accessed through setters/getters
Small examples are included in