Move .Net Td API to Api namespace.
GitOrigin-RevId: 5a8a0c9ccd49575e6e15db354e60b027e0346b19
This commit is contained in:
parent
7c445958ed
commit
6c6544fd06
@ -182,10 +182,12 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
"#include \"td/utils/port/CxCli.h\"\n"
|
"#include \"td/utils/port/CxCli.h\"\n"
|
||||||
"#include \"td/tl/tl_dotnet_object.h\"\n\n"
|
"#include \"td/tl/tl_dotnet_object.h\"\n\n"
|
||||||
"namespace Telegram {\n"
|
"namespace Telegram {\n"
|
||||||
"namespace Td {\n";
|
"namespace Td {\n"
|
||||||
|
"namespace Api {\n";
|
||||||
}
|
}
|
||||||
std::string gen_output_end() const override {
|
std::string gen_output_end() const override {
|
||||||
return "}\n"
|
return "}\n"
|
||||||
|
"}\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +226,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
fixed_field_name += "Value";
|
fixed_field_name += "Value";
|
||||||
}
|
}
|
||||||
if (type_name.substr(0, field_name.size()) == field_name) {
|
if (type_name.substr(0, field_name.size()) == field_name) {
|
||||||
auto fixed_type_name = "::Telegram::Td::" + type_name;
|
auto fixed_type_name = "::Telegram::Td::Api::" + type_name;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "private:\n";
|
ss << "private:\n";
|
||||||
ss << " " << fixed_type_name << " " << fixed_field_name << "Private;\n";
|
ss << " " << fixed_type_name << " " << fixed_field_name << "Private;\n";
|
||||||
@ -251,14 +253,14 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
ss << "\n";
|
ss << "\n";
|
||||||
if (storer_type) {
|
if (storer_type) {
|
||||||
ss << (is_header_ ? " virtual " : "") << "String^ " << (is_header_ ? "" : gen_class_name(class_name) + "::")
|
ss << (is_header_ ? " virtual " : "") << "String^ " << (is_header_ ? "" : gen_class_name(class_name) + "::")
|
||||||
<< "ToString()" << (is_header_ ? " override;" : " {\n return ::Telegram::Td::ToString(this);\n}") << "\n";
|
<< "ToString()" << (is_header_ ? " override;" : " {\n return ::Telegram::Td::Api::ToString(this);\n}") << "\n";
|
||||||
} else {
|
} else {
|
||||||
ss << (is_header_ ? " virtual " : "") << "NativeObject^ "
|
ss << (is_header_ ? " virtual " : "") << "NativeObject^ "
|
||||||
<< (is_header_ ? "" : gen_class_name(class_name) + "::") << "ToUnmanaged()";
|
<< (is_header_ ? "" : gen_class_name(class_name) + "::") << "ToUnmanaged()";
|
||||||
if (is_header_) {
|
if (is_header_) {
|
||||||
ss << ";\n";
|
ss << ";\n";
|
||||||
} else {
|
} else {
|
||||||
ss << "{\n return REF_NEW NativeObject(::Telegram::Td::ToUnmanaged(this).release());\n}\n";
|
ss << "{\n return REF_NEW NativeObject(::Telegram::Td::Api::ToUnmanaged(this).release());\n}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ss.str();
|
return ss.str();
|
||||||
@ -283,7 +285,7 @@ class TlWriterDotNet : public TL_writer {
|
|||||||
if (field_type.substr(0, 5) == "Array") {
|
if (field_type.substr(0, 5) == "Array") {
|
||||||
ss << "CXCONST ";
|
ss << "CXCONST ";
|
||||||
} else if (field_type.substr(0, 6) != "String" && to_upper(field_type[0]) == field_type[0]) {
|
} else if (field_type.substr(0, 6) != "String" && to_upper(field_type[0]) == field_type[0]) {
|
||||||
field_type = "::Telegram::Td::" + field_type;
|
field_type = "::Telegram::Td::Api::" + field_type;
|
||||||
}
|
}
|
||||||
ss << field_type << " " << to_camelCase(a.name);
|
ss << field_type << " " << to_camelCase(a.name);
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
@ -18,12 +18,12 @@ namespace Td {
|
|||||||
using namespace CxCli;
|
using namespace CxCli;
|
||||||
|
|
||||||
public interface class ClientResultHandler {
|
public interface class ClientResultHandler {
|
||||||
void OnResult(BaseObject^ object);
|
void OnResult(Api::BaseObject^ object);
|
||||||
};
|
};
|
||||||
|
|
||||||
public ref class Client sealed {
|
public ref class Client sealed {
|
||||||
public:
|
public:
|
||||||
void Send(Function^ function, ClientResultHandler^ handler) {
|
void Send(Api::Function^ function, ClientResultHandler^ handler) {
|
||||||
if (function == nullptr) {
|
if (function == nullptr) {
|
||||||
throw REF_NEW NullReferenceException("Function can't be null");
|
throw REF_NEW NullReferenceException("Function can't be null");
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public:
|
|||||||
client->send(std::move(request));
|
client->send(std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseObject^ Execute(Function^ function) {
|
Api::BaseObject^ Execute(Api::Function^ function) {
|
||||||
if (function == nullptr) {
|
if (function == nullptr) {
|
||||||
throw REF_NEW NullReferenceException("Function can't be null");
|
throw REF_NEW NullReferenceException("Function can't be null");
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
td::Client::Request request;
|
td::Client::Request request;
|
||||||
request.id = 0;
|
request.id = 0;
|
||||||
request.function = td::td_api::move_object_as<td::td_api::Function>(ToUnmanaged(function)->get_object_ptr());
|
request.function = td::td_api::move_object_as<td::td_api::Function>(ToUnmanaged(function)->get_object_ptr());
|
||||||
return FromUnmanaged(*client->execute(std::move(request)).object);
|
return Api::FromUnmanaged(*client->execute(std::move(request)).object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUpdatesHandler(ClientResultHandler^ handler) {
|
void SetUpdatesHandler(ClientResultHandler^ handler) {
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
while (true) {
|
while (true) {
|
||||||
auto response = client->receive(10.0);
|
auto response = client->receive(10.0);
|
||||||
if (response.object != nullptr) {
|
if (response.object != nullptr) {
|
||||||
ProcessResult(response.id, FromUnmanaged(*response.object));
|
ProcessResult(response.id, Api::FromUnmanaged(*response.object));
|
||||||
|
|
||||||
if (response.object->get_id() == td::td_api::updateAuthorizationState::ID &&
|
if (response.object->get_id() == td::td_api::updateAuthorizationState::ID &&
|
||||||
static_cast<td::td_api::updateAuthorizationState &>(*response.object).authorization_state_->get_id() ==
|
static_cast<td::td_api::updateAuthorizationState &>(*response.object).authorization_state_->get_id() ==
|
||||||
@ -86,7 +86,7 @@ private:
|
|||||||
ConcurrentDictionary<std::uint64_t, ClientResultHandler^> handlers;
|
ConcurrentDictionary<std::uint64_t, ClientResultHandler^> handlers;
|
||||||
td::Client *client = nullptr;
|
td::Client *client = nullptr;
|
||||||
|
|
||||||
void ProcessResult(std::uint64_t id, BaseObject^ object) {
|
void ProcessResult(std::uint64_t id, Api::BaseObject^ object) {
|
||||||
ClientResultHandler^ handler;
|
ClientResultHandler^ handler;
|
||||||
// update handler stays forever
|
// update handler stays forever
|
||||||
if (id == 0 ? handlers.TryGetValue(id, handler) : handlers.TryRemove(id, handler)) {
|
if (id == 0 ? handlers.TryGetValue(id, handler) : handlers.TryRemove(id, handler)) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace Telegram {
|
namespace Telegram {
|
||||||
namespace Td {
|
namespace Td {
|
||||||
|
namespace Api {
|
||||||
|
|
||||||
using namespace CxCli;
|
using namespace CxCli;
|
||||||
|
|
||||||
@ -174,5 +175,6 @@ inline String^ ToString(BaseObject^ from) {
|
|||||||
return string_from_unmanaged(td::td_api::to_string(ToUnmanaged(from)->get_object_ptr()));
|
return string_from_unmanaged(td::td_api::to_string(ToUnmanaged(from)->get_object_ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Api
|
||||||
} // namespace Td
|
} // namespace Td
|
||||||
} // namespace Telegram
|
} // namespace Telegram
|
||||||
|
Reference in New Issue
Block a user