Skip to content

Commit dc94073

Browse files
committed
Additional code cleanups ; Short option name for --python-script in type summary add moved from -s to -o (this is a preliminary step in moving the short option for --summary-string from -f to -s) ; Accordingly updated the test suite
llvm-svn: 138315
1 parent b50801f commit dc94073

File tree

13 files changed

+427
-345
lines changed

13 files changed

+427
-345
lines changed

lldb/include/lldb/Core/FormatClasses.h

Lines changed: 108 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
#include "lldb/lldb-public.h"
3232
#include "lldb/lldb-enumerations.h"
3333

34-
#include "lldb/API/SBValue.h"
3534
#include "lldb/Core/ValueObject.h"
3635
#include "lldb/Interpreter/ScriptInterpreterPython.h"
37-
#include "lldb/Symbol/SymbolContext.h"
3836

3937
namespace lldb_private {
4038

@@ -48,13 +46,7 @@ struct ValueFormat
4846
ValueFormat (lldb::Format f = lldb::eFormatInvalid,
4947
bool casc = false,
5048
bool skipptr = false,
51-
bool skipref = false) :
52-
m_cascades(casc),
53-
m_skip_pointers(skipptr),
54-
m_skip_references(skipref),
55-
m_format (f)
56-
{
57-
}
49+
bool skipref = false);
5850

5951
typedef lldb::SharedPtr<ValueFormat>::Type SharedPointer;
6052
typedef bool(*ValueCallback)(void*, ConstString, const lldb::ValueFormatSP&);
@@ -335,25 +327,7 @@ class SyntheticScriptProvider : public SyntheticChildren
335327
}
336328

337329
virtual lldb::ValueObjectSP
338-
GetChildAtIndex (uint32_t idx, bool can_create)
339-
{
340-
if (m_wrapper == NULL || m_interpreter == NULL)
341-
return lldb::ValueObjectSP();
342-
343-
PyObject* py_return = (PyObject*)m_interpreter->GetChildAtIndex(m_wrapper, idx);
344-
if (py_return == NULL || py_return == Py_None)
345-
{
346-
Py_XDECREF(py_return);
347-
return lldb::ValueObjectSP();
348-
}
349-
350-
lldb::SBValue *sb_ptr = m_interpreter->CastPyObjectToSBValue(py_return);
351-
352-
if (py_return == NULL || sb_ptr == NULL)
353-
return lldb::ValueObjectSP();
354-
355-
return sb_ptr->m_opaque_sp;
356-
}
330+
GetChildAtIndex (uint32_t idx, bool can_create);
357331

358332
virtual void
359333
Update()
@@ -383,122 +357,121 @@ class SyntheticScriptProvider : public SyntheticChildren
383357
}
384358

385359
};
386-
387-
struct SyntheticArrayRange
388-
{
389-
private:
390-
int m_low;
391-
int m_high;
392-
SyntheticArrayRange* m_next;
393360

361+
class SyntheticArrayView : public SyntheticChildren
362+
{
394363
public:
395364

396-
SyntheticArrayRange () :
365+
struct SyntheticArrayRange
366+
{
367+
private:
368+
int m_low;
369+
int m_high;
370+
SyntheticArrayRange* m_next;
371+
372+
public:
373+
374+
SyntheticArrayRange () :
397375
m_low(-1),
398376
m_high(-2),
399377
m_next(NULL)
400-
{}
401-
402-
SyntheticArrayRange (int L) :
378+
{}
379+
380+
SyntheticArrayRange (int L) :
403381
m_low(L),
404382
m_high(L),
405383
m_next(NULL)
406-
{}
407-
408-
SyntheticArrayRange (int L, int H) :
384+
{}
385+
386+
SyntheticArrayRange (int L, int H) :
409387
m_low(L),
410388
m_high(H),
411389
m_next(NULL)
412-
{}
413-
414-
SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) :
390+
{}
391+
392+
SyntheticArrayRange (int L, int H, SyntheticArrayRange* N) :
415393
m_low(L),
416394
m_high(H),
417395
m_next(N)
418-
{}
419-
420-
inline int
421-
GetLow ()
422-
{
423-
return m_low;
424-
}
425-
426-
inline int
427-
GetHigh ()
428-
{
429-
return m_high;
430-
}
431-
432-
inline void
433-
SetLow (int L)
434-
{
435-
m_low = L;
436-
}
437-
438-
inline void
439-
SetHigh (int H)
440-
{
441-
m_high = H;
442-
}
443-
444-
inline int
445-
GetSelfCount()
446-
{
447-
return GetHigh() - GetLow() + 1;
448-
}
449-
450-
int
451-
GetCount()
452-
{
453-
int count = GetSelfCount();
454-
if (m_next)
455-
count += m_next->GetCount();
456-
return count;
457-
}
458-
459-
inline SyntheticArrayRange*
460-
GetNext()
461-
{
462-
return m_next;
463-
}
464-
465-
void
466-
SetNext(SyntheticArrayRange* N)
467-
{
468-
if (m_next)
469-
delete m_next;
470-
m_next = N;
471-
}
472-
473-
void
474-
SetNext(int L, int H)
475-
{
476-
if (m_next)
477-
delete m_next;
478-
m_next = new SyntheticArrayRange(L, H);
479-
}
480-
481-
void
482-
SetNext(int L)
483-
{
484-
if (m_next)
396+
{}
397+
398+
inline int
399+
GetLow ()
400+
{
401+
return m_low;
402+
}
403+
404+
inline int
405+
GetHigh ()
406+
{
407+
return m_high;
408+
}
409+
410+
inline void
411+
SetLow (int L)
412+
{
413+
m_low = L;
414+
}
415+
416+
inline void
417+
SetHigh (int H)
418+
{
419+
m_high = H;
420+
}
421+
422+
inline int
423+
GetSelfCount()
424+
{
425+
return GetHigh() - GetLow() + 1;
426+
}
427+
428+
int
429+
GetCount()
430+
{
431+
int count = GetSelfCount();
432+
if (m_next)
433+
count += m_next->GetCount();
434+
return count;
435+
}
436+
437+
inline SyntheticArrayRange*
438+
GetNext()
439+
{
440+
return m_next;
441+
}
442+
443+
void
444+
SetNext(SyntheticArrayRange* N)
445+
{
446+
if (m_next)
447+
delete m_next;
448+
m_next = N;
449+
}
450+
451+
void
452+
SetNext(int L, int H)
453+
{
454+
if (m_next)
455+
delete m_next;
456+
m_next = new SyntheticArrayRange(L, H);
457+
}
458+
459+
void
460+
SetNext(int L)
461+
{
462+
if (m_next)
463+
delete m_next;
464+
m_next = new SyntheticArrayRange(L);
465+
}
466+
467+
~SyntheticArrayRange()
468+
{
485469
delete m_next;
486-
m_next = new SyntheticArrayRange(L);
487-
}
488-
489-
~SyntheticArrayRange()
490-
{
491-
delete m_next;
492-
m_next = NULL;
493-
}
494-
495-
};
470+
m_next = NULL;
471+
}
472+
473+
};
496474

497-
class SyntheticArrayView : public SyntheticChildren
498-
{
499-
SyntheticArrayRange m_head;
500-
SyntheticArrayRange *m_tail;
501-
public:
502475
SyntheticArrayView(bool casc = false,
503476
bool skipptr = false,
504477
bool skipref = false) :
@@ -524,29 +497,7 @@ class SyntheticArrayView : public SyntheticChildren
524497
}
525498

526499
const int
527-
GetRealIndexForIndex(int i)
528-
{
529-
if (i >= GetCount())
530-
return -1;
531-
532-
SyntheticArrayRange* ptr = &m_head;
533-
534-
int residual = i;
535-
536-
while(ptr && ptr != m_tail)
537-
{
538-
if (residual >= ptr->GetSelfCount())
539-
{
540-
residual -= ptr->GetSelfCount();
541-
ptr = ptr->GetNext();
542-
}
543-
544-
return ptr->GetLow() + residual;
545-
}
546-
547-
return -1;
548-
549-
}
500+
GetRealIndexForIndex(int i);
550501

551502
bool
552503
IsScripted()
@@ -592,20 +543,7 @@ class SyntheticArrayView : public SyntheticChildren
592543
Update() {}
593544

594545
virtual uint32_t
595-
GetIndexOfChildWithName (const ConstString &name_cs)
596-
{
597-
const char* name_cstr = name_cs.GetCString();
598-
if (*name_cstr != '[')
599-
return UINT32_MAX;
600-
std::string name(name_cstr+1);
601-
if (name[name.size()-1] != ']')
602-
return UINT32_MAX;
603-
name = name.erase(name.size()-1,1);
604-
int index = Args::StringToSInt32 (name.c_str(), -1);
605-
if (index < 0)
606-
return UINT32_MAX;
607-
return index;
608-
}
546+
GetIndexOfChildWithName (const ConstString &name_cs);
609547

610548
typedef lldb::SharedPtr<SyntheticChildrenFrontEnd>::Type SharedPointer;
611549

@@ -616,6 +554,9 @@ class SyntheticArrayView : public SyntheticChildren
616554
{
617555
return SyntheticChildrenFrontEnd::SharedPointer(new FrontEnd(this, backend));
618556
}
557+
private:
558+
SyntheticArrayRange m_head;
559+
SyntheticArrayRange *m_tail;
619560

620561
};
621562

@@ -635,15 +576,7 @@ struct SummaryFormat
635576
bool skipref = false,
636577
bool nochildren = true,
637578
bool novalue = true,
638-
bool oneliner = false) :
639-
m_cascades(casc),
640-
m_skip_pointers(skipptr),
641-
m_skip_references(skipref),
642-
m_dont_show_children(nochildren),
643-
m_dont_show_value(novalue),
644-
m_show_members_oneliner(oneliner)
645-
{
646-
}
579+
bool oneliner = false);
647580

648581
bool
649582
Cascades() const
@@ -707,11 +640,7 @@ struct StringSummaryFormat : public SummaryFormat
707640
bool nochildren = true,
708641
bool novalue = true,
709642
bool oneliner = false,
710-
std::string f = "") :
711-
SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner),
712-
m_format(f)
713-
{
714-
}
643+
std::string f = "");
715644

716645
std::string
717646
GetFormat() const
@@ -745,12 +674,7 @@ struct ScriptSummaryFormat : public SummaryFormat
745674
bool novalue = true,
746675
bool oneliner = false,
747676
std::string fname = "",
748-
std::string pscri = "") :
749-
SummaryFormat(casc,skipptr,skipref,nochildren,novalue,oneliner),
750-
m_function_name(fname),
751-
m_python_script(pscri)
752-
{
753-
}
677+
std::string pscri = "");
754678

755679
std::string
756680
GetFunctionName() const

0 commit comments

Comments
 (0)