summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2012-03-02 14:44:55 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2012-03-02 15:15:27 (GMT)
commitd96960360496245a1a9e259b08b0afcabc9149e6 (patch)
tree897bfe8a0a1ebfe02e36b0d498e7d5795de0e711 /bindings
parent2a9d50b69dd5149c0b26450a6f1fa417c1ae538c (diff)
downloadlasso-d96960360496245a1a9e259b08b0afcabc9149e6.zip
lasso-d96960360496245a1a9e259b08b0afcabc9149e6.tar.gz
lasso-d96960360496245a1a9e259b08b0afcabc9149e6.tar.bz2
[bindings php5] fix missing wrappers for constructors
Diffstat (limited to 'bindings')
-rw-r--r--bindings/php5/php_code.py41
1 files changed, 30 insertions, 11 deletions
diff --git a/bindings/php5/php_code.py b/bindings/php5/php_code.py
index 2787410..091ae98 100644
--- a/bindings/php5/php_code.py
+++ b/bindings/php5/php_code.py
@@ -136,6 +136,7 @@ function lassoRegisterIdWsf2DstService($prefix, $href) {
def generate_constructors(self, klass):
method_prefix = format_as_underscored(klass.name) + '_'
for m in self.binding_data.functions:
+ name = m.rename or m.name
if m.name == method_prefix + 'new':
php_args = []
c_args = []
@@ -163,18 +164,36 @@ function lassoRegisterIdWsf2DstService($prefix, $href) {
print >> self.fd, ' }'
print >> self.fd, ''
- if m.name == method_prefix + 'new_from_dump':
- if len(m.args) == 1:
- print >> self.fd, ' public static function newFromDump($dump) {'
- print >> self.fd, ' return cptrToPhp(%s($dump));' % m.name
+ elif name.startswith(method_prefix) and m.args \
+ and clean_type(unconstify(m.args[0][0])) != klass.name:
+ if m.rename:
+ php_name = m.rename
else:
- print >> self.fd, ' public static function newFromDump($server, $dump) {'
- print >> self.fd, ' return cptrToPhp(%s($server->_cptr, $dump));' % m.name
- # XXX: Else throw an exception
- print >> self.fd, ' }'
- print >> self.fd, ''
- elif m.name == method_prefix + 'new_full':
- pass
+ mname = m.name
+ mname = mname[len(method_prefix):]
+ if 'new' in mname and not mname.startswith('new'):
+ continue
+ php_name = format_underscore_as_camelcase(mname)
+ php_args = []
+ c_args = []
+ for arg in m.args:
+ arg_type, arg_name, arg_options = arg
+ if arg_options.get('optional'):
+ php_args.append('$%s = null' % arg_name)
+ else:
+ php_args.append('$%s' % arg_name)
+
+ if self.is_object(arg_type):
+ c_args.append('$%s->_cptr' % arg_name)
+ else:
+ c_args.append('$%s' % arg_name)
+ php_args = ', '.join(php_args)
+ c_args = ', '.join(c_args)
+ print >>self.fd, ' public static function %s(%s) {' % (php_name, php_args)
+ print >>self.fd, ' return cptrToPhp(%s(%s));' % (m.name, c_args)
+ print >>self.fd, ' }'
+ print >>self.fd, ''
+
def generate_getter(self, c, m):