[haXe] a haxe extern generator
Niel Drummond
niel at cyanescent.co.uk
Sat Feb 17 15:46:45 CET 2007
Hi Nicolas,
I'll go through your queries again later in the weekend with all the
actual compile errors,
Nicolas Cannasse wrote:
>> - extending interfaces are not allowed in haxe, so I have left
>> interfaces out of all externs. So far I do not get any compile problems,
>> but maybe this can cause type related runtime errors?
>>
>
> What do you mean by "extending interfaces" ?
>
This problem crept up a while ago, as far as I remember, when I try to
extend an interface I get a haxe compile error saying I cannot extend an
interface
e.g.
extern interface A {
// ...
}
extern interface B extends A {
//..
}
if I am wrong I will reimplement them.
>> - static members are not inherited in haxe (whereas counterintuitively
>> they are in actionscript), so I have copied static declarations up the
>> inheritance heirarchy.
>>
>
> This will not work.
> In AS2, statics are inherited but they are still part of the super class
> object prototype. For example the following :
>
> class A {
> static var x;
> }
>
> class B extends A {
> function f() {
> return x; // gets compiled to A.x
> }
> }
>
> So you just must keep the "x" variable as a "A" static, and haXe users
> will use A.x instead of simply using "x".
>
>
ok... this did not work as far as calling a static actionscript member
from an inherited class
>> - all function parameters become optional, and I've added 4 optional
>> parameters to each function, in order to fake function overloading.
>>
>
> It would be better to have the default being not-optional, and allow
> some kind of AS2 comments in function declarations, such as :
>
> function f( x : String, /*?*/ a : Number /*...*/ ) {
> }
>
> that would get generated to :
>
> function f( x : String, ?a : Number, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 :
> Dynamic, ?p4 : Dynamic );
>
>
I will look to implement this. Unfortunately, if I go this route, the
default extern output will compile, but since actionscript does not
require all parameters, there can be errors in the implementation...
>> There are some more issues, which I suspect arise from type problems.
>> For example AsWing delegation does not work, which may be because you
>> cannot pass functions as variables to Actionscript (I'm groping a bit
>> for an explanation, I have to admit)...
>>
>
>
If I do the first JButton example from AsWing, I try
import org.aswing.util.Extern;
class TestAswing extends JWindow {
private var jbutton1:JButton;
public function createEast (eventObj : Event) : Void
{
trace( "hello" );
getContentPane ().append (jbutton2, BorderLayout.EAST);
}
public static function main():Void{
var myWindow : TestAswing = new TestAswing ();
var jbutton1:JButton = new JButton("JButton1");
myWindow.getContentPane ().append (jbutton1,
BorderLayout.NORTH);
jbutton1.addEventListener (JButton.ON_PRESS,
myWindow.createEast, myWindow);
}
}
myWindow is instantiated and filled with a button, but the
addEventListener is not. the addEventListener will use the Delegate
class which requires the function createEast as its argument. Maybe I am
writing this wrong...
regards
- Niel
> An example maybe ?
>
> Best,
> Nicolas
>
>
More information about the Haxe
mailing list