Created
July 26, 2012 14:00
-
-
Save waneck/3182194 to your computer and use it in GitHub Desktop.
@:generic proposal, 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@:generic class Array<T> | |
{ | |
private var arr:NativeArrayWrapper<T>; | |
public function new() | |
{ | |
arr = new NativeArrayWrapper<T>(0); // this will be automatically replaced | |
} | |
public function get(x:Int):T | |
{ | |
return arr.get(x); | |
} | |
} | |
//this will be transformed into: | |
@:generic class Array<T> | |
{ | |
private var arr:NativeArrayWrapper<T>; | |
public function new(cl:Class<T>) | |
{ | |
arr = NativeArrayWrapper.alloc(cl, 0); | |
} | |
public function get(x:Int):T | |
{ | |
return arr.get(x); | |
} | |
public function get_f(x:Int):Float | |
{ | |
return arr.get_f(x); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment