Fix .NET binding.

GitOrigin-RevId: 4e251471a358c4d5546663eca7cd16b91ec2574e
This commit is contained in:
levlam 2020-04-08 22:21:42 +03:00
parent 77c7f4c660
commit af61f0c7c4
3 changed files with 8 additions and 7 deletions

View File

@ -54,7 +54,7 @@ class DotnetTlDocumentationGenerator extends TlDocumentationGenerator
case 'string':
return 'String^';
case 'bytes':
return 'Array<byte>^';
return 'Array<BYTE>^';
case 'bool':
case 'int':
case 'long':
@ -210,7 +210,7 @@ EOT
while (substr($field_type, $pos, 6) === 'Array<') {
$pos += 6;
}
if (substr($field_type, $pos, 6) !== 'String' && ucfirst(substr($field_type, $pos)) === substr($field_type, $pos)) {
if (substr($field_type, $pos, 4) !== 'BYTE' && substr($field_type, $pos, 6) !== 'String' && ucfirst(substr($field_type, $pos)) === substr($field_type, $pos)) {
$field_type = substr($field_type, 0, $pos).'::Telegram::Td::Api::'.substr($field_type, $pos);
}
$full_constructor .= $colon.$field_type.' '.$this->getParameterName($name, $class_name);

View File

@ -158,7 +158,7 @@ class TlWriterDotNet : public TL_writer {
return "String^";
}
if (name == "Bytes") {
return "Array<byte>^";
return "Array<BYTE>^";
}
if (name == "Vector") {
@ -288,7 +288,8 @@ class TlWriterDotNet : public TL_writer {
while (field_type.substr(pos, 6) == "Array<") {
pos += 6;
}
if (field_type.substr(pos, 6) != "String" && to_upper(field_type[pos]) == field_type[pos]) {
if (field_type.substr(pos, 4) != "BYTE" && field_type.substr(pos, 6) != "String" &&
to_upper(field_type[pos]) == field_type[pos]) {
field_type = field_type.substr(0, pos) + "::Telegram::Td::Api::" + field_type.substr(pos);
}
ss << field_type << " " << to_camelCase(a.name);
@ -383,7 +384,7 @@ class TlWriterDotNet : public TL_writer {
} else {
ss << ", ";
}
bool need_bytes = gen_field_type(it) == "Array<byte>^" || gen_field_type(it) == "Array<Array<byte>^>^";
bool need_bytes = gen_field_type(it) == "Array<BYTE>^" || gen_field_type(it) == "Array<Array<BYTE>^>^";
ss << (need_bytes ? "Bytes" : "") << "FromUnmanaged(from." << gen_native_field_name(it.name) << ")";
}
ss << ");\n}\n";

View File

@ -63,7 +63,7 @@ inline String^ FromUnmanaged(const std::string &from) {
}
inline auto CLRCALL BytesFromUnmanaged(const std::string &from) {
Array<byte>^ res = REF_NEW Vector<byte>(static_cast<ArrayIndexType>(from.size()));
Array<BYTE>^ res = REF_NEW Vector<BYTE>(static_cast<ArrayIndexType>(from.size()));
ArrayIndexType i = 0;
for (auto b : from) {
ArraySet(res, i++, b);
@ -160,7 +160,7 @@ inline std::string ToUnmanaged(String ^from) {
return string_to_unmanaged(from);
}
inline std::string ToUnmanaged(Array<byte>^ from) {
inline std::string ToUnmanaged(Array<BYTE>^ from) {
if (!from) {
return std::string();
}