From 52372fa4379d87a47330087934b8120794e66560 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Sun, 6 Jun 2010 14:03:57 +0000 Subject: Bindings: keep retro compatibility for member field names * Special kludge price go to PHP: methods name are insensitive so nothing to do here, BUT, if you use getters/setters then your objects fields can be case insensitive too ;-) (DNS, dns, DnS, dNs all maps to get_dns ). --- bindings/java/lang.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'bindings/java') diff --git a/bindings/java/lang.py b/bindings/java/lang.py index 9d221192..64ec2e0f 100644 --- a/bindings/java/lang.py +++ b/bindings/java/lang.py @@ -286,7 +286,7 @@ protected static native void destroy(long cptr); def JNI_member_function_prefix(self,c,m): klassname = c.name[5:] - mname = format_as_camelcase(m[1]) + mname = old_format_as_camelcase(m[1]) return '%s_%s' % (klassname,mname) def generate_JNI_member(self, c, fd): @@ -804,7 +804,9 @@ protected static native void destroy(long cptr); for m in c.members: type, name, options = m prefix = self.JNI_member_function_prefix(c,m) - jname = format_as_camelcase('_'+name) + jname = format_as_camelcase(name) + jname = jname[0].capitalize() + jname[1:] + old_jname = old_format_as_camelcase('_' + name) jtype = self.JNI_member_type(m) if type == 'GList*' or type == 'const GList*': print >> fd, ' public void set%s(List list) {' % jname @@ -829,6 +831,20 @@ protected static native void destroy(long cptr); print >> fd, ' public void removeFrom%s(%s value) {' % (jname,jtype) print >> fd, ' LassoJNI.%s_remove(this, value);' % prefix print >> fd, ' }' + if old_jname != jname: + print >> fd, ' public void set%s(List list) {' % old_jname + print >> fd, ' this.set%s(list);' % jname + print >> fd, ' }' + print >> fd, ' public List get%s() {' % old_jname + print >> fd, ' return this.get%s();' % jname + print >> fd, ' }' + print >> fd, ' public void addTo%s(%s value) {' % (old_jname,jtype) + print >> fd, ' this.addTo%s(value);' % jname + print >> fd, ' }' + if m[2].get('element-type') not in ('xmlNode*',): + print >> fd, ' public void removeFrom%s(%s value) {' % (old_jname,jtype) + print >> fd, ' this.removeFrom%s(value);' % jname + print >> fd, ' }' elif type == 'GHashTable*': print >> fd, ' public void set%s(Map map) {' % jname print >> fd, ' %s[] arr = null;' % jtype @@ -848,6 +864,13 @@ protected static native void destroy(long cptr); print >> fd, ' public %s get%s() {' % (jtype,jname) print >> fd, ' return LassoJNI.%s_get(this);' % prefix print >> fd, ' }' + if old_jname != jname: + print >> fd, ' public void set%s(%s value) {' % (old_jname,jtype) + print >> fd, ' this.set%s(value);' % jname + print >> fd, ' }' + print >> fd, ' public %s get%s() {' % (jtype,old_jname) + print >> fd, ' return this.get%s();' % jname + print >> fd, ' }' print >> fd, ' /* Methods */' for m in c.methods: return_type = self.JNI_return_type(m.return_type) -- cgit