This commit is contained in:
blueloveTH 2022-12-04 16:46:33 +08:00
parent d954e74188
commit 46230f4225
4 changed files with 8 additions and 8 deletions

View File

@ -233,7 +233,7 @@ import json as _json
def jsonrpc(method, params, raw=False):
assert type(method) is str
assert type(params) is list
assert type(params) is list or type(params) is tuple
data = {
'jsonrpc': '2.0',
'method': method,

View File

@ -51,7 +51,7 @@ void _tvm_dispatch(ThreadedVM* vm){
ss << '{';
ss << "\"result\": " << _Str(line).__escape(false);
ss << '}';
pkpy_tvm_jsonrpc_response(vm, ss.str().c_str());
pkpy_tvm_write_jsonrpc_response(vm, ss.str().c_str());
}else{
std::cout << "unknown jsonrpc call" << std::endl;
std::cout << obj << std::endl;

View File

@ -830,14 +830,14 @@ extern "C" {
__EXPORT
/// Read the current JSONRPC request from shared string buffer.
char* pkpy_tvm_read_jsonrpc_request(ThreadedVM* vm){
_Str s = vm->readSharedStr();
_Str s = vm->readJsonRpcRequest();
return strdup(s.c_str());
}
__EXPORT
/// Write a JSONRPC response to shared string buffer.
void pkpy_tvm_jsonrpc_response(ThreadedVM* vm, const char* value){
vm->jsonrpcResponse(value);
void pkpy_tvm_write_jsonrpc_response(ThreadedVM* vm, const char* value){
vm->writeJsonrpcResponse(value);
}
__EXPORT

View File

@ -1103,7 +1103,7 @@ public:
ThreadedVM* tvm = (ThreadedVM*)vm;
tvm->_sharedStr = data;
tvm->suspend();
return tvm->PyStr(tvm->readSharedStr());
return tvm->PyStr(tvm->readJsonRpcRequest());
});
}
@ -1124,7 +1124,7 @@ public:
}
}
_Str readSharedStr(){
_Str readJsonRpcRequest(){
_Str copy = _sharedStr;
_sharedStr = ""_c;
return copy;
@ -1136,7 +1136,7 @@ public:
return _state;
}
void jsonrpcResponse(const char* value){
void writeJsonrpcResponse(const char* value){
if(_state != THREAD_SUSPENDED) UNREACHABLE();
_state = THREAD_RUNNING;
_sharedStr = _Str(value);