コード例 #1
0
    def __init__(self,*args):
        test_util.DummyEndpoint.__init__(self,*args)

        # adding data for a
        self.alpha_name = 'alpha'
        self._global_var_store.add_var(
            self.alpha_name,
            wVariables.WaldoNumVariable(
                self.alpha_name,self._host_uuid,
                False,1))

        setattr(
            self,
            util.endpoint_call_func_name('update_alpha'),
            self.update_alpha)
        setattr(
            self,
            util.endpoint_call_func_name('update_alpha_and_send_message'),
            self.update_alpha_and_send_message)
コード例 #2
0
    def __init__(self,conn_obj,host_uuid=None):
        test_util.DummyEndpoint.__init__(self,conn_obj,host_uuid)

        # when dispatching to partner, we request the function name as
        # it would appear in the Waldo source file.  However, the
        # compiler mangles it into another name.  The call below
        # ensures that that the mangled name exists.
        setattr(
            self,
            util.endpoint_call_func_name('endpoint_func'),
            self.endpoint_func)
コード例 #3
0
    def __init__(self,*args):
        test_util.DummyEndpoint.__init__(self,*args)

        # adding data for b
        self.beta_name = 'beta'
        self._global_var_store.add_var(
            self.beta_name,
            wVariables.WaldoNumVariable(
                self.beta_name,self._host_uuid,
                False,1))
        setattr(
            self,
            util.endpoint_call_func_name('update_beta'),
            self.update_beta)
        setattr(
            self,
            util.partner_endpoint_msg_call_func_name('update_beta_when_receive_message'),
            self.update_beta_when_receive_message)
コード例 #4
0
ファイル: emit_endpoints.py プロジェクト: JayThomason/Waldo
def emit_public_method_interface(
    public_method_node,endpoint_name,ast_root,fdep_dict,emit_ctx):
    '''
    @param {AstNode} public_method_node --- An AstNode with label
    AST_PUBLIC_FUNCTION
    '''
    method_name_node = public_method_node.children[0]
    method_name = method_name_node.value

    method_arg_names = get_method_arg_names(public_method_node)
    # turns the array of argnames above into a single string of csv
    # arg names
    comma_sep_arg_names = reduce (
        lambda x, y : x + ',' + y,
        method_arg_names,'')

    public_header = '''
def %s(self%s):
''' % (method_name, comma_sep_arg_names)

    # wait until ready initialization for node has completed before
    # continuing
    public_body = '''
# ensure that both sides have completed their onCreate calls
# before continuing
self._block_ready()
'''
    
    #### Deep copy non-external args
    # non_ext_arg_names is an array of strings
    non_ext_arg_names = get_non_external_arg_names_from_func_node(
        public_method_node)
                
    # do not need to copy arguments in: each function call does so on
    # its own.

    # Each element in this list is an index for a return parameter
    # that should be de-waldo-ified before returning.  We pass this
    # argument to the internal function that the internal function
    # knows which returns need to be de-waldo-ified before being
    # returned and which do not.
    list_return_external_positions = (
        get_external_return_positions_from_func_node(public_method_node))

    #### create a root event + ctx for event, call internal, and reurn
    internal_method_name = lib_util.endpoint_call_func_name(method_name)
    public_body += '''
while True:  # FIXME: currently using infinite retry 
    _root_event = self._act_event_map.create_root_event()
    _ctx = %s(
        self._global_var_store,
        # not using sequence local store
        %s(self._host_uuid))

    # call internal function... note True as last param tells internal
    # version of function that it needs to de-waldo-ify all return
    # arguments (while inside transaction) so that this method may
    # return them....if it were false, might just get back refrences
    # to Waldo variables, and de-waldo-ifying them outside of the
    # transaction might return over-written/inconsistent values.
    _to_return = self.%s(_root_event,_ctx %s,%s)
    # try committing root event
    _root_event.request_commit()
    _commit_resp = _root_event.event_complete_queue.get()
    if isinstance(_commit_resp,%s):
        # means it isn't a backout message: we're done
        return _to_return
''' % (emit_utils.library_transform('ExecutingEventContext'),
       emit_utils.library_transform('VariableStore'),
       internal_method_name,
       comma_sep_arg_names,
       str(list_return_external_positions),
       emit_utils.library_transform('CompleteRootCallResult'))

    return public_header + emit_utils.indent_str(public_body)