When embedding Python there is the PyCapsule
type to create an object containing a C pointer which cannot be modified from Python code, i.e. it's perfect to pass around stuff that is used only by the C code.
Since my application also supports JavaScript via the SpiderMonkey engine I'm looking for something similar in SpiderMonkey. I know that I can create a custom JSClass
with the JSCLASS_HAS_PRIVATE
flag but I wonder if there's another simpler/more lightweight approach.