Boilerplate code run after the supplied code.
Boilerplate script run before the supplied code.
Additional objects inserted into the evaluation context.
Protected
memoryProtected
moduleAdd objects to the evaluation context.
An object containing properties or methods.
Add a method to the evaluation context, with cleanup.
Calls to the method will be intercepted, and their results added to the cleanup list. If your function does not generate new Manifold or CrossSection objects, you can add it to the context directly.
The name for the method in the context.
The function to intercept and include.
Protected
addIntercept calls and add their results to our garbage collection list.
The class to intercept.
An array of methods to intercept.
Are these static methods? If so, intercept them at the prototype level.
Delete any objects tagged for garbage collection.
Clear the evaluation context.
Evaluate a string as javascript code creating a Manifold model.
This function assembles the final execution context. It then runs
beforeScript
, code
and afterScript
in order. Finally, it
returns the end result.
The input string.
any By default, this script will return either undefined
or a Manifold
object. Changing afterScript
will affect this
behaviour.
Get the instantiated manifold WASM instance owned by this module.
Note that function calls that have been intercepted for garbage collection will continue to be intercepted, even outside of the evaluator.
An object that will evaluate ManifoldCAD scripts on demand.
It inserts the Manifold instance (
module
) into the evaluation context, as well as a selection of available methods. Additional properties can be inserted throughaddContext
,addContextMethodWithCleanup
or can be directly added to thecontext
property.This class provides some simple garbage collection. It does this by intercepting calls to a white-list of functions, tracking new instances of
Manifold
andCrossSection
. This way, users don't have to care about callingdelete
manually. Note that this only fixes memory leak across different runs: the memory will only be freed whencleanup()
is called.