Back to index

salome-paravis  6.5.0
Public Member Functions | Public Attributes
pythonIDL.PythonVisitor Class Reference

List of all members.

Public Member Functions

def __init__
def handleImported
def visitAST
def visitModule
def visitForward
def visitInterface
def visitConst
def visitTypedef
def visitStruct
def visitStructForward
def visitException
def visitUnion
def visitUnionForward
def visitEnum
def visitNative
def visitValueForward
def visitValueBox
def visitValueAbs
def visitValue

Public Attributes

 st
 outpymodule
 at_module_scope
 at_global_scope
 currentScope
 modname

Detailed Description

Definition at line 920 of file pythonIDL.py.


Constructor & Destructor Documentation

def pythonIDL.PythonVisitor.__init__ (   self,
  st,
  outpymodule 
)

Definition at line 921 of file pythonIDL.py.

00921 
00922     def __init__(self, st, outpymodule):
00923         self.st          = st
00924         self.outpymodule = outpymodule


Member Function Documentation

def pythonIDL.PythonVisitor.handleImported (   self,
  node 
)

Definition at line 925 of file pythonIDL.py.

00925 
00926     def handleImported(self, node):
00927         global imported_files
00928 
00929         if node.mainFile() or output_inline:
00930             return 0
00931         else:
00932             ifilename = outputFileName(node.file())
00933             if not imported_files.has_key(ifilename):
00934                 imported_files[ifilename] = 1
00935                 ibasename,ext = os.path.splitext(os.path.basename(node.file()))
00936                 if extern_stub_pkgs.has_key(ibasename):
00937                     ipackage = extern_stub_pkgs[ibasename]
00938                     if ipackage:
00939                         fn = ipackage + '.' + ifilename
00940                     else:
00941                         fn = ifilename
00942                 else:
00943                     fn = stub_package + ifilename
00944 
00945                 self.st.out(import_idl_file,
00946                             idlfile=node.file(),
00947                             ifilename=fn)
00948             return 1
        

Here is the call graph for this function:

Here is the caller graph for this function:

def pythonIDL.PythonVisitor.visitAST (   self,
  node 
)

Definition at line 952 of file pythonIDL.py.

00952 
00953     def visitAST(self, node):
00954         self.at_module_scope = 1
00955         self.at_global_scope = 1
00956         self.currentScope    = ["_0_" + global_module]
00957 
00958         decls_in_global_module = 0
00959 
00960         for n in node.declarations():
00961             if not isinstance(n, idlast.Module):
00962                 decls_in_global_module = 1
00963                 break
00964 
00965         if decls_in_global_module:
00966             self.modname = global_module
00967             self.st.out(module_start,
00968                         sname=global_module,
00969                         s_sname=skeletonModuleName(global_module),
00970                         filename=node.file(), package=module_package)
00971         else:
00972             self.modname = self.outpymodule
00973 
00974         for n in node.declarations():
00975             n.accept(self)
00976 
00977         if decls_in_global_module:
00978             exported_modules[global_module] = 1
00979             self.st.out(module_end, modname=self.outpymodule,
00980                         sname=global_module,
00981                         package="")

def pythonIDL.PythonVisitor.visitConst (   self,
  node 
)

Definition at line 1338 of file pythonIDL.py.

01338 
01339     def visitConst(self, node):
01340         if self.handleImported(node): return
01341 
01342         cname = mangle(node.identifier())
01343 
01344         if self.at_module_scope:
01345             value = valueToString(node.value(), node.constKind(), [])
01346         else:
01347             value = valueToString(node.value(), node.constKind(),
01348                                   self.currentScope)
01349         if self.at_module_scope:
01350             self.st.out(constant_at_module_scope,
01351                         cname   = cname,
01352                         value   = value,
01353                         modname = self.modname)
01354         else:
01355             self.st.out(constant,
01356                         cname   = cname,
01357                         value   = value)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitEnum (   self,
  node 
)

Definition at line 1813 of file pythonIDL.py.

01813 
01814     def visitEnum(self, node):
01815         if self.handleImported(node): return
01816 
01817         ename = mangle(node.identifier())
01818         self.st.out(enum_start, ename = ename)
01819 
01820         i=0
01821         elist = []
01822         for item in node.enumerators():
01823             eval = str(i)
01824 
01825             if self.at_module_scope:
01826                 self.st.out(enum_item_at_module_scope,
01827                             item    = item.identifier(),
01828                             eitem   = mangle(item.identifier()),
01829                             eval    = eval,
01830                             modname = self.modname)
01831             else:
01832                 self.st.out(enum_item,
01833                             item    = item.identifier(),
01834                             eitem   = mangle(item.identifier()),
01835                             eval    = eval)
01836 
01837             if self.at_module_scope:
01838                 elist.append(dotName(fixupScopedName(item.scopedName())))
01839             else:
01840                 elist.append(mangle(item.identifier()))
01841 
01842             i = i + 1
01843 
01844         eitems = string.join(elist, ", ")
01845 
01846         if self.at_module_scope:
01847             self.st.out(enum_object_and_descriptor_at_module_scope,
01848                         ename   = ename,
01849                         repoId  = node.repoId(),
01850                         eitems  = eitems,
01851                         modname = self.modname)
01852         else:
01853             self.st.out(enum_object_and_descriptor,
01854                         ename   = ename,
01855                         repoId  = node.repoId(),
01856                         eitems  = eitems)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitException (   self,
  node 
)

Definition at line 1563 of file pythonIDL.py.

01563 
01564     def visitException(self, node):
01565         if self.handleImported(node): return
01566 
01567         sname = mangle(node.identifier())
01568         fscopedName = fixupScopedName(node.scopedName(), "")
01569         self.st.out(exception_class,
01570                     sname = sname,
01571                     repoId = node.repoId(),
01572                     scopedname = dotName(fscopedName))
01573 
01574         if not self.at_module_scope:
01575             self.st.out(struct_class_name, cname = dotName(fscopedName))
01576 
01577         mnamel = []
01578         mdescl = []
01579         for mem in node.members():
01580 
01581             # Deal with nested declarations
01582             if mem.constrType():
01583                 self.st.inc_indent()
01584                 ams = self.at_module_scope
01585                 self.at_module_scope = 0
01586                 self.currentScope.append(node.identifier())
01587                 
01588                 mem.memberType().decl().accept(self)
01589 
01590                 self.currentScope.pop()
01591                 self.at_module_scope = ams
01592                 self.st.dec_indent()
01593                 self.st.out("")
01594 
01595             for decl in mem.declarators():
01596                 mnamel.append(mangle(decl.identifier()))
01597                 mdescl.append('"' + mangle(decl.identifier()) + '"')
01598 
01599                 if self.at_module_scope:
01600                     mdescl.append(\
01601                         typeAndDeclaratorToDescriptor(mem.memberType(),
01602                                                       decl,
01603                                                       []))
01604                 else:
01605                     mdescl.append(\
01606                         typeAndDeclaratorToDescriptor(mem.memberType(),
01607                                                       decl,
01608                                                       self.currentScope))
01609 
01610         if len(mnamel) > 0:
01611             mnames = ", " + string.join(mnamel, ", ")
01612         else:
01613             mnames = ""
01614 
01615         self.st.out(exception_class_init, mnames = mnames)
01616 
01617         for mname in mnamel:
01618             self.st.out(exception_init_member, mname = mname)
01619 
01620         if len(mdescl) > 0:
01621             mdescs = ", " + string.join(mdescl, ", ")
01622         else:
01623             mdescs = ""
01624 
01625         if self.at_module_scope:
01626             self.st.out(exception_descriptor_at_module_scope,
01627                         sname = sname, mdescs = mdescs, modname = self.modname)
01628         else:
01629             self.st.out(exception_descriptor, sname = sname, mdescs = mdescs)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitForward (   self,
  node 
)

Definition at line 1043 of file pythonIDL.py.

01043 
01044     def visitForward(self, node):
01045         if self.handleImported(node): return
01046 
01047         assert self.at_module_scope
01048         ifid   = mangle(node.identifier())
01049         repoId = node.repoId()
01050         if node.abstract():
01051             tvkind = "tv_abstract_interface"
01052             abstract = "abstract "
01053         else:
01054             tvkind = "tv_objref"
01055             abstract = ""
01056 
01057         self.st.out(forward_interface, ifid=ifid, tvkind=tvkind,
01058                     repoId=repoId, abstract=abstract, modname=self.modname)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitInterface (   self,
  node 
)

Definition at line 1062 of file pythonIDL.py.

01062 
01063     def visitInterface(self, node):
01064         if self.handleImported(node): return
01065 
01066         assert self.at_module_scope
01067         ifid = mangle(node.identifier())
01068 
01069         if len(node.inherits()) > 0:
01070             inheritl = []
01071             for i in node.inherits():
01072                 i = i.fullDecl()
01073                 inheritl.append(dotName(fixupScopedName(i.scopedName())))
01074             
01075             inherits = "(" + string.join(inheritl, ", ") + ")"
01076         else:
01077             inherits = ""
01078 
01079         if node.abstract():
01080             tvkind = "tv_abstract_interface"
01081             abstract = "abstract "
01082         else:
01083             tvkind = "tv_objref"
01084             abstract = ""
01085 
01086         # Class header
01087         self.st.out(interface_class, ifid=ifid, tvkind=tvkind,
01088                     inherits=inherits, repoId=node.repoId(),
01089                     abstract=abstract, modname=self.modname)
01090 
01091         # Declarations within the interface
01092         if len(node.declarations()) > 0:
01093             self.st.inc_indent()
01094             self.at_module_scope = 0
01095             self.currentScope.append(node.identifier())
01096 
01097             for d in node.declarations():
01098                 d.accept(self)
01099 
01100             self.currentScope.pop()
01101             self.at_module_scope = 1
01102             self.st.dec_indent()
01103             self.st.out("")
01104 
01105         # Descriptor and TypeCode for the interface
01106         self.st.out(interface_descriptor,
01107                     modname = self.modname, ifid = ifid)
01108 
01109         # Attributes and operations
01110         # *** Was there a good reason for putting these in the class def?
01111         if len(node.callables()) > 0:
01112             self.st.out(callables_header, ifid=ifid)
01113 
01114         for c in node.callables():
01115             if isinstance(c, idlast.Attribute):
01116 
01117                 descr = typeToDescriptor(c.attrType())
01118 
01119                 for attr in c.identifiers():
01120 
01121                     self.st.out(attribute_get_descriptor,
01122                                 attr=attr, descr=descr, ifid=ifid)
01123 
01124                     if not c.readonly():
01125 
01126                         self.st.out(attribute_set_descriptor,
01127                                     attr=attr, descr=descr, ifid=ifid)
01128             else: # Operation
01129 
01130                 inds, outds, excs, ctxts, cv = operationToDescriptors(c)
01131 
01132                 options = ""
01133 
01134                 if cv:
01135                     ctxts = ctxts or "None"
01136 
01137                 if ctxts:
01138                     options = ", " + ctxts
01139 
01140                 if cv:
01141                     options = options + ", 1"
01142 
01143                 # Output the declaration
01144                 self.st.out(operation_descriptor,
01145                             opname  = mangle(c.identifier()),
01146                             inds    = inds,
01147                             outds   = outds,
01148                             excs    = excs,
01149                             options = options,
01150                             ifid    = ifid)
01151 
01152         # Objref class
01153         if node.inherits():
01154             inheritl = []
01155             for i in node.inherits():
01156                 i = i.fullDecl()
01157                 sn = fixupScopedName(i.scopedName())
01158                 inheritl.append(dotName(sn[:-1] + ["_objref_" + sn[-1]]))
01159                 
01160             inherits = string.join(inheritl, ", ")
01161         else:
01162             inherits = "CORBA.Object"
01163 
01164         self.st.out(objref_class, ifid=ifid, inherits=inherits)
01165 
01166         if node.inherits():
01167             for inclass in inheritl:
01168                 self.st.out(objref_inherit_init, inclass=inclass)
01169         else:
01170             self.st.out(objref_object_init)
01171 
01172         # Operations and attributes
01173         methodl = []
01174         methadd = []
01175         methdsc = []
01176 
01177         for c in node.callables():
01178 
01179             if isinstance(c, idlast.Attribute):
01180 
01181                 for attr in c.identifiers():
01182 
01183                     self.st.out(objref_attribute_get,
01184                                 attr    = attr,
01185                                 ifid    = ifid,
01186                                 modname = self.modname)
01187                     
01188                     methodl.append('"_get_' + attr + '"')
01189 
01190                     if not c.readonly():
01191 
01192                         self.st.out(objref_attribute_set,
01193                                     attr    = attr,
01194                                     ifid    = ifid,
01195                                     modname = self.modname)
01196                         
01197                         methodl.append('"_set_' + attr + '"')
01198 
01199             else: # Operation
01200                 opname = mangle(c.identifier())
01201                 
01202                 if len(opname) > 2 and opname[-2] == '_':
01203                     methlen = methgrp_index(methadd,opname)
01204                     if methlen < 0:
01205                         methodl.append('"' + opname[:-2] + '"')
01206 
01207                         methlen = len(methadd)
01208 
01209                         methadd = methadd + [opname[:-2]]
01210 
01211                         methdsc = methdsc + [""]
01212                         methdsc[methlen] = "\n    def "+opname[:-2]+"(self, *args):"
01213 
01214                     methdsc[methlen] = methdsc[methlen] + "\n        "
01215                         
01216                     methdsc[methlen] = methdsc[methlen] + "if len(args) == " + str(len(c.parameters()))
01217 
01218                     for p in range(0,len(c.parameters())):
01219                         methdsc[methlen] = methdsc[methlen] + " and "
01220                         if c.parameters()[p].paramType().kind() in [idltype.tk_short,idltype.tk_long]:
01221                             methdsc[methlen] = methdsc[methlen] + is_int(p)
01222                         if c.parameters()[p].paramType().kind() in [idltype.tk_float,idltype.tk_double]:
01223                             methdsc[methlen] = methdsc[methlen] + is_double(p)
01224                         if c.parameters()[p].paramType().kind() in [idltype.tk_string]:
01225                             methdsc[methlen] = methdsc[methlen] + is_string(p)
01226                         if c.parameters()[p].paramType().kind() in [idltype.tk_sequence,idltype.tk_alias]:
01227                             methdsc[methlen] = methdsc[methlen] + is_list(p)
01228                         if c.parameters()[p].paramType().kind() in [idltype.tk_objref]:
01229                             methdsc[methlen] = methdsc[methlen] + is_vtkPtr(p)
01230                         if c.parameters()[p].paramType().kind() in [idltype.tk_boolean]:
01231                             methdsc[methlen] = methdsc[methlen] + is_boolean(p)
01232                         if c.parameters()[p].paramType().kind() in [idltype.tk_any]:
01233                             methdsc[methlen] = methdsc[methlen] + is_any(p)
01234                         if c.parameters()[p].paramType().kind() in [idltype.tk_char]:
01235                             methdsc[methlen] = methdsc[methlen] + is_char(p)
01236                         if c.parameters()[p].paramType().kind() not in [idltype.tk_boolean,idltype.tk_short,idltype.tk_long,idltype.tk_float,idltype.tk_double,idltype.tk_string,idltype.tk_sequence,idltype.tk_alias,idltype.tk_objref,idltype.tk_any,idltype.tk_char]:
01237                             methdsc[methlen] = methdsc[methlen] + " " + str(c.parameters()[p].paramType().kind()) + " == '' "
01238 
01239                     methdsc[methlen] = methdsc[methlen] + ":"
01240                     methdsc[methlen] = methdsc[methlen] + "\n            return self."+opname+"(*args)"
01241 
01242                 self.st.out(objref_operation,
01243                             opname   = opname,
01244                             r_opname = c.identifier(),
01245                             ifid     = ifid,
01246                             modname  = self.modname)
01247                 methodl.append('"' + opname + '"')
01248 
01249         for p in range(0,len(methadd)):
01250             methgrp = methadd[p]
01251             methtmp = methdsc[p]
01252             methtmp = methtmp + "\n        print 'Warning: The corresponding method of " + methgrp + " group is not found for ' + str(args)"
01253             self.st.out(methtmp)
01254 
01255         #self.st.out("\n    def __eq__(self,other):")
01256         #self.st.out("        return self.IsSame(other)==0")
01257 
01258         # __methods__ assignment
01259         methods = "[" + string.join(methodl, ", ") + "]"
01260 
01261         if node.inherits():
01262             inheritl = []
01263             for i in node.inherits():
01264                 i = i.fullDecl()
01265                 sn = fixupScopedName(i.scopedName())
01266                 methods = methods + " + " + \
01267                           dotName(sn[:-1] + ["_objref_" + sn[-1]]) + \
01268                           ".__methods__"
01269         else:
01270             methods = methods + " + CORBA.Object.__methods__"
01271 
01272         self.st.out(objref_methods, methods = methods)
01273 
01274         # registerObjRef()
01275         self.st.out(objref_register, ifid = ifid, modname = self.modname)
01276 
01277         # Skeleton class
01278         if node.inherits():
01279             inheritl = []
01280             for i in node.inherits():
01281                 i = i.fullDecl()
01282                 fsn = fixupScopedName(i.scopedName())
01283                 dsn = dotName(fsn)
01284                 ssn = skeletonModuleName(dsn)
01285                 inheritl.append(ssn)
01286                 
01287             inherits = string.join(inheritl, ", ")
01288         else:
01289             inherits = "PortableServer.Servant"
01290 
01291         self.st.out(skeleton_class,
01292                     ifid      = ifid,
01293                     inherits  = inherits,
01294                     modname   = self.modname,
01295                     s_modname = skeletonModuleName(self.modname),
01296                     package   = module_package)
01297 
01298         # Operations and attributes
01299         methodl = []
01300 
01301         for c in node.callables():
01302             if isinstance(c, idlast.Attribute):
01303 
01304                 for attr in c.identifiers():
01305 
01306                     methodl.append('"_get_' + attr + '": ' + \
01307                                    '_0_' + self.modname + '.' + \
01308                                    ifid + '.' + '_d__get_' + attr)
01309 
01310                     if not c.readonly():
01311 
01312                         methodl.append('"_set_' + attr + '": ' + \
01313                                        '_0_' + self.modname + '.' + \
01314                                        ifid + '.' + '_d__set_' + attr)
01315 
01316             else: # Operation
01317                 opname = mangle(c.identifier())
01318                 
01319                 methodl.append('"' + opname + '": ' + '_0_' + self.modname + \
01320                                '.' + ifid + '.' + '_d_' + opname)
01321 
01322         methodmap = "{" + string.join(methodl, ", ") + "}"
01323 
01324         self.st.out(skeleton_methodmap, methodmap = methodmap)
01325 
01326         if node.inherits():
01327             for inheritclass in inheritl:
01328                 self.st.out(skeleton_inheritmap, inheritclass = inheritclass)
01329 
01330         self.st.out(skeleton_end,
01331                     ifid      = ifid,
01332                     modname   = self.modname,
01333                     s_modname = skeletonModuleName(self.modname),
01334                     package   = module_package)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitModule (   self,
  node 
)

Definition at line 985 of file pythonIDL.py.

00985 
00986     def visitModule(self, node):
00987         if self.handleImported(node):
00988             imodname = dotName(node.scopedName())
00989             ibasename,ext = os.path.splitext(os.path.basename(node.file()))
00990 
00991             if extern_stub_pkgs.has_key(ibasename):
00992                 package = extern_stub_pkgs[ibasename]
00993                 if package is None:
00994                     package = ""
00995                 else:
00996                     package = package + "."
00997             else:
00998                 package = module_package
00999 
01000             self.st.out(open_imported_module_name,
01001                         imodname=imodname,
01002                         s_imodname=skeletonModuleName(imodname),
01003                         package=package)
01004 
01005         assert self.at_module_scope
01006 
01007         sname = dotName(node.scopedName())
01008 
01009         if node.mainFile() or output_inline:
01010             self.st.out(module_start,
01011                         sname = sname,
01012                         s_sname = skeletonModuleName(sname),
01013                         filename = node.file(), package=module_package)
01014 
01015         parentmodname = self.modname
01016         self.modname  = dotName(node.scopedName())
01017 
01018         ags = self.at_global_scope
01019         if ags:
01020             self.currentScope = ["_0_" + node.identifier()]
01021         else:
01022             self.currentScope.append(node.identifier())
01023 
01024         self.at_global_scope = 0
01025 
01026         for n in node.definitions():
01027             n.accept(self)
01028 
01029         if ags:
01030             self.currentScope = ["_0_" + global_module]
01031         else:
01032             self.currentScope.pop()
01033         self.at_global_scope = ags
01034         self.modname         = parentmodname
01035 
01036         if node.mainFile() or output_inline:
01037             exported_modules[sname] = 1
01038             self.st.out(module_end, modname=parentmodname, sname=sname,
01039                         package=module_package)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitNative (   self,
  node 
)

Definition at line 1857 of file pythonIDL.py.

01857 
01858     def visitNative(self, node):
01859         if self.handleImported(node): return
01860 
01861         sys.stderr.write(main.cmdname + \
01862                          ": Warning: ignoring declaration of native " + \
01863                          node.identifier() + "\n")

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitStruct (   self,
  node 
)

Definition at line 1452 of file pythonIDL.py.

01452 
01453     def visitStruct(self, node):
01454         if self.handleImported(node): return
01455 
01456         sname = mangle(node.identifier())
01457 
01458         fscopedName = fixupScopedName(node.scopedName(), "")
01459 
01460         if node.recursive():
01461             if self.at_module_scope:
01462                 self.st.out(recursive_struct_descr_at_module_scope,
01463                             sname   = sname,
01464                             repoId  = node.repoId(),
01465                             modname = self.modname)
01466             else:
01467                 self.st.out(recursive_struct_descr,
01468                             sname   = sname,
01469                             repoId  = node.repoId(),
01470                             scope   = dotName(fscopedName[:-1]))
01471 
01472         self.st.out(struct_class,
01473                     sname      = sname,
01474                     repoId     = node.repoId(),
01475                     scopedname = dotName(fscopedName))
01476 
01477         if not self.at_module_scope:
01478             self.st.out(struct_class_name, cname = dotName(fscopedName))
01479 
01480         mnamel = []
01481         mdescl = []
01482         for mem in node.members():
01483 
01484             # Deal with nested declarations
01485             if mem.constrType():
01486                 self.st.inc_indent()
01487                 ams = self.at_module_scope
01488                 self.at_module_scope = 0
01489                 self.currentScope.append(node.identifier())
01490                 
01491                 mem.memberType().decl().accept(self)
01492 
01493                 self.currentScope.pop()
01494                 self.at_module_scope = ams
01495                 self.st.dec_indent()
01496                 self.st.out("")
01497 
01498             for decl in mem.declarators():
01499                 mnamel.append(mangle(decl.identifier()))
01500                 mdescl.append('"' + mangle(decl.identifier()) + '"')
01501                 
01502                 if self.at_module_scope:
01503                     mdescl.append(\
01504                         typeAndDeclaratorToDescriptor(mem.memberType(),
01505                                                       decl,
01506                                                       []))
01507                 else:
01508                     mdescl.append(\
01509                         typeAndDeclaratorToDescriptor(mem.memberType(),
01510                                                       decl,
01511                                                       self.currentScope))
01512         if len(mnamel) > 0:
01513             mnames = ", " + string.join(mnamel, ", ")
01514 
01515             self.st.out(struct_class_init, mnames = mnames)
01516 
01517             for mname in mnamel:
01518                 self.st.out(struct_init_member, mname = mname)
01519 
01520         if len(mdescl) > 0:
01521             mdescs = ", " + string.join(mdescl, ", ")
01522         else:
01523             mdescs = ""
01524 
01525         if self.at_module_scope:
01526             self.st.out(struct_descriptor_at_module_scope,
01527                         sname   = sname,
01528                         mdescs  = mdescs,
01529                         modname = self.modname)
01530             
01531             self.st.out(struct_register_at_module_scope,
01532                         sname   = sname,
01533                         modname = self.modname)
01534         else:
01535             self.st.out(struct_descriptor,
01536                         sname  = sname,
01537                         mdescs = mdescs,
01538                         scope  = dotName(fscopedName[:-1]))
01539 
01540             self.st.out(struct_register, sname = sname)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitStructForward (   self,
  node 
)

Definition at line 1544 of file pythonIDL.py.

01544 
01545     def visitStructForward(self, node):
01546         if self.handleImported(node): return
01547 
01548         sname = mangle(node.identifier())
01549 
01550         if self.at_module_scope:
01551             self.st.out(forward_struct_descr_at_module_scope,
01552                         sname   = sname,
01553                         repoId  = node.repoId(),
01554                         modname = self.modname)
01555         else:
01556             self.st.out(forward_struct_descr,
01557                         sname   = sname,
01558                         repoId  = node.repoId(),
01559                         modname = self.modname)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitTypedef (   self,
  node 
)

Definition at line 1361 of file pythonIDL.py.

01361 
01362     def visitTypedef(self, node):
01363         if self.handleImported(node): return
01364 
01365         if node.constrType():
01366             node.aliasType().decl().accept(self)
01367 
01368         for decl in node.declarators():
01369             tdname = mangle(decl.identifier())
01370             if self.at_module_scope:
01371                 desc   = typeAndDeclaratorToDescriptor(node.aliasType(),
01372                                                        decl, [])
01373                 tddesc = typeAndDeclaratorToDescriptor(node.aliasType(),
01374                                                        decl, [], 1)
01375 
01376                 unaliased_type = node.aliasType().unalias()
01377 
01378                 if len(decl.sizes()) == 0 and \
01379                    unaliased_type.kind() in [idltype.tk_struct,
01380                                              idltype.tk_union]:
01381 
01382                     parent = dotName(fixupScopedName(unaliased_type.decl().\
01383                                                      scopedName()))
01384 
01385                     self.st.out(typedef_struct_union_header,
01386                                 tdname = tdname,
01387                                 repoId = decl.repoId(),
01388                                 parent = parent)
01389 
01390                 elif len(decl.sizes()) == 0 and\
01391                      unaliased_type.kind() == idltype.tk_fixed:
01392 
01393                     self.st.out(typedef_fixed_header,
01394                                 tdname = tdname,
01395                                 repoId = decl.repoId(),
01396                                 digits = unaliased_type.digits(),
01397                                 scale  = unaliased_type.scale())
01398                     
01399                 else:
01400                     self.st.out(typedef_header,
01401                                 tdname  = tdname,
01402                                 repoId  = decl.repoId())
01403 
01404                 self.st.out(typedef_at_module_scope,
01405                             tdname  = tdname,
01406                             desc    = desc,
01407                             tddesc  = tddesc,
01408                             modname = self.modname)
01409             else:
01410                 desc   = typeAndDeclaratorToDescriptor(node.aliasType(),
01411                                                        decl,
01412                                                        self.currentScope)
01413                 tddesc = typeAndDeclaratorToDescriptor(node.aliasType(),
01414                                                        decl,
01415                                                        self.currentScope, 1)
01416 
01417                 unaliased_type = node.aliasType().unalias()
01418 
01419                 if len(decl.sizes()) == 0 and \
01420                    unaliased_type.kind() in [idltype.tk_struct,
01421                                              idltype.tk_union]:
01422 
01423                     psname  = unaliased_type.decl().scopedName()
01424                     myscope = decl.scopedName()[:-1]
01425 
01426                     # If the struct/union definition is in the same
01427                     # scope as the typedef, we must use a relative
01428                     # name to refer to the parent class, since the
01429                     # enclosing Python class has not yet been fully
01430                     # defined.
01431 
01432                     if psname[:len(myscope)] == myscope:
01433                         parent = dotName(psname[len(myscope):])
01434                     else:
01435                         parent = dotName(fixupScopedName(psname))
01436 
01437                     self.st.out(typedef_struct_union_header,
01438                                 tdname = tdname,
01439                                 repoId = decl.repoId(),
01440                                 parent = parent)
01441                 else:
01442                     self.st.out(typedef_header,
01443                                 tdname  = tdname,
01444                                 repoId  = decl.repoId())
01445 
01446                 self.st.out(typedef,
01447                             tdname  = tdname,
01448                             desc    = desc,
                            tddesc  = tddesc)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitUnion (   self,
  node 
)

Definition at line 1633 of file pythonIDL.py.

01633 
01634     def visitUnion(self, node):
01635         if self.handleImported(node): return
01636 
01637         uname = mangle(node.identifier())
01638         if self.at_module_scope:
01639             stype = typeToDescriptor(node.switchType(), [])
01640         else:
01641             stype = typeToDescriptor(node.switchType(), self.currentScope)
01642 
01643         fscopedName = fixupScopedName(node.scopedName(), "")
01644         
01645         if node.recursive():
01646             if self.at_module_scope:
01647                 self.st.out(recursive_union_descr_at_module_scope,
01648                             uname   = uname,
01649                             repoId  = node.repoId(),
01650                             modname = self.modname)
01651             else:
01652                 self.st.out(recursive_union_descr,
01653                             uname   = uname,
01654                             repoId  = node.repoId(),
01655                             scope   = dotName(fscopedName[:-1]))
01656 
01657         self.st.out(union_class,
01658                     uname      = uname,
01659                     repoId     = node.repoId(),
01660                     scopedname = dotName(fscopedName))
01661 
01662         if not self.at_module_scope:
01663             self.st.out(union_class_name, cname = dotName(fscopedName))
01664 
01665         if node.constrType():
01666             self.st.inc_indent()
01667             ams = self.at_module_scope
01668             self.at_module_scope = 0
01669             self.currentScope.append(node.identifier())
01670             
01671             node.switchType().decl().accept(self)
01672 
01673             self.currentScope.pop()
01674             self.at_module_scope = ams
01675             self.st.dec_indent()
01676 
01677         def_m    = "None"
01678         def_d    = "None"
01679         m_def    = "None"
01680         defpos   = "-1"
01681         m_to_d_l = []
01682         d_to_m_l = []
01683         m_un_l   = []
01684         d_map_l  = []
01685 
01686         i = 0
01687         for case in node.cases():
01688 
01689             # Deal with nested declarations
01690             if case.constrType():
01691                 self.st.inc_indent()
01692                 ams = self.at_module_scope
01693                 self.at_module_scope = 0
01694                 self.currentScope.append(node.identifier())
01695                 
01696                 case.caseType().decl().accept(self)
01697 
01698                 self.currentScope.pop()
01699                 self.at_module_scope = ams
01700                 self.st.dec_indent()
01701                 self.st.out("")
01702 
01703             if self.at_module_scope:
01704                 ctype = typeAndDeclaratorToDescriptor(case.caseType(),
01705                                                       case.declarator(),
01706                                                       [])
01707             else:
01708                 ctype = typeAndDeclaratorToDescriptor(case.caseType(),
01709                                                       case.declarator(),
01710                                                       self.currentScope)
01711 
01712             cname = mangle(case.declarator().identifier())
01713 
01714             for label in case.labels():
01715                 if label.default():
01716                     def_m  = '"' + cname + '"'
01717                     defpos = str(i)
01718                     if self.at_module_scope:
01719                         def_d  = valueToString(label.value(),
01720                                                label.labelKind(), [])
01721                         m_def  = "_0_" + self.modname + "._m_" + uname + \
01722                                  "[" + defpos + "]"
01723                     else:
01724                         def_d  = valueToString(label.value(),
01725                                                label.labelKind(),
01726                                                self.currentScope)
01727                         m_def  = "_m_" + uname + "[" + defpos + "]"
01728 
01729                     m_un_l.append('(' + def_d + ', "' + cname + '", ' +\
01730                                   ctype + ')')
01731                 else:
01732                     if self.at_module_scope:
01733                         slabel = valueToString(label.value(),
01734                                                label.labelKind(), [])
01735                     else:
01736                         slabel = valueToString(label.value(),
01737                                                label.labelKind(),
01738                                                self.currentScope)
01739 
01740                     m_to_d_l.append('"' + cname + '": ' + slabel)
01741                     d_to_m_l.append(slabel + ': "' + cname + '"')
01742 
01743                     m_un_l.append('(' + slabel + ', "' + cname + '", ' +\
01744                                   ctype + ')')
01745 
01746                     if self.at_module_scope:
01747                         d_map_l.append(slabel + ': ' + '_0_' + self.modname + \
01748                                        "._m_" + uname + "[" + str(i) + "]")
01749                     else:
01750                         d_map_l.append(slabel + ': ' + "_m_" + \
01751                                        uname + "[" + str(i) + "]")
01752                 i = i + 1
01753 
01754         m_to_d = string.join(m_to_d_l, ", ")
01755         d_to_m = string.join(d_to_m_l, ", ")
01756         m_un   = string.join(m_un_l,   ", ")
01757         d_map  = string.join(d_map_l,  ", ")
01758 
01759         if self.at_module_scope:
01760             self.st.out(union_descriptor_at_module_scope,
01761                         uname   = uname,
01762                         m_to_d  = m_to_d,
01763                         d_to_m  = d_to_m,
01764                         def_m   = def_m,
01765                         def_d   = def_d,
01766                         m_un    = m_un,
01767                         stype   = stype,
01768                         defpos  = defpos,
01769                         m_def   = m_def,
01770                         d_map   = d_map,
01771                         modname = self.modname)
01772             
01773             self.st.out(union_register_at_module_scope,
01774                         uname   = uname,
01775                         modname = self.modname)
01776         else:
01777             self.st.out(union_descriptor,
01778                         uname   = uname,
01779                         m_to_d  = m_to_d,
01780                         d_to_m  = d_to_m,
01781                         def_m   = def_m,
01782                         def_d   = def_d,
01783                         m_un    = m_un,
01784                         stype   = stype,
01785                         defpos  = defpos,
01786                         m_def   = m_def,
01787                         d_map   = d_map,
01788                         scope   = dotName(fscopedName[:-1]))
01789             
01790             self.st.out(union_register, uname = uname)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitUnionForward (   self,
  node 
)

Definition at line 1794 of file pythonIDL.py.

01794 
01795     def visitUnionForward(self, node):
01796         if self.handleImported(node): return
01797 
01798         uname = mangle(node.identifier())
01799 
01800         if self.at_module_scope:
01801             self.st.out(forward_union_descr_at_module_scope,
01802                         uname   = uname,
01803                         repoId  = node.repoId(),
01804                         modname = self.modname)
01805         else:
01806             self.st.out(forward_union_descr,
01807                         uname   = uname,
01808                         repoId  = node.repoId(),
01809                         modname = self.modname)

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitValue (   self,
  node 
)

Definition at line 1927 of file pythonIDL.py.

01927 
01928     def visitValue(self, node):
01929         if self.handleImported(node): return
01930 
01931         vname = mangle(node.identifier())
01932 
01933         fscopedName = fixupScopedName(node.scopedName(), "")
01934         scopedname  = dotName(fscopedName)
01935 
01936         if node.inherits():
01937             inheritl = []
01938             for i in node.inherits():
01939                 i = i.fullDecl()
01940                 inheritl.append(dotName(fixupScopedName(i.scopedName())))
01941             
01942         else:
01943             inheritl = ["_0_CORBA.ValueBase"]
01944 
01945         skeleton_opl = []
01946         for i in node.supports():
01947             i = i.fullDecl()
01948             sn = fixupScopedName(i.scopedName())
01949             sn[0] = sn[0] + "__POA"
01950             dn = dotName(sn)
01951             inheritl.append(dn)
01952             skeleton_opl.append(dn)
01953 
01954         inherits = string.join(inheritl, ", ")
01955 
01956         # Go up the chain of inherited interfaces, picking out the
01957         # state members
01958         members = []
01959         ilist   = []
01960         cnode   = node
01961         
01962         while 1:
01963             cin = cnode.inherits()
01964             if not cin:
01965                 break
01966             i = cin[0].fullDecl()
01967             if not isinstance(i, idlast.Value):
01968                 break
01969             ilist.append(i)
01970             cnode = i
01971 
01972         ilist.reverse()
01973         ilist.append(node)
01974         
01975         for i in ilist:
01976             members.extend(i.statemembers())
01977 
01978         set_argl = []
01979 
01980         for i in range(len(members)):
01981             member = members[i]
01982             for d in member.declarators():
01983                 set_argl.append("self.%s = args[%d]" %
01984                                 (mangle(d.identifier()),i))
01985 
01986         if set_argl:
01987             set_args = string.join(set_argl, "\n")
01988         else:
01989             set_args = "pass"
01990 
01991         if len(set_argl) == 1:
01992             s = ""
01993         else:
01994             s = "s"
01995 
01996         self.st.out(value_class,
01997                     vname=vname, scopedname=scopedname, repoId=node.repoId(),
01998                     inherits=inherits, set_args=set_args, arglen=len(set_argl),
01999                     s=s, modname=self.modname)
02000 
02001         # Declarations within the value
02002         if len(node.declarations()) > 0:
02003             self.st.inc_indent()
02004             self.at_module_scope = 0
02005             self.currentScope.append(node.identifier())
02006 
02007             for d in node.declarations():
02008                 d.accept(self)
02009 
02010             self.currentScope.pop()
02011             self.at_module_scope = 1
02012             self.st.dec_indent()
02013             self.st.out("")
02014 
02015         # Skeleton operation declarations if necessary
02016         if node.supports():
02017             self.st.out(skeleton_methodmap, methodmap="{}")
02018             for i in skeleton_opl:
02019                 self.st.out(skeleton_inheritmap, inheritclass=i)
02020 
02021             self.st.out(skeleton_set_skel, ifid=vname)
02022 
02023         # Register factory if no callables or factories
02024         register_factory = 1
02025 
02026         if not all_factories:
02027             cnode = node
02028             while 1:
02029                 if cnode.callables() or cnode.factories() or cnode.supports():
02030                     register_factory = 0
02031                     break
02032                 cin = cnode.inherits()
02033                 if not cin:
02034                     break
02035                 for n in cin:
02036                     n = n.fullDecl()
02037                     if not isinstance(n, idlast.Value):
02038                         register_factory = 0
02039                         break
02040                 cnode = cin[0].fullDecl()
02041 
02042         if register_factory:
02043             self.st.out(value_register_factory, vname=vname)
02044         
02045         # If value supports some interfaces, output an objref class for it
02046         if node.supports():
02047             inheritl = []
02048             methodl  = []
02049             for i in node.supports():
02050                 i = i.fullDecl()
02051                 sn = fixupScopedName(i.scopedName())
02052                 inheritl.append(dotName(sn[:-1] + ["_objref_" + sn[-1]]))
02053                 methodl.append(dotName(sn[:-1] + ["_objref_" + sn[-1]]) +
02054                                ".__methods__")
02055                 
02056             inherits = string.join(inheritl, ", ")
02057 
02058             self.st.out(objref_class, ifid=vname, inherits=inherits)
02059 
02060             for inclass in inheritl:
02061                 self.st.out(objref_inherit_init, inclass=inclass)
02062 
02063             methods = string.join(methodl, " + ")
02064             self.st.out(objref_methods, methods = methods)
02065 
02066             # registerObjRef()
02067             self.st.out(value_objref_register,
02068                         ifid=vname, modname=self.modname)
02069 
02070         # Modifier
02071         if node.custom():
02072             modifier = "_0_CORBA.VM_CUSTOM"
02073         elif node.truncatable():
02074             modifier = "_0_CORBA.VM_TRUNCATABLE"
02075         else:
02076             modifier = "_0_CORBA.VM_NONE"
02077 
02078         # Truncatable bases
02079         tbasel = []
02080         cnode  = node
02081         while 1:
02082             cin = cnode.inherits()
02083             if not cin:
02084                 break
02085             i = cin[0]
02086             i = i.fullDecl()
02087             if not isinstance(i, idlast.Value):
02088                 break
02089             if cnode.truncatable():
02090                 sn = fixupScopedName(i.scopedName())
02091                 tbasel.append(dotName(sn) + "._NP_RepositoryId")
02092             else:
02093                 break
02094             cnode = i
02095 
02096         if tbasel:
02097             tbaseids = "(%s._NP_RepositoryId, %s)" % (vname,
02098                                                      string.join(tbasel, ", "))
02099         else:
02100             tbaseids = "None"
02101 
02102         basedesc = None
02103         if node.inherits():
02104             i = node.inherits()[0].fullDecl()
02105             if isinstance(i, idlast.Value):
02106                 sn = i.scopedName()[:]
02107                 sn[-1] = "_d_" + sn[-1]
02108                 basedesc = dotName(fixupScopedName(sn))
02109 
02110         if basedesc is None:
02111             basedesc = "_0_CORBA.tcInternal.tv_null"
02112 
02113         mlist = []
02114         for m in node.statemembers():
02115             for d in m.declarators():
02116                 mlist.append('"%s"' % mangle(d.identifier()))
02117                 mlist.append(typeAndDeclaratorToDescriptor(m.memberType(),
02118                                                            d, []))
02119                 if m.memberAccess() == 1:
02120                     mlist.append("_0_CORBA.PRIVATE_MEMBER")
02121                 else:
02122                     mlist.append("_0_CORBA.PUBLIC_MEMBER")
02123                     
02124         mdescs = string.join(mlist, ", ")
02125         self.st.out(value_descriptor_at_module_scope,
02126                     vname=vname, modifier=modifier, tbaseids=tbaseids,
02127                     basedesc=basedesc, mdescs=mdescs, modname=self.modname)
02128 
02129 

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitValueAbs (   self,
  node 
)

Definition at line 1883 of file pythonIDL.py.

01883 
01884     def visitValueAbs(self, node):
01885         if self.handleImported(node): return
01886 
01887         vname = mangle(node.identifier())
01888 
01889         fscopedName = fixupScopedName(node.scopedName(), "")
01890         scopedname  = dotName(fscopedName)
01891 
01892         if node.inherits():
01893             inheritl = []
01894             for i in node.inherits():
01895                 i = i.fullDecl()
01896                 inheritl.append(dotName(fixupScopedName(i.scopedName())))
01897             
01898             inherits = string.join(inheritl, ", ")
01899         else:
01900             inherits = "_0_CORBA.ValueBase"
01901 
01902         self.st.out(valueabs_class,
01903                     vname=vname, scopedname=scopedname, repoId=node.repoId(),
01904                     inherits=inherits, modname=self.modname)
01905 
01906         # Declarations within the value
01907         if len(node.declarations()) > 0:
01908             self.st.inc_indent()
01909             self.at_module_scope = 0
01910             self.currentScope.append(node.identifier())
01911 
01912             for d in node.declarations():
01913                 d.accept(self)
01914 
01915             self.currentScope.pop()
01916             self.at_module_scope = 1
01917             self.st.dec_indent()
01918             self.st.out("")
01919 
01920         basedesc = "_0_CORBA.tcInternal.tv_null"
01921 
01922         self.st.out(value_descriptor_at_module_scope,
01923                     vname=vname, modifier="_0_CORBA.VM_ABSTRACT",
01924                     tbaseids="None", basedesc=basedesc, mdescs="",
01925                     modname=self.modname)
01926 

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitValueBox (   self,
  node 
)

Definition at line 1873 of file pythonIDL.py.

01873 
01874     def visitValueBox(self, node):
01875         if self.handleImported(node): return
01876 
01877         boxname = mangle(node.identifier())
01878         boxdesc = typeToDescriptor(node.boxedType())
01879 
01880         self.st.out(valuebox, boxname=boxname, repoId=node.repoId(),
01881                     boxdesc=boxdesc, modname=self.modname)
01882 

Here is the call graph for this function:

def pythonIDL.PythonVisitor.visitValueForward (   self,
  node 
)

Definition at line 1864 of file pythonIDL.py.

01864 
01865     def visitValueForward(self, node):
01866         if self.handleImported(node): return
01867 
01868         vname = mangle(node.identifier())
01869 
01870         self.st.out(value_forward_at_module_scope,
01871                     vname=vname, repoId=node.repoId(), modname=self.modname)
01872 

Here is the call graph for this function:


Member Data Documentation

Definition at line 954 of file pythonIDL.py.

Definition at line 953 of file pythonIDL.py.

Definition at line 955 of file pythonIDL.py.

Definition at line 965 of file pythonIDL.py.

Definition at line 923 of file pythonIDL.py.

Definition at line 922 of file pythonIDL.py.


The documentation for this class was generated from the following file: