Browse Source

updated xml output and html doc - add inline, override, dynamic functions support

Nicolas Cannasse 16 years ago
parent
commit
ae2b1a76d3
5 changed files with 34 additions and 26 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 8 10
      genxml.ml
  3. 6 4
      std/haxe/rtti/CType.hx
  4. 4 2
      std/haxe/rtti/XmlParser.hx
  5. 15 10
      std/tools/haxedoc/HtmlPrinter.hx

+ 1 - 0
doc/CHANGES.txt

@@ -3,6 +3,7 @@
 	js : added js.Scroll
 	js : added js.Scroll
 	js : package names are now checked at runtime to avoid clashes with existing libs
 	js : package names are now checked at runtime to avoid clashes with existing libs
 	js : added --js-namespace to create a namespace for types that are defined in the root
 	js : added --js-namespace to create a namespace for types that are defined in the root
+	all : updated xml output and html doc - add inline, override, dynamic functions support
 
 
 2009-07-26: 2.04
 2009-07-26: 2.04
 	flash9 : fixed get_full_path error with -D fdb
 	flash9 : fixed get_full_path error with -D fdb

+ 8 - 10
genxml.ml

@@ -85,16 +85,14 @@ let gen_constr e =
 let gen_field att f =
 let gen_field att f =
 	let add_get_set acc name att =
 	let add_get_set acc name att =
 		match acc with
 		match acc with
-		| NormalAccess | ResolveAccess | MethodAccess _  -> att
+		| NormalAccess | ResolveAccess -> att
+		| MethodAccess dyn -> (name, if dyn then "dynamic" else "method") :: att 
 		| NoAccess | NeverAccess -> (name, "null") :: att
 		| NoAccess | NeverAccess -> (name, "null") :: att
-		| CallAccess m -> (name, if m = name ^ "_" ^ f.cf_name then "dynamic" else m) :: att
-		| InlineAccess -> assert false
+		| CallAccess m -> (name,m) :: att
+		| InlineAccess -> (name,"inline") :: att
 	in
 	in
 	let att = (match f.cf_expr with None -> att | Some e -> ("line",string_of_int (Lexer.get_error_line e.epos)) :: att) in
 	let att = (match f.cf_expr with None -> att | Some e -> ("line",string_of_int (Lexer.get_error_line e.epos)) :: att) in
-	let att = (match f.cf_get with
-		| InlineAccess -> att
-		| g -> add_get_set f.cf_get "get" (add_get_set f.cf_set "set" att)
-	) in
+	let att = add_get_set f.cf_get "get" (add_get_set f.cf_set "set" att) in	
 	let att = (match f.cf_params with [] -> att | l -> ("params", String.concat ":" (List.map (fun (n,_) -> n) l)) :: 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_doc_opt f.cf_doc)
 	node f.cf_name (if f.cf_public then ("public","1") :: att else att) (gen_type f.cf_type :: gen_doc_opt f.cf_doc)
 
 
@@ -122,10 +120,10 @@ let gen_type_decl com t =
 	| TClassDecl c ->
 	| TClassDecl c ->
 		let stats = List.map (gen_field ["static","1"]) c.cl_ordered_statics in
 		let stats = List.map (gen_field ["static","1"]) c.cl_ordered_statics in
 		let fields = (match c.cl_super with
 		let fields = (match c.cl_super with
-			| None -> c.cl_ordered_fields
-			| Some (csup,_) -> List.filter (fun f -> exists f csup) c.cl_ordered_fields
+			| None -> List.map (fun f -> f,[]) c.cl_ordered_fields
+			| Some (csup,_) -> List.map (fun f -> if exists f csup then (f,["override","1"]) else (f,[])) c.cl_ordered_fields
 		) in
 		) in
-		let fields = List.map (gen_field []) fields in
+		let fields = List.map (fun (f,att) -> gen_field att f) fields in
 		let constr = (match c.cl_constructor with None -> [] | Some f -> [gen_field [] f]) in
 		let constr = (match c.cl_constructor with None -> [] | Some f -> [gen_field [] f]) in
 		let impl = List.map (gen_class_path "implements") c.cl_implements in
 		let impl = List.map (gen_class_path "implements") c.cl_implements in
 		let tree = (match c.cl_super with
 		let tree = (match c.cl_super with

+ 6 - 4
std/haxe/rtti/CType.hx

@@ -48,15 +48,17 @@ typedef TypeParams = Array<String> // no contraints
 enum Rights {
 enum Rights {
 	RNormal;
 	RNormal;
 	RNo;
 	RNo;
-	RMethod( m : String );
+	RCall( m : String );
+	RMethod;
 	RDynamic;
 	RDynamic;
-	RF9Dynamic;
+	RInline;
 }
 }
 
 
 typedef ClassField = {
 typedef ClassField = {
 	var name : String;
 	var name : String;
 	var type : CType;
 	var type : CType;
 	var isPublic : Bool;
 	var isPublic : Bool;
+	var isOverride : Bool;
 	var doc : String;
 	var doc : String;
 	var get : Rights;
 	var get : Rights;
 	var set : Rights;
 	var set : Rights;
@@ -147,9 +149,9 @@ class TypeApi {
 		if( r1 == r2 )
 		if( r1 == r2 )
 			return true;
 			return true;
 		switch( r1 ) {
 		switch( r1 ) {
-		case RMethod(m1):
+		case RCall(m1):
 			switch( r2 ) {
 			switch( r2 ) {
-			case RMethod(m2):
+			case RCall(m2):
 				return m1 == m2;
 				return m1 == m2;
 			default:
 			default:
 			}
 			}

+ 4 - 2
std/haxe/rtti/XmlParser.hx

@@ -228,9 +228,10 @@ class XmlParser {
 	function mkRights( r : String ) : Rights {
 	function mkRights( r : String ) : Rights {
 		return switch( r ) {
 		return switch( r ) {
 		case "null": RNo;
 		case "null": RNo;
+		case "method": RMethod;
 		case "dynamic": RDynamic;
 		case "dynamic": RDynamic;
-		case "f9dynamic": RF9Dynamic;
-		default: RMethod(r);
+		case "inline": RInline;
+		default: RCall(r);
 		}
 		}
 	}
 	}
 
 
@@ -314,6 +315,7 @@ class XmlParser {
 			name : x.name,
 			name : x.name,
 			type : t,
 			type : t,
 			isPublic : x.x.exists("public"),
 			isPublic : x.x.exists("public"),
+			isOverride : x.x.exists("override"),
 			doc : doc,
 			doc : doc,
 			get : if( x.has.get ) mkRights(x.att.get) else RNormal,
 			get : if( x.has.get ) mkRights(x.att.get) else RNormal,
 			set : if( x.has.set ) mkRights(x.att.set) else RNormal,
 			set : if( x.has.set ) mkRights(x.att.set) else RNormal,

+ 15 - 10
std/tools/haxedoc/HtmlPrinter.hx

@@ -235,7 +235,7 @@ class HtmlPrinter {
 	}
 	}
 
 
 	function processClassField(platforms : Platforms,f : ClassField,stat) {
 	function processClassField(platforms : Platforms,f : ClassField,stat) {
-		if( !f.isPublic )
+		if( !f.isPublic || f.isOverride )
 			return;
 			return;
 		var oldParams = typeParams;
 		var oldParams = typeParams;
 		if( f.params != null )
 		if( f.params != null )
@@ -243,12 +243,15 @@ class HtmlPrinter {
 		print('<dt>');
 		print('<dt>');
 		if( stat ) keyword("static");
 		if( stat ) keyword("static");
 		var isMethod = false;
 		var isMethod = false;
+		var isInline = (f.get == RInline && f.set == RNo);
 		switch( f.type ) {
 		switch( f.type ) {
 		case CFunction(args,ret):
 		case CFunction(args,ret):
-			if( f.get == RNormal && (f.set == RNormal || f.set == RF9Dynamic) ) {
+			if( (f.get == RNormal && (f.set == RMethod || f.set == RDynamic)) || isInline ) {
 				isMethod = true;
 				isMethod = true;
-				if( f.set == RF9Dynamic )
-					keyword("f9dynamic");
+				if( f.set == RDynamic )
+					keyword("dynamic");
+				if( isInline )
+					keyword("inline");
 				keyword("function");
 				keyword("function");
 				print(f.name);
 				print(f.name);
 				if( f.params != null )
 				if( f.params != null )
@@ -270,10 +273,12 @@ class HtmlPrinter {
 		default:
 		default:
 		}
 		}
 		if( !isMethod ) {
 		if( !isMethod ) {
+			if( isInline )
+				keyword("inline");
 			keyword("var");
 			keyword("var");
 			print(f.name);
 			print(f.name);
-			if( f.get != RNormal || f.set != RNormal )
-				print("("+rightsStr(f.get)+","+rightsStr(f.set)+")");
+			if( !isInline && (f.get != RNormal || f.set != RNormal) )
+				print("("+rightsStr(f,true,f.get)+","+rightsStr(f,false,f.set)+")");
 			print(" : ");
 			print(" : ");
 			processType(f.type);
 			processType(f.type);
 		}
 		}
@@ -372,6 +377,7 @@ class HtmlPrinter {
 					name : f.name,
 					name : f.name,
 					type : f.t,
 					type : f.t,
 					isPublic : true,
 					isPublic : true,
+					isOverride : false,
 					doc : null,
 					doc : null,
 					get : RNormal,
 					get : RNormal,
 					set : RNormal,
 					set : RNormal,
@@ -454,13 +460,12 @@ class HtmlPrinter {
 			print(")");
 			print(")");
 	}
 	}
 
 
-	function rightsStr(r) {
+	function rightsStr(f:ClassField,get,r) {
 		return switch(r) {
 		return switch(r) {
 		case RNormal: "default";
 		case RNormal: "default";
 		case RNo: "null";
 		case RNo: "null";
-		case RMethod(m): m;
-		case RDynamic: "dynamic";
-		case RF9Dynamic: "f9dynamic";
+		case RCall(m): if( m == ((get?"get_":"set_")+f.name) ) "dynamic" else m;
+		case RMethod, RDynamic, RInline: throw "assert";
 		}
 		}
 	}
 	}