mirror of https://github.com/aap/librw.git
fixed more leaks
This commit is contained in:
parent
7fdb483d4e
commit
c4ffa3622a
13
src/anim.cpp
13
src/anim.cpp
|
@ -24,8 +24,6 @@ namespace rw {
|
||||||
|
|
||||||
static AnimInterpolatorInfo *interpInfoList[MAXINTERPINFO];
|
static AnimInterpolatorInfo *interpInfoList[MAXINTERPINFO];
|
||||||
|
|
||||||
// TODO MEMORY: also clean it up again
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AnimInterpolatorInfo::registerInterp(AnimInterpolatorInfo *interpInfo)
|
AnimInterpolatorInfo::registerInterp(AnimInterpolatorInfo *interpInfo)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +35,17 @@ AnimInterpolatorInfo::registerInterp(AnimInterpolatorInfo *interpInfo)
|
||||||
assert(0 && "no room for interpolatorInfo");
|
assert(0 && "no room for interpolatorInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AnimInterpolatorInfo::unregisterInterp(AnimInterpolatorInfo *interpInfo)
|
||||||
|
{
|
||||||
|
for(int32 i = 0; i < MAXINTERPINFO; i++)
|
||||||
|
if(interpInfoList[i] == interpInfo){
|
||||||
|
rwFree(interpInfoList[i]);
|
||||||
|
interpInfoList[i] = nil;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AnimInterpolatorInfo*
|
AnimInterpolatorInfo*
|
||||||
AnimInterpolatorInfo::find(int32 id)
|
AnimInterpolatorInfo::find(int32 id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace rw {
|
||||||
|
|
||||||
int32 Camera::numAllocated;
|
int32 Camera::numAllocated;
|
||||||
|
|
||||||
PluginList Camera::s_plglist = { sizeof(Camera), sizeof(Camera), nil, nil };
|
PluginList Camera::s_plglist(sizeof(Camera));
|
||||||
|
|
||||||
void
|
void
|
||||||
defaultBeginUpdateCB(Camera *cam)
|
defaultBeginUpdateCB(Camera *cam)
|
||||||
|
|
|
@ -109,10 +109,9 @@ Charset::setColors(const RGBA *foreground, const RGBA *background)
|
||||||
img->palette[7] = foreground->alpha;
|
img->palette[7] = foreground->alpha;
|
||||||
|
|
||||||
Raster *newRaster = Raster::createFromImage(img);
|
Raster *newRaster = Raster::createFromImage(img);
|
||||||
if(newRaster == nil){
|
img->destroy();
|
||||||
img->destroy();
|
if(newRaster == nil)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
|
||||||
if(this->raster)
|
if(this->raster)
|
||||||
this->raster->destroy();
|
this->raster->destroy();
|
||||||
this->raster = newRaster;
|
this->raster = newRaster;
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace rw {
|
||||||
int32 Clump::numAllocated;
|
int32 Clump::numAllocated;
|
||||||
int32 Atomic::numAllocated;
|
int32 Atomic::numAllocated;
|
||||||
|
|
||||||
PluginList Clump::s_plglist = { sizeof(Clump), sizeof(Clump), nil, nil };
|
PluginList Clump::s_plglist(sizeof(Clump));
|
||||||
PluginList Atomic::s_plglist = { sizeof(Atomic), sizeof(Atomic), nil, nil };
|
PluginList Atomic::s_plglist(sizeof(Atomic));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clump
|
// Clump
|
||||||
|
|
|
@ -1207,6 +1207,10 @@ closeD3D(void)
|
||||||
if(ref != 0)
|
if(ref != 0)
|
||||||
printf("IDirect3D9_Release did not destroy\n");
|
printf("IDirect3D9_Release did not destroy\n");
|
||||||
d3d9Globals.d3d9 = nil;
|
d3d9Globals.d3d9 = nil;
|
||||||
|
rwFree(d3d9Globals.modes);
|
||||||
|
d3d9Globals.modes = nil;
|
||||||
|
d3d9Globals.numModes = 0;
|
||||||
|
d3d9Globals.currentMode = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,7 @@ closeIm3D(void)
|
||||||
destroyVertexBuffer(im3dvertbuf);
|
destroyVertexBuffer(im3dvertbuf);
|
||||||
im3dvertbuf = nil;
|
im3dvertbuf = nil;
|
||||||
|
|
||||||
|
removeDynamicIB(&im3dindbuf);
|
||||||
destroyIndexBuffer(im3dindbuf);
|
destroyIndexBuffer(im3dindbuf);
|
||||||
im3dindbuf = nil;
|
im3dindbuf = nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include "rwbase.h"
|
#include "rwbase.h"
|
||||||
#include "rwerror.h"
|
#include "rwerror.h"
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
namespace rw {
|
namespace rw {
|
||||||
|
|
||||||
Engine *engine;
|
Engine *engine;
|
||||||
PluginList Engine::s_plglist;
|
PluginList Engine::s_plglist(sizeof(Engine));
|
||||||
Engine::State Engine::state = Dead;
|
Engine::State Engine::state = Dead;
|
||||||
MemoryFunctions Engine::memfuncs;
|
MemoryFunctions Engine::memfuncs;
|
||||||
PluginList Driver::s_plglist[NUM_PLATFORMS];
|
PluginList Driver::s_plglist[NUM_PLATFORMS];
|
||||||
|
@ -128,7 +129,7 @@ free_managed(void *p)
|
||||||
void *mustmalloc_h(size_t sz, uint32 hint)
|
void *mustmalloc_h(size_t sz, uint32 hint)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
ret = rwMalloc(sz, hint);
|
ret = Engine::memfuncs.rwmalloc(sz, hint);
|
||||||
if(ret || sz == 0)
|
if(ret || sz == 0)
|
||||||
return ret;
|
return ret;
|
||||||
fprintf(stderr, "Error: out of memory\n");
|
fprintf(stderr, "Error: out of memory\n");
|
||||||
|
@ -138,7 +139,7 @@ void *mustmalloc_h(size_t sz, uint32 hint)
|
||||||
void *mustrealloc_h(void *p, size_t sz, uint32 hint)
|
void *mustrealloc_h(void *p, size_t sz, uint32 hint)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
ret = rwRealloc(p, sz, hint);
|
ret = Engine::memfuncs.rwrealloc(p, sz, hint);
|
||||||
if(ret || sz == 0)
|
if(ret || sz == 0)
|
||||||
return ret;
|
return ret;
|
||||||
fprintf(stderr, "Error: out of memory\n");
|
fprintf(stderr, "Error: out of memory\n");
|
||||||
|
@ -174,13 +175,10 @@ Engine::init(void)
|
||||||
memfuncs.rwmustmalloc = mustmalloc_h;
|
memfuncs.rwmustmalloc = mustmalloc_h;
|
||||||
memfuncs.rwmustrealloc = mustrealloc_h;
|
memfuncs.rwmustrealloc = mustrealloc_h;
|
||||||
|
|
||||||
PluginList init = { sizeof(Driver), sizeof(Driver), nil, nil };
|
PluginList::open();
|
||||||
|
|
||||||
for(uint i = 0; i < NUM_PLATFORMS; i++)
|
for(uint i = 0; i < NUM_PLATFORMS; i++)
|
||||||
Driver::s_plglist[i] = init;
|
new (&Driver::s_plglist[i]) PluginList(sizeof(Driver));
|
||||||
Engine::s_plglist.size = sizeof(Engine);
|
|
||||||
Engine::s_plglist.defaultSize = sizeof(Engine);
|
|
||||||
Engine::s_plglist.first = nil;
|
|
||||||
Engine::s_plglist.last = nil;
|
|
||||||
|
|
||||||
// core plugin attach here
|
// core plugin attach here
|
||||||
Frame::registerModule();
|
Frame::registerModule();
|
||||||
|
@ -288,12 +286,13 @@ Engine::start(void)
|
||||||
void
|
void
|
||||||
Engine::term(void)
|
Engine::term(void)
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
if(engine || Engine::state != Initialized){
|
if(engine || Engine::state != Initialized){
|
||||||
RWERROR((ERR_GENERAL));
|
RWERROR((ERR_GENERAL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PluginList::close();
|
||||||
|
|
||||||
#ifdef TRACK_ALLOCATIONS
|
#ifdef TRACK_ALLOCATIONS
|
||||||
FORLIST(lnk, allocations){
|
FORLIST(lnk, allocations){
|
||||||
MemoryBlock *mem = LLLinkGetData(lnk, MemoryBlock, inAllocList);
|
MemoryBlock *mem = LLLinkGetData(lnk, MemoryBlock, inAllocList);
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace rw {
|
||||||
|
|
||||||
int32 Frame::numAllocated;
|
int32 Frame::numAllocated;
|
||||||
|
|
||||||
PluginList Frame::s_plglist = { sizeof(Frame), sizeof(Frame), nil, nil };
|
PluginList Frame::s_plglist(sizeof(Frame));
|
||||||
static void *frameOpen(void *object, int32 offset, int32 size) { engine->frameDirtyList.init(); return object; }
|
static void *frameOpen(void *object, int32 offset, int32 size) { engine->frameDirtyList.init(); return object; }
|
||||||
static void *frameClose(void *object, int32 offset, int32 size) { return object; }
|
static void *frameClose(void *object, int32 offset, int32 size) { return object; }
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ namespace rw {
|
||||||
int32 Geometry::numAllocated;
|
int32 Geometry::numAllocated;
|
||||||
int32 Material::numAllocated;
|
int32 Material::numAllocated;
|
||||||
|
|
||||||
PluginList Geometry::s_plglist = { sizeof(Geometry), sizeof(Geometry), nil, nil };
|
PluginList Geometry::s_plglist(sizeof(Geometry));
|
||||||
PluginList Material::s_plglist = { sizeof(Material), sizeof(Material), nil, nil };
|
PluginList Material::s_plglist(sizeof(Material));
|
||||||
|
|
||||||
static SurfaceProperties defaultSurfaceProps = { 1.0f, 1.0f, 1.0f };
|
static SurfaceProperties defaultSurfaceProps = { 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,13 @@ hanimOpen(void *object, int32 offset, int32 size)
|
||||||
AnimInterpolatorInfo::registerInterp(info);
|
AnimInterpolatorInfo::registerInterp(info);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
static void *hanimClose(void *object, int32 offset, int32 size) { return object; }
|
|
||||||
|
static void*
|
||||||
|
hanimClose(void *object, int32 offset, int32 size)
|
||||||
|
{
|
||||||
|
AnimInterpolatorInfo::unregisterInterp(AnimInterpolatorInfo::find(1));
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace rw {
|
||||||
|
|
||||||
int32 Light::numAllocated;
|
int32 Light::numAllocated;
|
||||||
|
|
||||||
PluginList Light::s_plglist = { sizeof(Light), sizeof(Light), nil, nil };
|
PluginList Light::s_plglist(sizeof(Light));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lightSync(ObjectWithFrame*)
|
lightSync(ObjectWithFrame*)
|
||||||
|
|
80
src/plg.cpp
80
src/plg.cpp
|
@ -18,25 +18,58 @@ static void *defCtor(void *object, int32, int32) { return object; }
|
||||||
static void *defDtor(void *object, int32, int32) { return object; }
|
static void *defDtor(void *object, int32, int32) { return object; }
|
||||||
static void *defCopy(void *dst, void*, int32, int32) { return dst; }
|
static void *defCopy(void *dst, void*, int32, int32) { return dst; }
|
||||||
|
|
||||||
|
static LinkList allPlugins;
|
||||||
|
|
||||||
|
#define PLG(lnk) LLLinkGetData(lnk, Plugin, inParentList)
|
||||||
|
|
||||||
|
void
|
||||||
|
PluginList::open(void)
|
||||||
|
{
|
||||||
|
allPlugins.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PluginList::close(void)
|
||||||
|
{
|
||||||
|
PluginList *l;
|
||||||
|
Plugin *p;
|
||||||
|
FORLIST(lnk, allPlugins){
|
||||||
|
p = LLLinkGetData(lnk, Plugin, inGlobalList);
|
||||||
|
l = p->parentList;
|
||||||
|
p->inParentList.remove();
|
||||||
|
p->inGlobalList.remove();
|
||||||
|
rwFree(p);
|
||||||
|
if(l->plugins.isEmpty())
|
||||||
|
l->size = l->defaultSize;
|
||||||
|
}
|
||||||
|
assert(allPlugins.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PluginList::construct(void *object)
|
PluginList::construct(void *object)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
p->constructor(object, p->offset, p->size);
|
p->constructor(object, p->offset, p->size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PluginList::destruct(void *object)
|
PluginList::destruct(void *object)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
p->destructor(object, p->offset, p->size);
|
p->destructor(object, p->offset, p->size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PluginList::copy(void *dst, void *src)
|
PluginList::copy(void *dst, void *src)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
p->copy(dst, src, p->offset, p->size);
|
p->copy(dst, src, p->offset, p->size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -50,12 +83,14 @@ PluginList::streamRead(Stream *stream, void *object)
|
||||||
if(!readChunkHeaderInfo(stream, &header))
|
if(!readChunkHeaderInfo(stream, &header))
|
||||||
return false;
|
return false;
|
||||||
length -= 12;
|
length -= 12;
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->id == header.type && p->read){
|
if(p->id == header.type && p->read){
|
||||||
p->read(stream, header.length,
|
p->read(stream, header.length,
|
||||||
object, p->offset, p->size);
|
object, p->offset, p->size);
|
||||||
goto cont;
|
goto cont;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
stream->seek(header.length);
|
stream->seek(header.length);
|
||||||
cont:
|
cont:
|
||||||
length -= header.length;
|
length -= header.length;
|
||||||
|
@ -68,7 +103,8 @@ PluginList::streamWrite(Stream *stream, void *object)
|
||||||
{
|
{
|
||||||
int size = this->streamGetSize(object);
|
int size = this->streamGetSize(object);
|
||||||
writeChunkHeader(stream, ID_EXTENSION, size);
|
writeChunkHeader(stream, ID_EXTENSION, size);
|
||||||
for(Plugin *p = this->first; p; p = p->next){
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->getSize == nil ||
|
if(p->getSize == nil ||
|
||||||
(size = p->getSize(object, p->offset, p->size)) <= 0)
|
(size = p->getSize(object, p->offset, p->size)) <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -82,10 +118,12 @@ PluginList::streamGetSize(void *object)
|
||||||
{
|
{
|
||||||
int32 size = 0;
|
int32 size = 0;
|
||||||
int32 plgsize;
|
int32 plgsize;
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->getSize &&
|
if(p->getSize &&
|
||||||
(plgsize = p->getSize(object, p->offset, p->size)) > 0)
|
(plgsize = p->getSize(object, p->offset, p->size)) > 0)
|
||||||
size += 12 + plgsize;
|
size += 12 + plgsize;
|
||||||
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,13 +145,15 @@ PluginList::streamSkip(Stream *stream)
|
||||||
void
|
void
|
||||||
PluginList::assertRights(void *object, uint32 pluginID, uint32 data)
|
PluginList::assertRights(void *object, uint32 pluginID, uint32 data)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->id == pluginID){
|
if(p->id == pluginID){
|
||||||
if(p->rightsCallback)
|
if(p->rightsCallback)
|
||||||
p->rightsCallback(object,
|
p->rightsCallback(object,
|
||||||
p->offset, p->size, data);
|
p->offset, p->size, data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,17 +176,9 @@ PluginList::registerPlugin(int32 size, uint32 id,
|
||||||
p->write = nil;
|
p->write = nil;
|
||||||
p->getSize = nil;
|
p->getSize = nil;
|
||||||
p->rightsCallback = nil;
|
p->rightsCallback = nil;
|
||||||
p->next = nil;
|
p->parentList = this;
|
||||||
p->prev = nil;
|
this->plugins.add(&p->inParentList);
|
||||||
|
allPlugins.add(&p->inGlobalList);
|
||||||
if(this->first == nil){
|
|
||||||
this->first = p;
|
|
||||||
this->last = p;
|
|
||||||
}else{
|
|
||||||
this->last->next = p;
|
|
||||||
p->prev = this->last;
|
|
||||||
this->last = p;
|
|
||||||
}
|
|
||||||
return p->offset;
|
return p->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,33 +186,39 @@ int32
|
||||||
PluginList::registerStream(uint32 id,
|
PluginList::registerStream(uint32 id,
|
||||||
StreamRead read, StreamWrite write, StreamGetSize getSize)
|
StreamRead read, StreamWrite write, StreamGetSize getSize)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->id == id){
|
if(p->id == id){
|
||||||
p->read = read;
|
p->read = read;
|
||||||
p->write = write;
|
p->write = write;
|
||||||
p->getSize = getSize;
|
p->getSize = getSize;
|
||||||
return p->offset;
|
return p->offset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
PluginList::setStreamRightsCallback(uint32 id, RightsCallback cb)
|
PluginList::setStreamRightsCallback(uint32 id, RightsCallback cb)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->id == id){
|
if(p->id == id){
|
||||||
p->rightsCallback = cb;
|
p->rightsCallback = cb;
|
||||||
return p->offset;
|
return p->offset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32
|
int32
|
||||||
PluginList::getPluginOffset(uint32 id)
|
PluginList::getPluginOffset(uint32 id)
|
||||||
{
|
{
|
||||||
for(Plugin *p = this->first; p; p = p->next)
|
FORLIST(lnk, this->plugins){
|
||||||
|
Plugin *p = PLG(lnk);
|
||||||
if(p->id == id)
|
if(p->id == id)
|
||||||
return p->offset;
|
return p->offset;
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ struct AnimInterpolatorInfo
|
||||||
uint32 (*streamGetSize)(Animation *anim);
|
uint32 (*streamGetSize)(Animation *anim);
|
||||||
|
|
||||||
static void registerInterp(AnimInterpolatorInfo *interpInfo);
|
static void registerInterp(AnimInterpolatorInfo *interpInfo);
|
||||||
|
static void unregisterInterp(AnimInterpolatorInfo *interpInfo);
|
||||||
static AnimInterpolatorInfo *find(int32 id);
|
static AnimInterpolatorInfo *find(int32 id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
44
src/rwplg.h
44
src/rwplg.h
|
@ -11,28 +11,19 @@ typedef Stream *(*StreamWrite)(Stream *stream, int32 length, void *object, int32
|
||||||
typedef int32 (*StreamGetSize)(void *object, int32 offset, int32 size);
|
typedef int32 (*StreamGetSize)(void *object, int32 offset, int32 size);
|
||||||
typedef void (*RightsCallback)(void *object, int32 offset, int32 size, uint32 data);
|
typedef void (*RightsCallback)(void *object, int32 offset, int32 size, uint32 data);
|
||||||
|
|
||||||
struct Plugin
|
|
||||||
{
|
|
||||||
int32 offset;
|
|
||||||
int32 size;
|
|
||||||
uint32 id;
|
|
||||||
Constructor constructor;
|
|
||||||
Destructor destructor;
|
|
||||||
CopyConstructor copy;
|
|
||||||
StreamRead read;
|
|
||||||
StreamWrite write;
|
|
||||||
StreamGetSize getSize;
|
|
||||||
RightsCallback rightsCallback;
|
|
||||||
Plugin *next;
|
|
||||||
Plugin *prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PluginList
|
struct PluginList
|
||||||
{
|
{
|
||||||
int32 size;
|
int32 size;
|
||||||
int32 defaultSize;
|
int32 defaultSize;
|
||||||
Plugin *first;
|
LinkList plugins;
|
||||||
Plugin *last;
|
|
||||||
|
PluginList(void) {}
|
||||||
|
PluginList(int32 defSize)
|
||||||
|
: size(defSize), defaultSize(defSize)
|
||||||
|
{ plugins.init(); }
|
||||||
|
|
||||||
|
static void open(void);
|
||||||
|
static void close(void);
|
||||||
|
|
||||||
void construct(void *);
|
void construct(void *);
|
||||||
void destruct(void *);
|
void destruct(void *);
|
||||||
|
@ -50,6 +41,23 @@ struct PluginList
|
||||||
int32 getPluginOffset(uint32 id);
|
int32 getPluginOffset(uint32 id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Plugin
|
||||||
|
{
|
||||||
|
int32 offset;
|
||||||
|
int32 size;
|
||||||
|
uint32 id;
|
||||||
|
Constructor constructor;
|
||||||
|
Destructor destructor;
|
||||||
|
CopyConstructor copy;
|
||||||
|
StreamRead read;
|
||||||
|
StreamWrite write;
|
||||||
|
StreamGetSize getSize;
|
||||||
|
RightsCallback rightsCallback;
|
||||||
|
PluginList *parentList;
|
||||||
|
LLLink inParentList;
|
||||||
|
LLLink inGlobalList;
|
||||||
|
};
|
||||||
|
|
||||||
#define PLUGINBASE \
|
#define PLUGINBASE \
|
||||||
static PluginList s_plglist; \
|
static PluginList s_plglist; \
|
||||||
static int32 registerPlugin(int32 size, uint32 id, Constructor ctor, \
|
static int32 registerPlugin(int32 size, uint32 id, Constructor ctor, \
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace rw {
|
||||||
int32 Texture::numAllocated;
|
int32 Texture::numAllocated;
|
||||||
int32 TexDictionary::numAllocated;
|
int32 TexDictionary::numAllocated;
|
||||||
|
|
||||||
PluginList TexDictionary::s_plglist = { sizeof(TexDictionary), sizeof(TexDictionary), nil, nil };
|
PluginList TexDictionary::s_plglist(sizeof(TexDictionary));
|
||||||
PluginList Texture::s_plglist = { sizeof(Texture), sizeof(Texture), nil, nil };
|
PluginList Texture::s_plglist(sizeof(Texture));
|
||||||
PluginList Raster::s_plglist = { sizeof(Raster), sizeof(Raster), nil, nil };
|
PluginList Raster::s_plglist(sizeof(Raster));
|
||||||
|
|
||||||
struct TextureGlobals
|
struct TextureGlobals
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace rw {
|
||||||
|
|
||||||
int32 World::numAllocated = 0;
|
int32 World::numAllocated = 0;
|
||||||
|
|
||||||
PluginList World::s_plglist = { sizeof(World), sizeof(World), nil, nil };
|
PluginList World::s_plglist(sizeof(World));
|
||||||
|
|
||||||
World*
|
World*
|
||||||
World::create(void)
|
World::create(void)
|
||||||
|
|
Loading…
Reference in New Issue