modjke / mixin Goto Github PK
View Code? Open in Web Editor NEWMixins for haxe
Mixins for haxe
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
[]
mixin level metadata
add a bunch of @:base methods
or something like that
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) {}
}
dont even touch class fields :)
Should work more like concating two mixins: fields should be merged, raise exception on name conflicts.
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!
makeSureFieldIsExplicitlyTyped
should add expected types where possible
and not break completion
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;
}
}
while overwriting methods and constructors
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.