Move .Net classes to Telegram::Td namespace.

GitOrigin-RevId: 31d5cf030c30d7a1f58099decdcec265dbf6be0a
This commit is contained in:
levlam 2018-02-28 04:11:29 +03:00
parent 1b2367c866
commit 83d845ad32
6 changed files with 23 additions and 14 deletions

View File

@ -281,7 +281,7 @@ set(TL_C_SCHEME_SOURCE
set_source_files_properties(${TL_DOTNET_AUTO} PROPERTIES GENERATED TRUE) set_source_files_properties(${TL_DOTNET_AUTO} PROPERTIES GENERATED TRUE)
set(TL_DOTNET_SCHEME_SOURCE set(TL_DOTNET_SCHEME_SOURCE
${TL_TD_DOTNET_AUTO} ${TL_DOTNET_AUTO}
td/tl/tl_dotnet_object.h td/tl/tl_dotnet_object.h
) )

View File

@ -37,7 +37,7 @@ set(TL_C_AUTO
PARENT_SCOPE PARENT_SCOPE
) )
set(TL_TD_DOTNET_AUTO set(TL_DOTNET_AUTO
${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdDotNetApi.cpp ${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdDotNetApi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdDotNetApi.h ${CMAKE_CURRENT_SOURCE_DIR}/auto/td/telegram/TdDotNetApi.h
PARENT_SCOPE PARENT_SCOPE

View File

@ -180,10 +180,12 @@ class TlWriterDotNet : public TL_writer {
return prefix_ + return prefix_ +
"#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 TdWindows {\n"; "namespace Telegram {\n"
"namespace Td {\n";
} }
std::string gen_output_end() const override { std::string gen_output_end() const override {
return "}\n"; return "}\n"
"}\n";
} }
std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const override { std::string gen_forward_class_declaration(const std::string &class_name, bool is_proxy) const override {
@ -221,7 +223,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 = "::TdWindows::" + type_name; auto fixed_type_name = "::Telegram::Td::" + 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";
@ -248,14 +250,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 ::TdWindows::ToString(this);\n}") << "\n"; << "ToString()" << (is_header_ ? " override;" : " {\n return ::Telegram::Td::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(::TdWindows::ToUnmanaged(this).release());\n}\n"; ss << "{\n return REF_NEW NativeObject(::Telegram::Td::ToUnmanaged(this).release());\n}\n";
} }
} }
return ss.str(); return ss.str();
@ -280,7 +282,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 = "::TdWindows::" + field_type; field_type = "::Telegram::Td::" + field_type;
} }
ss << field_type << " " << to_camelCase(a.name); ss << field_type << " " << to_camelCase(a.name);
return ss.str(); return ss.str();

View File

@ -10,7 +10,8 @@
#include "td/utils/port/CxCli.h" #include "td/utils/port/CxCli.h"
namespace TdWindows { namespace Telegram {
namespace Td {
using namespace CxCli; using namespace CxCli;
@ -93,4 +94,5 @@ private:
} }
}; };
} // namespace TdWindows } // namespace Td
} // namespace Telegram

View File

@ -8,7 +8,8 @@
#include "td/utils/port/CxCli.h" #include "td/utils/port/CxCli.h"
namespace TdWindows { namespace Telegram {
namespace Td {
using namespace CxCli; using namespace CxCli;
@ -27,4 +28,5 @@ public:
} }
}; };
} // namespace TdWindows } // namespace Td
} // namespace Telegram

View File

@ -12,7 +12,9 @@
#include "td/telegram/td_api.h" #include "td/telegram/td_api.h"
#include "td/telegram/td_api.hpp" #include "td/telegram/td_api.hpp"
namespace TdWindows { namespace Telegram {
namespace Td {
using namespace CxCli; using namespace CxCli;
public ref class NativeObject sealed { public ref class NativeObject sealed {
@ -172,4 +174,5 @@ 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 TdWindows } // namespace Td
} // namespace Telegram