as3hx icon indicating copy to clipboard operation
as3hx copied to clipboard

Генерация переопределённых геттеров/сеттеров для классов, расширяющих плеерные as3 классы.

Open k0t0vich opened this issue 8 years ago • 0 comments
trafficstars

as3 code for example:

package {
    public class Test extends flash.display.Sprite {
    private var _width:Number;
  
    override public function set width(value:Number): Number {
        _width = value;
        return _width;
    }

    override public function get width():Number {
        return _width;
    }
}
}
class Child extends Test {
    
    override public function get width():Number {
        return 10;
    }
}

expected result


class Test extends flash.display.Sprite {
    private var _width:Float;
    static function main() {
        trace("Haxe is great!");
    }
    
     #if flash @:setter(width) #else override #end
    public function set_width(value:Float): #if flash Void #else Float #end {
        _width = value;
        #if !flash return _width; #end
    }
 #if flash @:getter(width) #else override #end
    public function get_width():Float {
        return _width;
    }
}
    
class Child extends Test {
    #if flash @:getter(width) #end
    override public function get_width():Float {
        return 10;
    }
}

actual result


class Test extends flash.display.Sprite {
    private var _width:Float;
    static function main() {
        trace("Haxe is great!");
    }
     
    override public function set_width(value:Float): Float {
        _width = value;
        return _width;
    }

    override public function get_width():Float {
        return _width;
    }
}
    
class Child extends Test {
    
    override public function get_width():Float {
        return 10;
    }
}  

Особое внимание уделить наличию модификатора override у впервые переопределённого сеттера/геттера и уже повторного.

k0t0vich avatar Nov 13 '17 20:11 k0t0vich