Move .Net Td API to Api namespace.

GitOrigin-RevId: 5a8a0c9ccd49575e6e15db354e60b027e0346b19
This commit is contained in:
levlam 2018-02-28 21:38:21 +03:00
parent 7c445958ed
commit 6c6544fd06
3 changed files with 15 additions and 11 deletions

View File

@ -182,10 +182,12 @@ class TlWriterDotNet : public TL_writer {
"#include \"td/utils/port/CxCli.h\"\n"
"#include \"td/tl/tl_dotnet_object.h\"\n\n"
"namespace Telegram {\n"
"namespace Td {\n";
"namespace Td {\n"
"namespace Api {\n";
}
std::string gen_output_end() const override {
return "}\n"
"}\n"
"}\n";
}
@ -224,7 +226,7 @@ class TlWriterDotNet : public TL_writer {
fixed_field_name += "Value";
}
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;
ss << "private:\n";
ss << " " << fixed_type_name << " " << fixed_field_name << "Private;\n";
@ -251,14 +253,14 @@ class TlWriterDotNet : public TL_writer {
ss << "\n";
if (storer_type) {
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 {
ss << (is_header_ ? " virtual " : "") << "NativeObject^ "
<< (is_header_ ? "" : gen_class_name(class_name) + "::") << "ToUnmanaged()";
if (is_header_) {
ss << ";\n";
} 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();
@ -283,7 +285,7 @@ class TlWriterDotNet : public TL_writer {
if (field_type.substr(0, 5) == "Array") {
ss << "CXCONST ";
} 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);
return ss.str();

View File

@ -18,12 +18,12 @@ namespace Td {
using namespace CxCli;
public interface class ClientResultHandler {
void OnResult(BaseObject^ object);
void OnResult(Api::BaseObject^ object);
};
public ref class Client sealed {
public:
void Send(Function^ function, ClientResultHandler^ handler) {
void Send(Api::Function^ function, ClientResultHandler^ handler) {
if (function == nullptr) {
throw REF_NEW NullReferenceException("Function can't be null");
}
@ -38,7 +38,7 @@ public:
client->send(std::move(request));
}
BaseObject^ Execute(Function^ function) {
Api::BaseObject^ Execute(Api::Function^ function) {
if (function == nullptr) {
throw REF_NEW NullReferenceException("Function can't be null");
}
@ -46,7 +46,7 @@ public:
td::Client::Request request;
request.id = 0;
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) {
@ -57,7 +57,7 @@ public:
while (true) {
auto response = client->receive(10.0);
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 &&
static_cast<td::td_api::updateAuthorizationState &>(*response.object).authorization_state_->get_id() ==
@ -86,7 +86,7 @@ private:
ConcurrentDictionary<std::uint64_t, ClientResultHandler^> handlers;
td::Client *client = nullptr;
void ProcessResult(std::uint64_t id, BaseObject^ object) {
void ProcessResult(std::uint64_t id, Api::BaseObject^ object) {
ClientResultHandler^ handler;
// update handler stays forever
if (id == 0 ? handlers.TryGetValue(id, handler) : handlers.TryRemove(id, handler)) {

View File

@ -14,6 +14,7 @@
namespace Telegram {
namespace Td {
namespace Api {
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()));
}
} // namespace Api
} // namespace Td
} // namespace Telegram