Skip to content

Commit

Permalink
Revised Object methods.
Browse files Browse the repository at this point in the history
- Added Object.InsertAt(), Object.Push() and ObjRawSet().
    Original source: fbe20bd
- Added Object.Delete(), Object.RemoveAt() and Object.Pop().
    Original source: a2debf6  (Delete renamed from Remove)
- Added Object.Length().
  • Loading branch information
Lexikos committed Mar 14, 2015
1 parent 9d503ee commit 37038e7
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 101 deletions.
14 changes: 13 additions & 1 deletion source/script.cpp
Expand Up @@ -8216,8 +8216,14 @@ Func *Script::FindFunc(LPCTSTR aFuncName, size_t aFuncNameLength, int *apInsertP
}
// All of these functions require the "object" parameter,
// but it is excluded from the counts below for clarity:
BIF_OBJ_CASE(Insert, 1, 10000) // [key,] value [, value2, ...]
BIF_OBJ_CASE(Insert, 1, 10000) // [key,] value [, value2, ...]
BIF_OBJ_CASE(InsertAt, 2, 10000) // index, value [, value2, ...]
BIF_OBJ_CASE(Push, 1, 10000)
BIF_OBJ_CASE(Delete, 1, 2) // min_key [, max_key]
BIF_OBJ_CASE(Remove, 0, 2) // [min_key, max_key]
BIF_OBJ_CASE(RemoveAt, 1, 2) // position [, count]
BIF_OBJ_CASE(Pop, 0, 0)
BIF_OBJ_CASE(Length, 0, 0)
BIF_OBJ_CASE(MinIndex, 0, 0)
BIF_OBJ_CASE(MaxIndex, 0, 0)
BIF_OBJ_CASE(HasKey, 1, 1) // key
Expand All @@ -8230,6 +8236,12 @@ Func *Script::FindFunc(LPCTSTR aFuncName, size_t aFuncNameLength, int *apInsertP
#undef BIF_OBJ_CASE
else if (!_tcsicmp(suffix, _T("AddRef")) || !_tcsicmp(suffix, _T("Release")))
bif = BIF_ObjAddRefRelease;
else if (!_tcsicmp(suffix, _T("RawSet")))
{
bif = BIF_ObjRawSet;
min_params = 3;
max_params = 3;
}
else return NULL;
}
else if (!_tcsicmp(func_name, _T("Array")))
Expand Down
7 changes: 7 additions & 0 deletions source/script.h
Expand Up @@ -3192,12 +3192,19 @@ BIF_DECL(BIF_ObjNew); // Pseudo-operator.
BIF_DECL(BIF_ObjIncDec); // Pseudo-operator.
BIF_DECL(BIF_ObjAddRefRelease);
BIF_DECL(BIF_ObjBindMethod);
BIF_DECL(BIF_ObjRawSet);
// Built-ins also available as methods -- these are available as functions for use primarily by overridden methods (i.e. where using the built-in methods isn't possible as they're no longer accessible).
BIF_DECL(BIF_ObjInsert);
BIF_DECL(BIF_ObjInsertAt);
BIF_DECL(BIF_ObjPush);
BIF_DECL(BIF_ObjPop);
BIF_DECL(BIF_ObjDelete);
BIF_DECL(BIF_ObjRemove);
BIF_DECL(BIF_ObjRemoveAt);
BIF_DECL(BIF_ObjGetCapacity);
BIF_DECL(BIF_ObjSetCapacity);
BIF_DECL(BIF_ObjGetAddress);
BIF_DECL(BIF_ObjLength);
BIF_DECL(BIF_ObjMaxIndex);
BIF_DECL(BIF_ObjMinIndex);
BIF_DECL(BIF_ObjNewEnum);
Expand Down

0 comments on commit 37038e7

Please sign in to comment.