From 9413360255138b99eaaa6a48d2866d9026f4bb77 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 11 Jan 2024 02:08:43 +0300 Subject: [PATCH] Improve SplitSource.php. --- SplitSource.php | 172 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 122 insertions(+), 50 deletions(-) diff --git a/SplitSource.php b/SplitSource.php index 33b217aed..c3b9f4e93 100644 --- a/SplitSource.php +++ b/SplitSource.php @@ -231,27 +231,46 @@ function split_file($file, $chunks, $undo) { 'std::int32_t' => '', 'std::int64_t' => '', 'td::unique' => 'algorithm', + 'std::count_if' => 'algorithm', 'std::fill' => 'algorithm', 'std::find' => 'algorithm', + 'std::is_sorted' => 'algorithm', + 'std::lower_bound' => 'algorithm', 'std::max' => 'algorithm', + 'std::merge' => 'algorithm', 'std::min' => 'algorithm', + 'std::partial_sort' => 'algorithm', + 'std::partition' => 'algorithm', 'std::remove' => 'algorithm', 'std::reverse' => 'algorithm', 'std::rotate' => 'algorithm', 'std::sort' => 'algorithm', + 'std::stable_sort' => 'algorithm', + 'std::upper_bound' => 'algorithm', 'std::abs' => 'cmath', + 'std::isfinite' => 'cmath', + 'std::function' => 'functional', + 'std::greater' => 'functional', + 'std::reference_wrapper' => 'functional', + 'std::make_move_iterator' => 'iterator', 'std::numeric_limits' => 'limits', + 'std::map' => 'map', + 'std::multimap' => 'map', 'std::make_shared' => 'memory', 'std::shared_ptr' => 'memory', + 'std::multiset' => 'set', + 'std::set' => 'set', + 'std::get' => 'tuple', + 'std::make_tuple' => 'tuple', 'std::tie' => 'tuple', 'std::tuple' => 'tuple', 'std::decay_t' => 'type_traits', 'std::is_same' => 'type_traits', + 'std::unordered_map' => 'unordered_map', + 'std::unordered_set' => 'unordered_set', 'std::make_pair' => 'utility', 'std::pair' => 'utility', - 'std::swap' => 'utility', - 'std::unordered_map' => 'unordered_map', - 'std::unordered_set' => 'unordered_set'); + 'std::swap' => 'utility'); foreach ($type_headers as $type => $header) { if (in_array($type, $std_methods)) { $std_methods = array_diff($std_methods, array($type)); @@ -276,62 +295,115 @@ function split_file($file, $chunks, $undo) { if (!preg_match('/Td::~?Td/', $new_content)) { // destructor Td::~Td needs to see definitions of all forward-declared classes $td_methods = array( - 'account_manager[_(-][^.]|AccountManager[^;>]' => "AccountManager", - 'animations_manager[_(-][^.]|AnimationsManager[^;>]' => "AnimationsManager", - 'attach_menu_manager[_(-][^.]|AttachMenuManager[^;>]' => "AttachMenuManager", - 'audios_manager[_(-][^.]|AudiosManager' => "AudiosManager", - 'auth_manager[_(-][^.]|AuthManager' => 'AuthManager', - 'autosave_manager[_(-][^.]|AutosaveManager' => 'AutosaveManager', - 'background_manager[_(-][^.]|BackgroundManager' => "BackgroundManager", - 'boost_manager[_(-][^.]|BoostManager' => "BoostManager", - 'bot_info_manager[_(-][^.]|BotInfoManager' => "BotInfoManager", - 'common_dialog_manager[_(-][^.]|CommonDialogManager' => "CommonDialogManager", - 'contacts_manager[_(-][^.]|ContactsManager([^ ;.]| [^*])' => 'ContactsManager', - 'country_info_manager[_(-][^.]|CountryInfoManager' => 'CountryInfoManager', - 'dialog_action_manager[_(-][^.]|DialogActionManager' => "DialogActionManager", - 'dialog_filter_manager[_(-][^.]|DialogFilterManager' => "DialogFilterManager", - 'dialog_invite_link_manager[_(-][^.]|DialogInviteLinkManager' => "DialogInviteLinkManager", - 'dialog_manager[_(-][^.]|DialogManager' => "DialogManager", - 'dialog_participant_manager[_(-][^.]|DialogParticipantManager' => "DialogParticipantManager", - 'documents_manager[_(-][^.]|DocumentsManager' => "DocumentsManager", - 'download_manager[_(-][^.]|DownloadManager' => "DownloadManager", - 'file_reference_manager[_(-][^.]|FileReferenceManager|file_references[)]' => 'FileReferenceManager', - 'file_manager[_(-][^.]|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager', - 'forum_topic_manager[_(-][^.]|ForumTopicManager' => 'ForumTopicManager', + 'AccentColorId' => 'AccentColorId', + 'account_manager[_(-](?![.]get[(][)])|AccountManager[^;>]' => 'AccountManager', + 'animations_manager[_(-](?![.]get[(][)])|AnimationsManager[^;>]' => 'AnimationsManager', + 'attach_menu_manager[_(-](?![.]get[(][)])|AttachMenuManager[^;>]' => 'AttachMenuManager', + 'audios_manager[_(-](?![.]get[(][)])|AudiosManager' => 'AudiosManager', + 'auth_manager[_(-](?![.]get[(][)])|AuthManager' => 'AuthManager', + 'AutoDownloadSettings|[a-z_]*auto_download_settings' => 'AutoDownloadSettings', + 'autosave_manager[_(-](?![.]get[(][)])|AutosaveManager' => 'AutosaveManager', + 'BackgroundId' => 'BackgroundId', + 'background_manager[_(-](?![.]get[(][)])|BackgroundManager' => 'BackgroundManager', + 'BackgroundType' => 'BackgroundType', + 'BotMenuButton|[a-z_]*_menu_button' => 'BotMenuButton', + 'boost_manager[_(-](?![.]get[(][)])|BoostManager' => 'BoostManager', + 'bot_info_manager[_(-](?![.]get[(][)])|BotInfoManager' => 'BotInfoManager', + 'callback_queries_manager[_(-](?![.]get[(][)])|CallbackQueriesManager' => 'CallbackQueriesManager', + 'CallId' => 'CallId', + 'call_manager[_(-](?![.]get[(][)])|CallManager' => 'CallManager', + 'ChannelId' => 'ChannelId', + 'ChatId' => 'ChatId', + 'common_dialog_manager[_(-](?![.]get[(][)])|CommonDialogManager' => 'CommonDialogManager', + 'contacts_manager[_(-](?![.]get[(][)])|ContactsManager([^ ;.]| [^*])' => 'ContactsManager', + 'country_info_manager[_(-](?![.]get[(][)])|CountryInfoManager' => 'CountryInfoManager', + 'CustomEmojiId' => 'CustomEmojiId', + 'device_token_manager[_(-](?![.]get[(][)])|DeviceTokenManager' => 'DeviceTokenManager', + 'DialogAction[^M]' => 'DialogAction', + 'dialog_action_manager[_(-](?![.]get[(][)])|DialogActionManager' => 'DialogActionManager', + 'DialogFilter[^A-Z]' => 'DialogFilter', + 'DialogFilterId' => 'DialogFilterId', + 'dialog_filter_manager[_(-](?![.]get[(][)])|DialogFilterManager' => 'DialogFilterManager', + 'DialogId' => 'DialogId', + 'dialog_invite_link_manager[_(-](?![.]get[(][)])|DialogInviteLinkManager' => 'DialogInviteLinkManager', + 'DialogListId' => 'DialogListId', + 'DialogLocation' => 'DialogLocation', + 'dialog_manager[_(-](?![.]get[(][)])|DialogManager' => 'DialogManager', + 'DialogParticipantFilter' => 'DialogParticipantFilter', + 'dialog_participant_manager[_(-](?![.]get[(][)])|DialogParticipantManager' => 'DialogParticipantManager', + 'DialogSource' => 'DialogSource', + 'documents_manager[_(-](?![.]get[(][)])|DocumentsManager' => 'DocumentsManager', + 'download_manager[_(-](?![.]get[(][)])|DownloadManager[^C]' => 'DownloadManager', + 'DownloadManagerCallback' => 'DownloadManagerCallback', + 'EmailVerification' => 'EmailVerification', + 'EmojiGroup' => 'EmojiGroup', + 'EmojiStatus|[a-z_]*_emoji_status' => 'EmojiStatus', + 'file_reference_manager[_(-](?![.]get[(][)])|FileReferenceManager|file_references[)]' => 'FileReferenceManager', + 'file_manager[_(-](?![.]get[(][)])|FileManager([^ ;.]| [^*])|update_file[)]' => 'files/FileManager', + 'FolderId' => 'FolderId', + 'forum_topic_manager[_(-](?![.]get[(][)])|ForumTopicManager' => 'ForumTopicManager', + 'game_manager[_(-](?![.]get[(][)])|GameManager' => 'GameManager', 'G[(][)]|Global[^A-Za-z]' => 'Global', - 'game_manager[_(-][^.]|GameManager' => 'GameManager', - 'group_call_manager[_(-][^.]|GroupCallManager' => 'GroupCallManager', + 'GlobalPrivacySettings' => 'GlobalPrivacySettings', + 'GroupCallId' => 'GroupCallId', + 'group_call_manager[_(-](?![.]get[(][)])|GroupCallManager' => 'GroupCallManager', 'HashtagHints' => 'HashtagHints', - 'inline_queries_manager[_(-][^.]|InlineQueriesManager' => 'InlineQueriesManager', + 'inline_queries_manager[_(-](?![.]get[(][)])|InlineQueriesManager' => 'InlineQueriesManager', 'language_pack_manager[_(-]|LanguagePackManager' => 'LanguagePackManager', - 'link_manager[_(-][^.]|LinkManager' => 'LinkManager', + 'link_manager[_(-](?![.]get[(][)])|LinkManager' => 'LinkManager', 'LogeventIdWithGeneration|add_log_event|delete_log_event|get_erase_log_event_promise|parse_time|store_time' => 'logevent/LogEventHelper', 'MessageCopyOptions' => 'MessageCopyOptions', - 'message_import_manager[_(-][^.]|MessageImportManager' => 'MessageImportManager', - 'messages_manager[_(-][^.]|MessagesManager' => 'MessagesManager', - 'notification_manager[_(-][^.]|NotificationManager|notifications[)]' => 'NotificationManager', - 'notification_settings_manager[_(-][^.]|NotificationSettingsManager' => 'NotificationSettingsManager', - 'option_manager[_(-][^.]|OptionManager' => "OptionManager", - 'phone_number_manager[_(-][^.]|PhoneNumberManager' => "PhoneNumberManager", - 'poll_manager[_(-][^.]|PollManager' => "PollManager", - 'privacy_manager[_(-][^.]|PrivacyManager' => "PrivacyManager", + 'MessageFullId' => 'MessageFullId', + 'MessageId' => 'MessageId', + 'message_import_manager[_(-](?![.]get[(][)])|MessageImportManager' => 'MessageImportManager', + 'MessageLinkInfo' => 'MessageLinkInfo', + 'MessageReaction|UnreadMessageReaction|[a-z_]*message[a-z_]*reaction' => 'MessageReaction', + '[a-z_]*_message_sender' => 'MessageSender', + 'messages_manager[_(-](?![.]get[(][)])|MessagesManager' => 'MessagesManager', + 'MessageThreadInfo' => 'MessageThreadInfo', + 'MessageTtl' => 'MessageTtl', + 'notification_manager[_(-](?![.]get[(][)])|NotificationManager|notifications[)]' => 'NotificationManager', + 'notification_settings_manager[_(-](?![.]get[(][)])|NotificationSettingsManager' => 'NotificationSettingsManager', + 'option_manager[_(-](?![.]get[(][)])|OptionManager' => 'OptionManager', + 'password_manager[_(-](?![.]get[(][)])|PasswordManager' => 'PasswordManager', + '[a-z_]*phone_number_manager[_(-](?![.]get[(][)])|PhoneNumberManager' => 'PhoneNumberManager', + 'PhotoSizeSource' => 'PhotoSizeSource', + 'poll_manager[_(-](?![.]get[(][)])|PollManager' => 'PollManager', + 'privacy_manager[_(-](?![.]get[(][)])|PrivacyManager' => 'PrivacyManager', 'PublicDialogType|get_public_dialog_type' => 'PublicDialogType', - 'reaction_manager[_(-][^.]|ReactionManager' => 'ReactionManager', + 'reaction_manager[_(-](?![.]get[(][)])|ReactionManager' => 'ReactionManager', + 'ReactionType|[a-z_]*_reaction_type' => 'ReactionType', + 'RequestActor|RequestOnceActor' => 'RequestActor', + 'ScopeNotificationSettings|[a-z_]*_scope_notification_settings' => 'ScopeNotificationSettings', 'SecretChatActor' => 'SecretChatActor', 'secret_chats_manager[_(-]|SecretChatsManager' => 'SecretChatsManager', - 'sponsored_message_manager[_(-][^.]|SponsoredMessageManager' => 'SponsoredMessageManager', - 'statistics_manager[_(-][^.]|StatisticsManager' => 'StatisticsManager', - 'stickers_manager[_(-][^.]|StickersManager' => 'StickersManager', - 'story_manager[_(-][^.]|StoryManager' => 'StoryManager', - '[>](td_db[(][)]|get_td_db_impl[(])|TdDb[^A-Za-z]' => 'TdDb', - 'theme_manager[_(-][^.]|ThemeManager' => "ThemeManager", + 'secure_manager[_(-](?![.]get[(][)])|SecureManager' => 'SecureManager', + 'SentEmailCode' => 'SentEmailCode', + 'sponsored_message_manager[_(-](?![.]get[(][)])|SponsoredMessageManager' => 'SponsoredMessageManager', + 'state_manager[_(-](?![.]get[(][)])|StateManager' => 'StateManager', + 'statistics_manager[_(-](?![.]get[(][)])|StatisticsManager' => 'StatisticsManager', + 'StickerSetId' => 'StickerSetId', + 'stickers_manager[_(-](?![.]get[(][)])|StickersManager' => 'StickersManager', + 'storage_manager[_(-](?![.]get[(][)])|StorageManager' => 'StorageManager', + 'StoryId' => 'StoryId', + 'StoryListId' => 'StoryListId', + 'story_manager[_(-](?![.]get[(][)])|StoryManager' => 'StoryManager', + 'SuggestedAction|[a-z_]*_suggested_action' => 'SuggestedAction', + 'td_api' => 'td_api', + 'td_db[(][)]|TdDb[^A-Za-z]' => 'TdDb', + 'telegram_api' => 'telegram_api', + 'theme_manager[_(-](?![.]get[(][)])|ThemeManager' => 'ThemeManager', 'TopDialogCategory|get_top_dialog_category' => 'TopDialogCategory', - 'top_dialog_manager[_(-][^.]|TopDialogManager' => 'TopDialogManager', - 'translation_manager[_(-][^.]|TranslationManager' => "TranslationManager", - 'transcription_manager[_(-][^.]|TranscriptionManager' => "TranscriptionManager", - 'updates_manager[_(-][^.]|UpdatesManager|get_difference[)]|updateSentMessage|dummyUpdate' => 'UpdatesManager', + 'top_dialog_manager[_(-](?![.]get[(][)])|TopDialogManager' => 'TopDialogManager', + 'translation_manager[_(-](?![.]get[(][)])|TranslationManager' => 'TranslationManager', + 'transcription_manager[_(-](?![.]get[(][)])|TranscriptionManager' => 'TranscriptionManager', + 'updates_manager[_(-](?![.]get[(][)])|UpdatesManager|get_difference[)]|updateSentMessage|dummyUpdate' => 'UpdatesManager', + 'UserId' => 'UserId', + 'video_notes_manager[_(-](?![.]get[(][)])|VideoNotesManager' => 'VideoNotesManager', + 'videos_manager[_(-](?![.]get[(][)])|VideosManager' => 'VideosManager', + 'voice_notes_manager[_(-](?![.]get[(][)])|VoiceNotesManager' => 'VoiceNotesManager', 'WebPageId(Hash)?' => 'WebPageId', - 'web_pages_manager[_(-][^.]|WebPagesManager' => 'WebPagesManager'); + 'web_pages_manager[_(-](?![.]get[(][)])|WebPagesManager' => 'WebPagesManager'); foreach ($td_methods as $pattern => $header) { if (strpos($cpp_name, $header) !== false) { @@ -339,7 +411,7 @@ function split_file($file, $chunks, $undo) { } $include_name = '#include "td/telegram/'.$header.'.h"'; - if (strpos($new_content, $include_name) !== false && preg_match('/'.$pattern.'/', str_replace($include_name, '', $new_content)) === 0) { + if (strpos($new_content, $include_name) !== false && preg_match('/[^a-zA-Z0-9_]('.$pattern.')/', str_replace($include_name, '', $new_content)) === 0) { $new_content = str_replace($include_name, '', $new_content); } }