Browse Source

fixed hierarchy problem for classes with the name from different packages haXe/PHP
php.db.Mysql now throws an exception when tries to connect to an unexistant DB
fixed blocks in if statements for haXe/PHP
more fixes in SPOD/PHP

Franco Ponticelli 17 years ago
parent
commit
183dc01f5f
4 changed files with 15 additions and 11 deletions
  1. 4 1
      doc/CHANGES.txt
  2. 7 8
      genphp.ml
  3. 2 1
      std/php/db/Manager.hx
  4. 2 1
      std/php/db/Mysql.hx

+ 4 - 1
doc/CHANGES.txt

@@ -30,6 +30,9 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	haXe/PHP now generates code for extern classes __init__
 	added strings literal support in haxe.Template
 	fixed Process arguments and exitCode() in haXe/PHP
+	fixed hierarchy problem for classes with the name from different packages haXe/PHP
+	php.db.Mysql now throws an exception when tries to connect to an unexistant DB
+	fixed blocks in if statements for haXe/PHP
 
 2008-07-28: 2.0
 	fixed current package bug in inherited constructor type
@@ -729,7 +732,7 @@ TODO inlining : substitute class+function type parameters in order to have fully
 
 2005-11-17: alpha 1b
 	fix some bugs
-	changed package syntax
+	changed package tests.lang
 
 2005-11-14: alpha 1
 	lexer

+ 7 - 8
genphp.ml

@@ -182,16 +182,15 @@ let s_path ctx path isextern p =
 		| (["php"],"PhpDate__")	-> "Date"
 		| (["php"],"PhpMath__")	-> "Math"
 		| (pack,name) ->
-			try
+			(try
 				(match Hashtbl.find ctx.imports name with
 				| [p] when p = pack ->
-					String.concat "_" pack ^ "_" ^ name
+					()
 				| packs ->
-					if not (List.mem pack packs) then Hashtbl.replace ctx.imports name (pack :: packs);
-					Ast.s_type_path path)
+					if not (List.mem pack packs) then Hashtbl.replace ctx.imports name (pack :: packs))
 			with Not_found ->
-				Hashtbl.add ctx.imports name [pack];
-				String.concat "_" pack ^ "_" ^ name);
+				Hashtbl.add ctx.imports name [pack]);
+			String.concat "_" pack ^ "_" ^ name);
 	end
 
 let s_path_haxe path =
@@ -1326,14 +1325,14 @@ and gen_expr ctx e =
 		spr ctx "if";
 		gen_value ctx (parent cond);
 		spr ctx " ";
-		gen_expr ctx e;
+		gen_expr ctx (mk_block e);
 		(match eelse with
 		| None -> ()
 		| Some e when e.eexpr = TConst(TNull) -> ()
 		| Some e ->
 			newline ctx;
 			spr ctx "else ";
-			gen_expr ctx e);
+			gen_expr ctx (mk_block e));
 	| TUnop (op,Ast.Prefix,e) ->
 		spr ctx (Ast.s_unop op);
 		gen_value ctx e

+ 2 - 1
std/php/db/Manager.hx

@@ -70,6 +70,7 @@ class Manager<T : Object> {
 		apriv.push("__cache__");
 //		apriv.push("update");
 		apriv.push("__noupdate__");
+//		apriv.push("local_manager");
 
 		// get the proto fields not marked private (excluding methods)
 		table_fields = new List();
@@ -331,13 +332,13 @@ class Manager<T : Object> {
 	/* ---------------------------- INTERNAL API -------------------------- */
 
 	function cacheObject( byref___x : T, lock : Bool ) {
-		addToCache(byref___x);
 		var o = Type.createEmptyInstance(cls);
 		for(field in Reflect.fields(byref___x)) {
 			Reflect.setField(o, field, Reflect.field(byref___x, field));
 		}
 		untyped o.__init_object();
 		byref___x = cast o;
+		addToCache(byref___x);
 		Reflect.setField(byref___x, cache_field, Type.createEmptyInstance(cls));
 		if( !lock )
 			untyped byref___x.__noupdate__ = true;

+ 2 - 1
std/php/db/Mysql.hx

@@ -183,7 +183,8 @@ class Mysql {
 			params.host + (params.port == null ? '' : ':'+params.port) + (params.socket == null ? '' : ':'+params.socket),
 			params.user,
 			params.pass);
-		untyped __call__("mysql_select_db", params.database, c);
+		if(!untyped __call__("mysql_select_db", params.database, c))
+			throw "Unable to connect to " + params.database;
 		return new MysqlConnection(c);
 	}