Hi
Thanks Alex for the explanation and background! Yes I think that the
BinaryOperatorEmitter code is kicking in to do the actual conversion during the
emitting phase, so that bit works fine; it was just earlier on (and as you
suggest, a think it's trying to build some ABC from the parsed tree which is
where this issue came up - ASCompilationUnit.handleABCBytesRequest is lower
down the call stack..)
I hadn't spotted the 'missing.js' file; presumably then, this is compiled into
the js.swc file ...
First try: I just added the blank definition "Date.prototype.fullYear;" to the
bottom of missing.js per Harbs' suggestion, and built js.swc again (had to
manually then copy it into the royale-asjs folder?); this solved the
compilation error but then I think the later conversion to getFullYear() didn't
work as this returned "undefined" when I called it...
Second try: adding the below to missing.js:
Date.prototype.__defineGetter__("fullYear", function() { return
this.getFullYear(); });
just didn't work; the generated SWC file didn't include any properties on the
Date object.
I've tried a couple of other things but I'm not sure how it would be possible
to add separate get/set methods using this mechanism.. or maybe the translation
needs to change so that it has higher priority?
I'll do a little more digging, unless anyone knows how we could map different
functions to the set/get methods? Maybe with the below updates, it makes more
sense to change the specialCaseDate function..
thanks
Andrew
-----Original Message-----
From: Harbs [mailto:[email protected]]
Sent: 28 June 2018 19:31
To: [email protected]
Subject: [EXTERNAL] Re: Royale compiler not handling Date.fullYear etc
Yes. That sounds like a good solution to me.
Adding:
/**
* @type {number}
*/
Date.prototype.time;
/**
* @type {number}
*/
Date.prototype.fullYear;
Etc… to missing.js should do it.
Harbs
> On Jun 28, 2018, at 8:36 PM, Alex Harui <[email protected]> wrote:
>
> It's only been the past year or so that we've got the "JS Only" configuration
> working where you compile against js.swc instead of playerglobal. And I
> suspect that nobody has tried Date until you just did. We could say that, if
> you are compiling against js.swc you are expected to use the APIs for the
> browser and can't use Date.fullYear, but because specialCaseDate already
> exists, we have the choice of adding Date.fullYear to the missing.js file in
> royale-typedefs/js/src/main/javascript. Then I think you would be allowed to
> use Date.fullYear and it would get transpiled correctly.
>
> I don't see any harm in adding SWF APIs to js.swc if we know how to transpile
> them. What do others think? It would be great if you could give that a try.