From: Samuele P. <ped...@us...> - 2005-02-15 22:52:03
|
Update of /cvsroot/jython/sandbox/jt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13507 Modified Files: gexpose-defs gexpose.py type.expose Log Message: directive to expose getset descriptors (with this we should have enough fetature to construct relevant typeSetups) Index: gexpose-defs =================================================================== RCS file: /cvsroot/jython/sandbox/jt/gexpose-defs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gexpose-defs 13 Feb 2005 21:40:41 -0000 1.1 --- gexpose-defs 15 Feb 2005 22:51:36 -0000 1.2 *************** *** 15,18 **** --- 15,23 ---- `trailer; `last; + define: getset + dict.__setitem__( + `strfy`(`name), + new PyGetSetDescr(`strfy`(`name), `typ.class, `get, `set)); + define: (ClassBodyDeclarations)call_meths args body public PyObject __call__(`args) { Index: gexpose.py =================================================================== RCS file: /cvsroot/jython/sandbox/jt/gexpose.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gexpose.py 15 Feb 2005 22:12:55 -0000 1.2 --- gexpose.py 15 Feb 2005 22:51:37 -0000 1.3 *************** *** 9,13 **** import java_parser import java_templating ! from java_templating import JavaTemplate,jast_make,jast --- 9,13 ---- import java_parser import java_templating ! from java_templating import JavaTemplate,jast_make,jast, make_id, make_literal *************** *** 20,23 **** --- 20,24 ---- 'type_as', 'type_name','type_class','type_base_class', + 'expose_getset', 'expose_unary','expose_binary','expose_nonzero', 'expose_vanilla_cmp','expose_vanilla_pow', *************** *** 118,121 **** --- 119,148 ---- self.type_base_class = JavaTemplate(parm.strip()) + def dire_expose_getset(self,name,parm,body): + if body is not None: + self.invalid(name,'non-empty body') + + parms = parm.strip().split() + + if len(parms) not in (2,3): + self.invalid(name, parm) + + name = parms[0] + get = '"%s"' % parms[1] + if len(parms) == 3: + set = '"%s"' % parms[2] + else: + set = "null" + + getset_bindings = self.global_bindings.copy() + + getset_bindings['name'] = JavaTemplate(make_id(name)) + getset_bindings['get'] = JavaTemplate(make_literal(get)) + getset_bindings['set'] = JavaTemplate(make_literal(set)) + + getset = self.get_aux('getset') + + self.statements.append(getset.tbind(getset_bindings)) + NOARGS = JavaTemplate("void()") EMPTYALL = JavaTemplate(jast_make(jast.Expressions)) *************** *** 188,193 **** argj = "arg%d" % j args += JavaTemplate("void(PyObject %s)" % argj) - all += JavaTemplate(jast_make(jast.Expressions,[java_parser.parse(argj,start="Expression")])) new_body_bindings[argj],err = getattr(self,'arg_%s' % k)(argj,j,tg) if err: conv_errors.setdefault(err,[]).append(j) --- 215,220 ---- argj = "arg%d" % j args += JavaTemplate("void(PyObject %s)" % argj) new_body_bindings[argj],err = getattr(self,'arg_%s' % k)(argj,j,tg) + all += JavaTemplate(jast_make(jast.Expressions,[new_body_bindings[argj].fragment])) if err: conv_errors.setdefault(err,[]).append(j) *************** *** 375,378 **** --- 402,406 ---- self.statements.append(templ.tbind({'body': body})) + def dire_rest(self,name,parm,body): if parm: Index: type.expose =================================================================== RCS file: /cvsroot/jython/sandbox/jt/type.expose,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** type.expose 13 Feb 2005 21:40:41 -0000 1.1 --- type.expose 15 Feb 2005 22:51:37 -0000 1.2 *************** *** 4,7 **** --- 4,9 ---- define: void return Py.None; + # gesets + expose_getset: __dict__ getDict # exposed methods expose_meth: __getattribute__ n{attribute name} *************** *** 14,21 **** self.type___setattr__(name,`arg1); `void; ! expose_meth: __delattr__ n{attribute name} ! String name = `arg0; ! self.type___delattr__(name); ! `void; expose_meth: __subclasses__ return self.type_getSubclasses(); --- 16,23 ---- self.type___setattr__(name,`arg1); `void; ! expose_meth: :- __delattr__ n{attribute name} ! # String name = `arg0; ! # self.type___delattr__(name); ! # `void; expose_meth: __subclasses__ return self.type_getSubclasses(); |