[FlexJS] Object.setObjectIsEnumerable()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[FlexJS] Object.setObjectIsEnumerable()

Harbs
As far as I can tell, there’s not platform agnostic way to create properties in objects which are not enumerable. In Flash you’d use setObjectIsEnumerable() and in JS, you’d use Object.defineProperty().

Using setObjectIsEnumerable() in AS3 code and cross-compiling keeps the call as-is and generates a runtime error.

There seem to be two ways to resolve this problem that I can think of:
1. Falcon can rewrite any setObjectIsEnumerable() calls to use Object.defineProperty() on the JS side.
2. We can add a Util class to add non-enumerable properties which has conditional compilation.

#1 should be more efficient at runtime, but is probably more work to implement.

Thoughts?

Harbs
Reply | Threaded
Open this post in threaded view
|

Re: [FlexJS] Object.setObjectIsEnumerable()

Harbs
On second thought, the Flash and JS implementations is not 1 to 1. The assignment in Flash is a two-step rpocess of first assigning the value and then defining it as non-enumerable, while it happens all in a single call in JS.

The Util call is probably the better solution.

> On Apr 30, 2017, at 11:21 AM, Harbs <[hidden email]> wrote:
>
> As far as I can tell, there’s not platform agnostic way to create properties in objects which are not enumerable. In Flash you’d use setObjectIsEnumerable() and in JS, you’d use Object.defineProperty().
>
> Using setObjectIsEnumerable() in AS3 code and cross-compiling keeps the call as-is and generates a runtime error.
>
> There seem to be two ways to resolve this problem that I can think of:
> 1. Falcon can rewrite any setObjectIsEnumerable() calls to use Object.defineProperty() on the JS side.
> 2. We can add a Util class to add non-enumerable properties which has conditional compilation.
>
> #1 should be more efficient at runtime, but is probably more work to implement.
>
> Thoughts?
>
> Harbs