diff options
author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-06-06 14:03:57 +0000 |
---|---|---|
committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-06-06 14:03:57 +0000 |
commit | 52372fa4379d87a47330087934b8120794e66560 (patch) | |
tree | 4543006f2d02231b57cc0e90e73fc986d567ba3b /bindings/java | |
parent | 692e2985974febda3c83e87e63b7541d6b663f2f (diff) | |
download | lasso-52372fa4379d87a47330087934b8120794e66560.tar.gz lasso-52372fa4379d87a47330087934b8120794e66560.tar.xz lasso-52372fa4379d87a47330087934b8120794e66560.zip |
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 ).
Diffstat (limited to 'bindings/java')
-rw-r--r-- | bindings/java/lang.py | 27 |
1 files changed, 25 insertions, 2 deletions
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) |