From c4e42ab49019bcd9f05217abe8e5d4c083622473 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 22 Jan 2024 13:13:49 -0800 Subject: Fix language server for VS. (#3473) Co-authored-by: Yong He --- source/compiler-core/slang-json-rpc-connection.cpp | 18 ++++++++++++++++++ source/compiler-core/slang-json-rpc-connection.h | 2 ++ 2 files changed, 20 insertions(+) (limited to 'source/compiler-core') diff --git a/source/compiler-core/slang-json-rpc-connection.cpp b/source/compiler-core/slang-json-rpc-connection.cpp index c4413d306..af9dd9e48 100644 --- a/source/compiler-core/slang-json-rpc-connection.cpp +++ b/source/compiler-core/slang-json-rpc-connection.cpp @@ -136,6 +136,24 @@ SlangResult JSONRPCConnection::sendError(JSONRPC::ErrorCode errorCode, const Uno return sendRPC(&errorResponse); } +SlangResult JSONRPCConnection::checkArrayObjectWrap( const JSONValue& srcArgs, const RttiInfo* dstArgsRttiInfo, void* dstArgs, const JSONValue& id ) +{ + if ( dstArgsRttiInfo->m_kind == RttiInfo::Kind::Struct && + srcArgs.getKind() == JSONValue::Kind::Array ) + { + auto array = m_container.getArray( srcArgs ); + if ( array.getCount() == 1 ) + { + return toNativeOrSendError( array[0], dstArgsRttiInfo, dstArgs, id ); + } + return SLANG_OK; + } + else + { + return toNativeOrSendError( srcArgs, dstArgsRttiInfo, dstArgs, id ); + } +} + SlangResult JSONRPCConnection::toNativeArgsOrSendError(const JSONValue& srcArgs, const RttiInfo* dstArgsRttiInfo, void* dstArgs, const JSONValue& id) { if (dstArgsRttiInfo->m_kind == RttiInfo::Kind::Struct && diff --git a/source/compiler-core/slang-json-rpc-connection.h b/source/compiler-core/slang-json-rpc-connection.h index 7246fb780..f5525d033 100644 --- a/source/compiler-core/slang-json-rpc-connection.h +++ b/source/compiler-core/slang-json-rpc-connection.h @@ -48,6 +48,8 @@ public: /// Disconnect. May block while server shuts down void disconnect(); + SlangResult checkArrayObjectWrap( const JSONValue& srcArgs, const RttiInfo* dstArgsRttiInfo, void* dstArgs, const JSONValue& id ); + /// Convert value to dst. Will write response on fails SlangResult toNativeOrSendError(const JSONValue& value, const RttiInfo* info, void* dst, const JSONValue& id); -- cgit v1.2.3