summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Palmisciano <jp@jonpalmisc.com>2022-12-15 11:55:13 -0500
committerJon Palmisciano <jp@jonpalmisc.com>2022-12-16 15:44:04 -0500
commit74dfc90a4291ff12228288e45bdbfe714869bac3 (patch)
treea057a8b49f4ad79158354ea43bc6b684a62f234c
parent7f2d3ad1f37f8944d0158448072d2db5b167fa43 (diff)
Add new "Create Array" dialog
-rw-r--r--ui/createarraydialog.h49
-rw-r--r--ui/linearview.h1
2 files changed, 50 insertions, 0 deletions
diff --git a/ui/createarraydialog.h b/ui/createarraydialog.h
new file mode 100644
index 00000000..d14bbca3
--- /dev/null
+++ b/ui/createarraydialog.h
@@ -0,0 +1,49 @@
+#include "uitypes.h"
+
+#include <QtWidgets/QDialog>
+#include <QtWidgets/QSpinBox>
+#include <QtWidgets/QLineEdit>
+#include <QtWidgets/QComboBox>
+
+class CreateArrayDialog : public QDialog
+{
+ Q_OBJECT
+
+ BinaryViewRef m_data;
+
+ uint64_t m_startAddress;
+ TypeRef m_elementType;
+ uint64_t m_elementCount;
+
+ QLineEdit* m_startField;
+ QComboBox* m_countTypeDropdown;
+ QComboBox* m_typeDropdown;
+ QSpinBox* m_countField;
+
+ QPushButton* m_acceptButton;
+
+ void validate();
+
+public:
+ CreateArrayDialog(BinaryViewRef data, QWidget* parent = nullptr);
+
+ /// Set the initial start address, element type, and element count for
+ /// the dialog. The element type may be null if no default is desired; a
+ /// default will be chosen by the dialog.
+ void setInitialState(uint64_t start, TypeRef elementType, uint64_t count);
+
+ /// Get the desired start address from the accepted dialog.
+ uint64_t startAddress() const;
+
+ /// Get the desired array element type from the accepted dialog.
+ ///
+ /// The returned value will NOT be of `Type::ArrayType(...)`, but rather
+ /// the element inside.
+ TypeRef elementType() const;
+
+ /// Get the desired element count from the accepted dialog.
+ uint64_t elementCount() const;
+
+ void accept() override;
+ void reject() override;
+};
diff --git a/ui/linearview.h b/ui/linearview.h
index 4814fc6b..329c7119 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -350,6 +350,7 @@ private Q_SLOTS:
void undefineVariable();
void displayAs(const UIActionContext& context, BNIntegerDisplayType displayType) override;
void createStructOrInferStructureType();
+ bool autoCreateArray();
void createArray();
void createStruct();
void createNewTypes();