Convert tabs to spaces

This commit is contained in:
Deve 2018-01-26 22:03:04 +01:00
parent 5aaf3a9c39
commit 0532a41ab3
4 changed files with 2287 additions and 2287 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,109 +25,109 @@ struct SArrayCache;
class CScriptArray
{
public:
// Set the memory functions that should be used by all CScriptArrays
static void SetMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc);
// Set the memory functions that should be used by all CScriptArrays
static void SetMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc);
// Factory functions
static CScriptArray *Create(asITypeInfo *ot);
static CScriptArray *Create(asITypeInfo *ot, asUINT length);
static CScriptArray *Create(asITypeInfo *ot, asUINT length, void *defaultValue);
static CScriptArray *Create(asITypeInfo *ot, void *listBuffer);
// Factory functions
static CScriptArray *Create(asITypeInfo *ot);
static CScriptArray *Create(asITypeInfo *ot, asUINT length);
static CScriptArray *Create(asITypeInfo *ot, asUINT length, void *defaultValue);
static CScriptArray *Create(asITypeInfo *ot, void *listBuffer);
// Memory management
void AddRef() const;
void Release() const;
// Memory management
void AddRef() const;
void Release() const;
// Type information
asITypeInfo *GetArrayObjectType() const;
int GetArrayTypeId() const;
int GetElementTypeId() const;
// Type information
asITypeInfo *GetArrayObjectType() const;
int GetArrayTypeId() const;
int GetElementTypeId() const;
// Get the current size
asUINT GetSize() const;
// Get the current size
asUINT GetSize() const;
// Returns true if the array is empty
bool IsEmpty() const;
// Returns true if the array is empty
bool IsEmpty() const;
// Pre-allocates memory for elements
void Reserve(asUINT maxElements);
// Pre-allocates memory for elements
void Reserve(asUINT maxElements);
// Resize the array
void Resize(asUINT numElements);
// Resize the array
void Resize(asUINT numElements);
// Get a pointer to an element. Returns 0 if out of bounds
void *At(asUINT index);
const void *At(asUINT index) const;
// Get a pointer to an element. Returns 0 if out of bounds
void *At(asUINT index);
const void *At(asUINT index) const;
// Set value of an element.
// The value arg should be a pointer to the value that will be copied to the element.
// Remember, if the array holds handles the value parameter should be the
// address of the handle. The refCount of the object will also be incremented
void SetValue(asUINT index, void *value);
// Set value of an element.
// The value arg should be a pointer to the value that will be copied to the element.
// Remember, if the array holds handles the value parameter should be the
// address of the handle. The refCount of the object will also be incremented
void SetValue(asUINT index, void *value);
// Copy the contents of one array to another (only if the types are the same)
CScriptArray &operator=(const CScriptArray&);
// Copy the contents of one array to another (only if the types are the same)
CScriptArray &operator=(const CScriptArray&);
// Compare two arrays
bool operator==(const CScriptArray &) const;
// Compare two arrays
bool operator==(const CScriptArray &) const;
// Array manipulation
void InsertAt(asUINT index, void *value);
void InsertAt(asUINT index, const CScriptArray &arr);
void InsertLast(void *value);
void RemoveAt(asUINT index);
void RemoveLast();
void RemoveRange(asUINT start, asUINT count);
void SortAsc();
void SortDesc();
void SortAsc(asUINT startAt, asUINT count);
void SortDesc(asUINT startAt, asUINT count);
void Sort(asUINT startAt, asUINT count, bool asc);
void Sort(asIScriptFunction *less, asUINT startAt, asUINT count);
void Reverse();
int Find(void *value) const;
int Find(asUINT startAt, void *value) const;
int FindByRef(void *ref) const;
int FindByRef(asUINT startAt, void *ref) const;
// Array manipulation
void InsertAt(asUINT index, void *value);
void InsertAt(asUINT index, const CScriptArray &arr);
void InsertLast(void *value);
void RemoveAt(asUINT index);
void RemoveLast();
void RemoveRange(asUINT start, asUINT count);
void SortAsc();
void SortDesc();
void SortAsc(asUINT startAt, asUINT count);
void SortDesc(asUINT startAt, asUINT count);
void Sort(asUINT startAt, asUINT count, bool asc);
void Sort(asIScriptFunction *less, asUINT startAt, asUINT count);
void Reverse();
int Find(void *value) const;
int Find(asUINT startAt, void *value) const;
int FindByRef(void *ref) const;
int FindByRef(asUINT startAt, void *ref) const;
// Return the address of internal buffer for direct manipulation of elements
void *GetBuffer();
// Return the address of internal buffer for direct manipulation of elements
void *GetBuffer();
// GC methods
int GetRefCount();
void SetFlag();
bool GetFlag();
void EnumReferences(asIScriptEngine *engine);
void ReleaseAllHandles(asIScriptEngine *engine);
// GC methods
int GetRefCount();
void SetFlag();
bool GetFlag();
void EnumReferences(asIScriptEngine *engine);
void ReleaseAllHandles(asIScriptEngine *engine);
protected:
mutable int refCount;
mutable bool gcFlag;
asITypeInfo *objType;
SArrayBuffer *buffer;
int elementSize;
int subTypeId;
mutable int refCount;
mutable bool gcFlag;
asITypeInfo *objType;
SArrayBuffer *buffer;
int elementSize;
int subTypeId;
// Constructors
CScriptArray(asITypeInfo *ot, void *initBuf); // Called from script when initialized with list
CScriptArray(asUINT length, asITypeInfo *ot);
CScriptArray(asUINT length, void *defVal, asITypeInfo *ot);
CScriptArray(const CScriptArray &other);
virtual ~CScriptArray();
// Constructors
CScriptArray(asITypeInfo *ot, void *initBuf); // Called from script when initialized with list
CScriptArray(asUINT length, asITypeInfo *ot);
CScriptArray(asUINT length, void *defVal, asITypeInfo *ot);
CScriptArray(const CScriptArray &other);
virtual ~CScriptArray();
bool Less(const void *a, const void *b, bool asc, asIScriptContext *ctx, SArrayCache *cache);
void *GetArrayItemPointer(int index);
void *GetDataPointer(void *buffer);
void Copy(void *dst, void *src);
void Precache();
bool CheckMaxSize(asUINT numElements);
void Resize(int delta, asUINT at);
void CreateBuffer(SArrayBuffer **buf, asUINT numElements);
void DeleteBuffer(SArrayBuffer *buf);
void CopyBuffer(SArrayBuffer *dst, SArrayBuffer *src);
void Construct(SArrayBuffer *buf, asUINT start, asUINT end);
void Destruct(SArrayBuffer *buf, asUINT start, asUINT end);
bool Equals(const void *a, const void *b, asIScriptContext *ctx, SArrayCache *cache) const;
bool Less(const void *a, const void *b, bool asc, asIScriptContext *ctx, SArrayCache *cache);
void *GetArrayItemPointer(int index);
void *GetDataPointer(void *buffer);
void Copy(void *dst, void *src);
void Precache();
bool CheckMaxSize(asUINT numElements);
void Resize(int delta, asUINT at);
void CreateBuffer(SArrayBuffer **buf, asUINT numElements);
void DeleteBuffer(SArrayBuffer *buf);
void CopyBuffer(SArrayBuffer *dst, SArrayBuffer *src);
void Construct(SArrayBuffer *buf, asUINT start, asUINT end);
void Destruct(SArrayBuffer *buf, asUINT start, asUINT end);
bool Equals(const void *a, const void *b, asIScriptContext *ctx, SArrayCache *cache) const;
};
void RegisterScriptArray(asIScriptEngine *engine, bool defaultArray);

File diff suppressed because it is too large Load Diff

View File

@ -22,45 +22,45 @@ BEGIN_AS_NAMESPACE
// array<string>@ string::split(const string &in delim) const
static CScriptArray *StringSplit(const string &delim, const string &str)
{
// Obtain a pointer to the engine
asIScriptContext *ctx = asGetActiveContext();
asIScriptEngine *engine = ctx->GetEngine();
// Obtain a pointer to the engine
asIScriptContext *ctx = asGetActiveContext();
asIScriptEngine *engine = ctx->GetEngine();
// TODO: This should only be done once
// TODO: This assumes that CScriptArray was already registered
asITypeInfo *arrayType = engine->GetTypeInfoByDecl("array<string>");
// TODO: This should only be done once
// TODO: This assumes that CScriptArray was already registered
asITypeInfo *arrayType = engine->GetTypeInfoByDecl("array<string>");
// Create the array object
CScriptArray *array = CScriptArray::Create(arrayType);
// Create the array object
CScriptArray *array = CScriptArray::Create(arrayType);
// Find the existence of the delimiter in the input string
int pos = 0, prev = 0, count = 0;
while( (pos = (int)str.find(delim, prev)) != (int)string::npos )
{
// Add the part to the array
array->Resize(array->GetSize()+1);
((string*)array->At(count))->assign(&str[prev], pos-prev);
// Find the existence of the delimiter in the input string
int pos = 0, prev = 0, count = 0;
while( (pos = (int)str.find(delim, prev)) != (int)string::npos )
{
// Add the part to the array
array->Resize(array->GetSize()+1);
((string*)array->At(count))->assign(&str[prev], pos-prev);
// Find the next part
count++;
prev = pos + (int)delim.length();
}
// Find the next part
count++;
prev = pos + (int)delim.length();
}
// Add the remaining part
array->Resize(array->GetSize()+1);
((string*)array->At(count))->assign(&str[prev]);
// Add the remaining part
array->Resize(array->GetSize()+1);
((string*)array->At(count))->assign(&str[prev]);
return array;
return array;
}
static void StringSplit_Generic(asIScriptGeneric *gen)
{
// Get the arguments
string *str = (string*)gen->GetObject();
string *delim = *(string**)gen->GetAddressOfArg(0);
// Get the arguments
string *str = (string*)gen->GetObject();
string *delim = *(string**)gen->GetAddressOfArg(0);
// Return the array by handle
*(CScriptArray**)gen->GetAddressOfReturnLocation() = StringSplit(*delim, *str);
// Return the array by handle
*(CScriptArray**)gen->GetAddressOfReturnLocation() = StringSplit(*delim, *str);
}
@ -80,50 +80,50 @@ static void StringSplit_Generic(asIScriptGeneric *gen)
// string join(const array<string> &in array, const string &in delim)
static string StringJoin(const CScriptArray &array, const string &delim)
{
// Create the new string
string str = "";
if( array.GetSize() )
{
int n;
for( n = 0; n < (int)array.GetSize() - 1; n++ )
{
str += *(string*)array.At(n);
str += delim;
}
// Create the new string
string str = "";
if( array.GetSize() )
{
int n;
for( n = 0; n < (int)array.GetSize() - 1; n++ )
{
str += *(string*)array.At(n);
str += delim;
}
// Add the last part
str += *(string*)array.At(n);
}
// Add the last part
str += *(string*)array.At(n);
}
return str;
return str;
}
static void StringJoin_Generic(asIScriptGeneric *gen)
{
// Get the arguments
CScriptArray *array = *(CScriptArray**)gen->GetAddressOfArg(0);
string *delim = *(string**)gen->GetAddressOfArg(1);
// Get the arguments
CScriptArray *array = *(CScriptArray**)gen->GetAddressOfArg(0);
string *delim = *(string**)gen->GetAddressOfArg(1);
// Return the string
new(gen->GetAddressOfReturnLocation()) string(StringJoin(*array, *delim));
// Return the string
new(gen->GetAddressOfReturnLocation()) string(StringJoin(*array, *delim));
}
// This is where the utility functions are registered.
// The string type must have been registered first.
void RegisterStdStringUtils(asIScriptEngine *engine)
{
int r;
int r;
if( strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY") )
{
r = engine->RegisterObjectMethod("string", "array<string>@ split(const string &in) const", asFUNCTION(StringSplit_Generic), asCALL_GENERIC); assert(r >= 0);
r = engine->RegisterGlobalFunction("string join(const array<string> &in, const string &in)", asFUNCTION(StringJoin_Generic), asCALL_GENERIC); assert(r >= 0);
}
else
{
r = engine->RegisterObjectMethod("string", "array<string>@ split(const string &in) const", asFUNCTION(StringSplit), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterGlobalFunction("string join(const array<string> &in, const string &in)", asFUNCTION(StringJoin), asCALL_CDECL); assert(r >= 0);
}
if( strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY") )
{
r = engine->RegisterObjectMethod("string", "array<string>@ split(const string &in) const", asFUNCTION(StringSplit_Generic), asCALL_GENERIC); assert(r >= 0);
r = engine->RegisterGlobalFunction("string join(const array<string> &in, const string &in)", asFUNCTION(StringJoin_Generic), asCALL_GENERIC); assert(r >= 0);
}
else
{
r = engine->RegisterObjectMethod("string", "array<string>@ split(const string &in) const", asFUNCTION(StringSplit), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterGlobalFunction("string join(const array<string> &in, const string &in)", asFUNCTION(StringJoin), asCALL_CDECL); assert(r >= 0);
}
}
END_AS_NAMESPACE