We can create a new object instance using jspNewObject()
Yes, although for most functions I'd suggest returning basic objects, made with jsvNewWithFlags(JSV_OBJECT)
the notion of "children" which I believe are what I consider to be "properties" in JavaScript
Yes, spot on
jsvLock()
Yes. Basically to get a pointer from a reference you jsvLock and when you're done with it you jsvUnLock - but you don't unlock if you're returning the pointer from a function. When setting stuff in an object, you might do something like:
See here for an example of how process.env does it.
deep testing will be required to ensure that objects created by the code are not left locked or we will run out of memory.
If you compile without RELEASE=1 a load of assertions are left in that catch multiple unlocks. You can call multiple times and then check with process.memory().usage to see if memory usage increases too.
When compiling for Linux, if you run the tests then each test checks for unfreed memory after execution and fails if there is any, so you can catch stuff that way too.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, although for most functions I'd suggest returning basic objects, made with
jsvNewWithFlags(JSV_OBJECT)
Yes, spot on
Yes. Basically to get a pointer from a reference you
jsvLock
and when you're done with it youjsvUnLock
- but you don't unlock if you're returning the pointer from a function. When setting stuff in an object, you might do something like:See here for an example of how
process.env
does it.If you compile without
RELEASE=1
a load of assertions are left in that catch multiple unlocks. You can call multiple times and then check withprocess.memory().usage
to see if memory usage increases too.When compiling for Linux, if you run the tests then each test checks for unfreed memory after execution and fails if there is any, so you can catch stuff that way too.