Skip to content

Commit

Permalink
configure mago: setup maximum number of elements for an array
Browse files Browse the repository at this point in the history
  • Loading branch information
rainers committed Jun 14, 2019
1 parent ad73343 commit 50ab239
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Expand Up @@ -2,4 +2,4 @@
#define VERSION_MINOR 50
#define VERSION_REVISION 0
#define VERSION_BETA -beta
#define VERSION_BUILD 2
#define VERSION_BUILD 3
10 changes: 5 additions & 5 deletions stdext/string.d
Expand Up @@ -261,7 +261,7 @@ bool _startsWith(string s, string w)
//alias startsWith _startsWith;

// munch deprecated in phobos
char[] _munch(ref char[] s, const(char)[] pattern) @safe pure @nogc
inout(char)[] _munch(ref inout(char)[] s, const(char)[] pattern) @safe pure @nogc
{
size_t j = s.length;
foreach (i, dchar c; s)
Expand All @@ -272,12 +272,12 @@ char[] _munch(ref char[] s, const(char)[] pattern) @safe pure @nogc
break;
}
}
char[] head = s[0 .. j];
auto head = s[0 .. j];
s = s[j .. $];
return head;
}

bool parseLong(ref char[] txt, out long res)
bool parseLong(ref const(char)[] txt, out long res)
{
_munch(txt, " \t\n\r");
int n = 0;
Expand All @@ -290,13 +290,13 @@ bool parseLong(ref char[] txt, out long res)
return true;
}

char[] parseNonSpace(ref char[] txt)
inout(char)[] parseNonSpace(ref inout(char)[] txt)
{
_munch(txt, " \t\n\r");
int n = 0;
while(n < txt.length && !isWhite(txt[n]))
n++;
char[] res = txt[0..n];
auto res = txt[0..n];
txt = txt[n..$];
return res;
}
Expand Down
6 changes: 3 additions & 3 deletions visuald/profiler.d
Expand Up @@ -2036,14 +2036,14 @@ class ProfileItemIndex
}
else if(curItem)
{
char[] txt = buf;
const(char)[] txt = buf;
_munch(txt, " \t\n\r");
if(txt.length > 0 && isDigit(txt[0]))
{
long calls;
if(parseLong(txt, calls))
{
char[] id = parseNonSpace(txt);
auto id = parseNonSpace(txt);
if(id.length > 0)
{
_munch(txt, " \t\n\r");
Expand All @@ -2061,7 +2061,7 @@ class ProfileItemIndex
else if(txt.length > 0)
{
long calls, treeTime, funcTime;
char[] id = parseNonSpace(txt);
auto id = parseNonSpace(txt);
if(id.length > 0 &&
parseLong(txt, calls) &&
parseLong(txt, treeTime) &&
Expand Down
15 changes: 15 additions & 0 deletions visuald/propertypage.d
Expand Up @@ -2985,6 +2985,7 @@ struct MagoOptions
bool showVTable;
bool flatClassFields;
bool expandableStrings;
uint maxArrayElements;

void saveToRegistry()
{
Expand All @@ -2994,6 +2995,7 @@ struct MagoOptions
keyMago.Set("showVTable", showVTable);
keyMago.Set("flatClassFields", flatClassFields);
keyMago.Set("expandableStrings", expandableStrings);
keyMago.Set("maxArrayElements", maxArrayElements);
}

void loadFromRegistry()
Expand All @@ -3005,6 +3007,7 @@ struct MagoOptions
showVTable = (keyMago.GetDWORD("showVTable", 1) != 0);
flatClassFields = (keyMago.GetDWORD("flatClassFields", 0) != 0);
expandableStrings = (keyMago.GetDWORD("expandableStrings", 0) != 0);
maxArrayElements = keyMago.GetDWORD("maxArrayElements", 1000);
}
}

Expand All @@ -3023,6 +3026,10 @@ class MagoPropertyPage : ResizablePropertyPage
AddControl("", mShowVTable = new CheckBox(mCanvas, "Show virtual function table as field of classes"));
AddControl("", mFlatClassFields = new CheckBox(mCanvas, "Show base class fields as direct fields"));
AddControl("", mExpandableStrings = new CheckBox(mCanvas, "Expand strings to show array of characters"));
auto saveWidth = kLabelWidth;
kLabelWidth = kPageWidth * 4 / 5;
AddControl("Limit array elements shown in expansions to", mMaxArrayElements = new Text(mCanvas));
kLabelWidth = saveWidth;
}

override void UpdateDirty(bool bDirty)
Expand Down Expand Up @@ -3069,6 +3076,7 @@ class MagoPropertyPage : ResizablePropertyPage
mShowVTable.setChecked(mOptions.showVTable);
mFlatClassFields.setChecked(mOptions.flatClassFields);
mExpandableStrings.setChecked(mOptions.expandableStrings);
mMaxArrayElements.setText(to!string(mOptions.maxArrayElements));
}

int DoApply(ref MagoOptions opts, ref MagoOptions refopts)
Expand All @@ -3079,6 +3087,12 @@ class MagoPropertyPage : ResizablePropertyPage
changes += changeOption(mShowVTable.isChecked(), opts.showVTable, refopts.showVTable);
changes += changeOption(mFlatClassFields.isChecked(), opts.flatClassFields, refopts.flatClassFields);
changes += changeOption(mExpandableStrings.isChecked(), opts.expandableStrings, refopts.expandableStrings);

import stdext.string;
long maxelem;
const(char)[] txt = mMaxArrayElements.getText();
if (parseLong(txt, maxelem))
changes += changeOption(cast(uint)maxelem, opts.maxArrayElements, refopts.maxArrayElements);
return changes;
}

Expand All @@ -3087,6 +3101,7 @@ class MagoPropertyPage : ResizablePropertyPage
CheckBox mShowVTable;
CheckBox mFlatClassFields;
CheckBox mExpandableStrings;
Text mMaxArrayElements;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 50ab239

Please sign in to comment.