Browse Source

fixes in core api method parameters names

Nicolas Cannasse 15 years ago
parent
commit
50c4117f83
11 changed files with 95 additions and 88 deletions
  1. 17 17
      std/Math.hx
  2. 2 2
      std/String.hx
  3. 1 1
      std/Xml.hx
  4. 2 2
      std/cpp/_std/Xml.hx
  5. 27 27
      std/flash/_std/Xml.hx
  6. 11 11
      std/neko/_std/Array.hx
  7. 15 15
      std/neko/_std/Math.hx
  8. 10 10
      std/neko/_std/String.hx
  9. 2 2
      std/neko/_std/Xml.hx
  10. 1 1
      std/php/_std/Math.hx
  11. 7 0
      typeload.ml

+ 17 - 17
std/Math.hx

@@ -33,23 +33,23 @@ extern class Math
 	static var NEGATIVE_INFINITY(default,null) : Float;
 	static var POSITIVE_INFINITY(default,null) : Float;
 
-	static function abs(value:Float):Float;
-	static function min(value1:Float,value2:Float):Float;
-	static function max(value1:Float,value2:Float):Float;
-	static function sin(value:Float):Float;
-	static function cos(value:Float):Float;
-	static function atan2(value1:Float,value2:Float):Float;
-	static function tan(value:Float):Float;
-	static function exp(value:Float):Float;
-	static function log(value:Float):Float;
-	static function sqrt(value:Float):Float;
-	static function round(value:Float):Int;
-	static function floor(value:Float):Int;
-	static function ceil(value:Float):Int;
-	static function atan(value:Float):Float;
-	static function asin(value:Float):Float;
-	static function acos(value:Float):Float;
-	static function pow(value1:Float,value2:Float):Float;
+	static function abs(v:Float):Float;
+	static function min(a:Float,b:Float):Float;
+	static function max(a:Float,b:Float):Float;
+	static function sin(v:Float):Float;
+	static function cos(v:Float):Float;
+	static function atan2(y:Float,x:Float):Float;
+	static function tan(v:Float):Float;
+	static function exp(v:Float):Float;
+	static function log(v:Float):Float;
+	static function sqrt(v:Float):Float;
+	static function round(v:Float):Int;
+	static function floor(v:Float):Int;
+	static function ceil(v:Float):Int;
+	static function atan(v:Float):Float;
+	static function asin(v:Float):Float;
+	static function acos(v:Float):Float;
+	static function pow(v:Float,exp:Float):Float;
 	static function random() : Float;
 
 	static function isFinite( f : Float ) : Bool;

+ 2 - 2
std/String.hx

@@ -66,12 +66,12 @@ extern class String {
 		The optional [startIndex] parameter allows you to specify at which character to start searching.
 		The position returned is still relative to the beginning of the string.
 	**/
-	function indexOf( value : String, ?startIndex : Int ) : Int;
+	function indexOf( str : String, ?startIndex : Int ) : Int;
 
 	/**
 		Similar to [indexOf] but returns the latest index.
 	**/
-	function lastIndexOf( value : String, ?startIndex : Int ) : Int;
+	function lastIndexOf( str : String, ?startIndex : Int ) : Int;
 
 	/**
 		Split the string using the specified delimiter.

+ 1 - 1
std/Xml.hx

@@ -80,7 +80,7 @@ extern class Xml {
 	/**
 		Parse a String into an Xml object.
 	**/
-	static function parse( s : String ) : Xml;
+	static function parse( str : String ) : Xml;
 
 	/**
 		Creates a node of the given type.

+ 2 - 2
std/cpp/_std/Xml.hx

@@ -47,7 +47,7 @@ enum XmlType {
 
 	private static var _parse = cpp.Lib.load("std","parse_xml",2);
 
-	public static function parse( xmlData : String ) : Xml {
+	public static function parse( str : String ) : Xml {
 		var x = new Xml();
 		x._children = new Array();
 		var parser = {
@@ -104,7 +104,7 @@ enum XmlType {
 				untyped this.cur = this.cur._parent;
 			}
 		};
-		untyped _parse(xmlData,parser);
+		untyped _parse(str,parser);
 		x.nodeType = Xml.Document;
 		return x;
 	}

+ 27 - 27
std/flash/_std/Xml.hx

@@ -64,9 +64,9 @@ enum XmlType {
 		return untyped r;
 	}
 
-	public static function parse( xmlData : String ) : Xml untyped {
+	public static function parse( str : String ) : Xml untyped {
 		var x = __new__(_global["XML"]);
-		x["parseXML"](xmlData);
+		x["parseXML"](str);
 		if( x["status"] != 0 )
 			throw ("Xml parse error #"+x["status"]);
 
@@ -83,36 +83,36 @@ enum XmlType {
 		return r;
 	}
 
-	public static function createCData( s : String ) : Xml {
-		var o = untyped __new__(_global["XML"])["createTextNode"]( s );
+	public static function createCData( data : String ) : Xml {
+		var o = untyped __new__(_global["XML"])["createTextNode"]( data );
 		var x = convert(o);
 		untyped x.nodeType = Xml.CData;
 		return x;
 	}
 
-	public static function createPCData( s : String ) : Xml {
-		var o = untyped __new__(_global["XML"])["createTextNode"]( s );
+	public static function createPCData( data : String ) : Xml {
+		var o = untyped __new__(_global["XML"])["createTextNode"]( data );
 
 		return convert(o);
 	}
 
-	public static function createElement( s : String ) : Xml {
-		var o = untyped __new__(_global["XML"])["createElement"]( s );
+	public static function createElement( name : String ) : Xml {
+		var o = untyped __new__(_global["XML"])["createElement"]( name );
 
 		return convert(o);
 	}
 
-	public static function createComment( s : String ) : Xml {
+	public static function createComment( data : String ) : Xml {
 		throw "not implemented";
 		return null;
 	}
 
-	public static function createDocType( s : String ) : Xml {
+	public static function createDocType( data : String ) : Xml {
 		throw "not implemented";
 		return null;
 	}
 
-	public static function createProlog( s : String ) : Xml {
+	public static function createProlog( data : String ) : Xml {
 		throw "not implemented";
 		return null;
 	}
@@ -201,21 +201,21 @@ enum XmlType {
 		}
 	}
 
-	public function elementsNamed( nodeName : String ) : Iterator<Xml> {
+	public function elementsNamed( name : String ) : Iterator<Xml> {
 		if( nodeType != Xml.Document && nodeType != Xml.Element )
 			throw "bad nodeType";
 		return untyped {
 			cur: this.__x[untyped "firstChild"],
 			hasNext : function() {
 				var r = this.cur;
-				while( r != null && (r["nodeType"] != 1 || r["nodeName"] != nodeName) )
+				while( r != null && (r["nodeType"] != 1 || r["nodeName"] != name) )
 					r = r["nextSibling"];
 				this.cur = r;
 				return r != null;
 			},
 			next : function(){
 				var r = this.cur;
-				while( r != null && (r["nodeType"] != 1 || r["nodeName"] != nodeName) )
+				while( r != null && (r["nodeType"] != 1 || r["nodeName"] != name) )
 					r = r["nextSibling"];
 				if( r == null ) {
 					this.cur = null;
@@ -227,28 +227,28 @@ enum XmlType {
 		}
 	}
 
-	public function get( k : String ) : String {
+	public function get( att : String ) : String {
 		if( nodeType != Xml.Element )
 			throw "bad nodeType";
-		return Reflect.field(__x[untyped "attributes"],k);
+		return Reflect.field(__x[untyped "attributes"],att);
 	}
 
-	public function set( k : String, v : String ) : Void {
+	public function set( att : String, value : String ) : Void {
 		if( nodeType != Xml.Element )
 			throw "bad nodeType";
-		return Reflect.setField(__x[untyped "attributes"],k,v);
+		return Reflect.setField(__x[untyped "attributes"],att,value);
 	}
 
-	public function exists( k : String ) : Bool {
+	public function exists( att : String ) : Bool {
 		if( nodeType != Xml.Element )
 			throw "bad nodeType";
-		return Reflect.hasField(__x[untyped "attributes"],k);
+		return Reflect.hasField(__x[untyped "attributes"],att);
 	}
 
-	public function remove( k : String ) : Void {
+	public function remove( att : String ) : Void {
 		if( nodeType != Xml.Element )
 			throw "bad nodeType";
-		Reflect.deleteField(__x[untyped "attributes"],k);
+		Reflect.deleteField(__x[untyped "attributes"],att);
 	}
 
 	public function attributes() : Iterator<String> {
@@ -257,18 +257,18 @@ enum XmlType {
 		return untyped __keys__(__x["attributes"])["iterator"]();
 	}
 
-	public function addChild( child : Xml ) : Void {
+	public function addChild( x : Xml ) : Void {
 		if( nodeType != Xml.Document && nodeType != Xml.Element )
 			throw "bad nodeType";
-		untyped __x[untyped "appendChild"](child.__x);
+		untyped __x[untyped "appendChild"](x.__x);
 	}
 
-	public function removeChild( child : Xml ) : Bool {
+	public function removeChild( x : Xml ) : Bool {
 		if( nodeType != Xml.Document && nodeType != Xml.Element )
 			throw "bad nodeType";
-		untyped if( child.__x["parentNode"] != __x )
+		untyped if( x.__x["parentNode"] != __x )
 			return false;
-		untyped child.__x["removeNode"]();
+		untyped x.__x["removeNode"]();
 		return true;
 	}
 

+ 11 - 11
std/neko/_std/Array.hx

@@ -40,11 +40,11 @@
 		return inst;
 	}
 
-	public function concat(arr : Array<T>) : Array<T> {
+	public function concat( a : Array<T>) : Array<T> {
 		var a1 = this.__a;
-		var a2 = arr.__a;
+		var a2 = a.__a;
 		var s1 = this.length;
-		var s2 = arr.length;
+		var s2 = a.length;
 		var a = neko.NativeArray.alloc(s1+s2);
 		neko.NativeArray.blit(a,0,a1,0,s1);
 		neko.NativeArray.blit(a,s1,a2,0,s2);
@@ -83,14 +83,14 @@
 		a[pos] = x;
 	}
 
-	public function join(delim : String) : String {
+	public function join( sep : String ) : String {
 		var s = new StringBuf();
 		var a = this.__a;
 		var max = this.length - 1;
 		for( p in 0...this.length ) {
 			s.add(a[p]);
 			if( p != max )
-				s.add(delim);
+				s.add(sep);
 		}
 		return s.toString();
 	}
@@ -117,27 +117,27 @@
 		return x;
 	}
 
-	public function push(v:T) : Int {
+	public function push(x:T) : Int {
 		var l = this.length;
 		this.__double(l + 1);
-		this.__a[l] = v;
+		this.__a[l] = x;
 		return l + 1;
 	}
 
-	public function unshift(v : T) : Void {
+	public function unshift(x : T) : Void {
 		var l = this.length;
 		this.__double(l + 1);
 		var a = this.__a;
 		neko.NativeArray.blit(a,1,a,0,l);
-		a[0] = v;
+		a[0] = x;
 	}
 
-	public function remove(v : T) : Bool {
+	public function remove(x : T) : Bool {
 		var i = 0;
 		var l = this.length;
 		var a = this.__a;
 		while( i < l ) {
-			if( a[i] == v ) {
+			if( a[i] == x ) {
 				neko.NativeArray.blit(a,i,a,i+1,l - i - 1);
 				l -= 1;
 				this.length = l;

+ 15 - 15
std/neko/_std/Math.hx

@@ -34,21 +34,21 @@ import neko.Lib;
 	public static function min(a:Float,b:Float) : Float { return if( a < b ) a else b; }
 	public static function max(a:Float,b:Float) : Float { return if( a < b ) b else a; }
 
-	public static function abs( f : Float ) : Float return 0.
-	public static function sin( f : Float ) : Float return 0.
-	public static function cos( f : Float ) : Float return 0.
-	public static function atan2( dy : Float, dx : Float ) : Float return 0.
-	public static function tan( f : Float ) : Float return 0.
-	public static function exp( f : Float ) : Float return 0.
-	public static function log( f : Float ) : Float return 0.
-	public static function sqrt( f : Float ) : Float return 0.
-	public static function round( f : Float ) : Int return 0
-	public static function floor( f : Float ) : Int return 0
-	public static function ceil( f : Float ) : Int return 0
-	public static function atan( f : Float ) : Float return 0.
-	public static function asin( f : Float ) : Float return 0.
-	public static function acos( f : Float ) : Float return 0.
-	public static function pow( f : Float, p : Float ) : Float return 0.
+	public static function abs( v : Float ) : Float return 0.
+	public static function sin( v : Float ) : Float return 0.
+	public static function cos( v : Float ) : Float return 0.
+	public static function atan2( y : Float, x : Float ) : Float return 0.
+	public static function tan( v : Float ) : Float return 0.
+	public static function exp( v : Float ) : Float return 0.
+	public static function log( v : Float ) : Float return 0.
+	public static function sqrt( v : Float ) : Float return 0.
+	public static function round( v : Float ) : Int return 0
+	public static function floor( v : Float ) : Int return 0
+	public static function ceil( v : Float ) : Int return 0
+	public static function atan( v : Float ) : Float return 0.
+	public static function asin( v : Float ) : Float return 0.
+	public static function acos( v : Float ) : Float return 0.
+	public static function pow( v : Float, exp : Float ) : Float return 0.
 
 	static var __rnd;
 	static var _rand_float = Lib.load("std","random_float",1);

+ 10 - 10
std/neko/_std/String.hx

@@ -43,11 +43,11 @@
 		}
 	}
 
-	public function charAt(p:Int) : String {
+	public function charAt(index:Int) : String {
 		untyped {
 			try {
 				var s = __dollar__smake(1);
-				__dollar__sset(s,0,__dollar__sget(this.__s,p));
+				__dollar__sset(s,0,__dollar__sget(this.__s,index));
 				return new String(s);
 			} catch( e : Dynamic ) {
 				return "";
@@ -55,13 +55,13 @@
 		}
 	}
 
-	public function charCodeAt(p : Int) : Null<Int> {
+	public function charCodeAt(index : Int) : Null<Int> {
 		untyped {
-			return __dollar__sget(this.__s,p);
+			return __dollar__sget(this.__s,index);
 		}
 	}
 
-	public function indexOf( str : String, ?pos : Int ) : Int {
+	public function indexOf( str : String, ?startIndex : Int ) : Int {
 		untyped {
 			var p = try __dollar__sfind(this.__s,if( pos == null ) 0 else pos,str.__s) catch( e : Dynamic ) null;
 			if( p == null )
@@ -70,7 +70,7 @@
 		}
 	}
 
-	public function lastIndexOf( str : String, ?pos : Int ) : Int {
+	public function lastIndexOf( str : String, ?startIndex : Int ) : Int {
 		untyped {
 			var last = -1;
 			if( pos == null )
@@ -85,9 +85,9 @@
 		}
 	}
 
-	public function split( delim : String ) : Array<String> {
+	public function split( delimiter : String ) : Array<String> {
 		untyped {
-			var l = __split(this.__s,delim.__s);
+			var l = __split(this.__s,delimiter.__s);
 			var a = new Array<String>();
 			if( l == null ) {
 				a.push("");
@@ -177,9 +177,9 @@
 		return new String(untyped __dollar__string(s)+this.__s);
 	}
 
-	public static function fromCharCode( c : Int ) : String untyped {
+	public static function fromCharCode( code : Int ) : String untyped {
 		var s = __dollar__smake(1);
-		__dollar__sset(s,0,c);
+		__dollar__sset(s,0,code);
 		return new String(s);
 	}
 

+ 2 - 2
std/neko/_std/Xml.hx

@@ -53,7 +53,7 @@ enum XmlType {
 
 	private static var _parse = neko.Lib.load("std","parse_xml",2);
 
-	public static function parse( xmlData : String ) : Xml {
+	public static function parse( str : String ) : Xml {
 		var x = new Xml();
 		x._children = new Array();
 		var parser = {
@@ -116,7 +116,7 @@ enum XmlType {
 				untyped this.cur = this.cur._parent;
 			}
 		};
-		untyped _parse(xmlData.__s,parser);
+		untyped _parse(str.__s,parser);
 		x.nodeType = Xml.Document;
 		return x;
 	}

+ 1 - 1
std/php/_std/Math.hx

@@ -46,7 +46,7 @@
 	public static function atan(v : Float) : Float     { return untyped __call__("atan", v); }
 	public static function asin(v : Float) : Float     { return untyped __call__("asin", v); }
 	public static function acos(v : Float) : Float     { return untyped __call__("acos", v); }
-	public static function pow(b : Float,e : Float) : Float    { return untyped __call__("pow", b, e); }
+	public static function pow(v : Float,exp : Float) : Float    { return untyped __call__("pow", v, exp); }
 	public static function random() : Float    { return untyped __call__("mt_rand") / __call__("mt_getrandmax"); }
 	public static function isNaN(f : Float) : Bool     { return untyped __call__("is_nan", f); }
 	public static function isFinite(f : Float) : Bool  { return untyped __call__("is_finite", f); }

+ 7 - 0
typeload.ml

@@ -605,6 +605,13 @@ let init_core_api ctx c =
 					| _ ->
 						error ("Field " ^ i ^ " has different property access than core type") p;
 				end;
+				(match follow f.cf_type, follow f2.cf_type with
+				| TFun (pl1,_), TFun (pl2,_) ->
+					if List.length pl1 != List.length pl2 then assert false;
+					List.iter2 (fun (n1,_,_) (n2,_,_) -> 
+						if n1 <> n2 then error ("Method parameter name '" ^ n2 ^ "' should be '" ^ n1 ^ "'") p;
+					) pl1 pl2;
+				| _ -> ());
 			) fcore;
 			PMap.iter (fun i f ->
 				let p = (match f.cf_expr with None -> c.cl_pos | Some e -> e.epos) in