Git Product home page Git Product logo

mixin's People

Contributors

modjke avatar rcstuber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mixin's Issues

Haxe for VSCode crashes when using mixins

I have some very basic usage of the library, which compiles and runs successfully, but for some reason fails when trying to get completions from the VSCode extension.

mixins/MovingObject.hx

package mixins;

@mixin interface MovingObject {
    public var speed: Int;
}

objects/Car.hx

package objects;
import mixins.MovingObject;

class Car implements MovingObject {
    public function isFast(): Boolean {
         return // Here I press Ctrl + Space to get completions
    }
}

And the following error message appears in the debug window of the extension:

Code: -32603 
/home/bary/haxelib/mixin/0,9,5/lib/mixin/Mixin.hx:229: characters 26-47 : Invalid field access : baseImplements
?:1: characters 1048575-8796094070782 : Called from
Aborted

If I add @baseImplements() to the mixin, I get a different error

 Code: -32603 
/home/bary/haxelib/mixin/0,9,5/lib/mixin/Mixin.hx:89: characters 3-8 : Mixin with mixins.MovingObject already existed...
/home/bary/haxelib/mixin/0,9,5/lib/mixin/Mixin.hx:48: characters 19-32 : Called from
?:1: characters 1-7 : Called from
Aborted
[]

static methods and var

support for static method can be supported adding for example with annotations. marking an instance method of an interface as static

interface A {
@:static function sum(a,b) {}
}

Cannot return `null` from Void-function

I want to use Mixins to add (empty) function stubs in case they aren't defined in the base class and to call the base class's implementation if the function is defined there. However this doesn't seem possible, as it will throw this compilation error Cannot return `null` from Void-function. Is there any way around this?

@mixin interface SomeMixin {
    @overwrite(addIfAbsent=true) function update():Void {
        $base.update();
    }
}

PS: I really like the library so far, very useful!

overwriting getter/setter

class Test {
    static function main() {
        var t = new Test();
        t.val++;
        trace(t.val);
    }
    
    @:isVar
    var val(get,set):Int;
    
    function get_val():Int {    
        function injected() return val;
        
        return injected();
	}
    
    function set_val(v:Int):Int {
        return val = v;
    }
    
    function new()
	{
        val = 0;
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.