Browse Source

[cpp] Respect the @:notNull metadata for Null<> types. Native implementation of Int64 for hxcpp

hughsando 10 years ago
parent
commit
c9eb7d76ad
3 changed files with 387 additions and 162 deletions
  1. 34 23
      gencpp.ml
  2. 353 0
      std/cpp/_std/haxe/Int64.hx
  3. 0 139
      std/cpp/_std/haxe/Int64.hx2

+ 34 - 23
gencpp.ml

@@ -367,11 +367,6 @@ let get_meta_string_path ctx meta key =
    loop meta
 ;;
 
-let has_meta_key meta key =
-   List.exists (fun m -> match m with | (k,_,_) when k=key-> true | _ -> false ) meta
-;;
-
-
 let get_field_access_meta field_access key =
 match field_access with
    | FInstance(_,_,class_field)
@@ -384,6 +379,19 @@ let get_code meta key =
    if (code<>"") then code ^ "\n" else code
 ;;
 
+let has_meta_key meta key =
+   List.exists (fun m -> match m with | (k,_,_) when k=key-> true | _ -> false ) meta
+;;
+
+let type_has_meta_key haxe_type key =
+   match follow haxe_type with
+   | TInst (klass,_) -> has_meta_key klass.cl_meta key
+   | TType (type_def,_) -> has_meta_key type_def.t_meta key
+   | TEnum (enum_def,_) -> has_meta_key enum_def.e_meta key
+   | _ -> false
+;;
+
+
 (*
 let dump_meta meta =
    List.iter (fun m -> match m with | (k,_,_) -> print_endline ((fst (MetaInfo.to_string k)) ^ "=" ^ (get_meta_string meta k) ) | _ -> () ) meta;;
@@ -489,15 +497,6 @@ let rec remove_parens_cast expression =
    | _ -> expression
 ;;
 *)
-
-let cant_be_null type_string =
-   is_numeric type_string
-;;
-
-let is_object type_string =
-   not (is_numeric type_string || type_string="::String");
-;;
-
 let is_interface_type t =
    match follow t with
    | TInst (klass,params) -> klass.cl_interface
@@ -609,6 +608,7 @@ let rec class_string klass suffix params remap =
             | TInst ({ cl_path = [],"Int" },_)
             | TInst ({ cl_path = [],"Float" },_)
             | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic"
+            | t when type_has_meta_key t Meta.NotNull -> "Dynamic"
             | _ -> "/*NULL*/" ^ (type_string t) )
          | _ -> assert false);
    (* Normal class *)
@@ -640,6 +640,7 @@ and type_string_suff suffix haxe_type remap =
             | TInst ({ cl_path = [],"Int" },_)
             | TInst ({ cl_path = [],"Float" },_)
             | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" ^ suffix
+            | t when type_has_meta_key t Meta.NotNull -> "Dynamic" ^ suffix
             | _ -> type_string_suff suffix t remap)
          | _ -> assert false);
       | [] , "Array" ->
@@ -692,7 +693,7 @@ and type_string haxe_type =
 
 and array_element_type haxe_type =
    match type_string haxe_type with
-   | x when cant_be_null x -> x
+   | x when cant_be_null haxe_type -> x
    | x when is_interface_type (follow haxe_type) -> x
    | "::String" -> "::String"
    | _ -> "::Dynamic"
@@ -725,15 +726,20 @@ and cpp_function_signature_params params = match params with
 
 and gen_interface_arg_type_name name opt typ =
    let type_str = (type_string typ) in
-   (if (opt && (cant_be_null type_str) ) then
+   (if (opt && (cant_be_null typ) ) then
       "hx::Null< " ^ type_str ^ " > "
    else
       type_str )
    ^ " " ^ (keyword_remap name)
 and gen_tfun_interface_arg_list args =
    String.concat "," (List.map (fun (name,opt,typ) -> gen_interface_arg_type_name name opt typ) args)
+and cant_be_null haxe_type =
+   is_numeric (type_string haxe_type) || (type_has_meta_key haxe_type Meta.NotNull )
 ;;
 
+let is_object type_string =
+   not (is_numeric type_string || type_string="::String");
+;;
 
 
 
@@ -867,7 +873,7 @@ let gen_arg_type_name name default_val arg_type prefix =
    let type_str = (type_string arg_type) in
    match default_val with
    | Some TNull  -> (type_str,remap_name)
-   | Some constant when (cant_be_null type_str) -> ("hx::Null< " ^ type_str ^ " > ",prefix ^ remap_name)
+   | Some constant when (cant_be_null arg_type) -> ("hx::Null< " ^ type_str ^ " > ",prefix ^ remap_name)
    | Some constant  -> (type_str,prefix ^ remap_name)
    | _ -> (type_str,remap_name);;
 
@@ -1830,7 +1836,7 @@ and gen_expression ctx retval expression =
       | TInst (klass,[element]) ->
          ( match type_string element with
          | _ when is_struct_access element -> ()
-         | x when cant_be_null x -> ()
+         | x when cant_be_null element -> ()
          | _ when is_interface_type element -> ()
          | "::String" | "Dynamic" -> ()
          | real_type -> gen_array_cast cast_name real_type call
@@ -2411,9 +2417,14 @@ and gen_expression ctx retval expression =
       gen_expression ctx retval cast;
    | TCast (cast,None) ->
       let ret_type = type_string expression.etype in
-      output ("((" ^ ret_type ^ ")(");
-      gen_expression ctx true cast;
-      output "))";
+      let from_type = if is_dynamic_in_cpp ctx cast then "Dynamic" else type_string cast.etype in
+      if (from_type = ret_type) then begin
+         gen_expression ctx true cast
+      end else begin
+         output ("((" ^ ret_type ^ ")(");
+         gen_expression ctx true cast;
+         output "))";
+      end;
    | TCast (e1,Some t) ->
       let class_name = (join_class_path_remap (t_path t) "::" ) in
       if (class_name="Array") then
@@ -5559,13 +5570,13 @@ let generate_source common_ctx =
                | ([],"Array"), [t] -> "Array<" ^ (stype t) ^ ">"
                | (["haxe";"io"],"Unsigned_char__"),_ -> "uint8"
                | ([],"EnumValue"),_ -> "Dynamic"
-               | ([],"Null"),[t] when cant_be_null (type_string t) -> "Null<" ^ (stype t) ^ ">"
+               | ([],"Null"),[t] when cant_be_null t -> "Null<" ^ (stype t) ^ ">"
                | ([],"Null"),[t] -> (stype t)
                | _ -> spath klass.cl_path
                )
             | TType (type_def,params) ->
                (match type_def.t_path, params with
-               | ([],"Null"),[t] when cant_be_null (type_string t) -> "Null<" ^ (stype t) ^ ">"
+               | ([],"Null"),[t] when cant_be_null t -> "Null<" ^ (stype t) ^ ">"
                | ([],"Array"), [t] -> "Array< " ^ (stype (follow t) ) ^ " >"
                | _,_ ->  stype (apply_params type_def.t_params params type_def.t_type)
                )

+ 353 - 0
std/cpp/_std/haxe/Int64.hx

@@ -0,0 +1,353 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe;
+
+
+
+@:notNull
+
+@:native("cpp::Int64Struct")
+extern class __Int64 { public function get():cpp.Int64; }
+
+abstract Int64( __Int64 ) from __Int64 to __Int64
+{
+   /**
+		Makes a copy of `this` Int64.
+	**/
+	public #if !cppua inline #end function copy():Int64 return this;
+
+
+	public static #if !cppia inline #end function make( high : Int, low : Int ) : Int64 {
+      return untyped __cpp__("cpp::Int64Struct(( ( (cpp::Int64)((unsigned int){0}) ) << 32 ) | ((unsigned int){1}))",high, low);
+	}
+
+	@:from public static function ofInt( x : Int ) : Int64 {
+		return untyped __cpp__("((cpp::Int64)({0}))", x);
+	}
+
+
+	/**
+		Returns an Int with the value of the Int64 `x`.
+		Throws an exception  if `x` cannot be represented in 32 bits.
+	**/
+	public static #if !cppia inline #end function toInt( x : Int64 ) : Int {
+		if( x.high != x.low >> 31 )
+			throw "Overflow";
+
+		return x.low;
+	}
+
+	/**
+		Returns whether the value `val` is of type `haxe.Int64`
+	**/
+	public static #if !cppia inline #end function is( val : Dynamic ) : Bool
+      return untyped __cpp__("(cpp::Int64Struct::is({0}))",val);
+
+	/**
+		Returns the high 32-bit word of `x`.
+	**/
+	@:deprecated("Use high instead")
+	public static #if !cppia inline #end function getHigh( x : Int64 ) : Int32
+		return x.high;
+
+	/**
+		Returns the low 32-bit word of `x`.
+	**/
+	@:deprecated("Use low instead")
+	public static #if !cppia inline #end function getLow( x : Int64 ) : Int32
+		return x.low;
+
+	/**
+		Returns `true` if `x` is less than zero.
+	**/
+	public static #if !cppia inline #end function isNeg( x : Int64) : Bool
+		return untyped __cpp__("(({0}.get()) < 0)", x);
+
+	/**
+		Returns `true` if `x` is exactly zero.
+	**/
+	public static #if !cppia inline #end function isZero( x : Int64 ) : Bool
+		return untyped __cpp__("(({0}.get()) == 0)", x);
+
+	/**
+		Compares `a` and `b` in signed mode.
+		Returns a negative value if `a < b`, positive if `a > b`,
+		or 0 if `a == b`.
+	**/
+	public static #if !cppia inline #end function compare( a : Int64, b : Int64 ) : Int {
+		return untyped __cpp__("( ({0}.get()) < ({1}.get()) ? -1 : ({0})==({1}) ? 0 : 1)", a, b, a, b);
+	}
+
+	/**
+		Compares `a` and `b` in unsigned mode.
+		Returns a negative value if `a < b`, positive if `a > b`,
+		or 0 if `a == b`.
+	**/
+	public static #if !cppia inline #end function ucompare( a : Int64, b : Int64 ) : Int {
+		return untyped __cpp__("( (cpp::UInt64)({0}.get()) < (cpp::UInt64)({1}.get()) ? -1 : ({0}.get())==({1}.get()) ? 0 : 1)", a, b, a, b);
+	}
+
+	/**
+		Returns a signed decimal `String` representation of `x`.
+	**/
+	public static #if !cppia inline #end function toStr(x:Int64) : String
+		return x.toString();
+
+	private function toString() : String
+	{
+		return untyped __cpp__("String( ({0}).get() )", this);
+	}
+
+	/**
+		Performs signed integer divison of `dividend` by `divisor`.
+		Returns `{ quotient : Int64, modulus : Int64 }`.
+	**/
+	public static function divMod( dividend : Int64, divisor : Int64 ) : { quotient : Int64, modulus : Int64 }
+	{
+      var q = dividend/divisor;
+      
+      if (isZero(divisor))
+	       throw "divide by zero";
+
+      var m = dividend - q*divisor;
+
+      return { quotient : q, modulus : m };
+	}
+
+	/**
+		Returns the negative of `x`.
+	**/
+	@:op(-A) public static #if !cppia inline #end function neg( x : Int64 ) : Int64 {
+		return untyped __cpp__("(-({0}.get()))",x);
+	}
+
+	@:op(++A) private inline  function preIncrement() : Int64 {
+      #if cppia
+      this = this + make(0,1);
+      return this;
+      #else
+		return untyped __cpp__("(++({0}.get()))",this);
+      #end
+	}
+
+	@:op(A++) private inline function postIncrement() : Int64 {
+      #if cppia
+      var result = this;
+      this = this + make(0,1);
+      return result;
+      #else
+		return untyped __cpp__("(({0}.get())++)",this);
+      #end
+	}
+
+	@:op(--A) private inline function preDecrement() : Int64 {
+      #if cppia
+      untyped this = this - make(0,1);
+      return this;
+      #else
+		return untyped __cpp__("(--({0}.get()))",this);
+      #end
+	}
+
+	@:op(A--) private inline function postDecrement() : Int64 {
+      #if cppia
+      var result = this;
+      this = this - make(0,1);
+      return result;
+      #else
+		return untyped __cpp__("(({0}.get())--)",this);
+      #end
+	}
+
+	/**
+		Returns the sum of `a` and `b`.
+	**/
+	@:op(A + B) public static #if !cppia inline #end function add( a : Int64, b : Int64 ) : Int64 {
+		return untyped __cpp__("(({0}.get()) + ({1}.get()))", a, b);
+	}
+
+	@:op(A + B) @:commutative private static #if !cppia inline #end function addInt( a : Int64, b : Int ) : Int64
+		return add( a, b );
+
+	/**
+		Returns `a` minus `b`.
+	**/
+	@:op(A - B) public static #if !cppia inline #end function sub( a : Int64, b : Int64 ) : Int64 {
+		return untyped __cpp__("(({0}.get()) - ({1}.get()))", a, b);
+	}
+
+	@:op(A - B) private static #if !cppia inline #end function subInt( a : Int64, b : Int ) : Int64
+		return sub( a, b );
+
+	@:op(A - B) private static #if !cppia inline #end function intSub( a : Int, b : Int64 ) : Int64
+		return sub( a, b );
+
+	/**
+		Returns the product of `a` and `b`.
+	**/
+	@:op(A * B) public static #if !cppia inline #end function mul( a : Int64, b : Int64 ) : Int64 {
+		return untyped __cpp__("(({0}.get()) * ({1}.get()))", a, b);
+	}
+
+	@:op(A * B) @:commutative private static #if !cppia inline #end function mulInt( a : Int64, b : Int ) : Int64
+		return mul( a, b );
+
+	/**
+		Returns the quotient of `a` divided by `b`.
+	**/
+	@:op(A / B) public static function div( a : Int64, b : Int64 ) : Int64 {
+		if (untyped __cpp__("(({0}.get()) == 0)",b) )
+			throw "divide by zero";
+		return untyped __cpp__("(({0}.get()) / ({1}.get()))", a, b);
+	}
+
+
+	@:op(A / B) private static #if !cppia inline #end function divInt( a : Int64, b : Int ) : Int64
+		return div( a, b );
+
+	@:op(A / B) private static #if !cppia inline #end function intDiv( a : Int, b : Int64 ) : Int64
+		return toInt(div( a, b ));
+
+	/**
+		Returns the modulus of `a` divided by `b`.
+	**/
+	@:op(A % B) public static #if !cppia inline #end function mod( a : Int64, b : Int64 ) : Int64
+   {
+		if (untyped __cpp__("(({0}.get()) == 0)",b) )
+			throw "divide by zero";
+		return untyped __cpp__("(({0}.get()) % ({1}.get()))", a, b);
+   }
+
+	@:op(A % B) private static #if !cppia inline #end function modInt( a : Int64, b : Int ) : Int64
+		return toInt(mod( a, b ));
+
+	@:op(A % B) private static #if !cppia inline #end function intMod( a : Int, b : Int64 ) : Int64
+		return toInt(mod( a, b ));
+
+	/**
+		Returns `true` if `a` is equal to `b`.
+	**/
+	@:op(A == B) public static #if !cppia inline #end function eq( a : Int64, b : Int64 ) : Bool
+		return untyped __cpp__("(({0}.get()) == ({1}.get()))", a, b);
+
+	@:op(A == B) @:commutative private static #if !cppia inline #end function eqInt( a : Int64, b : Int ) : Bool
+		return eq( a, b );
+
+	/**
+		Returns `true` if `a` is not equal to `b`.
+	**/
+	@:op(A != B) public static #if !cppia inline #end function neq( a : Int64, b : Int64 ) : Bool
+		return untyped __cpp__("(({0}.get()) != ({1}.get()))", a, b);
+
+	@:op(A != B) @:commutative private static #if !cppia inline #end function neqInt( a : Int64, b : Int ) : Bool
+		return neq(a, b);
+
+	@:op(A < B) private static #if !cppia inline #end function lt( a : Int64, b : Int64 ) : Bool
+		return compare(a, b) < 0;
+
+	@:op(A < B) private static #if !cppia inline #end function ltInt( a : Int64, b : Int ) : Bool
+		return lt(a, b);
+
+	@:op(A < B) private static #if !cppia inline #end function intLt( a : Int, b : Int64 ) : Bool
+		return lt(a, b);
+
+	@:op(A <= B) private static #if !cppia inline #end function lte( a : Int64, b : Int64 ) : Bool
+		return compare(a, b) <= 0;
+
+	@:op(A <= B) private static #if !cppia inline #end function lteInt( a : Int64, b : Int ) : Bool
+		return lte(a, b);
+
+	@:op(A <= B) private static #if !cppia inline #end function intLte( a : Int, b : Int64 ) : Bool
+		return lte(a, b);
+
+	@:op(A > B) private static #if !cppia inline #end function gt( a : Int64, b : Int64 ) : Bool
+		return compare(a, b) > 0;
+
+	@:op(A > B) private static #if !cppia inline #end function gtInt( a : Int64, b : Int ) : Bool
+		return gt(a, b);
+
+	@:op(A > B) private static #if !cppia inline #end function intGt( a : Int, b : Int64 ) : Bool
+		return gt( a, b );
+
+	@:op(A >= B) private static #if !cppia inline #end function gte( a : Int64, b : Int64 ) : Bool
+		return compare(a, b) >= 0;
+
+	@:op(A >= B) private static #if !cppia inline #end function gteInt( a : Int64, b : Int ) : Bool
+		return gte(a, b);
+
+	@:op(A >= B) private static #if !cppia inline #end function intGte( a : Int, b : Int64 ) : Bool
+		return gte(a, b);
+
+	/**
+		Returns the bitwise NOT of `a`.
+	**/
+	@:op(~A) private static #if !cppia inline #end function complement( a : Int64 ) : Int64
+		return untyped __cpp__("(~({0}.get()))", a);
+
+	/**
+		Returns the bitwise AND of `a` and `b`.
+	**/
+	@:op(A & B) public static #if !cppia inline #end function and( a : Int64, b : Int64 ) : Int64
+		return untyped __cpp__("(({0}) & ({1}))", a, b);
+
+	/**
+		Returns the bitwise OR of `a` and `b`.
+	**/
+	@:op(A | B) public static #if !cppia inline #end function or( a : Int64, b : Int64 ) : Int64
+		return untyped __cpp__("(({0}) | ({1}))", a, b);
+
+	/**
+		Returns the bitwise XOR of `a` and `b`.
+	**/
+	@:op(A ^ B) public static #if !cppia inline #end function xor( a : Int64, b : Int64 ) : Int64
+		return untyped __cpp__("(({0}) ^ ({1}))", a, b);
+
+	/**
+		Returns `a` left-shifted by `b` bits.
+	**/
+	@:op(A << B) public static #if !cppia inline #end function shl( a : Int64, b : Int ) : Int64
+		return untyped __cpp__("(({0}) << ({1}))", a, (b&63));
+
+	/**
+		Returns `a` right-shifted by `b` bits in signed mode.
+		`a` is sign-extended.
+	**/
+	@:op(A >> B) public static #if !cppia inline #end function shr( a : Int64, b : Int) : Int64
+		return untyped __cpp__("(({0}) >> ({1}))", a, (b&63));
+
+	/**
+		Returns `a` right-shifted by `b` bits in unsigned mode.
+		`a` is padded with zeroes.
+	**/
+	@:op(A >>> B) public static #if !cppia inline #end function ushr( a : Int64, b : Int ) : Int64
+		return untyped __cpp__("(((cpp::UInt64)({0})) >> ({1}))", a, (b&63));
+
+	public var high(get, never) : Int32;
+	private #if !cppia inline #end function get_high() : Int32
+		return  untyped __cpp__("(int)(((cpp::Int64)({0}))>>32)",this);
+
+	public var low(get, never) : Int32;
+	private #if !cppia inline #end function get_low() : Int32
+		return untyped __cpp__("(int)(({0})&0xffffffff)", this);
+
+}
+

+ 0 - 139
std/cpp/_std/haxe/Int64.hx2

@@ -1,139 +0,0 @@
-/*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-package haxe;
-
-
-
-@:native("cpp::Struct< cpp::Int64 >")
-extern class Int64Struct { }
-
-abstract Int64( Int64Struct )
-{
-   public function toString() : String {
-		return untyped __cpp__("String( (cpp::Int64)({0}) )", this);
-  }
-
-	public static inline function make( high : Int, low : Int ) : Int64 {
-      return untyped __cpp__("cpp::Struct< cpp::Int64 >(( ( (cpp::Int64)((unsigned int){0}) ) << 32 ) | ((unsigned int){1}))",high, low);
-	}
-
-	public static inline function ofInt( x : Int ) : Int64 {
-		return untyped __cpp__("((cpp::Int64)({0}))", x);
-	}
-
-	public static function toInt( x : Int64 ) : Int {
-		var high = getHigh(x);
-		if( high != 0 ) {
-			if( high < 0 )
-				return -toInt(neg(x));
-			throw "Overflow";
-		}
-		return getLow(x);
-	}
-
-	public static inline function neg( a : Int64 ) : Int64 {
-		return untyped __cpp__("(-({0}))",a);
-	}
-
-
-	public static inline function getLow( x : Int64 ) : Int {
-		return untyped __cpp__("(int)(({0})&0xffffffff)",x);
-	}
-
-	public static function getHigh( x : Int64 ) : Int {
-		return  untyped __cpp__("((cpp::Int64)({0}))>>32",x);
-	}
-
-	public static inline function add( a : Int64, b : Int64 ) : Int64 {
-		return untyped __cpp__("(({0}) + ({1}))", a, b);
-	}
-
-	public static function sub( a : Int64, b : Int64 ) : Int64 {
-		return untyped __cpp__("(({0}) - ({1}))", a, b);
-	}
-
-	public static function mul( a : Int64, b : Int64 ) : Int64 {
-		return untyped __cpp__("(({0}) * ({1}))", a, b);
-	}
-
-	public static function div( a : Int64, b : Int64 ) : Int64 {
-		if (untyped __cpp__("(({0}) == 0)",b) )
-			throw "divide by zero";
-		return untyped __cpp__("(({0}) / ({1}))", a, b);
-	}
-
-	public static function mod( a : Int64, b : Int64 ) : Int64 {
-		if (untyped __cpp__("(({0}) == 0)",b) )
-			throw "divide by zero";
-		return untyped __cpp__("(({0}) % ({1}))", a, b);
-	}
-
-	public static inline function shl( a : Int64, b : Int ) : Int64 {
-		return untyped __cpp__("(({0}) << ({1}))", a, b);
-	}
-
-	public static inline function shr( a : Int64, b : Int ) : Int64 {
-		return untyped __cpp__("(({0}) << ({1}))", a, b);
-	}
-
-	public static inline function ushr( a : Int64, b : Int ) : Int64 {
-		return untyped __cpp__("(((cpp::UInt64)({0})) >> ({1}))", a, b);
-	}
-
-	public static inline function and( a : Int64, b : Int64 ) : Int64 {
-		return untyped __cpp__("(({0}) & ({1}))", a, b);
-	}
-
-	public static inline function or( a : Int64, b : Int64 ) : Int64 {
-		return untyped __cpp__("(({0}) | ({1}))", a, b);
-	}
-
-	public static inline function xor( a : Int64, b : Int64 ) : Int64 {
-		return untyped __cpp__("(({0}) ^ ({1}))", a, b);
-	}
-
-
-	public static inline function isNeg( a : Int64 ) : Bool {
-		return untyped __cpp__("(({0}) < 0)", a);
-	}
-
-	public static inline function isZero( a : Int64 ) : Bool {
-		return untyped __cpp__("(({0}) == 0)", a);
-	}
-
-	public static function compare( a : Int64, b : Int64 ) : Int {
-		return untyped __cpp__("( ({0}) < ({1}) ? -1 : ({0})==({1}) ? 0 : 1)", a, b, a, b);
-	}
-
-	/**
-		Compare two Int64 in unsigned mode.
-	**/
-	public static function ucompare( a : Int64, b : Int64 ) : Int {
-		return untyped __cpp__("( (cpp::UInt64)({0}) < (cpp::UInt64)({1}) ? -1 : ({0})==({1}) ? 0 : 1)", a, b, a, b);
-	}
-
-	public static function toStr( a : Int64 ) : String {
-		return untyped __cpp__("String( (cpp::Int64)({0}) )", a);
-	}
-
-}
-