summaryrefslogtreecommitdiffstats
path: root/bindings/php5
diff options
context:
space:
mode:
authorDamien Laniel <dlaniel@entrouvert.com>2008-09-17 09:05:43 +0000
committerDamien Laniel <dlaniel@entrouvert.com>2008-09-17 09:05:43 +0000
commit3b071795ddcbc799206ab5dbf0bff06ba796057c (patch)
tree6f30c0b82d2b2b20c17a387f2b94785e70131fae /bindings/php5
parent6b9a2651020d56ddcc0de66b6c93e23f04508b3c (diff)
downloadlasso-3b071795ddcbc799206ab5dbf0bff06ba796057c.tar.gz
lasso-3b071795ddcbc799206ab5dbf0bff06ba796057c.tar.xz
lasso-3b071795ddcbc799206ab5dbf0bff06ba796057c.zip
php: added a root class to define generic getter and setter
Diffstat (limited to 'bindings/php5')
-rw-r--r--bindings/php5/php_code.py49
1 files changed, 26 insertions, 23 deletions
diff --git a/bindings/php5/php_code.py b/bindings/php5/php_code.py
index 1a5d238c..bce43ca1 100644
--- a/bindings/php5/php_code.py
+++ b/bindings/php5/php_code.py
@@ -55,6 +55,31 @@ if (!extension_loaded('lasso')) {
die("Lasso extension is not loaded");
}
+/**
+ * @package Lasso
+ *
+ * Root class of all Lasso objects to define generic getter and setter
+ */
+class LassoObject {
+ /**
+ * @return mixed
+ */
+ public function __get($attr) {
+ $func = "get_" . $attr;
+ if (method_exists($this, $func)) {
+ return call_user_func(array($this, $func));
+ }
+ return null;
+ }
+
+ public function __set($attr, $value) {
+ $func = "set_" . $attr;
+ if (method_exists($this, $func)) {
+ call_user_func(array($this, $func), $value);
+ }
+ }
+}
+
/*
* Convert a C object to a PHP object
*/
@@ -85,7 +110,7 @@ function lassoRegisterIdWsf2DstService($prefix, $href) {
if klass.parent != 'GObject':
inheritence = ' extends %s' % klass.parent
else:
- inheritence = ''
+ inheritence = ' extends LassoObject'
print >> self.fd, '/**'
print >> self.fd, ' * @package Lasso'
@@ -156,28 +181,6 @@ function lassoRegisterIdWsf2DstService($prefix, $href) {
# FIXME: handle objects and GLists
- # Generic getter
- print >> self.fd, ' /**'
- print >> self.fd, ' * @return mixed'
- print >> self.fd, ' */'
- print >> self.fd, ' public function __get($attr) {'
- print >> self.fd, ' $func = "get_" . $attr;'
- print >> self.fd, ' if (method_exists($this, $func)) {'
- print >> self.fd, ' return call_user_func(array($this, $func));'
- print >> self.fd, ' }'
- print >> self.fd, ' return null;'
- print >> self.fd, ' }'
- print >> self.fd, ''
-
- # Generic setter
- print >> self.fd, ' public function __set($attr, $value) {'
- print >> self.fd, ' $func = "set_" . $attr;'
- print >> self.fd, ' if (method_exists($this, $func)) {'
- print >> self.fd, ' call_user_func(array($this, $func), $value);'
- print >> self.fd, ' }'
- print >> self.fd, ' }'
- print >> self.fd, ''
-
for m in klass.members:
mtype = m[0]
mname = utils.format_as_camelcase(m[1])