mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Support for null chars in rawString view
This commit is contained in:
parent
49a470e154
commit
1097619f48
5 changed files with 24 additions and 24 deletions
|
@ -153,7 +153,7 @@ void StringView::ToString(StringImpl& str) const
|
||||||
|
|
||||||
StringSplitEnumerator StringView::Split(char c)
|
StringSplitEnumerator StringView::Split(char c)
|
||||||
{
|
{
|
||||||
return StringSplitEnumerator(mPtr, mLength, c, 0x7FFFFFFF, false);
|
return StringSplitEnumerator(mPtr, (int)mLength, c, 0x7FFFFFFF, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -314,11 +314,11 @@ bool StringImpl::EqualsHelper(const char * a, const char * b, intptr length)
|
||||||
return strncmp(a, b, length) == 0;
|
return strncmp(a, b, length) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StringImpl::EqualsIgnoreCaseHelper(const char * a, const char * b, int length)
|
bool StringImpl::EqualsIgnoreCaseHelper(const char * a, const char * b, intptr length)
|
||||||
{
|
{
|
||||||
const char* curA = a;
|
const char* curA = a;
|
||||||
const char* curB = b;
|
const char* curB = b;
|
||||||
int curLength = length;
|
intptr curLength = length;
|
||||||
|
|
||||||
/*Contract.Requires(strA != null);
|
/*Contract.Requires(strA != null);
|
||||||
Contract.Requires(strB != null);
|
Contract.Requires(strB != null);
|
||||||
|
@ -627,11 +627,11 @@ intptr StringImpl::Compare(const StringImpl & strA, intptr indexA, const StringI
|
||||||
|
|
||||||
void StringImpl::ReplaceLargerHelper(const StringView& find, const StringView& replace)
|
void StringImpl::ReplaceLargerHelper(const StringView& find, const StringView& replace)
|
||||||
{
|
{
|
||||||
Array<int> replaceEntries;
|
Array<intptr> replaceEntries;
|
||||||
|
|
||||||
int_strsize moveOffset = replace.mLength - find.mLength;
|
intptr moveOffset = replace.mLength - find.mLength;
|
||||||
|
|
||||||
for (int startIdx = 0; startIdx < mLength - find.mLength; startIdx++)
|
for (intptr startIdx = 0; startIdx < mLength - find.mLength; startIdx++)
|
||||||
{
|
{
|
||||||
if (EqualsHelper(GetPtr() + startIdx, find.mPtr, find.mLength))
|
if (EqualsHelper(GetPtr() + startIdx, find.mPtr, find.mLength))
|
||||||
{
|
{
|
||||||
|
@ -684,8 +684,8 @@ void StringImpl::Replace(const StringView& find, const StringView & replace)
|
||||||
auto findPtr = find.mPtr;
|
auto findPtr = find.mPtr;
|
||||||
auto replacePtr = replace.mPtr;
|
auto replacePtr = replace.mPtr;
|
||||||
|
|
||||||
int_strsize inIdx = 0;
|
intptr inIdx = 0;
|
||||||
int_strsize outIdx = 0;
|
intptr outIdx = 0;
|
||||||
|
|
||||||
while (inIdx < mLength - find.mLength)
|
while (inIdx < mLength - find.mLength)
|
||||||
{
|
{
|
||||||
|
@ -721,7 +721,7 @@ void StringImpl::Replace(const StringView& find, const StringView & replace)
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr[outIdx] = 0;
|
ptr[outIdx] = 0;
|
||||||
mLength = outIdx;
|
mLength = (int_strsize)outIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringImpl::TrimEnd()
|
void StringImpl::TrimEnd()
|
||||||
|
|
|
@ -18,7 +18,7 @@ class StringView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* mPtr;
|
const char* mPtr;
|
||||||
int mLength;
|
intptr mLength;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct iterator
|
struct iterator
|
||||||
|
@ -270,12 +270,12 @@ public:
|
||||||
mLength -= (int)length;
|
mLength -= (int)length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveToEnd(int startIdx)
|
void RemoveToEnd(intptr startIdx)
|
||||||
{
|
{
|
||||||
RemoveFromEnd(mLength - startIdx);
|
RemoveFromEnd(mLength - startIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveFromEnd(int length)
|
void RemoveFromEnd(intptr length)
|
||||||
{
|
{
|
||||||
mLength -= length;
|
mLength -= length;
|
||||||
}
|
}
|
||||||
|
@ -530,17 +530,17 @@ protected:
|
||||||
void Realloc(intptr newSize, bool copyStr = true);
|
void Realloc(intptr newSize, bool copyStr = true);
|
||||||
void Realloc(char* newPtr, intptr newSize);
|
void Realloc(char* newPtr, intptr newSize);
|
||||||
static bool EqualsHelper(const char* a, const char* b, intptr length);
|
static bool EqualsHelper(const char* a, const char* b, intptr length);
|
||||||
static bool EqualsIgnoreCaseHelper(const char* a, const char* b, int length);
|
static bool EqualsIgnoreCaseHelper(const char* a, const char* b, intptr length);
|
||||||
static int CompareOrdinalIgnoreCaseHelper(const StringImpl& strA, const StringImpl& strB);
|
static int CompareOrdinalIgnoreCaseHelper(const StringImpl& strA, const StringImpl& strB);
|
||||||
static intptr CompareOrdinalIgnoreCaseHelper(const char* strA, intptr lengthA, const char* strB, intptr lengthB);
|
static intptr CompareOrdinalIgnoreCaseHelper(const char* strA, intptr lengthA, const char* strB, intptr lengthB);
|
||||||
static intptr CompareOrdinalIgnoreCaseHelper(const StringImpl& strA, intptr indexA, intptr lengthA, const StringImpl& strB, intptr indexB, intptr lengthB);
|
static intptr CompareOrdinalIgnoreCaseHelper(const StringImpl& strA, intptr indexA, intptr lengthA, const StringImpl& strB, intptr indexB, intptr lengthB);
|
||||||
static intptr CompareOrdinalHelper(const char* strA, intptr lengthA, const char* strB, intptr lengthB);
|
static intptr CompareOrdinalHelper(const char* strA, intptr lengthA, const char* strB, intptr lengthB);
|
||||||
static intptr CompareOrdinalHelper(const StringImpl& strA, intptr indexA, intptr lengthA, const StringImpl& strB, intptr indexB, intptr lengthB);
|
static intptr CompareOrdinalHelper(const StringImpl& strA, intptr indexA, intptr lengthA, const StringImpl& strB, intptr indexB, intptr lengthB);
|
||||||
|
|
||||||
void Init(const char* charPtr, int_strsize count)
|
void Init(const char* charPtr, intptr count)
|
||||||
{
|
{
|
||||||
int_strsize internalSize = (int_strsize)(sizeof(StringImpl) - offsetof(StringImpl, mPtr));
|
int_strsize internalSize = (int_strsize)(sizeof(StringImpl) - offsetof(StringImpl, mPtr));
|
||||||
int_strsize allocSize = count + 1;
|
int_strsize allocSize = (int_strsize)count + 1;
|
||||||
|
|
||||||
if (allocSize <= internalSize)
|
if (allocSize <= internalSize)
|
||||||
{
|
{
|
||||||
|
@ -549,7 +549,7 @@ protected:
|
||||||
memcpy(ptr, charPtr, count);
|
memcpy(ptr, charPtr, count);
|
||||||
ptr[count] = 0;
|
ptr[count] = 0;
|
||||||
mAllocSizeAndFlags = internalSize;
|
mAllocSizeAndFlags = internalSize;
|
||||||
this->mLength = count;
|
this->mLength = (int_strsize)count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -559,7 +559,7 @@ protected:
|
||||||
ptr[count] = 0;
|
ptr[count] = 0;
|
||||||
this->mPtr = ptr;
|
this->mPtr = ptr;
|
||||||
mAllocSizeAndFlags = allocSize | DynAllocFlag | StrPtrFlag;
|
mAllocSizeAndFlags = allocSize | DynAllocFlag | StrPtrFlag;
|
||||||
this->mLength = count;
|
this->mLength = (int_strsize)count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ namespace IDE.Debugger
|
||||||
static extern void Debugger_EvaluateContinueKeep();
|
static extern void Debugger_EvaluateContinueKeep();
|
||||||
|
|
||||||
[CallingConvention(.Stdcall),CLink]
|
[CallingConvention(.Stdcall),CLink]
|
||||||
static extern char8* Debugger_Evaluate(char8* expr, int32 callStackIdx, int32 cursorPos, int32 language, EvalExpressionFlags expressionFlags);
|
static extern StringView Debugger_Evaluate(char8* expr, int32 callStackIdx, int32 cursorPos, int32 language, EvalExpressionFlags expressionFlags);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall),CLink]
|
[CallingConvention(.Stdcall),CLink]
|
||||||
static extern char8* Debugger_EvaluateToAddress(char8* expr, int32 callStackIdx, int32 cursorPos);
|
static extern char8* Debugger_EvaluateToAddress(char8* expr, int32 callStackIdx, int32 cursorPos);
|
||||||
|
@ -760,9 +760,7 @@ namespace IDE.Debugger
|
||||||
// AllowAssignment, allowCalls
|
// AllowAssignment, allowCalls
|
||||||
public void Evaluate(String expr, String outVal, int cursorPos = -1, int language = -1, EvalExpressionFlags expressionFlags = EvalExpressionFlags.None)
|
public void Evaluate(String expr, String outVal, int cursorPos = -1, int language = -1, EvalExpressionFlags expressionFlags = EvalExpressionFlags.None)
|
||||||
{
|
{
|
||||||
char8* result = Debugger_Evaluate(expr, (expressionFlags.HasFlag(.DeselectCallStackIdx)) ? -1 : mActiveCallStackIdx, (int32)cursorPos, (int32)language, expressionFlags);
|
StringView result = Debugger_Evaluate(expr, (expressionFlags.HasFlag(.DeselectCallStackIdx)) ? -1 : mActiveCallStackIdx, (int32)cursorPos, (int32)language, expressionFlags);
|
||||||
if (result == null)
|
|
||||||
return;
|
|
||||||
outVal.Append(result);
|
outVal.Append(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
#include "BeefySysLib/util/AllocDebug.h"
|
#include "BeefySysLib/util/AllocDebug.h"
|
||||||
|
|
||||||
|
#pragma warning(disable:4190)
|
||||||
|
|
||||||
#define ENABLE_DBG_32
|
#define ENABLE_DBG_32
|
||||||
|
|
||||||
//#define BF_DBG_32
|
//#define BF_DBG_32
|
||||||
|
@ -1219,7 +1221,7 @@ BF_EXPORT void BF_CALLTYPE Debugger_EvaluateContinueKeep()
|
||||||
debugger->EvaluateContinueKeep();
|
debugger->EvaluateContinueKeep();
|
||||||
}
|
}
|
||||||
|
|
||||||
BF_EXPORT const char* BF_CALLTYPE Debugger_Evaluate(const char* expr, int callStackIdx, int cursorPos, int32 language, int8 expressionFlags)
|
BF_EXPORT StringView BF_CALLTYPE Debugger_Evaluate(const char* expr, int callStackIdx, int cursorPos, int32 language, int8 expressionFlags)
|
||||||
{
|
{
|
||||||
auto debugger = gDebugger;
|
auto debugger = gDebugger;
|
||||||
|
|
||||||
|
@ -1238,7 +1240,7 @@ BF_EXPORT const char* BF_CALLTYPE Debugger_Evaluate(const char* expr, int callSt
|
||||||
BfLogDbg("Debugger_Evaluate Result=%s\n", outString.c_str());
|
BfLogDbg("Debugger_Evaluate Result=%s\n", outString.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return outString.c_str();
|
return outString;
|
||||||
}
|
}
|
||||||
|
|
||||||
BF_EXPORT const char* BF_CALLTYPE Debugger_EvaluateToAddress(const char* expr, int callStackIdx, int cursorPos)
|
BF_EXPORT const char* BF_CALLTYPE Debugger_EvaluateToAddress(const char* expr, int callStackIdx, int cursorPos)
|
||||||
|
|
|
@ -5455,7 +5455,7 @@ bool WinDebugger::ParseFormatInfo(DbgModule* dbgModule, const StringImpl& format
|
||||||
DbgEvaluationContext dbgEvaluationContext(this, dbgModule, countExpr, formatInfo);
|
DbgEvaluationContext dbgEvaluationContext(this, dbgModule, countExpr, formatInfo);
|
||||||
DbgTypedValue countValue = dbgEvaluationContext.EvaluateInContext(contextTypedValue);
|
DbgTypedValue countValue = dbgEvaluationContext.EvaluateInContext(contextTypedValue);
|
||||||
if ((countValue) && (countValue.mType->IsInteger()))
|
if ((countValue) && (countValue.mType->IsInteger()))
|
||||||
formatInfo->mOverrideCount = (intptr)countValue.GetInt64();
|
formatInfo->mMaxCount = (intptr)countValue.GetInt64();
|
||||||
if (dbgEvaluationContext.HadError())
|
if (dbgEvaluationContext.HadError())
|
||||||
{
|
{
|
||||||
if (errorString != NULL)
|
if (errorString != NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue