|
10 | 10 | #include <exception> |
11 | 11 | #include <fstream> |
12 | 12 | #include <ftw.h> |
| 13 | +#include <iomanip> |
13 | 14 | #include <iterator> |
14 | 15 | #include <map> |
15 | 16 | #include <sstream> |
@@ -326,12 +327,57 @@ struct FunctionGetTLFunctionName { |
326 | 327 | const PhpClassRepresentation& class_repr; |
327 | 328 |
|
328 | 329 | friend std::ostream& operator<<(std::ostream& os, const FunctionGetTLFunctionName& self) { |
| 330 | + // we will remove ALL tl2php code soon, so we added a bit hackish code here |
| 331 | + const char* header1 = R"( /** |
| 332 | + * @kphp-inline |
| 333 | + * |
| 334 | + * @return TL\RpcFunctionFetcher |
| 335 | + */ |
| 336 | + public function typedStore())"; |
| 337 | + const char* header2 = R"( /** |
| 338 | + * @kphp-inline |
| 339 | + * |
| 340 | + * @return TL\RpcFunctionFetcher |
| 341 | + */ |
| 342 | + public function typedFetch())"; |
| 343 | + const char* header_magic = R"( /** |
| 344 | + * @kphp-inline |
| 345 | + * |
| 346 | + * @return int |
| 347 | + */ |
| 348 | + public function getTLFunctionMagic())"; |
| 349 | + const char* body_null = R"({ |
| 350 | + return null; |
| 351 | + } |
| 352 | +
|
| 353 | +)"; |
| 354 | + os << header_magic; |
| 355 | + if (self.class_repr.is_interface) { |
| 356 | + os << ";" << std::endl; |
| 357 | + } else { |
| 358 | + std::stringstream ss; |
| 359 | + ss << std::hex << std::setw(8) << std::setfill('0') << self.class_repr.magic_id; |
| 360 | + os << " {" << std::endl << " return 0x" << ss.str() << ";" << std::endl << " }" << SkipLine{}; |
| 361 | + } |
329 | 362 | os << FunctionDeclaration{"getTLFunctionName", {}, "string", has_kphp_inline}; |
330 | 363 | if (self.class_repr.is_interface) { |
331 | | - return os << ";" << std::endl; |
| 364 | + os << ";" << std::endl; |
| 365 | + } else { |
| 366 | + os << " {" << std::endl << " return '" << self.class_repr.tl_name << "';" << std::endl << " }" << SkipLine{}; |
332 | 367 | } |
333 | | - |
334 | | - return os << " {" << std::endl << " return '" << self.class_repr.tl_name << "';" << std::endl << " }" << SkipLine{}; |
| 368 | + os << header1; |
| 369 | + if (self.class_repr.is_interface) { |
| 370 | + os << ";" << std::endl; |
| 371 | + } else { |
| 372 | + os << body_null; |
| 373 | + } |
| 374 | + os << header2; |
| 375 | + if (self.class_repr.is_interface) { |
| 376 | + os << ";" << std::endl; |
| 377 | + } else { |
| 378 | + os << body_null; |
| 379 | + } |
| 380 | + return os; |
335 | 381 | } |
336 | 382 | }; |
337 | 383 |
|
|
0 commit comments