commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src definitions/GParser.py rpc/driv...


From: Jan Ischebeck
Subject: gnue/common/src definitions/GParser.py rpc/driv...
Date: Thu, 03 Apr 2003 19:13:06 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jan Ischebeck <address@hidden>  03/04/03 19:13:06

Modified files:
        common/src/definitions: GParser.py 
        common/src/rpc/drivers/pw_xmlrpc: RpcDoc.py 

Log message:
        fix grpcdoc

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/definitions/GParser.py.diff?tr1=1.66&tr2=1.67&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/rpc/drivers/pw_xmlrpc/RpcDoc.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: gnue/common/src/definitions/GParser.py
diff -c gnue/common/src/definitions/GParser.py:1.66 
gnue/common/src/definitions/GParser.py:1.67
*** gnue/common/src/definitions/GParser.py:1.66 Thu Apr  3 18:30:44 2003
--- gnue/common/src/definitions/GParser.py      Thu Apr  3 19:13:06 2003
***************
*** 189,195 ****
      self._requiredTags = []
      self._singleInstanceTags = []
      self._tagCounts = {}
!     self.__encoding = gConfig('textEncoding')
  
  
    #
--- 189,198 ----
      self._requiredTags = []
      self._singleInstanceTags = []
      self._tagCounts = {}
!     try:
!       self.__encoding = gConfig('textEncoding')
!     except:
!       self.__encoding = "iso8859-1"
  
  
    #
Index: gnue/common/src/rpc/drivers/pw_xmlrpc/RpcDoc.py
diff -c gnue/common/src/rpc/drivers/pw_xmlrpc/RpcDoc.py:1.6 
gnue/common/src/rpc/drivers/pw_xmlrpc/RpcDoc.py:1.7
*** gnue/common/src/rpc/drivers/pw_xmlrpc/RpcDoc.py:1.6 Mon Feb 17 02:32:48 2003
--- gnue/common/src/rpc/drivers/pw_xmlrpc/RpcDoc.py     Thu Apr  3 19:13:06 2003
***************
*** 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
            
  """   
***************
*** 85,91 ****
        rpcdef = GComm.loadDefinition(arguments[0])
  
      except IndexError:
!       print "'doc' command expects a .grpc file as its argument."
        sys.exit()
  
      gendocC(rpcdef, outfile)
--- 88,94 ----
        rpcdef = GComm.loadDefinition(arguments[0])
  
      except IndexError:
!       print _("'doc' command expects a .grpc file as its argument.")
        sys.exit()
  
      gendocC(rpcdef, outfile)
***************
*** 96,108 ****
        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
  
  ##
  ##  Create normal documentation
--- 99,124 ----
        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:
!     tmsg = _("Unrecognized XML-RPC doc command: %s") % command 
!     raise StandardError, tmsg
  
  ##
  ##  Create normal documentation
***************
*** 118,126 ****
  def _gen(object):
    if hasattr(object,'name'):
      name=object.name
    else:
!     name=""                 
!   gloutfile.write(name + "\n")
  
  ##
  ##  Create python exsample
--- 134,149 ----
  def _gen(object):
    if hasattr(object,'name'):
      name=object.name
+     if hasattr(object,'_path'): # and hasattr(object._parent,'name'):
+       name=object._path+'.'+name
    else:
!     name=""
!     
!   if hasattr(object,'_children'):
!     for child in object._children:
!       child._path=name
!       
!   gloutfile.write(name[1:] + "\n")
  
  ##
  ##  Create python exsample
***************
*** 140,148 ****
  def _genPy(object):
    if hasattr(object,'name'):
      name=object.name
    else:
!     name=""                 
!   gloutfile.write("rpcClient.execute('%s')\n" % name)
  
  
  ##
--- 163,177 ----
  def _genPy(object):
    if hasattr(object,'name'):
      name=object.name
+     if hasattr(object,'_path'): # and hasattr(object._parent,'name'):
+       name=object._path+'.'+name
    else:
!     name=""
!     
!   if hasattr(object,'_children'):
!     for child in object._children:
!       child._path=name
!   gloutfile.write("rpcClient.execute('%s')\n" % name[1:])
  
  
  ##
***************
*** 162,167 ****
--- 191,275 ----
    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("     this.%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__':




reply via email to

[Prev in Thread] Current Thread [Next in Thread]