Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class Type(Construct):
def __repr__( self ):
return self.getQualifiedName( "::" )
def getMarshallerTypeName( self ):
return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in self.getName().split( " " )] )
class BoolType(Type): pass
class BufferType(Type): pass
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 ):
includes.extend( construct.getIncludes() )
return includes
def getInterfaces( self ): return self.__interfaces
def getModules( self ): return self.__modules
def getTypes( self ): return self.__types
class NumericType(Type):
def getMarshallerTypeName( self ):
name = self.getName()
if name.endswith( "_t" ): name = name[:-2]
return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in name.split( " " )] )
class Operation(Construct):
def __init__( self, scope, qname, oneway=False, return_type=None, const=False, tag=0 ):
if oneway: assert return_type is None
else: assert return_type is None or isinstance( return_type, Type )
assert isinstance( const, bool )
Construct.__init__( self, scope, qname, tag )
self.__oneway = oneway
self.__return_type = return_type
self.__const = const
self.__parameters = []
def __repr__( self ):
return self.__class__.__name__ + " " + ( self.isOneway() and "oneway " or "" ) + ( self.getReturnType() is None and "void" or repr( self.getReturnType() ) ) + " " + self.getName() + "( " + ", ".join( [repr( param ) for param in self.getParameters()] ) + " );"
def addParameter( self, parameter, *args, **kwds ): return self._addConstruct( parameter, "OperationParameter", OperationParameter, self.__parameters, *args, **kwds )
def getInboundParameters( self ): return [param for param in self.getParameters() if param.isInbound()]
def getOutboundParameters( self, include_return_value=None ): return [param for param in self.getParameters() if param.isOutbound()]
class Scope(Construct):
def __init__( self, scope, qname, local=False, tag=0 ):
Construct.__init__( self, scope, qname, tag )
self.__local = local
self.__constants = []
def __repr__( self ):
return rpad( "\n".join( [repr( constant ) for constant in self.getConstants()] ), "\n\n" )
def addConstant( self, constant, *args, **kwds ): return self._addConstruct( constant, "Constant", Constant, self.__constants, *args, **kwds )
def getConstants( self ): return self.__constants
def isLocal( self ): return self.__local
class Type(Construct):
def __repr__( self ):
return self.getQualifiedName( "::" )
def getMarshallerTypeName( self ):
return "".join( ["".join( ( space_part[0].upper(), space_part[1:] ) ) for space_part in self.getName().split( " " )] )
class BoolType(Type): pass
class BufferType(Type): pass
class Declaration(Construct):
def __init__( self, scope, type, qname, tag=0, default_value=None ):
assert isinstance( type, Type )
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
class Interface(Scope):
def __init__( self, scope, qname, local=False, tag=0, parent_interface_names=None ):
def getValue( self ): return self.__value
class EnumeratedType(Type):
def __init__( self, *args, **kwds ):
Type.__init__( self, *args, **kwds )
self.__enumerators = []
def __repr__( self ):
return self.__class__.__name__ + " " + self.getName() + "\n{\n" + "\n".join( [" " + repr( enumerator ) + ";" for enumerator in self.getEnumerators()] ) + "\n};"
def addEnumerator( self, enumerator, *args, **kwds ): return self._addConstruct( enumerator, "Enumerator", Construct, self.__enumerators, *args, **kwds )
def getEnumerators( self ): return self.__enumerators
class Enumerator(Construct):
def __init__( self, scope, qname, value=None ):
Construct.__init__( self, scope, qname )
self.__value = value
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 addEnumerator( self, enumerator, *args, **kwds ): return self._addConstruct( enumerator, "Enumerator", Construct, self.__enumerators, *args, **kwds )
def getEnumerators( self ): return self.__enumerators
def generate( self ): pass
def getIncludes( self ): return []
def getName( self ): return self.__qname[-1]
def getQualifiedName( self, scope_separator=None ):
if scope_separator is not None:
return scope_separator.join( self.__qname )
else:
return self.__qname
def getScope( self ): return self.__scope
def getTag( self ): return self.__tag
class Scope(Construct):
def __init__( self, scope, qname, local=False, tag=0 ):
Construct.__init__( self, scope, qname, tag )
self.__local = local
self.__constants = []
def __repr__( self ):
return rpad( "\n".join( [repr( constant ) for constant in self.getConstants()] ), "\n\n" )
def addConstant( self, constant, *args, **kwds ): return self._addConstruct( constant, "Constant", Constant, self.__constants, *args, **kwds )
def getConstants( self ): return self.__constants
def isLocal( self ): return self.__local
class Type(Construct):
def __repr__( self ):
return self.getQualifiedName( "::" )