diff --git a/libs/ruamoko/rua_plist.c b/libs/ruamoko/rua_plist.c index 36ec50b0c..f146dbb92 100644 --- a/libs/ruamoko/rua_plist.c +++ b/libs/ruamoko/rua_plist.c @@ -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)), diff --git a/ruamoko/include/PropertyList.h b/ruamoko/include/PropertyList.h index c61b16ef6..f6c059154 100644 --- a/ruamoko/include/PropertyList.h +++ b/ruamoko/include/PropertyList.h @@ -11,6 +11,7 @@ - (int) numKeys; - (PLItem *) getObjectForKey:(string) key; - (PLItem *) allKeys; +- (string) keyAtIndex:(int) index; - addKey:(string) key value:(PLItem *) value; @end diff --git a/ruamoko/include/plist.h b/ruamoko/include/plist.h index b99e1d19f..5482976fa 100644 --- a/ruamoko/include/plist.h +++ b/ruamoko/include/plist.h @@ -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); diff --git a/ruamoko/lib/PropertyList.r b/ruamoko/lib/PropertyList.r index 6197ec325..65e3b9124 100644 --- a/ruamoko/lib/PropertyList.r +++ b/ruamoko/lib/PropertyList.r @@ -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) { diff --git a/ruamoko/lib/plist.r b/ruamoko/lib/plist.r index d1c0838bc..743602888 100644 --- a/ruamoko/lib/plist.r +++ b/ruamoko/lib/plist.r @@ -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;