Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getIdentifier( self ): return self.getName()
def getValue( self ): return self.__value
class ExceptionType(Type):
def __init__( self, *args, **kwds ):
Type.__init__( self, *args, **kwds )
self.__members = []
def __repr__( self ):
return self.__class__.__name__ + " " + self.getName() + "\n{\n" + "\n".join( [" " + repr( member ) + ";" for member in self.getMembers()] ) + "\n};"
def addMember( self, member, *args, **kwds ): return self._addConstruct( member, "ExceptionTypeMember", Declaration, self.__members, *args, **kwds )
def getMembers( self ): return self.__members
class ExceptionTypeMember(Declaration): pass
class Include(Construct):
def __init__( self, scope, file_path, local=True ):
Construct.__init__( self, scope, [file_path] )
self.__local = local
def __eq__( self, other ):
return self.getFilePath() == other.getFilePath() and self.isLocal() == other.isLocal()
def __hash__( self ):
return hash( self.__repr__() )
def getFilePath( self ): return self.getName()
def isLocal( self ): return self.__local
def __init__( self, scope, qname, tag=0, parent_type_names=None, members=[] ):
Type.__init__( self, scope, qname, tag )
self.__parent_type_names = parent_type_names is not None and parent_type_names or []
if members is None: # A forward declaration or an undefined type
self.__members = None
else:
self.__members = []
if len( members ) > 0:
for member in members:
assert isinstance( member, Declaration )
self.__members.append( member )
class Declaration(Construct):
def __init__( self, scope, type, qname, tag=0, default_value=None ):
assert isinstance( type, Type )
Construct.__init__( self, scope, qname, tag )
self.__type = type
self.__default_value = default_value
def __repr__( self ):
return repr( self.getType() ) + " " + self.getIdentifier()
def getDefaultValue( self ): return self.__default_value
def getIdentifier( self ): return self.getName()
def getType( self ): return self.__type
class Constant(Declaration):
def __init__( self, scope, type, qname, value ):
Declaration.__init__( self, scope, type, qname )
self.__value = value
def __repr__( self ):
return "const " + Declaration.__repr__( self )
def getValue( self ): return self.__value
class EnumeratedType(Type):
def __init__( self, *args, **kwds ):
Type.__init__( self, *args, **kwds )
self.__enumerators = []
def __repr__( self ):
def addMember( self, member, *args, **kwds ): return self._addConstruct( member, "ExceptionTypeMember", Declaration, self.__members, *args, **kwds )
def getMembers( self ): return self.__members
def _getResponseType( self, return_value_identifier="_return_value" ):
try:
return self.__response_type
except AttributeError:
response_params = copy( self.getOutboundParameters() )
if self.getReturnType() is not None:
response_params.append( OperationParameter( in_=False, out_=True, scope=self.getScope(), type=self.getReturnType(), qname=self.getQualifiedName()+[return_value_identifier] ) )
self.__response_type = self._createConstruct( "ResponseType", Type, self.getQualifiedName()[:-1] + [self.getQualifiedName()[-1] + "Response"], self.getTag(), None, response_params )
return self.__response_type
def getReturnType( self ): return self.__return_type
def isConst( self ): return self.__const
def isOneway( self ): return self.__oneway
class OperationParameter(Declaration):
def __init__( self, scope, type, qname, in_=True, out_=False, tag=0, default_value=None ):
assert in_ or out_
Declaration.__init__( self, scope, type, qname, tag, default_value )
self.__in = in_
self.__out = out_
def __repr__( self ):
inout = []
if self.isInbound(): inout.append( "in" )
if self.isOutbound: inout.append( "out" )
return "".join( inout ) + " " + Declaration.__repr__( self )
def isInbound( self ): return self.__in
def isOutbound( self ): return self.__out
else:
self.__members = []
if len( members ) > 0:
for member in members:
assert isinstance( member, Declaration )
self.__members.append( member )
def __repr__( self ):
return self.__class__.__name__ + " " + self.getName() + "\n{\n" + "\n".join( [" " + repr( member ) + ";" for member in self.getMembers()] ) + "\n};"
def addMember( self, member, *args, **kwds ): return self._addConstruct( member, "StructTypeMember", Declaration, self.__members, *args, **kwds )
def getMembers( self ): return self.__members
def getMarshallerTypeName( self ): return "Struct"
def getParentTypeNames( self ): return self.__parent_type_names
class StructTypeMember(Declaration): pass
class Target(Scope):
def __init__( self ):
Construct.__init__( self, None, [self.__class__.__name__] )
self.__builtin_types = []
self.__includes = []
self.__modules = []
def __repr__( self ):
return rpad( "\n".join( [repr( include ) for include in self.getIncludes()] ), "\n\n" ) + \
"\n".join( [repr( module ) for module in self.getModules()] )
def generate( self ):
for module in self.getModules(): module.generate()