Add ez_restore function to Client. Also add c++.capnp and rpc.capnp
This commit is contained in:
27
capnp/c++.capnp
Normal file
27
capnp/c++.capnp
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@0xbdf87d7bb8304e81;
|
||||
$namespace("capnp::annotations");
|
||||
|
||||
annotation namespace(file): Text;
|
||||
@@ -1559,6 +1559,15 @@ cdef class RpcClient:
|
||||
else:
|
||||
raise ValueError("objectId unexpectedly was not convertible to the proper type")
|
||||
|
||||
cpdef ez_restore(self, textId) except +reraise_kj_exception:
|
||||
import rpc_capnp
|
||||
# ez-rpc from the C++ API uses SturdyRef.objectId under the hood
|
||||
ref = rpc_capnp.SturdyRef.new_message()
|
||||
# objectId is an AnyPointer, so we have a special method for setting it to text
|
||||
ref.objectId.set_as_text('calculator')
|
||||
|
||||
return self.restore(ref.objectId)
|
||||
|
||||
cdef class RpcServer:
|
||||
cdef RpcSystem * thisptr
|
||||
cdef public _TwoPartyVatNetwork network
|
||||
@@ -2561,6 +2570,9 @@ def add_import_hook(additional_paths=[]):
|
||||
if _importer is not None:
|
||||
remove_import_hook()
|
||||
|
||||
this_dir = _os.path.join(_os.path.dirname(__file__), '..')
|
||||
additional_paths.append(this_dir)
|
||||
|
||||
_importer = _Importer(additional_paths)
|
||||
_sys.meta_path.append(_importer)
|
||||
|
||||
|
||||
1251
capnp/rpc.capnp
Normal file
1251
capnp/rpc.capnp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user