[ruamoko] Add support for PL_KeyAtIndex

I'd forgotten to wrap the function when I added it, but didn't need it
until now.
This commit is contained in:
Bill Currie 2023-02-12 02:30:21 +09:00
parent c16d0bae7b
commit 2748f1c9f7
5 changed files with 21 additions and 0 deletions

View file

@ -322,6 +322,18 @@ bi_PL_D_NumKeys (progs_t *pr, void *_res)
R_INT (pr) = PL_D_NumKeys (plist->plitem);
}
static void
bi_PL_KeyAtIndex (progs_t *pr, void *_res)
{
plist_resources_t *res = _res;
int handle = P_INT (pr, 0);
int index = P_INT (pr, 1);
bi_plist_t *plist = get_plist (pr, res, __FUNCTION__, handle);
const char *key = PL_KeyAtIndex (plist->plitem, index);
RETURN_STRING (pr, key);
}
static void
bi_PL_D_AddObject (progs_t *pr, void *_res)
{
@ -474,6 +486,7 @@ static builtin_t builtins[] = {
bi(PL_ObjectAtIndex, 2, p(ptr), p(int)),
bi(PL_D_AllKeys, 1, p(ptr)),
bi(PL_D_NumKeys, 1, p(ptr)),
bi(PL_KeyAtIndex, 2, p(ptr), p(int)),
bi(PL_D_AddObject, 3, p(ptr), p(string), p(ptr)),
bi(PL_A_AddObject, 2, p(ptr), p(ptr)),
bi(PL_A_NumObjects, 1, p(ptr)),

View file

@ -11,6 +11,7 @@
- (int) numKeys;
- (PLItem *) getObjectForKey:(string) key;
- (PLItem *) allKeys;
- (string) keyAtIndex:(int) index;
- addKey:(string) key value:(PLItem *) value;
@end

View file

@ -16,6 +16,7 @@ typedef enum {QFDictionary, QFArray, QFBinary, QFString} pltype_t; // possible t
@extern plitem_t *PL_RemoveObjectForKey (plitem_t *item, string key);
@extern plitem_t *PL_ObjectAtIndex (plitem_t *item, int index);
@extern plitem_t *PL_D_AllKeys (plitem_t *item);
@extern string PL_KeyAtIndex (plitem_t *item, int index);
@extern int PL_D_NumKeys (plitem_t *item);
@extern int PL_D_AddObject (plitem_t *dict, string key, plitem_t *value);
@extern int PL_A_AddObject (plitem_t *array_item, plitem_t *item);

View file

@ -128,6 +128,11 @@
return [[PLItem itemClass: PL_D_AllKeys (item)] autorelease];
}
- (string) keyAtIndex:(int) index
{
return PL_KeyAtIndex (item, index);
}
- addKey:(string) key value:(PLItem *) value
{
if (!value.own) {

View file

@ -10,6 +10,7 @@ plitem_t *PL_ObjectForKey (plitem_t *item, string key) = #0;
plitem_t *PL_RemoveObjectForKey (plitem_t *item, string key) = #0;
plitem_t *PL_ObjectAtIndex (plitem_t *item, int index) = #0;
plitem_t *PL_D_AllKeys (plitem_t *item) = #0;
string PL_KeyAtIndex (plitem_t *item, int index) = #0;
int PL_D_NumKeys (plitem_t *item) = #0;
int PL_D_AddObject (plitem_t *dict, string key, plitem_t *value) = #0;
int PL_A_AddObject (plitem_t *array_item, plitem_t *item) = #0;