Move Debugger's Array class to headers/shared
This commit is contained in:
@@ -1,16 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. All Rights Reserved.
|
* Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef ARRAY_H
|
#ifndef _ARRAY_H
|
||||||
#define ARRAY_H
|
#define _ARRAY_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <OS.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
# include <OS.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
@@ -20,37 +27,37 @@ public:
|
|||||||
Array(const Array<Element>& other);
|
Array(const Array<Element>& other);
|
||||||
~Array();
|
~Array();
|
||||||
|
|
||||||
inline int Size() const { return fSize; }
|
inline int32 Size() const { return fSize; }
|
||||||
inline int Count() const { return fSize; }
|
inline int32 Count() const { return fSize; }
|
||||||
inline bool IsEmpty() const { return fSize == 0; }
|
inline bool IsEmpty() const { return fSize == 0; }
|
||||||
inline Element* Elements() const { return fElements; }
|
inline Element* Elements() const { return fElements; }
|
||||||
|
|
||||||
inline bool Add(const Element& element);
|
inline bool Add(const Element& element);
|
||||||
inline bool AddUninitialized(int elementCount);
|
inline bool AddUninitialized(int32 elementCount);
|
||||||
inline bool Insert(const Element& element, int index);
|
inline bool Insert(const Element& element, int32 index);
|
||||||
inline bool InsertUninitialized(int index, int count);
|
inline bool InsertUninitialized(int32 index, int32 count);
|
||||||
inline bool Remove(int index, int count = 1);
|
inline bool Remove(int32 index, int32 count = 1);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
inline void MakeEmpty();
|
inline void MakeEmpty();
|
||||||
|
|
||||||
inline Element& ElementAt(int index);
|
inline Element& ElementAt(int32 index);
|
||||||
inline const Element& ElementAt(int index) const;
|
inline const Element& ElementAt(int32 index) const;
|
||||||
|
|
||||||
inline Element& operator[](int index);
|
inline Element& operator[](int32 index);
|
||||||
inline const Element& operator[](int index) const;
|
inline const Element& operator[](int32 index) const;
|
||||||
|
|
||||||
Array<Element>& operator=(const Array<Element>& other);
|
Array<Element>& operator=(const Array<Element>& other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int kMinCapacity = 8;
|
static const int32 kMinCapacity = 8;
|
||||||
|
|
||||||
bool _Resize(int index, int delta);
|
bool _Resize(int32 index, int32 delta);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element* fElements;
|
Element* fElements;
|
||||||
int fSize;
|
int32 fSize;
|
||||||
int fCapacity;
|
int32 fCapacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -97,7 +104,7 @@ Array<Element>::Add(const Element& element)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
inline bool
|
inline bool
|
||||||
Array<Element>::AddUninitialized(int elementCount)
|
Array<Element>::AddUninitialized(int32 elementCount)
|
||||||
{
|
{
|
||||||
return InsertUninitialized(fSize, elementCount);
|
return InsertUninitialized(fSize, elementCount);
|
||||||
}
|
}
|
||||||
@@ -105,7 +112,7 @@ Array<Element>::AddUninitialized(int elementCount)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
bool
|
bool
|
||||||
Array<Element>::Insert(const Element& element, int index)
|
Array<Element>::Insert(const Element& element, int32 index)
|
||||||
{
|
{
|
||||||
if (index < 0 || index > fSize)
|
if (index < 0 || index > fSize)
|
||||||
index = fSize;
|
index = fSize;
|
||||||
@@ -121,7 +128,7 @@ Array<Element>::Insert(const Element& element, int index)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
bool
|
bool
|
||||||
Array<Element>::InsertUninitialized(int index, int count)
|
Array<Element>::InsertUninitialized(int32 index, int32 count)
|
||||||
{
|
{
|
||||||
if (index < 0 || index > fSize || count < 0)
|
if (index < 0 || index > fSize || count < 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -138,7 +145,7 @@ Array<Element>::InsertUninitialized(int index, int count)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
bool
|
bool
|
||||||
Array<Element>::Remove(int index, int count)
|
Array<Element>::Remove(int32 index, int32 count)
|
||||||
{
|
{
|
||||||
if (index < 0 || count < 0 || index + count > fSize) {
|
if (index < 0 || count < 0 || index + count > fSize) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -189,7 +196,7 @@ Array<Element>::MakeEmpty()
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
Element&
|
Element&
|
||||||
Array<Element>::ElementAt(int index)
|
Array<Element>::ElementAt(int32 index)
|
||||||
{
|
{
|
||||||
return fElements[index];
|
return fElements[index];
|
||||||
}
|
}
|
||||||
@@ -197,7 +204,7 @@ Array<Element>::ElementAt(int index)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
const Element&
|
const Element&
|
||||||
Array<Element>::ElementAt(int index) const
|
Array<Element>::ElementAt(int32 index) const
|
||||||
{
|
{
|
||||||
return fElements[index];
|
return fElements[index];
|
||||||
}
|
}
|
||||||
@@ -205,7 +212,7 @@ Array<Element>::ElementAt(int index) const
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
Element&
|
Element&
|
||||||
Array<Element>::operator[](int index)
|
Array<Element>::operator[](int32 index)
|
||||||
{
|
{
|
||||||
return fElements[index];
|
return fElements[index];
|
||||||
}
|
}
|
||||||
@@ -213,7 +220,7 @@ Array<Element>::operator[](int index)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
const Element&
|
const Element&
|
||||||
Array<Element>::operator[](int index) const
|
Array<Element>::operator[](int32 index) const
|
||||||
{
|
{
|
||||||
return fElements[index];
|
return fElements[index];
|
||||||
}
|
}
|
||||||
@@ -236,11 +243,11 @@ Array<Element>::operator=(const Array<Element>& other)
|
|||||||
|
|
||||||
template<typename Element>
|
template<typename Element>
|
||||||
bool
|
bool
|
||||||
Array<Element>::_Resize(int index, int delta)
|
Array<Element>::_Resize(int32 index, int32 delta)
|
||||||
{
|
{
|
||||||
// determine new capacity
|
// determine new capacity
|
||||||
int newSize = fSize + delta;
|
int32 newSize = fSize + delta;
|
||||||
int newCapacity = kMinCapacity;
|
int32 newCapacity = kMinCapacity;
|
||||||
while (newCapacity < newSize)
|
while (newCapacity < newSize)
|
||||||
newCapacity *= 2;
|
newCapacity *= 2;
|
||||||
|
|
||||||
@@ -287,4 +294,10 @@ Array<Element>::_Resize(int index, int delta)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // ARRAY_H
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::Array;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _ARRAY_H
|
||||||
@@ -6,8 +6,9 @@
|
|||||||
#define ARCHITECTURE_X86_H
|
#define ARCHITECTURE_X86_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Array.h>
|
||||||
|
|
||||||
#include "Architecture.h"
|
#include "Architecture.h"
|
||||||
#include "Array.h"
|
|
||||||
#include "Register.h"
|
#include "Register.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
#define COMPILATION_UNIT_H
|
#define COMPILATION_UNIT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <ObjectList.h>
|
#include <Array.h>
|
||||||
|
|
||||||
#include "Array.h"
|
|
||||||
#include "LineNumberProgram.h"
|
#include "LineNumberProgram.h"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
|
||||||
|
#include <Array.h>
|
||||||
|
|
||||||
#include "Array.h"
|
|
||||||
#include "SourceCode.h"
|
#include "SourceCode.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
#define ARRAY_INDEX_PATH_H
|
#define ARRAY_INDEX_PATH_H
|
||||||
|
|
||||||
|
|
||||||
#include "Array.h"
|
#include <Array.h>
|
||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
#ifndef TARGET_ADDRESS_RANGE_LIST_H
|
#ifndef TARGET_ADDRESS_RANGE_LIST_H
|
||||||
#define TARGET_ADDRESS_RANGE_LIST_H
|
#define TARGET_ADDRESS_RANGE_LIST_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Array.h>
|
||||||
#include <Referenceable.h>
|
#include <Referenceable.h>
|
||||||
|
|
||||||
#include "Array.h"
|
|
||||||
#include "TargetAddressRange.h"
|
#include "TargetAddressRange.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#define VALUE_LOCATION_H
|
#define VALUE_LOCATION_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Array.h>
|
||||||
#include <Referenceable.h>
|
#include <Referenceable.h>
|
||||||
|
|
||||||
#include "Array.h"
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
#include <Array.h>
|
||||||
#include "Array.h"
|
|
||||||
|
|
||||||
|
|
||||||
class BitBuffer {
|
class BitBuffer {
|
||||||
|
|||||||
Reference in New Issue
Block a user