[midgard-commits] r24463 - trunk/midgard/apis/php5

indeyets midgard-commits at lists.midgard-project.org
Tue Dec 15 12:19:49 CET 2009


Author: indeyets
Date: Tue Dec 15 12:19:48 2009
New Revision: 24463
URL: http://trac.midgard-project.org/changeset/24463

Log:
better error-reporting

Modified:
   trunk/midgard/apis/php5/midgard.c

Modified: trunk/midgard/apis/php5/midgard.c
==============================================================================
--- trunk/midgard/apis/php5/midgard.c	(original)
+++ trunk/midgard/apis/php5/midgard.c	Tue Dec 15 12:19:48 2009
@@ -724,24 +724,27 @@
 		return NULL;
 	}
 
-	if (G_TYPE_IS_DERIVED(class_type)) {
-		GType parent_type = g_type_parent(class_type);
+	if (!G_TYPE_IS_DERIVED(class_type)) {
+		php_error(E_ERROR, "'%s' class doesn't have base-class in GType system!", class_name);
+		return NULL;
+	}
 
-		if (parent_type > 0) {
-			gchar *parent_name = (gchar *) g_type_name(parent_type);
+	GType parent_type = g_type_parent(class_type);
 
-			zend_class_entry *pce, *registered_class = NULL;
+	if (parent_type <= 0) {
+		php_error(E_ERROR, "'%s' class has invalid base-class in GType system!", class_name);
+		return NULL;
+	}
 
-			pce = php_midgard_get_class_ptr_by_name(parent_name);
-			if (NULL != pce) {
-				registered_class = zend_register_internal_class_ex(&ce , pce, parent_name TSRMLS_CC);
-			}
+	gchar *parent_name = (gchar *) g_type_name(parent_type);
+	zend_class_entry *pce = php_midgard_get_class_ptr_by_name(parent_name);
 
-			return registered_class;
-		}
+	if (NULL == pce) {
+		php_error(E_ERROR, "'%s' class's parent '%s' is not registered in php", class_name, parent_name);
+		return NULL;
 	}
 
-	return NULL;
+	return zend_register_internal_class_ex(&ce , pce, parent_name TSRMLS_CC);
 }
 
 ZEND_GET_MODULE(midgard2)


More information about the midgard-commits mailing list