<s> import ufora . BackendGateway . ComputedGraph . ComputedGraph as ComputedGraph <EOL> import logging <EOL> class FieldImpl ( object ) : <EOL> def __init__ ( self , f , setter ) : <EOL> object . __init__ ( self ) <EOL> self . f = f <EOL> self . setter = setter <EOL> def __get__ ( self , obj , objType ) : <EOL> if obj is None : <EOL> return self <EOL> return self . f ( obj ) <EOL> def __call__ ( self , * args ) : <EOL> return self . f ( * args ) <EOL> def Field ( setter = None ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( f ) : <EOL> return FieldImpl ( f , setter ) <EOL> return decorator <EOL> class FunctionImpl ( object ) : <EOL> def __init__ ( self , f ) : <EOL> object . __init__ ( self ) <EOL> self . f = f <EOL> def __get__ ( self , obj , objType ) : <EOL> if obj is None : <EOL> return self <EOL> def closure ( * args ) : <EOL> return self . f ( obj , * args ) <EOL> return closure <EOL> def __call__ ( self , * args ) : <EOL> return self . f ( * args ) <EOL> def Function ( ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( f ) : <EOL> return FunctionImpl ( f ) <EOL> return decorator <EOL> def isPropertyToExpose ( classMember ) : <EOL> if isinstance ( classMember , FieldImpl ) : <EOL> return True <EOL> if isinstance ( classMember , ComputedGraph . Key ) : <EOL> return True <EOL> if isinstance ( classMember , ( <EOL> ComputedGraph . Property , <EOL> ComputedGraph . PropertyMaker , <EOL> ComputedGraph . Mutable <EOL> ) ) : <EOL> return classMember . exposeToProtocol <EOL> return False <EOL> def propertyHasSetter ( classMember ) : <EOL> if isinstance ( classMember , ( ComputedGraph . PropertyMaker , ComputedGraph . Mutable ) ) : <EOL> return True <EOL> if isinstance ( classMember , ComputedGraph . Key ) : <EOL> return False <EOL> return classMember . setter is not None <EOL> def isFunctionToExpose ( classMember ) : <EOL> if isinstance ( classMember , FunctionImpl ) : <EOL> return True <EOL> if isinstance ( classMember , ComputedGraph . Function ) : <EOL> return classMember . exposeToProtocol <EOL> return False <EOL> def functionExpectsExpandedArgs ( classMember ) : <EOL> if isinstance ( classMember , ComputedGraph . Function ) : <EOL> return classMember . expandArgs <EOL> return False <EOL> def functionExpectsCallback ( classMember ) : <EOL> if isinstance ( classMember , ComputedGraph . Function ) : <EOL> return classMember . wantsCallback <EOL> return False <EOL> def getSetter ( fieldname , classMember ) : <EOL> if isinstance ( classMember , ( ComputedGraph . Mutable , ComputedGraph . Property , ComputedGraph . PropertyMaker ) ) : <EOL> def setter ( object , value ) : <EOL> setattr ( object , fieldname , value ) <EOL> return setter <EOL> else : <EOL> return classMember . setter </s>
