How to use the replication.share.yidl.src.yidl.target.Scope function in replication

To help you get started, we’ve selected a few replication examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
def __init__( self, scope, qname, tag, key_type, value_type ):
        assert isinstance( key_type, Type )
        assert isinstance( value_type, Type )
        Type.__init__( self, scope, qname, tag )        
        self.__key_type = key_type
        self.__value_type = value_type        

    def __repr__( self ):
        return self.__class__.__name__ + " " + self.getName() + "<" + repr( self.getKeyType() ) + ", " + repr( self.getValueType() ) + ">;"

    def getKeyType( self ): return self.__key_type
    def getMarshallerTypeName( self ): return "Map"
    def getValueType( self ): return self.__value_type    

        
class Module(Scope):
    def __init__( self, scope, qname, local=False, tag=0 ):
        Scope.__init__( self, scope, qname, local, tag )
        self.__enumerated_types = []        
        self.__interfaces = []
        self.__modules = []
        self.__types = []        
                
    def __repr__( self ):
        return Scope.__repr__( self ) + \
               rpad( "\n".join( [repr( enumerated_type ) for enumerated_type in self.getEnumeratedTypes()] ), "\n\n" ) + \
               rpad( "\n\n".join( [repr( module ) for module in self.getModules()] ), "\n\n" ) + \
               rpad( "".join( [lpad( "\n", repr( type ) ) for type in self.getTypes() if not isinstance( type, StructType ) or type.getMembers() is not None] ), "\n\n" ) + \
               "\n\n".join( [repr( interface ) for interface in self.getInterfaces()] )

    def generate( self ):        
        for interface in self.getInterfaces():
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
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() 
            
    def addBuiltinType( self, builtin_type, *args, **kwds ):
        if isinstance( builtin_type, Type ):
            self.__builtin_types.append( builtin_type )
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
def __repr__( self ):
        return Scope.__repr__( self ) + \
               rpad( "\n".join( [repr( enumerated_type ) for enumerated_type in self.getEnumeratedTypes()] ), "\n\n" ) + \
               rpad( "\n\n".join( [repr( module ) for module in self.getModules()] ), "\n\n" ) + \
               rpad( "".join( [lpad( "\n", repr( type ) ) for type in self.getTypes() if not isinstance( type, StructType ) or type.getMembers() is not None] ), "\n\n" ) + \
               "\n\n".join( [repr( interface ) for interface in self.getInterfaces()] )
github xtreemfs / babudb / replication / share / yidl / src / yidl / target.py View on Github external
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 ):
        assert parent_interface_names is None or isinstance( parent_interface_names, list )        
        Scope.__init__( self, scope, qname, local, tag )                
        self.__parent_interface_names = parent_interface_names is not None and parent_interface_names or []
        self.__exception_types = []
        self.__operations = []        

    def __repr__( self ):
        return Scope.__repr__( self ) + \
               rpad( "\n".join( [repr( exception_type ) for exception_type in self.getExceptionTypes()] ), "\n" ) + \
               "\n".join( [repr( operation ) for operation in self.getOperations()] )

    def generate( self ):
        for construct in self.getExceptionTypes() + self.getOperations(): 
            construct.generate()