Fix C++/CLI.

GitOrigin-RevId: fd48669cdc54fafa3475dbd1aa6ab7cd49055a23
This commit is contained in:
levlam 2018-03-11 23:49:38 +03:00
parent e3d0534318
commit 1dd2e28551
4 changed files with 16 additions and 10 deletions

View File

@ -269,7 +269,7 @@ Client::Client() : impl_(make_unique<Impl>()) {
init_openssl_threads();
}
void Client::send(Request request) {
void Client::send(Request &&request) {
impl_->send(std::move(request));
}
@ -277,7 +277,7 @@ Client::Response Client::receive(double timeout) {
return impl_->receive(timeout);
}
Client::Response Client::execute(Request request) {
Client::Response Client::execute(Request &&request) {
Response response;
response.id = request.id;
response.object = Td::static_request(std::move(request.function));

View File

@ -77,7 +77,7 @@ class Client final {
* Sends request to TDLib. May be called from any thread.
* \param[in] request Request to TDLib.
*/
void send(Request request);
void send(Request &&request);
/**
* A response to a request, or an incoming update from TDLib.
@ -109,7 +109,7 @@ class Client final {
* \param[in] request Request to the TDLib.
* \return The request response.
*/
static Response execute(Request request);
static Response execute(Request &&request);
/**
* Destroys the client and TDLib instance.

View File

@ -17,8 +17,8 @@ using namespace CxCli;
public ref class Log sealed {
public:
static void SetFilePath(String^ filePath) {
::td::Log::set_file_path(string_to_unmanaged(filePath));
static bool SetFilePath(String^ filePath) {
return ::td::Log::set_file_path(string_to_unmanaged(filePath));
}
static void SetMaxFileSize(std::int64_t maxFileSize) {

View File

@ -74,8 +74,11 @@ inline std::int64_t Increment(volatile std::int64_t &value) {
return InterlockedIncrement64(&value);
}
inline std::string string_to_unmanaged(String^ string) {
return td::from_wstring(string->Data(), string->Length()).ok();
inline std::string string_to_unmanaged(String^ str) {
if (!str) {
return std::string();
}
return td::from_wstring(str->Data(), str->Length()).ok();
}
inline String^ string_from_unmanaged(const std::string &from) {
@ -117,8 +120,11 @@ inline std::int64_t Increment(std::int64_t %value) {
return System::Threading::Interlocked::Increment(value);
}
inline std::string string_to_unmanaged(String^ string) {
return msclr::interop::marshal_as<std::string>(string);
inline std::string string_to_unmanaged(String^ str) {
if (!str) {
return std::string();
}
return msclr::interop::marshal_as<std::string>(str);
}
inline String^ string_from_unmanaged(const std::string &from) {