Return-Path: X-Original-To: apmail-flex-dev-archive@www.apache.org Delivered-To: apmail-flex-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ADAAF183EE for ; Fri, 26 Jun 2015 17:06:21 +0000 (UTC) Received: (qmail 23818 invoked by uid 500); 26 Jun 2015 17:06:16 -0000 Delivered-To: apmail-flex-dev-archive@flex.apache.org Received: (qmail 23780 invoked by uid 500); 26 Jun 2015 17:06:16 -0000 Mailing-List: contact dev-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list dev@flex.apache.org Received: (qmail 23767 invoked by uid 99); 26 Jun 2015 17:06:16 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jun 2015 17:06:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 965931A61C7 for ; Fri, 26 Jun 2015 17:06:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.9 X-Spam-Level: ** X-Spam-Status: No, score=2.9 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id y52UDI0jTwW1 for ; Fri, 26 Jun 2015 17:06:10 +0000 (UTC) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 4C6324C0EA for ; Fri, 26 Jun 2015 17:06:10 +0000 (UTC) Received: by lbbpo10 with SMTP id po10so68250427lbb.3 for ; Fri, 26 Jun 2015 10:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=c9O9O/r2eY4tAXQCPLzC8Ntoz3RBnIwyWFZ0iMaPA8g=; b=buGX/j6syVmaZYyn6nI7POHVVmNiiYi+XiFxrERxpprufxKUBw2NZyGLQFxeOBMcZJ bQgsG+jthBWpodxS++UuUCLP6LeAr1tndjvp0nwUiQJVCI6titLRYxnO0dyZ603BROzF S5OcMtAY+RduNCYLCgYspWAIgrw1zyE+A2AbzDC82LpgRwyF6lP+S5FYoM+LVy2rB13L UmprovUET0gliYojoaMwEUkWvHIES1pmxeIzh2+JixJiRnkAF7m3W/8h2cVtVtHs/tb5 zajGGmWOn6XbuGK4fOFA9CPu0bGPEFQE/21/zcQA6DepKFp68cJNdKGgbWqe9jCTxXPB dABQ== MIME-Version: 1.0 X-Received: by 10.153.5.2 with SMTP id ci2mr2534546lad.28.1435338369212; Fri, 26 Jun 2015 10:06:09 -0700 (PDT) Received: by 10.114.174.35 with HTTP; Fri, 26 Jun 2015 10:06:09 -0700 (PDT) In-Reply-To: References: Date: Fri, 26 Jun 2015 13:06:09 -0400 Message-ID: Subject: Re: [FalconJX] Building CreateJS externs From: Michael Schmalle To: dev@flex.apache.org Content-Type: multipart/alternative; boundary=001a11349ff2a128e205196ec193 --001a11349ff2a128e205196ec193 Content-Type: text/plain; charset=UTF-8 Weird, looking at the generated source; /** * @param type [string] * @param opt_eventInitDict [(MouseEventInit|null|undefined)] * @see [w3c_event] */ public function MouseEvent(type:String, opt_eventInitDict:MouseEventInit = null) { super(null, null); } It's right, so I don't know what is happening in SWC the compiler. I did write logic that climbs the super chain to find the method signature. I said in a previous email that we can't use native because for some reason COMPC does't keep the optional args, weird I know. BTW, MouseEventInitis a @typedef and I havn't fully implemented them because they are weird and hard. :) Sometimes a @typedef could be a String, Boolean etc or an actual defined struct class. So I think I need some major logic to check whether it is a pointer to a native type which it would be converted to that native type, or if it's a struct create the fields and this is where we would have to have a JavaScript transform. At compile time, you have the typed object but in reality, it is just a plain {} object and not a javascript "type/class". I wasn't going to get into this typedef stuff until people started using it because it isn't trivial. But now that you are, I can see what I can to to normalize it. Mike On Fri, Jun 26, 2015 at 12:24 PM, Josh Tynjala wrote: > Yeah, I think metadata would be acceptable too. If that seems easier to > you, I say let's do that. > > I just found another issue in externc. I tried to subclass MouseEvent, > which is compiled into js.swc. It's not correctly determining the number of > constructor arguments for MouseEvent, so when I try to compile the subclass > in AS3, it gives me this error. > > Error: Incorrect number of arguments. Expected 1 > super(); > > MouseEvent has two constructor arguments, so I think it should be emitting > super(null, null); instead. > > In fact, when I manually add w3c_events.js to my configuration, then > externc correctly adds super(null, null);. So it seems to figure out the > number of constructor arguments from raw JS, but once the class is already > compiled into a SWC, it's losing that information somehow. > > - Josh > > > On Fri, Jun 26, 2015 at 3:53 AM, Michael Schmalle < > teotigraphixllc@gmail.com > > wrote: > > > 1) That is a bug, I think I hard-coded a quick fix on things that have a > > @template tag and I immediately transformed them to Object without > checking > > the for optional or var arg declarations. I can fix this, it's only > methods > > with that tag and there are no very many. > > > > 2) Yeah, I figured as much, I had experience with Randori and pretty much > > knew this was going to come up. > > > > That way I see it is, the absolute minimum solution to this problem is > > getting the "problem" to be the same that is in IDEs today and that is, > you > > can't use two classes of the same name without having to qualify one. To > > me, this is a fix until this project gets momentum to go farther down the > > rabbit hole. > > > > I know Alex chimed in but here is my opinion from experience; > > > > Introduce a JavaScript tag that can be resolved at run-time to reduce the > > name back into it's native JavaScript identifier/package. I have gone > back > > and forth with Alex about this, asdoc verses metadata but, metadata gets > > saved in a SWC and asdoc doesn't. For my ideas to work we must have > > metadata in an external library to resolve the true javascript identifier > > when transpileing. > > > > [JavaScript(name=Event")] > > package org.apache.flex.dom { > > public class Event {} > > } > > > > IMHO to fix this, there has to be a sacrifice in one of the "links". To > me > > that is putting the core classes in an apache.dom package and use the > > [JavaScript] metadata rewrite to reduce the package name during cross > > compile. > > > > With the above, you automatically solve all problems and only create one > > new one, you have to import DOM level classes. The EXTERNC compiler IMO > is > > still basic, it can understand basic package structures when defining > > externs, so we can have a createjs.Event and an > org.apache.flex.dom.Event. > > We can add a new config to the EXTERNC compiler that is > > -base-package="org.apache.flex.dom". > > > > We could also configure it to leave global constants, functions in global > > namespace, as well as config a list of global classes such as Object and > > Array so this doesn't screw up inheritance and leave out the kewl > > document:HTMLDocument stuff. > > > > There are many details I would need to test and implement doing what I > have > > described, but I already did it in the Randori compiler. > > > > As far as the other suggestions, since this is no-paid free time, I am > > looking for the quick solution that others don't think is out in left > > field. > > > > Let me know. > > > > PS I wish we could add on to the language, but from my perspective with > IDE > > support that isn't even an option... > > > > Mike > > > > On Thu, Jun 25, 2015 at 8:06 PM, Josh Tynjala > > wrote: > > > > > Hey Mike, > > > > > > I finally got a chance to start playing around with some of your work > > > today. I've been starting out with externc. I've run into a couple of > > > issues. One you already know about. Let's start with the other one, > > > though... > > > > > > 1) It looks like the Array class constructor has the wrong signature. > > This > > > is from the es3.js extern: > > > > > > /** > > > * @constructor > > > * @param {...*} var_args > > > * @return {!Array.} > > > * @nosideeffects > > > * @template T > > > * @see > > > > > > > > > http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array > > > */ > > > function Array(var_args) {} > > > > > > It looks like externc is producing the following AS3: > > > > > > public function Array(var_args:Object) {} > > > > > > However, I think it's meant to produce this AS3 instead: > > > > > > public function Array(...var_args:Array) {} > > > > > > There are probably other functions with the same issue too. > > > > > > 2) I immediately ran into that issue where a top-level class interferes > > > with a class that has the same name in a package. w3c_event.js defines > > the > > > top-level Event class, and CreateJS has a createjs.Event class. It's > the > > > exact same issue that you brought up earlier. I think I dismissed it > too > > > quickly. I apologize for that. > > > > > > At the time, I was thinking that FlexJS could easily work around it > > because > > > be new code. However, now that I'm running into the collision > directly, I > > > realize that this is going to be a big issue with external libraries. > > Like > > > CreateJS, a ton of existing JS frameworks define their own Event type. > > This > > > issue is going to come up a lot. You're absolutely right: it needs to > be > > > addressed somehow. > > > > > > I have some ideas. Some involve changes to the AS3 language. I don't > know > > > if that's on the table, but I'll throw them out there anyway. > > > > > > If AS3 would let us do something like this, the issue wouldn't be as > bad: > > > > > > import global.Event; > > > import createjs.Event; > > > var event2:createjs.Event; //createjs > > > var event:global.Event; //native > > > > > > But AS3 doesn't provide any kind of identifier to refer to the > top-level > > > package. Even if it did, though, always being forced to use the > > > fully-qualified class name would get annoying. At least if there are > two > > > packages, you only need to do it when they're both imported. With one > > class > > > in the top-level, you always need to do it. > > > > > > Alternatively, TypeScript has some interesting import syntax that I > > > remember wishing we could use in AS3: > > > > > > import CreateJSEvent = createjs.Event; > > > var event2:CreateJSEvent; //createjs > > > var event:Event; //native > > > > > > Now, within the scope of the class with these import statements, Event > is > > > the top-level function, and CreateJSEvent maps to createjs.Event. This > > > would be really cool, in my opinion. I wish I could use it in Starling > > > projects to do exactly the same thing with event conflicts: > > > > > > import FlashEvent = flash.events.Event; > > > import starling.events.Event; > > > var event:Event; //starling > > > var event2:FlashEvent; //flash > > > > > > Again, that would require changes to AS3. Maybe that's not acceptable. > > > > > > Another option might be to make the name mapping configurable as a > > compiler > > > argument: > > > > > > -map-class=createjs.Event,createjs.CreateJSEvent > > > > > > import createjs.CreateJSEvent; > > > var event:CreateJSEvent; //createjs > > > var event2:Event; //native > > > > > > or: > > > > > > -map-class=Event,NativeEvent > > > > > > import createjs.Event; > > > var event:Event; //createjs > > > var event2:NativeEvent; //native > > > > > > Very similar, but this would apply to a whole project instead of the > > scope > > > of a single class. The JavaScript output would use the real name > > > (createjs.Event or Event), but the AS3 would use the mapped name > > > (createjs.CreateJSEvent or NativeEvent). > > > > > > I suppose, with all of these, IDEs would probably fail to recognize > that > > > names were mapped and show incorrect errors. I'm finding this stagnant > > AS3 > > > IDE landscape frustrating (IDEs have some annoying bugs with the > Feathers > > > SDK too). It makes me want to forge ahead without them and hope that an > > > alternative comes along. > > > > > > Thoughts? Please feel free to shoot things down for being crazy or > > > impossible. > > > > > > - Josh > > > > > > --001a11349ff2a128e205196ec193--