reverting latest commit, merged by mistake

This commit is contained in:
Stanislav Shwartsman 2017-04-20 18:31:52 +00:00
parent e3fdf42225
commit 68b9d10b76
5 changed files with 97 additions and 39 deletions

View File

@ -30,8 +30,6 @@
#include "config.h" /* generated by configure script from config.h.in */
using namespace std;
#ifndef __QNXNTO__
extern "C" {
#endif
@ -103,8 +101,6 @@ extern "C" {
}
#endif
#include <string>
#include "osdep.h" /* platform dependent includes and defines */
#include "bx_debug/debug.h"
#include "gui/siminterface.h"

View File

@ -37,10 +37,15 @@ const char* bx_param_c::default_text_format = NULL;
bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_desc)
: bx_object_c(id),
parent(NULL),
name(param_name),
description(param_desc)
description(NULL),
label(NULL),
ask_format(NULL),
group_name(NULL)
{
set_type(BXT_PARAM);
this->name = new char[strlen(param_name)+1];
strcpy(this->name, param_name);
set_description(param_desc);
this->text_format = default_text_format;
this->long_text_format = default_text_format;
this->runtime_param = 0;
@ -54,11 +59,16 @@ bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_desc
bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_label, const char *param_desc)
: bx_object_c(id),
parent(NULL),
name(param_name),
description(param_desc),
label(param_label)
description(NULL),
label(NULL),
ask_format(NULL),
group_name(NULL)
{
set_type(BXT_PARAM);
this->name = new char[strlen(param_name)+1];
strcpy(this->name, param_name);
set_description(param_desc);
set_label(param_label);
this->text_format = default_text_format;
this->long_text_format = default_text_format;
this->runtime_param = 0;
@ -71,12 +81,61 @@ bx_param_c::bx_param_c(Bit32u id, const char *param_name, const char *param_labe
bx_param_c::~bx_param_c()
{
delete [] name;
delete [] label;
delete [] description;
delete [] ask_format;
delete [] group_name;
delete dependent_list;
}
void bx_param_c::set_description(const char *text)
{
delete [] this->description;
if (text) {
this->description = new char[strlen(text)+1];
strcpy(this->description, text);
} else {
this->description = NULL;
}
}
void bx_param_c::set_label(const char *text)
{
delete [] label;
if (text) {
label = new char[strlen(text)+1];
strcpy(label, text);
} else {
label = NULL;
}
}
void bx_param_c::set_ask_format(const char *format)
{
delete [] ask_format;
if (format) {
ask_format = new char[strlen(format)+1];
strcpy(ask_format, format);
} else {
ask_format = NULL;
}
}
void bx_param_c::set_group(const char *group)
{
delete [] group_name;
if (group) {
group_name = new char[strlen(group)+1];
strcpy(group_name, group);
} else {
group_name = NULL;
}
}
int bx_param_c::get_param_path(char *path_out, int maxlen)
{
if (get_parent() == NULL || get_parent() == root_param) {
if ((get_parent() == NULL) || (get_parent() == root_param)) {
// Start with an empty string.
// Never print the name of the root param.
path_out[0] = 0;
@ -86,7 +145,7 @@ int bx_param_c::get_param_path(char *path_out, int maxlen)
strncat(path_out, ".", maxlen);
}
}
strncat(path_out, name.c_str(), maxlen);
strncat(path_out, name, maxlen);
return strlen(path_out);
}
@ -997,11 +1056,18 @@ bx_list_c::~bx_list_c()
if (list != NULL) {
clear();
}
delete [] title;
}
void bx_list_c::init(const char *list_title)
{
title = string(list_title);
if (list_title) {
this->title = new char[strlen(list_title)+1];
strcpy(this->title, list_title);
} else {
this->title = new char[1];
this->title[0] = 0;
}
this->options = 0;
this->choice = 1;
}
@ -1024,7 +1090,7 @@ void bx_list_c::set_parent(bx_param_c *newparent)
bx_list_c* bx_list_c::clone()
{
bx_list_c *newlist = new bx_list_c(NULL, name.c_str(), title.c_str());
bx_list_c *newlist = new bx_list_c(NULL, name, title);
for (int i=0; i<get_size(); i++)
newlist->add(get(i));
newlist->set_options(options);

View File

@ -23,10 +23,6 @@
#ifndef BX_PARAM_TREE_H
#define BX_PARAM_TREE_H
using namespace std;
#include <string>
////////////////////////////////////////////////////////////////////
// parameter classes: bx_param_c and family
////////////////////////////////////////////////////////////////////
@ -99,13 +95,13 @@ class BOCHSAPI bx_param_c : public bx_object_c {
BOCHSAPI_CYGONLY static const char *default_text_format;
protected:
bx_list_c *parent;
string name;
string description;
string label; // label string for text menus and gui dialogs
char *name;
char *description;
char *label; // label string for text menus and gui dialogs
const char *text_format; // printf format string. %d for ints, %s for strings, etc.
const char *long_text_format; // printf format string. %d for ints, %s for strings, etc.
string ask_format; // format string for asking for a new value
string group_name; // name of the group the param belongs to
char *ask_format; // format string for asking for a new value
char *group_name; // name of the group the param belongs to
int runtime_param;
int enabled;
Bit32u options;
@ -128,7 +124,7 @@ public:
virtual void reset() {}
const char *get_name() const { return name.c_str(); }
const char *get_name() const { return name; }
bx_param_c *get_parent() { return (bx_param_c *) parent; }
int get_param_path(char *path_out, int maxlen);
@ -139,20 +135,20 @@ public:
void set_long_format(const char *format) {long_text_format = format;}
const char *get_long_format() const {return long_text_format;}
void set_ask_format(const char *txt) { ask_format = string(txt); }
const char *get_ask_format() const {return ask_format.c_str();}
void set_ask_format(const char *format);
const char *get_ask_format() const {return ask_format;}
void set_label(const char *txt) { label = string(txt); }
const char *get_label() const {return label.c_str();}
void set_label(const char *text);
const char *get_label() const {return label;}
void set_description(const char *desc) { description = string(desc); }
const char *get_description() const { return description.c_str(); }
void set_description(const char *text);
const char *get_description() const { return description; }
virtual void set_runtime_param(int val) { runtime_param = val; }
int get_runtime_param() const { return runtime_param; }
int get_runtime_param() { return runtime_param; }
void set_group(const char *group) { group_name = string(group); }
const char *get_group() const {return group_name.c_str();}
void set_group(const char *group);
const char *get_group() const {return group_name;}
int get_enabled() const { return enabled; }
virtual void set_enabled(int enabled) { this->enabled = enabled; }
@ -229,8 +225,8 @@ public:
void set_initial_val(Bit64s initial_val);
int get_base() const { return base; }
void set_range(Bit64u min, Bit64u max);
Bit64s get_min() const { return min; }
Bit64s get_max() const { return max; }
Bit64s get_min() { return min; }
Bit64s get_max() { return max; }
static Bit32u set_default_base(Bit32u val);
static Bit32u get_default_base() { return default_base; }
#if BX_USE_TEXTCONFIG
@ -490,7 +486,7 @@ protected:
// to 1 in the constructor.
Bit32u choice; // type Bit32u is compatible with ask_uint
// title of the menu or series
string title;
char *title;
void init(const char *list_title);
// save / restore support
void *sr_devptr;
@ -535,7 +531,7 @@ public:
int get_size() const { return size; }
int get_choice() const { return choice; }
void set_choice(int new_choice) { choice = new_choice; }
const char *get_title() const { return title.c_str(); }
char *get_title() { return title; }
void set_parent(bx_param_c *newparent);
bx_param_c *get_parent() { return parent; }
virtual void reset();

View File

@ -990,7 +990,7 @@ int bx_list_c::text_ask()
bx_listitem_t *item;
bx_list_c *child;
const char *my_title = title.c_str();
const char *my_title = title;
bx_printf("\n");
int i, imax = strlen(my_title);
for (i=0; i<imax; i++) bx_printf("-");

View File

@ -136,7 +136,7 @@ static BOOL CALLBACK StringParamProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
case WM_INITDIALOG:
param = (bx_param_string_c *)lParam;
title = param->get_label();
if (title == NULL || strlen(title) == 0) {
if ((title == NULL) || (strlen(title) == 0)) {
title = param->get_name();
}
SetWindowText(hDlg, title);
@ -168,7 +168,7 @@ void SetStandardLogOptions(HWND hDlg)
for (level=0; level<N_LOGLEV; level++) {
int mod = 0;
int first = SIM->get_log_action(mod, level);
int first = SIM->get_log_action (mod, level);
BOOL consensus = true;
// now compare all others to first. If all match, then use "first" as
// the initial value.