Example: it's not really documented anywhere that JS_SetProperty(ctx, obj, key, val) takes ownership of val but not key. One must call JS_FreeAtom(ctx, key) afterwards but not JS_FreeValue(ctx, val).
Another example of an undocumented constraint: you should not JS_FreeValue the elements of the argv array to your C callback. But you should JS_FreeValue the return value of JS_GetProperty(ctx, obj, key). Here too, one must JS_FreeAtom(ctx, key).
Neither is it documented that the first length elements of argv are valid (set to undefined) when JS calls a C function with too few arguments. Or that argc can be greater than length - which makes perfect sense but is undocumented.
Should probably go into docs/docs/developer-guide/api.md?
Example: it's not really documented anywhere that
JS_SetProperty(ctx, obj, key, val)takes ownership ofvalbut notkey. One must callJS_FreeAtom(ctx, key)afterwards but notJS_FreeValue(ctx, val).Another example of an undocumented constraint: you should not
JS_FreeValuethe elements of theargvarray to your C callback. But you shouldJS_FreeValuethe return value ofJS_GetProperty(ctx, obj, key). Here too, one mustJS_FreeAtom(ctx, key).Neither is it documented that the first
lengthelements ofargvare valid (set to undefined) when JS calls a C function with too few arguments. Or thatargccan be greater thanlength- which makes perfect sense but is undocumented.Should probably go into
docs/docs/developer-guide/api.md?