Back to index

salome-paravis  6.5.0
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
pythonIDL.ExampleVisitor Class Reference

List of all members.

Public Member Functions

def __init__
def visitAST
def visitModule
def visitInterface
def visitBaseType
def visitStringType
def visitWStringType
def visitDeclaredType

Public Attributes

 st
 first

Static Public Attributes

dictionary ttsMap

Private Attributes

 __result_type

Detailed Description

Definition at line 2265 of file pythonIDL.py.


Constructor & Destructor Documentation

def pythonIDL.ExampleVisitor.__init__ (   self,
  st 
)

Definition at line 2266 of file pythonIDL.py.

02266 
02267     def __init__(self, st):
02268         self.st = st
02269         self.first = None


Member Function Documentation

def pythonIDL.ExampleVisitor.visitAST (   self,
  node 
)

Definition at line 2270 of file pythonIDL.py.

02270 
02271     def visitAST(self, node):
02272         for n in node.declarations():
02273             if not output_inline and not n.mainFile(): continue
02274 
02275             if isinstance(n, idlast.Module) or isinstance(n, idlast.Interface):
02276                 n.accept(self)

def pythonIDL.ExampleVisitor.visitBaseType (   self,
  type 
)

Definition at line 2417 of file pythonIDL.py.

02417 
02418     def visitBaseType(self, type):
02419         self.__result_type = self.ttsMap[type.kind()]

def pythonIDL.ExampleVisitor.visitDeclaredType (   self,
  type 
)

Definition at line 2433 of file pythonIDL.py.

02433 
02434     def visitDeclaredType(self, type):
02435         self.__result_type = idlutil.ccolonName(type.decl().scopedName())
02436 
02437 
02438 
02439 

def pythonIDL.ExampleVisitor.visitInterface (   self,
  node 
)

Definition at line 2284 of file pythonIDL.py.

02284 
02285     def visitInterface(self, node):
02286         ifname = mangle(node.identifier())
02287         sname  = node.scopedName()
02288         ccname = idlutil.ccolonName(sname)
02289         fsname = fixupScopedName(sname, prefix="")
02290         dname  = dotName(fsname)
02291         skname = skeletonModuleName(dname)
02292 
02293         if self.first is None:
02294             self.first = ifname
02295 
02296         if len(node.inherits()) == 1:
02297             inheritance_note = """
02298     # Note: this interface inherits from another interface. You must
02299     # either multiply inherit from the servant class implementing the
02300     # base interface, or explicitly implement the inherited operations
02301     # here.
02302     #
02303     # Inherited interface:
02304     #
02305 """
02306         elif node.inherits():
02307             inheritance_note = """
02308     # Note: this interface inherits from other interfaces. You must either
02309     # multiply inherit from the servant classes implementing the base
02310     # interfaces, or explicitly implement the inherited operations here.
02311     #
02312     # Inherited interfaces:
02313     #
02314 """
02315         else:
02316             inheritance_note = ""
02317 
02318         for inh in node.inherits():
02319             iname = idlutil.ccolonName(inh.fullDecl().scopedName())
02320             inheritance_note = inheritance_note + "    #   %s\n" % iname
02321         
02322         self.st.out(example_classdef, ifname=ifname,
02323                     ccname=ccname, skname=skname,
02324                     inheritance_note = inheritance_note)
02325 
02326         for c in node.callables():
02327 
02328             if isinstance(c, idlast.Attribute):
02329 
02330                 c.attrType().accept(self)
02331                 attrtype = self.__result_type
02332 
02333                 for attr in c.identifiers():
02334 
02335                     signature = "attribute %s %s" % (attrtype, attr)
02336 
02337                     if c.readonly():
02338                         signature = "readonly " + signature
02339 
02340                     if not c.readonly():
02341                         self.st.out(example_opdef,
02342                                     signature = signature,
02343                                     opname = "_set_" + attr,
02344                                     args = ", value",
02345                                     returnspec = "None")
02346 
02347                     self.st.out(example_opdef,
02348                                 signature = signature,
02349                                 opname = "_get_" + attr,
02350                                 args = "",
02351                                 returnspec = "attribute value")
02352             else:
02353                 # Operation
02354                 innames  = []
02355                 outnames = []
02356                 siglist  = []
02357 
02358                 c.returnType().accept(self)
02359                 rettype = self.__result_type
02360 
02361                 if c.returnType().kind() != idltype.tk_void:
02362                     outnames.append("result")
02363 
02364                 for p in c.parameters():
02365                     if p.is_in():
02366                         innames.append(p.identifier())
02367                     if p.is_out():
02368                         outnames.append(p.identifier())
02369 
02370                     direction = {0:"in", 1:"out", 2:"inout"}[p.direction()]
02371 
02372                     p.paramType().accept(self)
02373                     siglist.append("%s %s %s" % (direction,
02374                                                  self.__result_type,
02375                                                  p.identifier()))
02376 
02377                 signature = "%s %s(%s)" % (rettype, c.identifier(),
02378                                            string.join(siglist, ", "))
02379 
02380                 if innames:
02381                     args = ", " + string.join(innames, ", ")
02382                 else:
02383                     args = ""
02384 
02385                 if outnames:
02386                     returnspec = string.join(outnames, ", ")
02387                 else:
02388                     returnspec = "None"
02389 
02390                 self.st.out(example_opdef,
02391                             signature = signature,
02392                             opname = c.identifier(),
02393                             args = args,
02394                             returnspec = returnspec)
02395 
02396 

Here is the call graph for this function:

def pythonIDL.ExampleVisitor.visitModule (   self,
  node 
)

Definition at line 2277 of file pythonIDL.py.

02277 
02278     def visitModule(self, node):
02279         for n in node.definitions():
02280             if not output_inline and not n.mainFile(): continue
02281 
02282             if isinstance(n, idlast.Module) or isinstance(n, idlast.Interface):
02283                 n.accept(self)

def pythonIDL.ExampleVisitor.visitStringType (   self,
  type 
)

Definition at line 2420 of file pythonIDL.py.

02420 
02421     def visitStringType(self, type):
02422         if type.bound() == 0:
02423             self.__result_type = "string"
02424         else:
02425             self.__result_type = "string<" + str(type.bound()) + ">"

def pythonIDL.ExampleVisitor.visitWStringType (   self,
  type 
)

Definition at line 2426 of file pythonIDL.py.

02426 
02427     def visitWStringType(self, type):
02428         if type.bound() == 0:
02429             self.__result_type = "wstring"
02430         else:
02431             self.__result_type = "wstring<" + str(type.bound()) + ">"
02432 


Member Data Documentation

Definition at line 2418 of file pythonIDL.py.

Definition at line 2268 of file pythonIDL.py.

Definition at line 2267 of file pythonIDL.py.

dictionary pythonIDL.ExampleVisitor.ttsMap [static]
Initial value:
{
        idltype.tk_void:       "void",
        idltype.tk_short:      "short",
        idltype.tk_long:       "long",
        idltype.tk_ushort:     "unsigned short",
        idltype.tk_ulong:      "unsigned long",
        idltype.tk_float:      "float",
        idltype.tk_double:     "double",
        idltype.tk_boolean:    "boolean",
        idltype.tk_char:       "char",
        idltype.tk_octet:      "octet",
        idltype.tk_any:        "any",
        idltype.tk_TypeCode:   "CORBA::TypeCode",
        idltype.tk_Principal:  "CORBA::Principal",
        idltype.tk_longlong:   "long long",
        idltype.tk_ulonglong:  "unsigned long long",
        idltype.tk_longdouble: "long double",
        idltype.tk_wchar:      "wchar"
        }

Definition at line 2397 of file pythonIDL.py.


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