Created
May 19, 2014 16:58
-
-
Save back2dos/b07b66904d88946281c2 to your computer and use it in GitHub Desktop.
Strict ints for Oleg.
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
| package strict; | |
| import StdTypes.Int in HxInt; | |
| abstract Int(HxInt) from HxInt to HxInt { | |
| @:op(this + b) inline function add(b:Int):Int return this + (b : HxInt); | |
| @:op(this - b) inline function subtract(b:Int):Int return this - (b : HxInt); | |
| @:op(this * b) inline function multiply(b:Int):Int return this * (b : HxInt); | |
| @:op(this >>> b) inline function urshift(b:Int):Int return this >>> (b : HxInt); | |
| @:op(this >> b) inline function rshift(b:Int):Int return this >> (b : HxInt); | |
| @:op(this << b) inline function lshift(b:Int):Int return this << (b : HxInt); | |
| @:op(this & b) inline function and(b:Int):Int return this & (b : HxInt); | |
| @:op(this | b) inline function or(b:Int):Int return this | (b : HxInt); | |
| @:op(this ^ b) inline function xor(b:Int):Int return this ^ (b : HxInt); | |
| @:op(~this) inline function not():Int return ~this; | |
| @:op(-this) inline function neg():Int return this; | |
| @:op(--this) inline function dec():Int return --this; | |
| @:op(++this) inline function inc():Int return ++this; | |
| @:op(this--) inline function rdec():Int return this--; | |
| @:op(this++) inline function rinc():Int return this++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In recent Haxe I think it's possible even to not specify operator functions when you're abstracting coreType: