mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
wrap the plist functions
This is an imperfect revision of history.
This commit is contained in:
parent
634dcbba95
commit
53f4d13f43
3 changed files with 80 additions and 13 deletions
|
@ -55,6 +55,7 @@ typedef struct {
|
|||
static inline void
|
||||
return_plitem (progs_t *pr, plitem_t *plitem)
|
||||
{
|
||||
memset (&R_INT (pr), 0, 8);
|
||||
memcpy (&R_INT (pr), &plitem, sizeof (plitem));
|
||||
}
|
||||
|
||||
|
@ -92,6 +93,27 @@ bi_PL_GetPropertyList (progs_t *pr)
|
|||
return_plitem (pr, record_plitem (pr, plitem));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_WritePropertyList (progs_t *pr)
|
||||
{
|
||||
char *pl = PL_WritePropertyList (p_plitem (pr, 0));
|
||||
R_STRING (pr) = PR_SetDynamicString (pr, pl);
|
||||
free (pl);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_Type (progs_t *pr)
|
||||
{
|
||||
R_INT (pr) = PL_Type (p_plitem (pr, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_String (progs_t *pr)
|
||||
{
|
||||
const char *str = PL_String (p_plitem (pr, 0));
|
||||
RETURN_STRING (pr, str);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_ObjectForKey (progs_t *pr)
|
||||
{
|
||||
|
@ -104,6 +126,18 @@ bi_PL_ObjectAtIndex (progs_t *pr)
|
|||
return_plitem (pr, PL_ObjectAtIndex (p_plitem (pr, 0), P_INT (pr, 1)));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_D_AllKeys (progs_t *pr)
|
||||
{
|
||||
return_plitem (pr, PL_D_AllKeys (p_plitem (pr, 0)));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_D_NumKeys (progs_t *pr)
|
||||
{
|
||||
R_INT (pr) = PL_D_NumKeys (p_plitem (pr, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_D_AddObject (progs_t *pr)
|
||||
{
|
||||
|
@ -119,6 +153,12 @@ bi_PL_A_AddObject (progs_t *pr)
|
|||
remove_plitem (pr, p_plitem (pr, 1)));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_A_NumObjects (progs_t *pr)
|
||||
{
|
||||
R_INT (pr) = PL_A_NumObjects (p_plitem (pr, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_A_InsertObjectAtIndex (progs_t *pr)
|
||||
{
|
||||
|
@ -128,9 +168,9 @@ bi_PL_A_InsertObjectAtIndex (progs_t *pr)
|
|||
}
|
||||
|
||||
static void
|
||||
bi_PL_NewDictionary (progs_t *pr)
|
||||
bi_PL_Free (progs_t *pr)
|
||||
{
|
||||
return_plitem (pr, record_plitem (pr, PL_NewDictionary ()));
|
||||
PL_Free (remove_plitem (pr, p_plitem (pr, 0)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -138,18 +178,26 @@ bi_PL_NewArray (progs_t *pr)
|
|||
{
|
||||
return_plitem (pr, record_plitem (pr, PL_NewArray ()));
|
||||
}
|
||||
/*
|
||||
|
||||
static void
|
||||
bi_PL_NewData (progs_t *pr)
|
||||
{
|
||||
return_plitem (pr, record_plitem (pr, PL_NewData (P_GPOINTER (pr, 0),
|
||||
P_INT (pr, 1))));
|
||||
}
|
||||
*/
|
||||
|
||||
static void
|
||||
bi_PL_NewString (progs_t *pr)
|
||||
{
|
||||
return_plitem (pr, record_plitem (pr, PL_NewString (P_GSTRING (pr, 0))));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_PL_NewDictionary (progs_t *pr)
|
||||
{
|
||||
return_plitem (pr, record_plitem (pr, PL_NewDictionary ()));
|
||||
}
|
||||
|
||||
static void
|
||||
bi_plist_clear (progs_t *pr, void *data)
|
||||
{
|
||||
|
@ -172,22 +220,29 @@ plist_compare (void *k1, void *k2, void *unused)
|
|||
|
||||
static builtin_t builtins[] = {
|
||||
{"PL_GetPropertyList", bi_PL_GetPropertyList, -1},
|
||||
{"PL_WritePropertyList", bi_PL_WritePropertyList, -1},
|
||||
{"PL_Type", bi_PL_Type, -1},
|
||||
{"PL_String", bi_PL_String, -1},
|
||||
{"PL_ObjectForKey", bi_PL_ObjectForKey, -1},
|
||||
{"PL_ObjectAtIndex", bi_PL_ObjectAtIndex, -1},
|
||||
{"PL_D_AllKeys", bi_PL_D_AllKeys, -1},
|
||||
{"PL_D_NumKeys", bi_PL_D_NumKeys, -1},
|
||||
{"PL_D_AddObject", bi_PL_D_AddObject, -1},
|
||||
{"PL_A_AddObject", bi_PL_A_AddObject, -1},
|
||||
{"PL_A_NumObjects", bi_PL_A_NumObjects, -1},
|
||||
{"PL_A_InsertObjectAtIndex", bi_PL_A_InsertObjectAtIndex, -1},
|
||||
{"PL_NewDictionary", bi_PL_NewDictionary, -1},
|
||||
{"PL_NewArray", bi_PL_NewArray, -1},
|
||||
// {"PL_NewData", bi_PL_NewData, -1},
|
||||
{"PL_NewData", bi_PL_NewData, -1},
|
||||
{"PL_NewString", bi_PL_NewString, -1},
|
||||
{"PL_Free", bi_PL_Free, -1},
|
||||
{0}
|
||||
};
|
||||
|
||||
void
|
||||
RUA_Plist_Init (progs_t *pr, int secure)
|
||||
{
|
||||
plist_resources_t *res = malloc (sizeof (plist_resources_t));
|
||||
plist_resources_t *res = calloc (1, sizeof (plist_resources_t));
|
||||
res->items = Hash_NewTable (1021, 0, 0, 0);
|
||||
Hash_SetHashCompare (res->items, plist_get_hash, plist_compare);
|
||||
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
#ifndef __ruamoko_plist_h
|
||||
#define __ruamoko_plist_h
|
||||
|
||||
struct plitem_s = {integer [2] dummy;};
|
||||
struct plitem_s {integer [2] dummy;};
|
||||
#define PL_TEST(item) (item.dummy[0] || item.dummy[1])
|
||||
typedef struct plitem_s plitem_t;
|
||||
typedef enum {QFDictionary, QFArray, QFBinary, QFString} pltype_t; // possible types
|
||||
|
||||
@extern plitem_t (string str) PL_GetPropertyList;
|
||||
@extern string (plitem_t pl) PL_WritePropertyList;
|
||||
@extern pltype_t (plitem_t str) PL_Type;
|
||||
@extern string (plitem_t str) PL_String;
|
||||
@extern plitem_t (plitem_t item, string key) PL_ObjectForKey;
|
||||
@extern plitem_t (plitem_t item, integer index) PL_ObjectAtIndex;
|
||||
|
||||
@extern plitem_t (plitem_t item) PL_D_AllKeys;
|
||||
@extern integer (plitem_t item) PL_D_NumKeys;
|
||||
@extern integer (plitem_t dict, plitem_t key, plitem_t value) PL_D_AddObject;
|
||||
@extern integer (plitem_t array_item, plitem_t item) PL_A_AddObject;
|
||||
@extern integer (plitem_t item) PL_A_NumObjects;
|
||||
@extern integer (plitem_t array_item, plitem_t item, integer index) PL_A_InsertObjectAtIndex;
|
||||
|
||||
@extern plitem_t () PL_NewDictionary;
|
||||
@extern plitem_t () PL_NewArray;
|
||||
//@extern plitem_t () PL_NewData;
|
||||
@extern plitem_t (void []data, integer len) PL_NewData;
|
||||
@extern plitem_t (string str) PL_NewString;
|
||||
@extern void (plitem_t pl) PL_Free;
|
||||
|
||||
#endif//__ruamoko_plist_h
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
#include "plist.h"
|
||||
|
||||
plitem_t (string str) PL_GetPropertyList = #0;
|
||||
string (plitem_t pl) PL_WritePropertyList = #0;
|
||||
pltype_t (plitem_t str) PL_Type = #0;
|
||||
string (plitem_t str) PL_String = #0;
|
||||
plitem_t (plitem_t item, string key) PL_ObjectForKey = #0;
|
||||
plitem_t (plitem_t item, integer index) PL_ObjectAtIndex = #0;
|
||||
|
||||
plitem_t (plitem_t item) PL_D_AllKeys = #0;
|
||||
integer (plitem_t item) PL_D_NumKeys = #0;
|
||||
integer (plitem_t dict, plitem_t key, plitem_t value) PL_D_AddObject = #0;
|
||||
integer (plitem_t array_item, plitem_t item) PL_A_AddObject = #0;
|
||||
integer (plitem_t item) PL_A_NumObjects = #0;
|
||||
integer (plitem_t array_item, plitem_t item, integer index) PL_A_InsertObjectAtIndex = #0;
|
||||
|
||||
plitem_t () PL_NewDictionary = #0;
|
||||
plitem_t () PL_NewArray = #0;
|
||||
//plitem_t () PL_NewData = #0;
|
||||
plitem_t (void []data, integer len) PL_NewData = #0;
|
||||
plitem_t (string str) PL_NewString = #0;
|
||||
void (plitem_t pl) PL_Free = #0;
|
||||
|
|
Loading…
Reference in a new issue