Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 )
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
nonlocal_includes_dict = dict( ( include.getFilePath(), include ) for include in includes if not include.isLocal() )
local_includes_dict_keys = local_includes_dict.keys()
local_includes_dict_keys.sort()
nonlocal_includes_dict_keys = nonlocal_includes_dict.keys()
nonlocal_includes_dict_keys.sort()
includes = []
for includes_dict_key in local_includes_dict_keys:
includes.append( local_includes_dict[includes_dict_key] )
for includes_dict_key in nonlocal_includes_dict_keys:
includes.append( nonlocal_includes_dict[includes_dict_key] )
return includes
def getModules( self ): return self.__modules
class VariadicType(Type): pass
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
class PointerType(Type):
def getMarshallerTypeName(): return "Pointer"
class ReferenceType(PointerType): pass
class SequenceType(Type):
def __init__( self, scope, qname, tag, value_type ):
Type.__init__( self, scope, qname, tag )
self.__value_type = value_type
def __repr__( self ):
return self.__class__.__name__ + " " + self.getName() + "<" + repr( self.getValueType() ) + ">;"
def getMarshallerTypeName( self ): return "Sequence"
def getValueType( self ): return self.__value_type
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 ):
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 __init__( self, scope, qname, tag, value_type ):
Type.__init__( self, scope, qname, tag )
self.__value_type = value_type
def __repr__( self ):
return self.__class__.__name__ + " " + self.getName() + "<" + repr( self.getValueType() ) + ">;"
def getMarshallerTypeName( self ): return "Sequence"
def getValueType( self ): return self.__value_type
class StringType(Type):
def getMarshallerTypeName( self ): return "String"
class StructType(Type):
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 )
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 addBuiltinType( self, builtin_type, *args, **kwds ):
if isinstance( builtin_type, Type ):
self.__builtin_types.append( builtin_type )
return builtin_type
else:
assert isinstance( builtin_type, list ) and len( builtin_type ) >= 1
assert len( args ) == 0
assert len( kwds ) == 0
name = builtin_type[-1]
if name == "string": return self._addConstruct( builtin_type, "StringType", StringType, self.__builtin_types, *args, **kwds )
elif name == "bool": return self._addConstruct( builtin_type, "BoolType", BoolType, self.__builtin_types, *args, **kwds )
elif name == "buffer": return self._addConstruct( builtin_type, "BufferType", BufferType, self.__builtin_types, *args, **kwds )
elif name == "any" or name == "ptr": return self._addConstruct( builtin_type, "PointerType", PointerType, self.__builtin_types, *args, **kwds )
elif name.endswith( "*" ): return self._addConstruct( builtin_type, "PointerType", PointerType, self.__builtin_types, *args, **kwds )
elif name.endswith( "&" ): return self._addConstruct( builtin_type, "ReferenceType", ReferenceType, self.__builtin_types, *args, **kwds )
else: return self._addConstruct( builtin_type, "NumericType", NumericType, self.__builtin_types, *args, **kwds )
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
class ReferenceType(PointerType): pass
class SequenceType(Type):
def __init__( self, scope, qname, tag, value_type ):
Type.__init__( self, scope, qname, tag )
self.__value_type = value_type
def __repr__( self ):
return self.__class__.__name__ + " " + self.getName() + "<" + repr( self.getValueType() ) + ">;"
def getMarshallerTypeName( self ): return "Sequence"
def getValueType( self ): return self.__value_type
class StringType(Type):
def getMarshallerTypeName( self ): return "String"
class StructType(Type):
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 )
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 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] )