Refactored the ResourceIndex type to fit UQM's standard for opaque types
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2967 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -25,7 +25,9 @@
|
||||
#include "misc.h"
|
||||
#include "libs/uio.h"
|
||||
|
||||
typedef struct resource_index *RESOURCE_INDEX;
|
||||
typedef struct resource_index_desc RESOURCE_INDEX_DESC;
|
||||
typedef RESOURCE_INDEX_DESC *RESOURCE_INDEX;
|
||||
|
||||
typedef const char *RESOURCE;
|
||||
|
||||
typedef enum
|
||||
|
||||
@@ -28,12 +28,12 @@ const char *_cur_resfile_name;
|
||||
// At other times, it is NULL.
|
||||
|
||||
static ResourceDesc *
|
||||
lookupResourceDesc (ResourceIndex *idx, RESOURCE res) {
|
||||
lookupResourceDesc (RESOURCE_INDEX idx, RESOURCE res) {
|
||||
return (ResourceDesc *) CharHashTable_find (idx->map, res);
|
||||
}
|
||||
|
||||
void *
|
||||
loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc)
|
||||
loadResourceDesc (RESOURCE_INDEX idx, ResourceDesc *desc)
|
||||
{
|
||||
desc->resdata = loadResource (desc->fname,
|
||||
idx->typeInfo.handlers[desc->restype].loadFun);
|
||||
@@ -79,7 +79,7 @@ err:
|
||||
void *
|
||||
res_GetResource (RESOURCE res)
|
||||
{
|
||||
ResourceIndex *resourceIndex;
|
||||
RESOURCE_INDEX resourceIndex;
|
||||
ResourceDesc *desc;
|
||||
|
||||
if (res == NULL_RESOURCE)
|
||||
@@ -113,7 +113,7 @@ res_FreeResource (RESOURCE res)
|
||||
{
|
||||
ResourceDesc *desc;
|
||||
ResourceFreeFun *freeFun;
|
||||
ResourceIndex *idx;
|
||||
RESOURCE_INDEX idx;
|
||||
|
||||
desc = lookupResourceDesc (_get_current_index_header(), res);
|
||||
if (desc == NULL)
|
||||
|
||||
@@ -46,15 +46,12 @@ typedef struct
|
||||
ResourceHandlers *handlers;
|
||||
} ResourceTypeInfo;
|
||||
|
||||
struct resource_index
|
||||
struct resource_index_desc
|
||||
{
|
||||
CharHashTable_HashTable *map;
|
||||
ResourceTypeInfo typeInfo;
|
||||
size_t numRes;
|
||||
};
|
||||
|
||||
/* XXX: This should almost certainly be folded into RESOURCE_INDEX wherever possible */
|
||||
typedef struct resource_index ResourceIndex;
|
||||
|
||||
#endif /* _INDEX_H */
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
#include "resintrn.h"
|
||||
|
||||
static ResourceIndex *curResourceIndex;
|
||||
static RESOURCE_INDEX curResourceIndex;
|
||||
|
||||
void
|
||||
_set_current_index_header (ResourceIndex *newResourceIndex)
|
||||
_set_current_index_header (RESOURCE_INDEX newResourceIndex)
|
||||
{
|
||||
curResourceIndex = newResourceIndex;
|
||||
}
|
||||
|
||||
ResourceIndex *
|
||||
RESOURCE_INDEX
|
||||
_get_current_index_header (void)
|
||||
{
|
||||
return curResourceIndex;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
static RESOURCE_INDEX
|
||||
allocResourceIndex (void) {
|
||||
RESOURCE_INDEX ndx = HMalloc (sizeof (struct resource_index));
|
||||
RESOURCE_INDEX ndx = HMalloc (sizeof (RESOURCE_INDEX_DESC));
|
||||
ndx->typeInfo.numTypes = 0;
|
||||
ndx->typeInfo.handlers = NULL;
|
||||
ndx->map = CharHashTable_newHashTable (NULL, NULL, NULL, NULL, 0, 0.85, 0.9);
|
||||
@@ -69,7 +69,7 @@ newResourceDesc (const char *res_id, const char *resval)
|
||||
int pathlen;
|
||||
RES_TYPE resType;
|
||||
ResourceDesc *result;
|
||||
ResourceIndex *idx = _get_current_index_header ();
|
||||
RESOURCE_INDEX idx = _get_current_index_header ();
|
||||
|
||||
path = strchr (resval, ':');
|
||||
if (path == NULL)
|
||||
@@ -164,7 +164,7 @@ process_resource_desc (const char *key, const char *value)
|
||||
RESOURCE_INDEX
|
||||
InitResourceSystem (void)
|
||||
{
|
||||
ResourceIndex *ndx = allocResourceIndex ();
|
||||
RESOURCE_INDEX ndx = allocResourceIndex ();
|
||||
|
||||
_set_current_index_header (ndx);
|
||||
|
||||
@@ -191,7 +191,7 @@ InstallResTypeVectors (RES_TYPE resType, ResourceLoadFun *loadFun,
|
||||
ResourceFreeFun *freeFun)
|
||||
{
|
||||
ResourceHandlers handlers;
|
||||
ResourceIndex *idx = _get_current_index_header ();
|
||||
RESOURCE_INDEX idx = _get_current_index_header ();
|
||||
handlers.loadFun = loadFun;
|
||||
handlers.freeFun = freeFun;
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
#include "reslib.h"
|
||||
#include "index.h"
|
||||
|
||||
void *loadResourceDesc (ResourceIndex *idx, ResourceDesc *desc);
|
||||
void *loadResourceDesc (RESOURCE_INDEX idx, ResourceDesc *desc);
|
||||
void *loadResource(const char *path, ResourceLoadFun *loadFun);
|
||||
|
||||
void _set_current_index_header (ResourceIndex *newResourceIndex);
|
||||
ResourceIndex *_get_current_index_header (void);
|
||||
void _set_current_index_header (RESOURCE_INDEX newResourceIndex);
|
||||
RESOURCE_INDEX _get_current_index_header (void);
|
||||
|
||||
|
||||
#endif /* _RESINTRN_H */
|
||||
|
||||
Reference in New Issue
Block a user