[quickjs-devel] Re: JS_CFUNC_DEF doesn't make properties enumerable

  • From: Charlie Gordon <quickjs@xxxxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Sun, 4 Aug 2019 20:13:07 +0200

Hi Saùl,

Yes, this is intentional. All methods documented in the ECMA specification have 
property flags writable and configurable but not enumerable.
Hence there was no need for a more general macro to define these methods in the 
static JSCFunctionListEntry tables.
You can write your own macros to define your own C based object properties, but 
the implementation of these macros and the JSCFunctionListEntry structure might 
change in the future so might need to change your macros to work with newer 
versions of quickjs.
There seems to be little use for enumerable object methods. You can always 
enumerate an object properties and its prototypes’ with Object methods.

Cheers

Chqrlie.


On 4 Aug 2019, at 14:31, Saúl Ibarra Corretgé <s@xxxxxxxxxx> wrote:

Hi,

I noticed JS_CFUNC_DEF "hardcodes" the property flags to
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, but not enumerable. Is this
intentional? Is the recommendation to define one's own such as:

#define JSUV_CFUNC_DEF(name, length, func1) { name, JS_PROP_ENUMERABLE,
JS_DEF_CFUNC, 0, .u.func = { length, JS_CFUNC_generic, { .generic =
func1 } } }

in order to make the definitions enumerable (or any other flag
combination) ?


Cheers,

-- 
Saúl



Other related posts: