Browse Source

- php: added support for metadata

Franco Ponticelli 15 years ago
parent
commit
dd0f3a19f0
2 changed files with 17 additions and 1 deletions
  1. 15 1
      genphp.ml
  2. 2 0
      std/php/Boot.hx

+ 15 - 1
genphp.ml

@@ -1887,6 +1887,13 @@ let generate_enum ctx e =
 	spr ctx ")";
 	
 	newline ctx;
+	
+	(match Codegen.build_metadata ctx.com (TEnumDecl e) with
+	| None -> ()
+	| Some _ ->
+		spr ctx "public static $__meta__";
+		newline ctx);
+	
 	pack();
 	
 	print ctx "}";
@@ -1900,7 +1907,14 @@ let generate_enum ctx e =
 			print ctx "%s::$%s = new %s(\"%s\", %d)" ename c.ef_name ename c.ef_name  c.ef_index;
 	) e.e_constrs;
 
-	newline ctx
+	newline ctx;
+	
+	match Codegen.build_metadata ctx.com (TEnumDecl e) with
+	| None -> ()
+	| Some e ->
+		print ctx "%s::$__meta__ = " ename;
+		gen_expr ctx e;
+		newline ctx
 
 let generate com =
 	let all_dynamic_methods = ref [] in

+ 2 - 0
std/php/Boot.hx

@@ -635,6 +635,8 @@ class _hx_type {
 		$this->__tname__ = $cn;
 		$this->__qname__ = $qn;
 		$this->__path__ = $path;
+		if(class_exists($cn) && isset($cn::$__meta__))
+			$this->__meta__ = $cn::$__meta__;
 	}
 
 	public function toString()   { return $this->__toString(); }