codegen_scheme.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. '''
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. '''
  7. import glob, re, binascii, os, sys
  8. sys.dont_write_bytecode = True
  9. scriptPath = os.path.dirname(os.path.realpath(__file__))
  10. sys.path.append(scriptPath + '/../../../lib_tl/tl')
  11. from generate_tl import generate
  12. generate({
  13. 'namespaces': {
  14. 'creator': 'MTP::details',
  15. },
  16. 'prefixes': {
  17. 'type': 'MTP',
  18. 'data': 'MTPD',
  19. 'id': 'mtpc',
  20. 'construct': 'MTP_',
  21. },
  22. 'types': {
  23. 'prime': 'mtpPrime',
  24. 'typeId': 'mtpTypeId',
  25. 'buffer': 'mtpBuffer',
  26. },
  27. 'sections': [
  28. 'read-write',
  29. ],
  30. # define some checked flag conversions
  31. # the key flag type should be a subset of the value flag type
  32. # with exact the same names, then the key flag can be implicitly
  33. # casted to the value flag type
  34. 'flagInheritance': {
  35. 'messageService': 'message',
  36. 'updateShortMessage': 'message',
  37. 'updateShortChatMessage': 'message',
  38. 'updateShortSentMessage': 'message',
  39. 'replyKeyboardHide': 'replyKeyboardMarkup',
  40. 'replyKeyboardForceReply': 'replyKeyboardMarkup',
  41. 'inputPeerNotifySettings': 'peerNotifySettings',
  42. 'peerNotifySettings': 'inputPeerNotifySettings',
  43. 'channelForbidden': 'channel',
  44. 'dialogFolder': 'dialog',
  45. },
  46. 'typeIdExceptions': [
  47. 'channel#c88974ac',
  48. 'ipPortSecret#37982646',
  49. 'accessPointRule#4679b65f',
  50. 'help.configSimple#5a592a6c',
  51. 'messageReplies#81834865',
  52. ],
  53. 'renamedTypes': {
  54. 'passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow': 'passwordKdfAlgoModPow',
  55. },
  56. 'skip': [
  57. 'int ? = Int;',
  58. 'long ? = Long;',
  59. 'double ? = Double;',
  60. 'string ? = String;',
  61. 'vector {t:Type} # [ t ] = Vector t;',
  62. 'int128 4*[ int ] = Int128;',
  63. 'int256 8*[ int ] = Int256;',
  64. 'vector#1cb5c415 {t:Type} # [ t ] = Vector t;',
  65. ],
  66. 'builtin': [
  67. 'int',
  68. 'long',
  69. 'double',
  70. 'string',
  71. 'bytes',
  72. 'int128',
  73. 'int256',
  74. ],
  75. 'builtinTemplates': [
  76. 'vector',
  77. 'flags',
  78. ],
  79. 'synonyms': {
  80. 'bytes': 'string',
  81. },
  82. 'builtinInclude': 'mtproto/core_types.h',
  83. 'optimizeSingleData': True,
  84. 'dumpToText': {
  85. 'include': 'mtproto/details/mtproto_dump_to_text.h',
  86. },
  87. })