def __init__(self, scope): ''' Create a new GlobalsManager for the scope @param scope: the scope owner of this manager @type scope: L{Scope} ''' Observable.__init__(self, [GlobalsManager.EVENT_NEW_DEFINITION]) RestrictedManager.__init__(self, scope)
def addDefinition(self, definition): ''' Add a new definition and notify observers about this @param definition: a new function definition @type definition: L{GlobalVarDefinition} ''' RestrictedManager.addDefinition(self, definition) # after i added the definition, i need to fire the event self.fire(self.__class__.EVENT_NEW_DEFINITION, definition)
def __init__(self, scope): ''' Create a new GlobalsManager for the scope @param scope: the scope owner of this manager @type scope: L{Scope} ''' Observable.__init__(self, [ GlobalsManager.EVENT_NEW_DEFINITION ]) RestrictedManager.__init__(self, scope)
def __init__(self, scope): ''' Create a new FunctionsManager for the scope @param scope: the scope owner of this manager @type scope: L{Scope} ''' Observable.__init__(self, [FunctionsManager.EVENT_NEW_DEFINITION]) RestrictedManager.__init__(self, scope) # need to import system function definitions # bypass registerSystemFunction to avoid debug logger self._systemsFunctions = Functions_ImportSystemDefinitions() '''definitions of system-functions'''
def __init__(self, scope): ''' Create a new FunctionsManager for the scope @param scope: the scope owner of this manager @type scope: L{Scope} ''' Observable.__init__(self, [ FunctionsManager.EVENT_NEW_DEFINITION ]) RestrictedManager.__init__(self, scope) # need to import system function definitions # bypass registerSystemFunction to avoid debug logger self._systemsFunctions = Functions_ImportSystemDefinitions() '''definitions of system-functions'''
def addDefinition(self, definition): ''' Add a new definition and notify observers about this @param definition: a new function definition @type definition: L{FunctionDefinition} ''' # need to check definition: # if definition scope different from this one # i need to mark the function as not forward # and lock redefinition if definition.moduleName != self.scope.moduleName and definition.isForward: definition.isForward = False myclips.logger.debug("DefFunction %s::%s imported. Can't be redefined", definition.moduleName, definition.name) RestrictedManager.addDefinition(self, definition) # after i added the definition, i need to fire the event self.fire(self.__class__.EVENT_NEW_DEFINITION, definition)
def getDefinition(self, defName): ''' Get a definition (sys or user one) for defName @param defName: a function sign @type defName: string @rtype: FunctionDefinition ''' try: return self.getSystemFunctionDefinition(defName) except: return RestrictedManager.getDefinition(self, defName)
def addDefinition(self, definition): ''' Add a new definition and notify observers about this @param definition: a new function definition @type definition: L{FunctionDefinition} ''' # need to check definition: # if definition scope different from this one # i need to mark the function as not forward # and lock redefinition if definition.moduleName != self.scope.moduleName and definition.isForward: definition.isForward = False myclips.logger.debug( "DefFunction %s::%s imported. Can't be redefined", definition.moduleName, definition.name) RestrictedManager.addDefinition(self, definition) # after i added the definition, i need to fire the event self.fire(self.__class__.EVENT_NEW_DEFINITION, definition)
def has(self, definitionName): ''' Check if a definition name is used in the this manager (search into user-functions and sys-functions) definitionName will be set as taken if: - sys-function exists with same sign - a user-function already used with the same sign exists definitionName will be set as available if: - no sys-function or user-function use the same sign - a user-function already used the sign, BUT it could be redefined (only if not used yet: FunctionDefinition.isForward = True) @param definitionName: the function name @type definitionName: string @rtype: boolean ''' return ((self.hasSystemFunction(definitionName) or RestrictedManager.has(self, definitionName)) and not self.getDefinition(definitionName).isForward)