From bb7e8985f6d189de0acac6a1c3033cb16378c1fb Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 4 Nov 2013 02:53:05 +0100 Subject: Reformat and (slightly) decruft all the things. --- CMakeLists.txt | 134 ++-- MultiMC.cpp | 6 +- depends/classparser/include/classparser_config.h | 5 +- depends/classparser/include/javautils.h | 8 +- depends/classparser/src/annotations.cpp | 136 ++-- depends/classparser/src/annotations.h | 487 +++++------ depends/classparser/src/classfile.h | 269 ++++--- depends/classparser/src/constants.h | 374 ++++----- depends/classparser/src/errors.h | 4 +- depends/classparser/src/javaendian.h | 54 +- depends/classparser/src/javautils.cpp | 17 +- depends/classparser/src/membuffer.h | 105 ++- depends/launcher/MCFrame.java | 163 ++-- depends/pack200/src/unpack.cpp | 8 +- depends/settings/include/basicsettingsobject.h | 16 +- depends/settings/include/inifile.h | 7 +- depends/settings/include/inisettingsobject.h | 31 +- depends/settings/include/keyring.h | 12 +- depends/settings/include/libsettings_config.h | 14 +- depends/settings/include/overridesetting.h | 13 +- depends/settings/include/setting.h | 51 +- depends/settings/include/settingsobject.h | 77 +- depends/settings/src/basicsettingsobject.cpp | 8 +- depends/settings/src/inifile.cpp | 32 +- depends/settings/src/inisettingsobject.cpp | 10 +- depends/settings/src/overridesetting.cpp | 6 +- depends/settings/src/setting.cpp | 9 +- depends/settings/src/settingsobject.cpp | 66 +- depends/settings/src/stubkeyring.cpp | 15 +- depends/settings/src/stubkeyring.h | 11 +- depends/util/CMakeLists.txt | 17 +- depends/util/include/apputils.h | 21 - depends/util/include/cmdutils.h | 77 +- depends/util/include/libutil_config.h | 15 +- depends/util/include/osutils.h | 11 +- depends/util/include/pathutils.h | 15 +- depends/util/include/siglist.h | 129 --- depends/util/include/siglist_impl.h | 156 ---- depends/util/include/userutils.h | 8 +- depends/util/src/cmdutils.cpp | 194 ++--- depends/util/src/osutils.cpp | 19 - depends/util/src/pathutils.cpp | 35 +- depends/util/src/userutils.cpp | 82 +- depends/xz-embedded/include/xz.h | 44 +- depends/xz-embedded/src/xz_config.h | 35 +- depends/xz-embedded/src/xz_crc32.c | 8 +- depends/xz-embedded/src/xz_crc64.c | 8 +- depends/xz-embedded/src/xz_dec_bcj.c | 148 ++-- depends/xz-embedded/src/xz_dec_lzma2.c | 324 +++++--- depends/xz-embedded/src/xz_dec_stream.c | 207 ++--- depends/xz-embedded/src/xz_lzma2.h | 8 +- depends/xz-embedded/src/xz_private.h | 124 ++- depends/xz-embedded/src/xz_stream.h | 14 +- depends/xz-embedded/xzminidec.c | 35 +- gui/ConsoleWindow.cpp | 135 ++++ gui/ConsoleWindow.h | 79 ++ gui/ConsoleWindow.ui | 85 ++ gui/CopyInstanceDialog.cpp | 84 -- gui/CopyInstanceDialog.h | 50 -- gui/CopyInstanceDialog.ui | 134 ---- gui/CustomMessageBox.cpp | 19 - gui/CustomMessageBox.h | 11 - gui/EditNotesDialog.cpp | 29 - gui/EditNotesDialog.h | 20 - gui/EditNotesDialog.ui | 77 -- gui/IconPickerDialog.cpp | 147 ---- gui/IconPickerDialog.h | 29 - gui/IconPickerDialog.ui | 67 -- gui/LabeledToolButton.cpp | 72 -- gui/LabeledToolButton.h | 22 - gui/LegacyModEditDialog.cpp | 393 --------- gui/LegacyModEditDialog.h | 78 -- gui/LegacyModEditDialog.ui | 321 -------- gui/MCModInfoFrame.cpp | 109 --- gui/MCModInfoFrame.h | 46 -- gui/MCModInfoFrame.ui | 68 -- gui/MainWindow.cpp | 976 +++++++++++++++++++++++ gui/MainWindow.h | 167 ++++ gui/MainWindow.ui | 474 +++++++++++ gui/ModEditDialogCommon.cpp | 41 - gui/ModEditDialogCommon.h | 7 - gui/ModListView.cpp | 36 - gui/ModListView.h | 13 - gui/OneSixModEditDialog.cpp | 317 -------- gui/OneSixModEditDialog.h | 67 -- gui/OneSixModEditDialog.ui | 319 -------- gui/Platform.h | 32 + gui/Platform_Other.cpp | 27 + gui/Platform_X11.cpp | 62 ++ gui/ProgressDialog.cpp | 110 --- gui/ProgressDialog.h | 62 -- gui/ProgressDialog.ui | 53 -- gui/aboutdialog.cpp | 24 - gui/aboutdialog.h | 22 - gui/aboutdialog.ui | 315 -------- gui/consolewindow.cpp | 120 --- gui/consolewindow.h | 63 -- gui/consolewindow.ui | 85 -- gui/dialogs/AboutDialog.cpp | 37 + gui/dialogs/AboutDialog.h | 35 + gui/dialogs/AboutDialog.ui | 316 ++++++++ gui/dialogs/CopyInstanceDialog.cpp | 84 ++ gui/dialogs/CopyInstanceDialog.h | 50 ++ gui/dialogs/CopyInstanceDialog.ui | 134 ++++ gui/dialogs/CustomMessageBox.cpp | 34 + gui/dialogs/CustomMessageBox.h | 26 + gui/dialogs/EditNotesDialog.cpp | 42 + gui/dialogs/EditNotesDialog.h | 38 + gui/dialogs/EditNotesDialog.ui | 77 ++ gui/dialogs/IconPickerDialog.cpp | 156 ++++ gui/dialogs/IconPickerDialog.h | 48 ++ gui/dialogs/IconPickerDialog.ui | 67 ++ gui/dialogs/InstanceSettings.cpp | 180 +++++ gui/dialogs/InstanceSettings.h | 50 ++ gui/dialogs/InstanceSettings.ui | 422 ++++++++++ gui/dialogs/LegacyModEditDialog.cpp | 393 +++++++++ gui/dialogs/LegacyModEditDialog.h | 78 ++ gui/dialogs/LegacyModEditDialog.ui | 321 ++++++++ gui/dialogs/LoginDialog.cpp | 252 ++++++ gui/dialogs/LoginDialog.h | 61 ++ gui/dialogs/LoginDialog.ui | 186 +++++ gui/dialogs/LwjglSelectDialog.cpp | 72 ++ gui/dialogs/LwjglSelectDialog.h | 44 + gui/dialogs/LwjglSelectDialog.ui | 85 ++ gui/dialogs/ModEditDialogCommon.cpp | 57 ++ gui/dialogs/ModEditDialogCommon.h | 22 + gui/dialogs/NewInstanceDialog.cpp | 125 +++ gui/dialogs/NewInstanceDialog.h | 55 ++ gui/dialogs/NewInstanceDialog.ui | 179 +++++ gui/dialogs/OneSixModEditDialog.cpp | 322 ++++++++ gui/dialogs/OneSixModEditDialog.h | 67 ++ gui/dialogs/OneSixModEditDialog.ui | 319 ++++++++ gui/dialogs/ProgressDialog.cpp | 107 +++ gui/dialogs/ProgressDialog.h | 60 ++ gui/dialogs/ProgressDialog.ui | 53 ++ gui/dialogs/SettingsDialog.cpp | 260 ++++++ gui/dialogs/SettingsDialog.h | 63 ++ gui/dialogs/SettingsDialog.ui | 569 +++++++++++++ gui/dialogs/VersionSelectDialog.cpp | 111 +++ gui/dialogs/VersionSelectDialog.h | 61 ++ gui/dialogs/VersionSelectDialog.ui | 103 +++ gui/instancedelegate.cpp | 231 ------ gui/instancedelegate.h | 12 - gui/instancesettings.cpp | 189 ----- gui/instancesettings.h | 35 - gui/instancesettings.ui | 422 ---------- gui/logindialog.cpp | 248 ------ gui/logindialog.h | 57 -- gui/logindialog.ui | 185 ----- gui/lwjglselectdialog.cpp | 72 -- gui/lwjglselectdialog.h | 46 -- gui/lwjglselectdialog.ui | 85 -- gui/mainwindow.cpp | 974 ---------------------- gui/mainwindow.h | 170 ---- gui/mainwindow.ui | 474 ----------- gui/newinstancedialog.cpp | 125 --- gui/newinstancedialog.h | 55 -- gui/newinstancedialog.ui | 179 ----- gui/newmodeditwindow.ui | 159 ---- gui/platform.h | 35 - gui/platform_other.cpp | 27 - gui/platform_x11.cpp | 62 -- gui/settingsdialog.cpp | 256 ------ gui/settingsdialog.h | 64 -- gui/settingsdialog.ui | 569 ------------- gui/versionselectdialog.cpp | 110 --- gui/versionselectdialog.h | 61 -- gui/versionselectdialog.ui | 103 --- gui/widgets/InstanceDelegate.cpp | 246 ++++++ gui/widgets/InstanceDelegate.h | 27 + gui/widgets/LabeledToolButton.cpp | 86 ++ gui/widgets/LabeledToolButton.h | 37 + gui/widgets/MCModInfoFrame.cpp | 111 +++ gui/widgets/MCModInfoFrame.h | 46 ++ gui/widgets/MCModInfoFrame.ui | 68 ++ gui/widgets/ModListView.cpp | 51 ++ gui/widgets/ModListView.h | 27 + logic/BaseInstance.cpp | 140 ++-- logic/BaseInstance_p.h | 17 +- logic/BaseUpdate.cpp | 17 +- logic/BaseUpdate.h | 13 +- logic/BaseVersion.h | 9 +- logic/CMakeLists.txt | 24 - logic/EnabledItemFilter.cpp | 27 +- logic/EnabledItemFilter.h | 18 +- logic/ForgeInstaller.cpp | 15 + logic/ForgeInstaller.h | 19 +- logic/InstanceFactory.cpp | 31 +- logic/InstanceLauncher.cpp | 77 +- logic/InstanceLauncher.h | 26 +- logic/JavaUtils.cpp | 72 +- logic/JavaUtils.h | 8 +- logic/LegacyForge.cpp | 37 +- logic/LegacyForge.h | 32 +- logic/LegacyInstance.cpp | 39 +- logic/LegacyInstance.h | 18 +- logic/LegacyInstance_p.h | 24 +- logic/LegacyUpdate.cpp | 17 +- logic/LegacyUpdate.h | 37 +- logic/MinecraftProcess.h | 43 +- logic/MinecraftVersion.h | 30 +- logic/Mod.cpp | 38 +- logic/Mod.h | 29 +- logic/ModList.cpp | 31 +- logic/ModList.h | 111 +-- logic/NagUtils.cpp | 27 +- logic/NostalgiaInstance.cpp | 26 +- logic/NostalgiaInstance.h | 19 +- logic/OneSixAssets.cpp | 22 +- logic/OneSixAssets.h | 22 +- logic/OneSixInstance.cpp | 19 +- logic/OneSixInstance.h | 19 +- logic/OneSixInstance_p.h | 27 +- logic/OneSixLibrary.cpp | 19 +- logic/OneSixLibrary.h | 36 +- logic/OneSixRule.cpp | 18 +- logic/OneSixRule.h | 59 +- logic/OneSixUpdate.cpp | 1 + logic/OneSixUpdate.h | 21 +- logic/OneSixVersion.cpp | 31 +- logic/OneSixVersion.h | 17 +- logic/OpSys.cpp | 35 +- logic/OpSys.h | 27 +- logic/lists/BaseVersionList.cpp | 36 +- logic/lists/BaseVersionList.h | 46 +- logic/lists/ForgeVersionList.cpp | 2 +- logic/lists/ForgeVersionList.h | 3 +- logic/lists/IconList.cpp | 146 ++-- logic/lists/IconList.h | 48 +- logic/lists/InstanceList.cpp | 4 +- logic/lists/InstanceList.h | 2 +- logic/lists/JavaVersionList.cpp | 7 +- logic/lists/JavaVersionList.h | 6 +- logic/lists/LwjglVersionList.cpp | 2 +- logic/lists/LwjglVersionList.h | 113 ++- logic/lists/MinecraftVersionList.cpp | 4 +- logic/lists/MinecraftVersionList.h | 31 +- logic/net/ByteArrayDownload.cpp | 17 +- logic/net/ByteArrayDownload.h | 15 + logic/net/CacheDownload.cpp | 28 +- logic/net/CacheDownload.h | 15 + logic/net/FileDownload.cpp | 74 +- logic/net/FileDownload.h | 15 + logic/net/ForgeXzDownload.cpp | 44 +- logic/net/ForgeXzDownload.h | 15 + logic/net/HttpMetaCache.cpp | 129 +-- logic/net/HttpMetaCache.h | 15 + logic/net/LoginTask.cpp | 29 +- logic/net/LoginTask.h | 6 +- logic/net/NetAction.h | 21 +- logic/net/NetJob.cpp | 21 +- logic/net/NetJob.h | 20 +- logic/net/S3ListBucket.cpp | 19 +- logic/net/S3ListBucket.h | 15 + logic/tasks/ProgressProvider.h | 25 +- logic/tasks/Task.cpp | 12 +- logic/tasks/Task.h | 22 +- 257 files changed, 12025 insertions(+), 11300 deletions(-) delete mode 100644 depends/util/include/apputils.h delete mode 100644 depends/util/include/siglist.h delete mode 100644 depends/util/include/siglist_impl.h delete mode 100644 depends/util/src/osutils.cpp create mode 100644 gui/ConsoleWindow.cpp create mode 100644 gui/ConsoleWindow.h create mode 100644 gui/ConsoleWindow.ui delete mode 100644 gui/CopyInstanceDialog.cpp delete mode 100644 gui/CopyInstanceDialog.h delete mode 100644 gui/CopyInstanceDialog.ui delete mode 100644 gui/CustomMessageBox.cpp delete mode 100644 gui/CustomMessageBox.h delete mode 100644 gui/EditNotesDialog.cpp delete mode 100644 gui/EditNotesDialog.h delete mode 100644 gui/EditNotesDialog.ui delete mode 100644 gui/IconPickerDialog.cpp delete mode 100644 gui/IconPickerDialog.h delete mode 100644 gui/IconPickerDialog.ui delete mode 100644 gui/LabeledToolButton.cpp delete mode 100644 gui/LabeledToolButton.h delete mode 100644 gui/LegacyModEditDialog.cpp delete mode 100644 gui/LegacyModEditDialog.h delete mode 100644 gui/LegacyModEditDialog.ui delete mode 100644 gui/MCModInfoFrame.cpp delete mode 100644 gui/MCModInfoFrame.h delete mode 100644 gui/MCModInfoFrame.ui create mode 100644 gui/MainWindow.cpp create mode 100644 gui/MainWindow.h create mode 100644 gui/MainWindow.ui delete mode 100644 gui/ModEditDialogCommon.cpp delete mode 100644 gui/ModEditDialogCommon.h delete mode 100644 gui/ModListView.cpp delete mode 100644 gui/ModListView.h delete mode 100644 gui/OneSixModEditDialog.cpp delete mode 100644 gui/OneSixModEditDialog.h delete mode 100644 gui/OneSixModEditDialog.ui create mode 100644 gui/Platform.h create mode 100644 gui/Platform_Other.cpp create mode 100644 gui/Platform_X11.cpp delete mode 100644 gui/ProgressDialog.cpp delete mode 100644 gui/ProgressDialog.h delete mode 100644 gui/ProgressDialog.ui delete mode 100644 gui/aboutdialog.cpp delete mode 100644 gui/aboutdialog.h delete mode 100644 gui/aboutdialog.ui delete mode 100644 gui/consolewindow.cpp delete mode 100644 gui/consolewindow.h delete mode 100644 gui/consolewindow.ui create mode 100644 gui/dialogs/AboutDialog.cpp create mode 100644 gui/dialogs/AboutDialog.h create mode 100644 gui/dialogs/AboutDialog.ui create mode 100644 gui/dialogs/CopyInstanceDialog.cpp create mode 100644 gui/dialogs/CopyInstanceDialog.h create mode 100644 gui/dialogs/CopyInstanceDialog.ui create mode 100644 gui/dialogs/CustomMessageBox.cpp create mode 100644 gui/dialogs/CustomMessageBox.h create mode 100644 gui/dialogs/EditNotesDialog.cpp create mode 100644 gui/dialogs/EditNotesDialog.h create mode 100644 gui/dialogs/EditNotesDialog.ui create mode 100644 gui/dialogs/IconPickerDialog.cpp create mode 100644 gui/dialogs/IconPickerDialog.h create mode 100644 gui/dialogs/IconPickerDialog.ui create mode 100644 gui/dialogs/InstanceSettings.cpp create mode 100644 gui/dialogs/InstanceSettings.h create mode 100644 gui/dialogs/InstanceSettings.ui create mode 100644 gui/dialogs/LegacyModEditDialog.cpp create mode 100644 gui/dialogs/LegacyModEditDialog.h create mode 100644 gui/dialogs/LegacyModEditDialog.ui create mode 100644 gui/dialogs/LoginDialog.cpp create mode 100644 gui/dialogs/LoginDialog.h create mode 100644 gui/dialogs/LoginDialog.ui create mode 100644 gui/dialogs/LwjglSelectDialog.cpp create mode 100644 gui/dialogs/LwjglSelectDialog.h create mode 100644 gui/dialogs/LwjglSelectDialog.ui create mode 100644 gui/dialogs/ModEditDialogCommon.cpp create mode 100644 gui/dialogs/ModEditDialogCommon.h create mode 100644 gui/dialogs/NewInstanceDialog.cpp create mode 100644 gui/dialogs/NewInstanceDialog.h create mode 100644 gui/dialogs/NewInstanceDialog.ui create mode 100644 gui/dialogs/OneSixModEditDialog.cpp create mode 100644 gui/dialogs/OneSixModEditDialog.h create mode 100644 gui/dialogs/OneSixModEditDialog.ui create mode 100644 gui/dialogs/ProgressDialog.cpp create mode 100644 gui/dialogs/ProgressDialog.h create mode 100644 gui/dialogs/ProgressDialog.ui create mode 100644 gui/dialogs/SettingsDialog.cpp create mode 100644 gui/dialogs/SettingsDialog.h create mode 100644 gui/dialogs/SettingsDialog.ui create mode 100644 gui/dialogs/VersionSelectDialog.cpp create mode 100644 gui/dialogs/VersionSelectDialog.h create mode 100644 gui/dialogs/VersionSelectDialog.ui delete mode 100644 gui/instancedelegate.cpp delete mode 100644 gui/instancedelegate.h delete mode 100644 gui/instancesettings.cpp delete mode 100644 gui/instancesettings.h delete mode 100644 gui/instancesettings.ui delete mode 100644 gui/logindialog.cpp delete mode 100644 gui/logindialog.h delete mode 100644 gui/logindialog.ui delete mode 100644 gui/lwjglselectdialog.cpp delete mode 100644 gui/lwjglselectdialog.h delete mode 100644 gui/lwjglselectdialog.ui delete mode 100644 gui/mainwindow.cpp delete mode 100644 gui/mainwindow.h delete mode 100644 gui/mainwindow.ui delete mode 100644 gui/newinstancedialog.cpp delete mode 100644 gui/newinstancedialog.h delete mode 100644 gui/newinstancedialog.ui delete mode 100644 gui/newmodeditwindow.ui delete mode 100644 gui/platform.h delete mode 100644 gui/platform_other.cpp delete mode 100644 gui/platform_x11.cpp delete mode 100644 gui/settingsdialog.cpp delete mode 100644 gui/settingsdialog.h delete mode 100644 gui/settingsdialog.ui delete mode 100644 gui/versionselectdialog.cpp delete mode 100644 gui/versionselectdialog.h delete mode 100644 gui/versionselectdialog.ui create mode 100644 gui/widgets/InstanceDelegate.cpp create mode 100644 gui/widgets/InstanceDelegate.h create mode 100644 gui/widgets/LabeledToolButton.cpp create mode 100644 gui/widgets/LabeledToolButton.h create mode 100644 gui/widgets/MCModInfoFrame.cpp create mode 100644 gui/widgets/MCModInfoFrame.h create mode 100644 gui/widgets/MCModInfoFrame.ui create mode 100644 gui/widgets/ModListView.cpp create mode 100644 gui/widgets/ModListView.h delete mode 100644 logic/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cb24499f..e150c459 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,49 +178,53 @@ logger/QsLog.h logger/QsLogDest.cpp logger/QsLogDest.h -# GUI -gui/mainwindow.h -gui/mainwindow.cpp -gui/settingsdialog.h -gui/settingsdialog.cpp -gui/CopyInstanceDialog.h -gui/CopyInstanceDialog.cpp -gui/newinstancedialog.h -gui/newinstancedialog.cpp -gui/logindialog.h -gui/logindialog.cpp -gui/ProgressDialog.h -gui/ProgressDialog.cpp -gui/aboutdialog.h -gui/aboutdialog.cpp -gui/consolewindow.h -gui/consolewindow.cpp -gui/instancedelegate.h -gui/instancedelegate.cpp -gui/versionselectdialog.h -gui/versionselectdialog.cpp -gui/lwjglselectdialog.h -gui/lwjglselectdialog.cpp -gui/instancesettings.h -gui/instancesettings.cpp -gui/IconPickerDialog.h -gui/IconPickerDialog.cpp -gui/LegacyModEditDialog.h -gui/LegacyModEditDialog.cpp -gui/OneSixModEditDialog.h -gui/OneSixModEditDialog.cpp -gui/ModEditDialogCommon.h -gui/ModEditDialogCommon.cpp -gui/ModListView.h -gui/ModListView.cpp -gui/LabeledToolButton.h -gui/LabeledToolButton.cpp -gui/EditNotesDialog.h -gui/EditNotesDialog.cpp -gui/MCModInfoFrame.h -gui/MCModInfoFrame.cpp -gui/CustomMessageBox.h -gui/CustomMessageBox.cpp +# GUI - windows +gui/MainWindow.h +gui/MainWindow.cpp +gui/ConsoleWindow.h +gui/ConsoleWindow.cpp + +# GUI - dialogs +gui/dialogs/SettingsDialog.h +gui/dialogs/SettingsDialog.cpp +gui/dialogs/CopyInstanceDialog.h +gui/dialogs/CopyInstanceDialog.cpp +gui/dialogs/dialogs/ +gui/dialogs/NewInstanceDialog.cpp +gui/dialogs/LoginDialog.h +gui/dialogs/LoginDialog.cpp +gui/dialogs/ProgressDialog.h +gui/dialogs/ProgressDialog.cpp +gui/dialogs/AboutDialog.h +gui/dialogs/AboutDialog.cpp +gui/dialogs/VersionSelectDialog.h +gui/dialogs/VersionSelectDialog.cpp +gui/dialogs/LwjglSelectDialog.h +gui/dialogs/LwjglSelectDialog.cpp +gui/dialogs/InstanceSettings.h +gui/dialogs/InstanceSettings.cpp +gui/dialogs/IconPickerDialog.h +gui/dialogs/IconPickerDialog.cpp +gui/dialogs/LegacyModEditDialog.h +gui/dialogs/LegacyModEditDialog.cpp +gui/dialogs/OneSixModEditDialog.h +gui/dialogs/OneSixModEditDialog.cpp +gui/dialogs/ModEditDialogCommon.h +gui/dialogs/ModEditDialogCommon.cpp +gui/dialogs/EditNotesDialog.h +gui/dialogs/EditNotesDialog.cpp +gui/dialogs/CustomMessageBox.h +gui/dialogs/CustomMessageBox.cpp + +# GUI - widgets +gui/widgets/InstanceDelegate.h +gui/widgets/InstanceDelegate.cpp +gui/widgets/ModListView.h +gui/widgets/ModListView.cpp +gui/widgets/LabeledToolButton.h +gui/widgets/LabeledToolButton.cpp +gui/widgets/MCModInfoFrame.h +gui/widgets/MCModInfoFrame.cpp # Base classes and infrastructure logic/BaseVersion.h @@ -332,24 +336,28 @@ logic/NagUtils.cpp ######## UIs ######## SET(MULTIMC_UIS -gui/mainwindow.ui -gui/settingsdialog.ui -gui/CopyInstanceDialog.ui -gui/newinstancedialog.ui -gui/logindialog.ui -gui/aboutdialog.ui -gui/consolewindow.ui -gui/versionselectdialog.ui -gui/lwjglselectdialog.ui -gui/instancesettings.ui - -gui/ProgressDialog.ui -gui/IconPickerDialog.ui -gui/LegacyModEditDialog.ui -gui/OneSixModEditDialog.ui -gui/EditNotesDialog.ui - -gui/MCModInfoFrame.ui + +# Windows +gui/MainWindow.ui +gui/ConsoleWindow.ui + +# Dialogs +gui/dialogs/SettingsDialog.ui +gui/dialogs/CopyInstanceDialog.ui +gui/dialogs/NewInstanceDialog.ui +gui/dialogs/LoginDialog.ui +gui/dialogs/AboutDialog.ui +gui/dialogs/VersionSelectDialog.ui +gui/dialogs/LwjglSelectDialog.ui +gui/dialogs/InstanceSettings.ui +gui/dialogs/ProgressDialog.ui +gui/dialogs/IconPickerDialog.ui +gui/dialogs/LegacyModEditDialog.ui +gui/dialogs/OneSixModEditDialog.ui +gui/dialogs/EditNotesDialog.ui + +# Widgets/other +gui/widgets/MCModInfoFrame.ui ) set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MULTIMC_SOURCES} ${MULTIMC_UIS}) @@ -364,9 +372,9 @@ ENDIF() IF(UNIX AND NOT APPLE) SET(MultiMC_QT_ADDITIONAL_MODULES ${MultiMC_QT_ADDITIONAL_MODULES} X11Extras) SET(MultiMC_LINK_ADDITIONAL_LIBS ${MultiMC_LINK_ADDITIONAL_LIBS} xcb) - LIST(APPEND MULTIMC_SOURCES gui/platform_x11.cpp) + LIST(APPEND MULTIMC_SOURCES gui/Platform_X11.cpp) ELSE() - LIST(APPEND MULTIMC_SOURCES gui/platform_other.cpp) + LIST(APPEND MULTIMC_SOURCES gui/Platform_Other.cpp) ENDIF() diff --git a/MultiMC.cpp b/MultiMC.cpp index e04904b4..1c70fb54 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -7,8 +7,8 @@ #include #include -#include "gui/mainwindow.h" -#include "gui/versionselectdialog.h" +#include "gui/MainWindow.h" +#include "gui/dialogs/VersionSelectDialog.h" #include "logic/lists/InstanceList.h" #include "logic/lists/IconList.h" #include "logic/lists/LwjglVersionList.h" @@ -24,7 +24,7 @@ #include "cmdutils.h" #include #include -#include +#include "logger/QsLog.h" #include #include "config.h" diff --git a/depends/classparser/include/classparser_config.h b/depends/classparser/include/classparser_config.h index fe6a2ab9..a043824a 100644 --- a/depends/classparser/include/classparser_config.h +++ b/depends/classparser/include/classparser_config.h @@ -16,8 +16,7 @@ #include #ifdef CLASSPARSER_LIBRARY -# define CLASSPARSER_EXPORT Q_DECL_EXPORT +#define CLASSPARSER_EXPORT Q_DECL_EXPORT #else -# define CLASSPARSER_EXPORT Q_DECL_IMPORT +#define CLASSPARSER_EXPORT Q_DECL_IMPORT #endif - diff --git a/depends/classparser/include/javautils.h b/depends/classparser/include/javautils.h index 63e5ec26..90042261 100644 --- a/depends/classparser/include/javautils.h +++ b/depends/classparser/include/javautils.h @@ -22,8 +22,8 @@ namespace javautils { - /** - * @brief Get the version from a minecraft.jar by parsing its class files. Expensive! - */ - QString GetMinecraftJarVersion(QString jar); +/** + * @brief Get the version from a minecraft.jar by parsing its class files. Expensive! + */ +QString GetMinecraftJarVersion(QString jar); } diff --git a/depends/classparser/src/annotations.cpp b/depends/classparser/src/annotations.cpp index fc0c98fa..d1a7c046 100644 --- a/depends/classparser/src/annotations.cpp +++ b/depends/classparser/src/annotations.cpp @@ -4,80 +4,82 @@ namespace java { - std::string annotation::toString() +std::string annotation::toString() +{ + std::ostringstream ss; + ss << "Annotation type : " << type_index << " - " << pool[type_index].str_data << std::endl; + ss << "Contains " << name_val_pairs.size() << " pairs:" << std::endl; + for (unsigned i = 0; i < name_val_pairs.size(); i++) { - std::ostringstream ss; - ss << "Annotation type : " << type_index << " - " << pool[type_index].str_data << std::endl; - ss << "Contains " << name_val_pairs.size() << " pairs:" << std::endl; - for(unsigned i = 0; i < name_val_pairs.size(); i++) - { - std::pair &val = name_val_pairs[i]; - auto name_idx = val.first; - ss << pool[name_idx].str_data << "(" << name_idx << ")" << " = " << val.second->toString() << std::endl; - } - return ss.str(); + std::pair &val = name_val_pairs[i]; + auto name_idx = val.first; + ss << pool[name_idx].str_data << "(" << name_idx << ")" + << " = " << val.second->toString() << std::endl; } + return ss.str(); +} + +annotation *annotation::read(util::membuffer &input, constant_pool &pool) +{ + uint16_t type_index = 0; + input.read_be(type_index); + annotation *ann = new annotation(type_index, pool); - annotation * annotation::read (util::membuffer& input, constant_pool& pool) + uint16_t num_pairs = 0; + input.read_be(num_pairs); + while (num_pairs) { - uint16_t type_index = 0; - input.read_be(type_index); - annotation * ann = new annotation(type_index,pool); - - uint16_t num_pairs = 0; - input.read_be(num_pairs); - while(num_pairs) - { - uint16_t name_idx = 0; - // read name index - input.read_be(name_idx); - auto elem = element_value::readElementValue(input,pool); - // read value - ann->add_pair(name_idx, elem); - num_pairs --; - } - return ann; + uint16_t name_idx = 0; + // read name index + input.read_be(name_idx); + auto elem = element_value::readElementValue(input, pool); + // read value + ann->add_pair(name_idx, elem); + num_pairs--; } - - element_value* element_value::readElementValue ( util::membuffer& input, java::constant_pool& pool ) + return ann; +} + +element_value *element_value::readElementValue(util::membuffer &input, + java::constant_pool &pool) +{ + element_value_type type = INVALID; + input.read(type); + uint16_t index = 0; + uint16_t index2 = 0; + std::vector vals; + switch (type) { - element_value_type type = INVALID; - input.read(type); - uint16_t index = 0; - uint16_t index2 = 0; - std::vector vals; - switch (type) + case PRIMITIVE_BYTE: + case PRIMITIVE_CHAR: + case PRIMITIVE_DOUBLE: + case PRIMITIVE_FLOAT: + case PRIMITIVE_INT: + case PRIMITIVE_LONG: + case PRIMITIVE_SHORT: + case PRIMITIVE_BOOLEAN: + case STRING: + input.read_be(index); + return new element_value_simple(type, index, pool); + case ENUM_CONSTANT: + input.read_be(index); + input.read_be(index2); + return new element_value_enum(type, index, index2, pool); + case CLASS: // Class + input.read_be(index); + return new element_value_class(type, index, pool); + case ANNOTATION: // Annotation + // FIXME: runtime visibility info needs to be passed from parent + return new element_value_annotation(ANNOTATION, annotation::read(input, pool), pool); + case ARRAY: // Array + input.read_be(index); + for (int i = 0; i < index; i++) { - case PRIMITIVE_BYTE: - case PRIMITIVE_CHAR: - case PRIMITIVE_DOUBLE: - case PRIMITIVE_FLOAT: - case PRIMITIVE_INT: - case PRIMITIVE_LONG: - case PRIMITIVE_SHORT: - case PRIMITIVE_BOOLEAN: - case STRING: - input.read_be(index); - return new element_value_simple(type, index, pool); - case ENUM_CONSTANT: - input.read_be(index); - input.read_be(index2); - return new element_value_enum(type, index, index2, pool); - case CLASS: // Class - input.read_be(index); - return new element_value_class(type, index, pool); - case ANNOTATION: // Annotation - // FIXME: runtime visibility info needs to be passed from parent - return new element_value_annotation(ANNOTATION, annotation::read(input, pool), pool); - case ARRAY: // Array - input.read_be(index); - for (int i = 0; i < index; i++) - { - vals.push_back(element_value::readElementValue(input, pool)); - } - return new element_value_array(ARRAY, vals, pool); - default: - throw new java::classfile_exception(); + vals.push_back(element_value::readElementValue(input, pool)); } + return new element_value_array(ARRAY, vals, pool); + default: + throw new java::classfile_exception(); } +} } \ No newline at end of file diff --git a/depends/classparser/src/annotations.h b/depends/classparser/src/annotations.h index b115dc0b..aa25d241 100644 --- a/depends/classparser/src/annotations.h +++ b/depends/classparser/src/annotations.h @@ -5,248 +5,273 @@ namespace java { - enum element_value_type : uint8_t - { - INVALID = 0, - STRING = 's', - ENUM_CONSTANT = 'e', - CLASS = 'c', - ANNOTATION = '@', - ARRAY = '[', // one array dimension - PRIMITIVE_INT = 'I', // integer - PRIMITIVE_BYTE = 'B', // signed byte - PRIMITIVE_CHAR = 'C', // Unicode character code point in the Basic Multilingual Plane, encoded with UTF-16 - PRIMITIVE_DOUBLE = 'D', // double-precision floating-point value - PRIMITIVE_FLOAT = 'F', // single-precision floating-point value - PRIMITIVE_LONG = 'J', // long integer - PRIMITIVE_SHORT = 'S', // signed short - PRIMITIVE_BOOLEAN = 'Z' // true or false - }; +enum element_value_type : uint8_t +{ + INVALID = 0, + STRING = 's', + ENUM_CONSTANT = 'e', + CLASS = 'c', + ANNOTATION = '@', + ARRAY = '[', // one array dimension + PRIMITIVE_INT = 'I', // integer + PRIMITIVE_BYTE = 'B', // signed byte + PRIMITIVE_CHAR = 'C', // Unicode character code point in the Basic Multilingual Plane, + // encoded with UTF-16 + PRIMITIVE_DOUBLE = 'D', // double-precision floating-point value + PRIMITIVE_FLOAT = 'F', // single-precision floating-point value + PRIMITIVE_LONG = 'J', // long integer + PRIMITIVE_SHORT = 'S', // signed short + PRIMITIVE_BOOLEAN = 'Z' // true or false +}; +/** + * The element_value structure is a discriminated union representing the value of an + *element-value pair. + * It is used to represent element values in all attributes that describe annotations + * - RuntimeVisibleAnnotations + * - RuntimeInvisibleAnnotations + * - RuntimeVisibleParameterAnnotations + * - RuntimeInvisibleParameterAnnotations). + * + * The element_value structure has the following format: + */ +class element_value +{ +protected: + element_value_type type; + constant_pool &pool; + +public: + element_value(element_value_type type, constant_pool &pool) : type(type), pool(pool) {}; + + element_value_type getElementValueType() + { + return type; + } + + virtual std::string toString() = 0; + + static element_value *readElementValue(util::membuffer &input, constant_pool &pool); +}; + +/** + * Each value of the annotations table represents a single runtime-visible annotation on a + * program element. + * The annotation structure has the following format: + */ +class annotation +{ +public: + typedef std::vector> value_list; + +protected: /** - * The element_value structure is a discriminated union representing the value of an element-value pair. - * It is used to represent element values in all attributes that describe annotations - * - RuntimeVisibleAnnotations - * - RuntimeInvisibleAnnotations - * - RuntimeVisibleParameterAnnotations - * - RuntimeInvisibleParameterAnnotations). + * The value of the type_index item must be a valid index into the constant_pool table. + * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure + * representing a field descriptor representing the annotation type corresponding + * to the annotation represented by this annotation structure. + */ + uint16_t type_index; + /** + * map between element_name_index and value. * - * The element_value structure has the following format: + * The value of the element_name_index item must be a valid index into the constant_pool + *table. + * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure + *representing + * a valid field descriptor (§4.3.2) that denotes the name of the annotation type element + *represented + * by this element_value_pairs entry. */ - class element_value - { - protected: - element_value_type type; - constant_pool & pool; - - public: - element_value(element_value_type type, constant_pool & pool): type(type), pool(pool) {}; + value_list name_val_pairs; + /** + * Reference to the parent constant pool + */ + constant_pool &pool; - element_value_type getElementValueType() +public: + annotation(uint16_t type_index, constant_pool &pool) + : type_index(type_index), pool(pool) {}; + ~annotation() + { + for (unsigned i = 0; i < name_val_pairs.size(); i++) { - return type; + delete name_val_pairs[i].second; } - - virtual std::string toString() = 0; + } + void add_pair(uint16_t key, element_value *value) + { + name_val_pairs.push_back(std::make_pair(key, value)); + } + ; + value_list::const_iterator begin() + { + return name_val_pairs.cbegin(); + } + value_list::const_iterator end() + { + return name_val_pairs.cend(); + } + std::string toString(); + static annotation *read(util::membuffer &input, constant_pool &pool); +}; +typedef std::vector annotation_table; + +/// type for simple value annotation elements +class element_value_simple : public element_value +{ +protected: + /// index of the constant in the constant pool + uint16_t index; - static element_value * readElementValue(util::membuffer & input, constant_pool & pool); - }; - +public: + element_value_simple(element_value_type type, uint16_t index, constant_pool &pool) + : element_value(type, pool), index(index) { + // TODO: verify consistency + }; + uint16_t getIndex() + { + return index; + } + virtual std::string toString() + { + return pool[index].toString(); + } + ; +}; +/// The enum_const_value item is used if the tag item is 'e'. +class element_value_enum : public element_value +{ +protected: /** - * Each value of the annotations table represents a single runtime-visible annotation on a program element. - * The annotation structure has the following format: + * The value of the type_name_index item must be a valid index into the constant_pool table. + * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure + * representing a valid field descriptor (§4.3.2) that denotes the internal form of the + * binary + * name (§4.2.1) of the type of the enum constant represented by this element_value + * structure. */ - class annotation - { - public: - typedef std::vector< std::pair > value_list; - protected: - /** - * The value of the type_index item must be a valid index into the constant_pool table. - * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure - * representing a field descriptor representing the annotation type corresponding - * to the annotation represented by this annotation structure. - */ - uint16_t type_index; - /** - * map between element_name_index and value. - * - * The value of the element_name_index item must be a valid index into the constant_pool table. - * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure representing - * a valid field descriptor (§4.3.2) that denotes the name of the annotation type element represented - * by this element_value_pairs entry. - */ - value_list name_val_pairs; - /** - * Reference to the parent constant pool - */ - constant_pool & pool; - public: - annotation(uint16_t type_index, constant_pool& pool):type_index(type_index), pool(pool) {}; - ~annotation() - { - for(unsigned i = 0 ; i < name_val_pairs.size(); i++) - { - delete name_val_pairs[i].second; - } - } - void add_pair(uint16_t key, element_value * value) - { - name_val_pairs.push_back(std::make_pair(key, value)); - }; - value_list::const_iterator begin() - { - return name_val_pairs.cbegin(); - } - value_list::const_iterator end() - { - return name_val_pairs.cend(); - } - std::string toString(); - static annotation * read(util::membuffer & input, constant_pool & pool); - }; - typedef std::vector annotation_table; - - - /// type for simple value annotation elements - class element_value_simple : public element_value - { - protected: - /// index of the constant in the constant pool - uint16_t index; - public: - element_value_simple(element_value_type type, uint16_t index , constant_pool& pool): - element_value(type, pool), index(index) - { - // TODO: verify consistency - }; - uint16_t getIndex() - { - return index; - } - virtual std::string toString() - { - return pool[index].toString(); - }; - }; - /// The enum_const_value item is used if the tag item is 'e'. - class element_value_enum : public element_value - { - protected: - /** - * The value of the type_name_index item must be a valid index into the constant_pool table. - * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure - * representing a valid field descriptor (§4.3.2) that denotes the internal form of the binary - * name (§4.2.1) of the type of the enum constant represented by this element_value structure. - */ - uint16_t typeIndex; - /** - * The value of the const_name_index item must be a valid index into the constant_pool table. - * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure - * representing the simple name of the enum constant represented by this element_value structure. - */ - uint16_t valueIndex; - public: - element_value_enum(element_value_type type, uint16_t typeIndex, uint16_t valueIndex, constant_pool& pool): - element_value(type, pool), typeIndex(typeIndex), valueIndex(valueIndex) - { - // TODO: verify consistency - } - uint16_t getValueIndex() - { - return valueIndex; - } - uint16_t getTypeIndex() - { - return typeIndex; - } - virtual std::string toString() - { - return "enum value"; - }; - }; - - class element_value_class : public element_value - { - protected: - /** - * The class_info_index item must be a valid index into the constant_pool table. - * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure - * representing the return descriptor (§4.3.3) of the type that is reified by the class - * represented by this element_value structure. - * - * For example, 'V' for Void.class, 'Ljava/lang/Object;' for Object, etc. - * - * Or in plain english, you can store type information in annotations. Yay. - */ - uint16_t classIndex; - public: - element_value_class(element_value_type type, uint16_t classIndex, constant_pool& pool): - element_value(type, pool), classIndex(classIndex) - { - // TODO: verify consistency - } - uint16_t getIndex() - { - return classIndex; - } - virtual std::string toString() - { - return "class"; - }; - }; - - /// nested annotations... yay - class element_value_annotation : public element_value - { - private: - annotation * nestedAnnotation; - public: - element_value_annotation(element_value_type type, annotation * nestedAnnotation, constant_pool& pool): - element_value(type, pool), nestedAnnotation(nestedAnnotation) - {}; - ~element_value_annotation() - { - if(nestedAnnotation) - { - delete nestedAnnotation; - nestedAnnotation = nullptr; - } - } - virtual std::string toString() - { - return "nested annotation"; - }; - }; - - /// and arrays! - class element_value_array : public element_value - { - public: - typedef std::vector elem_vec; - protected: - elem_vec values; - public: - element_value_array ( element_value_type type, std::vector & values, constant_pool& pool ): - element_value(type, pool), values(values) - {}; - ~element_value_array () - { - for(unsigned i = 0; i < values.size();i++) - { - delete values[i]; - } - }; - elem_vec::const_iterator begin() + uint16_t typeIndex; + /** + * The value of the const_name_index item must be a valid index into the constant_pool + * table. + * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure + * representing the simple name of the enum constant represented by this element_value + * structure. + */ + uint16_t valueIndex; + +public: + element_value_enum(element_value_type type, uint16_t typeIndex, uint16_t valueIndex, + constant_pool &pool) + : element_value(type, pool), typeIndex(typeIndex), valueIndex(valueIndex) + { + // TODO: verify consistency + } + uint16_t getValueIndex() + { + return valueIndex; + } + uint16_t getTypeIndex() + { + return typeIndex; + } + virtual std::string toString() + { + return "enum value"; + } + ; +}; + +class element_value_class : public element_value +{ +protected: + /** + * The class_info_index item must be a valid index into the constant_pool table. + * The constant_pool entry at that index must be a CONSTANT_Utf8_info (§4.4.7) structure + * representing the return descriptor (§4.3.3) of the type that is reified by the class + * represented by this element_value structure. + * + * For example, 'V' for Void.class, 'Ljava/lang/Object;' for Object, etc. + * + * Or in plain english, you can store type information in annotations. Yay. + */ + uint16_t classIndex; + +public: + element_value_class(element_value_type type, uint16_t classIndex, constant_pool &pool) + : element_value(type, pool), classIndex(classIndex) + { + // TODO: verify consistency + } + uint16_t getIndex() + { + return classIndex; + } + virtual std::string toString() + { + return "class"; + } + ; +}; + +/// nested annotations... yay +class element_value_annotation : public element_value +{ +private: + annotation *nestedAnnotation; + +public: + element_value_annotation(element_value_type type, annotation *nestedAnnotation, + constant_pool &pool) + : element_value(type, pool), nestedAnnotation(nestedAnnotation) {}; + ~element_value_annotation() + { + if (nestedAnnotation) { - return values.cbegin(); + delete nestedAnnotation; + nestedAnnotation = nullptr; } - elem_vec::const_iterator end() + } + virtual std::string toString() + { + return "nested annotation"; + } + ; +}; + +/// and arrays! +class element_value_array : public element_value +{ +public: + typedef std::vector elem_vec; + +protected: + elem_vec values; + +public: + element_value_array(element_value_type type, std::vector &values, + constant_pool &pool) + : element_value(type, pool), values(values) {}; + ~element_value_array() + { + for (unsigned i = 0; i < values.size(); i++) { - return values.cend(); + delete values[i]; } - virtual std::string toString() - { - return "array"; - }; - }; + } + ; + elem_vec::const_iterator begin() + { + return values.cbegin(); + } + elem_vec::const_iterator end() + { + return values.cend(); + } + virtual std::string toString() + { + return "array"; + } + ; +}; } \ No newline at end of file diff --git a/depends/classparser/src/classfile.h b/depends/classparser/src/classfile.h index 33207e99..a5e7ee50 100644 --- a/depends/classparser/src/classfile.h +++ b/depends/classparser/src/classfile.h @@ -5,149 +5,152 @@ #include namespace java { - /** - * Class representing a Java .class file - */ - class classfile : public util::membuffer +/** + * Class representing a Java .class file + */ +class classfile : public util::membuffer +{ +public: + classfile(char *data, std::size_t size) : membuffer(data, size) { - public: - classfile(char * data, std::size_t size) : membuffer(data, size) + valid = false; + is_synthetic = false; + read_be(magic); + if (magic != 0xCAFEBABE) + throw new classfile_exception(); + read_be(minor_version); + read_be(major_version); + constants.load(*this); + read_be(access_flags); + read_be(this_class); + read_be(super_class); + + // Interfaces + uint16_t iface_count = 0; + read_be(iface_count); + while (iface_count) { - valid = false; - is_synthetic = false; - read_be(magic); - if(magic != 0xCAFEBABE) - throw new classfile_exception(); - read_be(minor_version); - read_be(major_version); - constants.load(*this); - read_be(access_flags); - read_be(this_class); - read_be(super_class); - - // Interfaces - uint16_t iface_count = 0; - read_be(iface_count); - while (iface_count) - { - uint16_t iface; - read_be(iface); - interfaces.push_back(iface); - iface_count --; - } - - // Fields - // read fields (and attributes from inside fields) (and possible inner classes. yay for recursion!) - // for now though, we will ignore all attributes - /* - * field_info - * { - * u2 access_flags; - * u2 name_index; - * u2 descriptor_index; - * u2 attributes_count; - * attribute_info attributes[attributes_count]; - * } - */ - uint16_t field_count = 0; - read_be(field_count); - while (field_count) - { - // skip field stuff - skip(6); - // and skip field attributes - uint16_t attr_count = 0; - read_be(attr_count); - while(attr_count) - { - skip(2); - uint32_t attr_length = 0; - read_be(attr_length); - skip(attr_length); - attr_count --; - } - field_count --; - } + uint16_t iface; + read_be(iface); + interfaces.push_back(iface); + iface_count--; + } - // class methods - /* - * method_info - * { - * u2 access_flags; - * u2 name_index; - * u2 descriptor_index; - * u2 attributes_count; - * attribute_info attributes[attributes_count]; - * } - */ - uint16_t method_count = 0; - read_be(method_count); - while( method_count ) + // Fields + // read fields (and attributes from inside fields) (and possible inner classes. yay for + // recursion!) + // for now though, we will ignore all attributes + /* + * field_info + * { + * u2 access_flags; + * u2 name_index; + * u2 descriptor_index; + * u2 attributes_count; + * attribute_info attributes[attributes_count]; + * } + */ + uint16_t field_count = 0; + read_be(field_count); + while (field_count) + { + // skip field stuff + skip(6); + // and skip field attributes + uint16_t attr_count = 0; + read_be(attr_count); + while (attr_count) { - skip(6); - // and skip method attributes - uint16_t attr_count = 0; - read_be(attr_count); - while(attr_count) - { - skip(2); - uint32_t attr_length = 0; - read_be(attr_length); - skip(attr_length); - attr_count --; - } - method_count --; + skip(2); + uint32_t attr_length = 0; + read_be(attr_length); + skip(attr_length); + attr_count--; } + field_count--; + } - // class attributes - // there are many kinds of attributes. this is just the generic wrapper structure. - // type is decided by attribute name. extensions to the standard are *possible* - // class annotations are one kind of a attribute (one per class) - /* - * attribute_info - * { - * u2 attribute_name_index; - * u4 attribute_length; - * u1 info[attribute_length]; - * } - */ - uint16_t class_attr_count = 0; - read_be(class_attr_count); - while(class_attr_count) + // class methods + /* + * method_info + * { + * u2 access_flags; + * u2 name_index; + * u2 descriptor_index; + * u2 attributes_count; + * attribute_info attributes[attributes_count]; + * } + */ + uint16_t method_count = 0; + read_be(method_count); + while (method_count) + { + skip(6); + // and skip method attributes + uint16_t attr_count = 0; + read_be(attr_count); + while (attr_count) { - uint16_t name_idx = 0; - read_be(name_idx); + skip(2); uint32_t attr_length = 0; read_be(attr_length); - - auto name = constants[name_idx]; - if(name.str_data == "RuntimeVisibleAnnotations") + skip(attr_length); + attr_count--; + } + method_count--; + } + + // class attributes + // there are many kinds of attributes. this is just the generic wrapper structure. + // type is decided by attribute name. extensions to the standard are *possible* + // class annotations are one kind of a attribute (one per class) + /* + * attribute_info + * { + * u2 attribute_name_index; + * u4 attribute_length; + * u1 info[attribute_length]; + * } + */ + uint16_t class_attr_count = 0; + read_be(class_attr_count); + while (class_attr_count) + { + uint16_t name_idx = 0; + read_be(name_idx); + uint32_t attr_length = 0; + read_be(attr_length); + + auto name = constants[name_idx]; + if (name.str_data == "RuntimeVisibleAnnotations") + { + uint16_t num_annotations = 0; + read_be(num_annotations); + while (num_annotations) { - uint16_t num_annotations = 0; - read_be(num_annotations); - while (num_annotations) - { - visible_class_annotations.push_back(annotation::read(*this, constants)); - num_annotations --; - } + visible_class_annotations.push_back(annotation::read(*this, constants)); + num_annotations--; } - else skip(attr_length); - class_attr_count --; } - valid = true; - }; - bool valid; - bool is_synthetic; - uint32_t magic; - uint16_t minor_version; - uint16_t major_version; - constant_pool constants; - uint16_t access_flags; - uint16_t this_class; - uint16_t super_class; - // interfaces this class implements ? must be. investigate. - std::vector interfaces; - // FIXME: doesn't free up memory on delete - java::annotation_table visible_class_annotations; - }; + else + skip(attr_length); + class_attr_count--; + } + valid = true; + } + ; + bool valid; + bool is_synthetic; + uint32_t magic; + uint16_t minor_version; + uint16_t major_version; + constant_pool constants; + uint16_t access_flags; + uint16_t this_class; + uint16_t super_class; + // interfaces this class implements ? must be. investigate. + std::vector interfaces; + // FIXME: doesn't free up memory on delete + java::annotation_table visible_class_annotations; +}; } \ No newline at end of file diff --git a/depends/classparser/src/constants.h b/depends/classparser/src/constants.h index 61aa5687..242b943e 100644 --- a/depends/classparser/src/constants.h +++ b/depends/classparser/src/constants.h @@ -4,209 +4,217 @@ namespace java { - class constant +class constant +{ +public: + enum type_t : uint8_t { - public: - enum type_t : uint8_t - { - j_hole = 0, // HACK: this is a hole in the array, because java is crazy - j_string_data = 1, - j_int = 3, - j_float = 4, - j_long = 5, - j_double = 6, - j_class = 7, - j_string = 8, - j_fieldref = 9, - j_methodref = 10, - j_interface_methodref = 11, - j_nameandtype = 12 - } type; + j_hole = 0, // HACK: this is a hole in the array, because java is crazy + j_string_data = 1, + j_int = 3, + j_float = 4, + j_long = 5, + j_double = 6, + j_class = 7, + j_string = 8, + j_fieldref = 9, + j_methodref = 10, + j_interface_methodref = 11, + j_nameandtype = 12 + } type; - constant(util::membuffer & buf ) - { - buf.read(type); - // invalid constant type! - if(type > j_nameandtype || type == (type_t)0 || type == (type_t)2) - throw new classfile_exception(); - - // load data depending on type - switch(type) - { - case j_float: - case j_int: - buf.read_be(int_data); // same as float data really - break; - case j_double: - case j_long: - buf.read_be(long_data); // same as double - break; - case j_class: - buf.read_be(ref_type.class_idx); - break; - case j_fieldref: - case j_methodref: - case j_interface_methodref: - buf.read_be(ref_type.class_idx); - buf.read_be(ref_type.name_and_type_idx); - break; - case j_string: - buf.read_be(index); - break; - case j_string_data: - // HACK HACK: for now, we call these UTF-8 and do no further processing. - // Later, we should do some decoding. It's really modified UTF-8 - // * U+0000 is represented as 0xC0,0x80 invalid character - // * any single zero byte ends the string - // * characters above U+10000 are encoded like in CESU-8 - buf.read_jstr(str_data); - break; - case j_nameandtype: - buf.read_be(name_and_type.name_index); - buf.read_be(name_and_type.descriptor_index); - break; - } - } + constant(util::membuffer &buf) + { + buf.read(type); + // invalid constant type! + if (type > j_nameandtype || type == (type_t)0 || type == (type_t)2) + throw new classfile_exception(); - constant(int fake) + // load data depending on type + switch (type) { - type = j_hole; + case j_float: + case j_int: + buf.read_be(int_data); // same as float data really + break; + case j_double: + case j_long: + buf.read_be(long_data); // same as double + break; + case j_class: + buf.read_be(ref_type.class_idx); + break; + case j_fieldref: + case j_methodref: + case j_interface_methodref: + buf.read_be(ref_type.class_idx); + buf.read_be(ref_type.name_and_type_idx); + break; + case j_string: + buf.read_be(index); + break; + case j_string_data: + // HACK HACK: for now, we call these UTF-8 and do no further processing. + // Later, we should do some decoding. It's really modified UTF-8 + // * U+0000 is represented as 0xC0,0x80 invalid character + // * any single zero byte ends the string + // * characters above U+10000 are encoded like in CESU-8 + buf.read_jstr(str_data); + break; + case j_nameandtype: + buf.read_be(name_and_type.name_index); + buf.read_be(name_and_type.descriptor_index); + break; } + } + + constant(int fake) + { + type = j_hole; + } - std::string toString() + std::string toString() + { + std::ostringstream ss; + switch (type) { - std::ostringstream ss; - switch(type) - { - case j_hole: - ss << "Fake legacy entry"; - break; - case j_float: - ss << "Float: " << float_data; - break; - case j_double: - ss << "Double: " << double_data; - break; - case j_int: - ss << "Int: " << int_data; - break; - case j_long: - ss << "Long: " << long_data; - break; - case j_string_data: - ss << "StrData: " << str_data; - break; - case j_string: - ss << "Str: " << index; - break; - case j_fieldref: - ss << "FieldRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx; - break; - case j_methodref: - ss << "MethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx; - break; - case j_interface_methodref: - ss << "IfMethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx; - break; - case j_class: - ss << "Class: " << ref_type.class_idx; - break; - case j_nameandtype: - ss << "NameAndType: " << name_and_type.name_index << " " << name_and_type.descriptor_index; - break; - } - return ss.str(); + case j_hole: + ss << "Fake legacy entry"; + break; + case j_float: + ss << "Float: " << float_data; + break; + case j_double: + ss << "Double: " << double_data; + break; + case j_int: + ss << "Int: " << int_data; + break; + case j_long: + ss << "Long: " << long_data; + break; + case j_string_data: + ss << "StrData: " << str_data; + break; + case j_string: + ss << "Str: " << index; + break; + case j_fieldref: + ss << "FieldRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx; + break; + case j_methodref: + ss << "MethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx; + break; + case j_interface_methodref: + ss << "IfMethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx; + break; + case j_class: + ss << "Class: " << ref_type.class_idx; + break; + case j_nameandtype: + ss << "NameAndType: " << name_and_type.name_index << " " + << name_and_type.descriptor_index; + break; } + return ss.str(); + } - std::string str_data; /** String data in 'modified utf-8'.*/ - // store everything here. - union + std::string str_data; /** String data in 'modified utf-8'.*/ + // store everything here. + union + { + int32_t int_data; + int64_t long_data; + float float_data; + double double_data; + uint16_t index; + struct { - int32_t int_data; - int64_t long_data; - float float_data; - double double_data; - uint16_t index; - struct - { - /** - * Class reference: - * an index within the constant pool to a UTF-8 string containing - * the fully qualified class name (in internal format) - * Used for j_class, j_fieldref, j_methodref and j_interface_methodref - */ - uint16_t class_idx; - // used for j_fieldref, j_methodref and j_interface_methodref - uint16_t name_and_type_idx; - } ref_type; - struct - { - uint16_t name_index; - uint16_t descriptor_index; - } name_and_type; - }; + /** + * Class reference: + * an index within the constant pool to a UTF-8 string containing + * the fully qualified class name (in internal format) + * Used for j_class, j_fieldref, j_methodref and j_interface_methodref + */ + uint16_t class_idx; + // used for j_fieldref, j_methodref and j_interface_methodref + uint16_t name_and_type_idx; + } ref_type; + struct + { + uint16_t name_index; + uint16_t descriptor_index; + } name_and_type; }; +}; +/** + * A helper class that represents the custom container used in Java class file for storage of + * constants + */ +class constant_pool +{ +public: + /** + * Create a pool of constants + */ + constant_pool() + { + } /** - * A helper class that represents the custom container used in Java class file for storage of constants + * Load a java constant pool */ - class constant_pool + void load(util::membuffer &buf) { - public: - /** - * Create a pool of constants - */ - constant_pool(){} - /** - * Load a java constant pool - */ - void load(util::membuffer & buf) + uint16_t length = 0; + buf.read_be(length); + length--; + uint16_t index = 1; + const constant *last_constant = nullptr; + while (length) { - uint16_t length = 0; - buf.read_be(length); - length --; - uint16_t index = 1; - const constant * last_constant = nullptr; - while(length) + const constant &cnst = constant(buf); + constants.push_back(cnst); + last_constant = &constants[constants.size() - 1]; + if (last_constant->type == constant::j_double || + last_constant->type == constant::j_long) { - const constant & cnst = constant(buf); - constants.push_back(cnst); - last_constant = &constants[constants.size() - 1]; - if(last_constant->type == constant::j_double || last_constant->type == constant::j_long) - { - // push in a fake constant to preserve indexing - constants.push_back(constant(0)); - length-=2; - index+=2; - } - else - { - length--; - index++; - } + // push in a fake constant to preserve indexing + constants.push_back(constant(0)); + length -= 2; + index += 2; } - } - typedef std::vector container_type; - /** - * Access constants based on jar file index numbers (index of the first element is 1) - */ - java::constant & operator[](std::size_t constant_index) - { - if(constant_index == 0 || constant_index > constants.size()) + else { - throw new classfile_exception(); + length--; + index++; } - return constants[constant_index - 1]; - }; - container_type::const_iterator begin() const - { - return constants.begin(); - }; - container_type::const_iterator end() const + } + } + typedef std::vector container_type; + /** + * Access constants based on jar file index numbers (index of the first element is 1) + */ + java::constant &operator[](std::size_t constant_index) + { + if (constant_index == 0 || constant_index > constants.size()) { - return constants.end(); + throw new classfile_exception(); } - private: - container_type constants; - }; + return constants[constant_index - 1]; + } + ; + container_type::const_iterator begin() const + { + return constants.begin(); + } + ; + container_type::const_iterator end() const + { + return constants.end(); + } + +private: + container_type constants; +}; } diff --git a/depends/classparser/src/errors.h b/depends/classparser/src/errors.h index c02b07c8..ddbbd828 100644 --- a/depends/classparser/src/errors.h +++ b/depends/classparser/src/errors.h @@ -2,5 +2,7 @@ #include namespace java { - class classfile_exception : public std::exception {}; +class classfile_exception : public std::exception +{ +}; } diff --git a/depends/classparser/src/javaendian.h b/depends/classparser/src/javaendian.h index fa6207fe..d488b382 100644 --- a/depends/classparser/src/javaendian.h +++ b/depends/classparser/src/javaendian.h @@ -10,53 +10,67 @@ namespace util inline uint