diff options
-rw-r--r-- | bindings/lang_php5_helpers/php_code.py | 4 | ||||
-rw-r--r-- | bindings/lang_php5_helpers/wrapper_source.py | 8 | ||||
-rw-r--r-- | bindings/lang_php5_helpers/wrapper_source_top.c | 18 | ||||
-rw-r--r-- | bindings/php5/Makefile.am | 2 | ||||
-rwxr-xr-x | bindings/php5/tests/binding_tests.php | 1 | ||||
-rwxr-xr-x | bindings/php5/tests/profile_tests.php | 1 |
6 files changed, 25 insertions, 9 deletions
diff --git a/bindings/lang_php5_helpers/php_code.py b/bindings/lang_php5_helpers/php_code.py index fe69bee9..a15a08b1 100644 --- a/bindings/lang_php5_helpers/php_code.py +++ b/bindings/lang_php5_helpers/php_code.py @@ -72,7 +72,7 @@ if (!extension_loaded('lasso')) { * Convert a C object to a PHP object */ function cptrToPhp ($cptr) { - if (is_null($cptr)) return null; + if (is_null($cptr) || !$cptr) return null; $typename = lasso_get_object_typename($cptr); $class_name = $typename . "NoInit"; $obj = new $class_name(); @@ -138,7 +138,7 @@ function getRequestTypeFromSoapMsg($mesg) { php_args = ', '.join(php_args) c_args = ', '.join(c_args) - # XXX: could check self._cptr.typename to see if it got the + # XXX: could check $this->_cptr->typename to see if it got the # right class type print >> self.fd, ' public $_cptr = null;' print >> self.fd, '' diff --git a/bindings/lang_php5_helpers/wrapper_source.py b/bindings/lang_php5_helpers/wrapper_source.py index 3905d048..46ea5f60 100644 --- a/bindings/lang_php5_helpers/wrapper_source.py +++ b/bindings/lang_php5_helpers/wrapper_source.py @@ -64,7 +64,7 @@ class WrapperSource: print >> self.fd, '''\ PHP_MINIT_FUNCTION(lasso) { - le_lasso_server = zend_register_list_destructors_ex(NULL, NULL, PHP_LASSO_SERVER_RES_NAME, module_number); + le_lasso_server = zend_register_list_destructors_ex(php_gobject_generic_destructor, NULL, PHP_LASSO_SERVER_RES_NAME, module_number); ''' def generate_constants(self): @@ -149,9 +149,7 @@ PHP_MSHUTDOWN_FUNCTION(lasso) else: print >> self.fd, '''\ if (return_c_value) { - self = (PhpGObjectPtr *)emalloc(sizeof(PhpGObjectPtr)); - self->obj = G_OBJECT(return_c_value); - self->typename = estrdup(G_OBJECT_TYPE_NAME(G_OBJECT(return_c_value))); + self = PhpGObjectPtr_New(G_OBJECT(return_c_value)); ZEND_REGISTER_RESOURCE(return_value, self, le_lasso_server); } else { RETURN_NULL(); @@ -287,7 +285,7 @@ PHP_MSHUTDOWN_FUNCTION(lasso) if self.is_object(m_type): print >> self.fd, ' if (this->%s != NULL) {' % m_name - print >> self.fd, ' return_c_value = g_object_ref(this->%s);' % m_name + print >> self.fd, ' return_c_value = this->%s;' % m_name print >> self.fd, ' }' else: print >> self.fd, ' return_c_value = this->%s;' % m_name diff --git a/bindings/lang_php5_helpers/wrapper_source_top.c b/bindings/lang_php5_helpers/wrapper_source_top.c index 34e1e1b0..4835913c 100644 --- a/bindings/lang_php5_helpers/wrapper_source_top.c +++ b/bindings/lang_php5_helpers/wrapper_source_top.c @@ -34,7 +34,7 @@ PhpGObjectPtr_New(GObject *obj) } self = (PhpGObjectPtr *)emalloc(sizeof(PhpGObjectPtr)); - self->obj = obj; + self->obj = g_object_ref(obj); self->typename = estrdup(G_OBJECT_TYPE_NAME(obj)); return self; @@ -53,6 +53,22 @@ PHP_FUNCTION(lasso_get_object_typename) RETURN_STRING(self->typename, 1); } +/* Generic destructor for PHP GObject */ +static void php_gobject_generic_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +{ + PhpGObjectPtr* gobject = (PhpGObjectPtr*)rsrc->ptr; + + if (gobject) { + if (gobject->obj) { + g_object_unref(G_OBJECT(gobject->obj)); + } + if (gobject->typename) { + efree(gobject->typename); + } + efree(gobject); + } +} + /* List handling */ static void free_glist(GList **list, GFunc free_function) { diff --git a/bindings/php5/Makefile.am b/bindings/php5/Makefile.am index ea89d36a..1ff0023f 100644 --- a/bindings/php5/Makefile.am +++ b/bindings/php5/Makefile.am @@ -21,7 +21,7 @@ if WSF_ENABLED EXTRA_ARGS = --enable-id-wsf endif -lasso.php _lasso.c: ../lang_php5.py ../lang_php5_helpers/php_code.py ../lang_php5_helpers/wrapper_source.py +lasso.php _lasso.c: ../lang_php5.py ../lang_php5_helpers/php_code.py ../lang_php5_helpers/wrapper_source.py ../lang_php5_helpers/wrapper_source_top.c $(PYTHON) $(top_srcdir)/bindings/bindings.py -l php5 --src-dir=$(top_srcdir)/lasso/ $(EXTRA_ARGS) doc: diff --git a/bindings/php5/tests/binding_tests.php b/bindings/php5/tests/binding_tests.php index 240be092..4c9fb962 100755 --- a/bindings/php5/tests/binding_tests.php +++ b/bindings/php5/tests/binding_tests.php @@ -1,3 +1,4 @@ +#!/usr/bin/php <?php # Lasso - A free implementation of the Liberty Alliance specifications. # diff --git a/bindings/php5/tests/profile_tests.php b/bindings/php5/tests/profile_tests.php index 71d525bf..a6497a3b 100755 --- a/bindings/php5/tests/profile_tests.php +++ b/bindings/php5/tests/profile_tests.php @@ -1,3 +1,4 @@ +#!/usr/bin/php <?php # Lasso - A free implementation of the Liberty Alliance specifications. # |