diff options
author | Frederic Peters <fpeters@entrouvert.com> | 2008-04-29 12:04:56 +0000 |
---|---|---|
committer | Frederic Peters <fpeters@entrouvert.com> | 2008-04-29 12:04:56 +0000 |
commit | b7e5f34fcbb03460b81c5b05bf245ef5641e0cbc (patch) | |
tree | 094313a9fa62187d23cf4f78ef83bb99f9013efd /bindings/lang_php5_helpers/php_code.py | |
parent | 08cedd3c6e9d910eda1e7ba42ea313d23506d6f0 (diff) | |
download | lasso-b7e5f34fcbb03460b81c5b05bf245ef5641e0cbc.tar.gz lasso-b7e5f34fcbb03460b81c5b05bf245ef5641e0cbc.tar.xz lasso-b7e5f34fcbb03460b81c5b05bf245ef5641e0cbc.zip |
[project @ fpeters@0d.be-20071111213604-1prv8pyvnwr6gdly]
moved is_null check into cptrToPhp function instead of duplicating it in
callers.
Original author: Frederic Peters <fpeters@0d.be>
Date: 2007-11-11 22:36:04.472000+01:00
Diffstat (limited to 'bindings/lang_php5_helpers/php_code.py')
-rw-r--r-- | bindings/lang_php5_helpers/php_code.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/bindings/lang_php5_helpers/php_code.py b/bindings/lang_php5_helpers/php_code.py index 6f572147..d8b8d267 100644 --- a/bindings/lang_php5_helpers/php_code.py +++ b/bindings/lang_php5_helpers/php_code.py @@ -65,6 +65,7 @@ if (!extension_loaded('lasso')) { } function cptrToPhp ($cptr) { + if (is_null($cptr)) return null; $typename = lasso_get_object_typename($cptr); $class_name = $typename . "NoInit"; $obj = new $class_name(); @@ -131,11 +132,7 @@ function cptrToPhp ($cptr) { if m.name == method_prefix + 'new_from_dump': print >> self.fd, ' public static function newFromDump($dump) {' - print >> self.fd, ' $cptr = %s($dump);' % m.name - print >> self.fd, ' if (! is_null($cptr)) {' - print >> self.fd, ' return cptrToPhp($cptr);' - print >> self.fd, ' }' - print >> self.fd, ' return null;' + print >> self.fd, ' return cptrToPhp(%s($dump));' % m.name # XXX: Else throw an exception print >> self.fd, ' }' print >> self.fd, '' @@ -184,11 +181,8 @@ writing a standard accessor for attribute "%s"' % (m2.name, attr_name) else: print >> self.fd, ' protected function get_%s() {' % mname if self.is_object(m[0]): - print >> self.fd, ' $cptr = %s_%s_get($this->_cptr);' % (klass.name, mname) - print >> self.fd, ' if (! is_null($cptr)) {' - print >> self.fd, ' return cptrToPhp($cptr);' - print >> self.fd, ' }' - print >> self.fd, ' return null;' + print >> self.fd, ' return cptrToPhp(%s_%s_get($this->_cptr));' % ( + klass.name, mname) else: print >> self.fd, ' return %s_%s_get($this->_cptr);' % (klass.name, mname) print >> self.fd, ' }' |