Browse Source

generate overloads as children of parent field

Simon Krajewski 12 years ago
parent
commit
2e4736d2b1
3 changed files with 17 additions and 1 deletions
  1. 5 1
      genxml.ml
  2. 1 0
      std/haxe/rtti/CType.hx
  3. 11 0
      std/haxe/rtti/XmlParser.hx

+ 5 - 1
genxml.ml

@@ -125,7 +125,11 @@ and gen_field att f =
 			| MethInline -> ("get", "inline") :: ("set","null") :: att)
 	) in
 	let att = (match f.cf_params with [] -> att | l -> ("params", String.concat ":" (List.map (fun (n,_) -> n) l)) :: att) in
-	node f.cf_name (if f.cf_public then ("public","1") :: att else att) (gen_type f.cf_type :: gen_meta f.cf_meta @ gen_doc_opt f.cf_doc)
+	let overloads = match List.map (gen_field []) f.cf_overloads with
+		| [] -> []
+		| nl -> [node "overloads" [] nl]
+	in
+	node f.cf_name (if f.cf_public then ("public","1") :: att else att) (gen_type f.cf_type :: gen_meta f.cf_meta @ gen_doc_opt f.cf_doc @ overloads)
 
 let gen_constr e =
 	let doc = gen_doc_opt e.ef_doc in

+ 1 - 0
std/haxe/rtti/CType.hx

@@ -66,6 +66,7 @@ typedef ClassField = {
 	var platforms : Platforms;
 	var meta : MetaData;
 	var line : Null<Int>;
+	var overloads : Null<List<ClassField>>;
 }
 
 typedef TypeInfos = {

+ 11 - 0
std/haxe/rtti/XmlParser.hx

@@ -332,6 +332,14 @@ class XmlParser {
 		}
 		return ml;
 	}
+	
+	function xoverloads( x : Fast ) : List<ClassField> {
+		var l = new List();
+		for ( m in x.elements ) {
+			l.add(xclassfield(m));
+		}
+		return l;
+	}
 
 	function xpath( x : Fast ) : PathParams {
 		var path = mkPath(x.att.path);
@@ -389,10 +397,12 @@ class XmlParser {
 		var t = xtype(e.next());
 		var doc = null;
 		var meta = [];
+		var overloads = null;
 		for( c in e )
 			switch( c.name ) {
 			case "haxe_doc": doc = c.innerData;
 			case "meta": meta = xmeta(c);
+			case "overloads": overloads = xoverloads(c);
 			default: xerror(c);
 			}
 		return {
@@ -407,6 +417,7 @@ class XmlParser {
 			params : if( x.has.params ) mkTypeParams(x.att.params) else null,
 			platforms : defplat(),
 			meta : meta,
+			overloads: overloads
 		};
 	}