[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src/commdrivers/xmlrpc RpcDoc.py
From: |
Jan Ischebeck |
Subject: |
gnue/common/src/commdrivers/xmlrpc RpcDoc.py |
Date: |
Sun, 06 Oct 2002 11:21:08 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/10/06 11:21:08
Modified files:
common/src/commdrivers/xmlrpc: RpcDoc.py
Log message:
add javascript stub file generation to grpcdoc tool
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/commdrivers/xmlrpc/RpcDoc.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gnue/common/src/commdrivers/xmlrpc/RpcDoc.py
diff -c gnue/common/src/commdrivers/xmlrpc/RpcDoc.py:1.5
gnue/common/src/commdrivers/xmlrpc/RpcDoc.py:1.6
*** gnue/common/src/commdrivers/xmlrpc/RpcDoc.py:1.5 Mon May 13 13:40:24 2002
--- gnue/common/src/commdrivers/xmlrpc/RpcDoc.py Sun Oct 6 11:21:08 2002
***************
*** 52,57 ****
--- 52,60 ----
of the .grpc file in c
doc-php create example code for all methods and objects
of the .grpc file in PHP
+ js-stub creates stub file to allow direct access to all methods
+ and objects defined in the .grpc file by an Javascript
+ client
help prints this help message
"""
***************
*** 96,105 ****
rpcdef = GComm.loadDefinition(arguments[0])
except IndexError:
! print _("'doc' command expects a .grpc file as its argument.")
sys.exit()
! gendoc(rpcdef, outfile)
else:
raise StandardError, _("Unrecognized XML-RPC doc command: %s") % command
--- 99,120 ----
rpcdef = GComm.loadDefinition(arguments[0])
except IndexError:
! print _("'doc-php' command expects a .grpc file as its argument.")
sys.exit()
! print "PHP code generation not implemented yet."
! # gendoc(rpcdef, outfile)
!
! elif command == 'js-stub':
!
! try:
! rpcdef = GComm.loadDefinition(arguments[0])
!
! except IndexError:
! print _("'js-stub' command expects a .grpc file as its argument.")
! sys.exit()
!
! gendocJS(rpcdef, outfile)
else:
raise StandardError, _("Unrecognized XML-RPC doc command: %s") % command
***************
*** 175,180 ****
--- 190,274 ----
else:
name=""
gloutfile.write(name + "\n")
+
+ ##
+ ## Create Javascript exsample
+ ##
+ def gendocJS(rpcdef, outfile):
+
+ outfile.write("// Javascript example\n")
+ outfile.write("// ==================\n\n")
+ outfile.write("include ( 'vcXMLRPC.js')\n")
+
+ gloutfile= outfile
+ _genJs(rpcdef)
+
+
+ def _genJs(object):
+ if hasattr(object,'name'):
+ name=object.name
+ if hasattr(object,'_path'): # and hasattr(object._parent,'name'):
+ name=object._path+'_'+name
+ else:
+ name=""
+ if object._type=="RpObject" or object._type=="RpService":
+ gloutfile.write("function %s(host,handle) {\n" % name[1:])
+ gloutfile.write(" this.host=host\n")
+ gloutfile.write(" this.handle=handle\n")
+ if hasattr(object,'_children'):
+ for child in object._children:
+ child._path=name
+ if child._type=="RpMethod" or child._type=="RpAttribute":
+ _genJs(child)
+ gloutfile.write("}\n")
+ if hasattr(object,'_children'):
+ for child in object._children:
+ child._path=name
+ if child._type=="RpObject" or child._type=="RpService":
+ _genJs(child)
+
+ elif object._type=="RpGnuRpc":
+ if hasattr(object,'_children'):
+ for child in object._children:
+ child._path=name
+ _genJs(child)
+
+ elif object._type=="RpMethod":
+ # build attribut list
+ attr=""
+ delim=""
+ if hasattr(object,'_children'):
+ for child in object._children:
+ attr=attr+delim+child.name
+ delim=","
+
+ gloutfile.write(" self.%s = function (%s) {\n" % (object.name,attr) )
+
+ if object._parent._type=="RpObject":
+ procname="'['+this.handle+'].%s'" % object.name
+ else:
+ procname="'%s'" % string.join(string.split(name[1:],"_"),".")
+
+ if len(attr):
+ procname=procname+","+attr
+
+ ret="nothing"
+ if hasattr(object,"return"):
+ ret=getattr(object,"return")
+
+ if ret[:1]=="<" and ret[-1:]==">":
+
+ gloutfile.write(" handle=XMLRPC.call(this.host,%s);\n"
+ % procname)
+ gloutfile.write(" return new %s(host,handle)" %
+ string.join(string.split(ret[1:-1],"."),"_"))
+
+ else:
+ gloutfile.write(" return XMLRPC.call(this.host,%s);\n"
+ % procname)
+
+ gloutfile.write(" }\n")
+
if __name__ == '__main__':
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src/commdrivers/xmlrpc RpcDoc.py,
Jan Ischebeck <=