Fix memory error with reflection
This commit is contained in:
@@ -23,7 +23,7 @@ namespace B3D
|
|||||||
Reflection::ReflectionProperty<Enum::Shape::Value> shape;
|
Reflection::ReflectionProperty<Enum::Shape::Value> shape;
|
||||||
//OnTouch
|
//OnTouch
|
||||||
Reflection::ReflectionProperty<Enum::ActionType::Value> onTouchAction;
|
Reflection::ReflectionProperty<Enum::ActionType::Value> onTouchAction;
|
||||||
Reflection::ReflectionProperty<Enum::Sound::Value> OnTouchSound;
|
Reflection::ReflectionProperty<Enum::Sound::Value> onTouchSound;
|
||||||
|
|
||||||
//Non-Reflective Variables
|
//Non-Reflective Variables
|
||||||
dBodyID physBody;
|
dBodyID physBody;
|
||||||
|
|||||||
@@ -2,16 +2,22 @@
|
|||||||
|
|
||||||
namespace Enum
|
namespace Enum
|
||||||
{
|
{
|
||||||
|
struct EnumMeta {
|
||||||
|
int maxLength;
|
||||||
|
const char ** nameValues;
|
||||||
|
};
|
||||||
namespace SurfaceType
|
namespace SurfaceType
|
||||||
{
|
{
|
||||||
static const char* STR_TABLE[] = {
|
static const char* STR_TABLE[] = {
|
||||||
"Smooth", "Bumps", "Hinge",
|
"Smooth", "Bumps", "Hinge",
|
||||||
"Motor", "StepperMotor", "Spawn"
|
"Motor", "StepperMotor", "Spawn"
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Value {
|
enum Value {
|
||||||
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5, LENGTH = 6
|
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5, LENGTH = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumMeta ENUM_META = {LENGTH, STR_TABLE};
|
||||||
}
|
}
|
||||||
namespace Shape
|
namespace Shape
|
||||||
{
|
{
|
||||||
@@ -21,6 +27,8 @@ namespace Enum
|
|||||||
enum Value {
|
enum Value {
|
||||||
Ball = 0, Block = 1, Cylinder = 2, LENGTH = 3
|
Ball = 0, Block = 1, Cylinder = 2, LENGTH = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumMeta ENUM_META = {LENGTH, STR_TABLE};
|
||||||
}
|
}
|
||||||
namespace Controller
|
namespace Controller
|
||||||
{
|
{
|
||||||
@@ -31,6 +39,8 @@ namespace Enum
|
|||||||
enum Value {
|
enum Value {
|
||||||
None = 0, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, LENGTH=7
|
None = 0, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, LENGTH=7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumMeta ENUM_META = {LENGTH, STR_TABLE};
|
||||||
}
|
}
|
||||||
namespace ActionType
|
namespace ActionType
|
||||||
{
|
{
|
||||||
@@ -40,6 +50,8 @@ namespace Enum
|
|||||||
enum Value {
|
enum Value {
|
||||||
Nothing = 0, Pause = 1, Lose = 2, Draw = 3, Win = 4, LENGTH = 5
|
Nothing = 0, Pause = 1, Lose = 2, Draw = 3, Win = 4, LENGTH = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumMeta ENUM_META = {LENGTH, STR_TABLE};
|
||||||
}
|
}
|
||||||
namespace AffectType
|
namespace AffectType
|
||||||
{
|
{
|
||||||
@@ -49,6 +61,8 @@ namespace Enum
|
|||||||
enum Value {
|
enum Value {
|
||||||
NoChange = 0, Increase = 1, Decrease = 2, LENGTH = 3
|
NoChange = 0, Increase = 1, Decrease = 2, LENGTH = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumMeta ENUM_META = {LENGTH, STR_TABLE};
|
||||||
}
|
}
|
||||||
namespace Sound
|
namespace Sound
|
||||||
{
|
{
|
||||||
@@ -63,5 +77,7 @@ namespace Enum
|
|||||||
Snap = 8, Page = 9, Click = 10, Clock = 11, Step = 12, StepOn = 13,
|
Snap = 8, Page = 9, Click = 10, Clock = 11, Step = 12, StepOn = 13,
|
||||||
LENGTH = 14
|
LENGTH = 14
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const EnumMeta ENUM_META = {LENGTH, STR_TABLE};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,17 +5,6 @@
|
|||||||
namespace B3D{
|
namespace B3D{
|
||||||
namespace Reflection{
|
namespace Reflection{
|
||||||
//I do not like this... Structs?
|
//I do not like this... Structs?
|
||||||
class EnumMeta {
|
|
||||||
public:
|
|
||||||
EnumMeta(int maxLength, const char ** nameValues)
|
|
||||||
{
|
|
||||||
this->maxLength = maxLength;
|
|
||||||
this->nameValues = nameValues;
|
|
||||||
}
|
|
||||||
int maxLength;
|
|
||||||
const char ** nameValues;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ReflectionType {
|
enum ReflectionType {
|
||||||
TYPE_INT,
|
TYPE_INT,
|
||||||
TYPE_FLOAT,
|
TYPE_FLOAT,
|
||||||
@@ -26,6 +15,7 @@ namespace B3D{
|
|||||||
TYPE_CFRAME,
|
TYPE_CFRAME,
|
||||||
TYPE_BOOLEAN,
|
TYPE_BOOLEAN,
|
||||||
TYPE_ENUM,
|
TYPE_ENUM,
|
||||||
|
TYPE_INVALID,
|
||||||
LENGTH
|
LENGTH
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ namespace B3D{
|
|||||||
|
|
||||||
void setValue(T);
|
void setValue(T);
|
||||||
void setValueNotify(T);
|
void setValueNotify(T);
|
||||||
void dispose();
|
|
||||||
|
|
||||||
//Too many
|
//Too many
|
||||||
#include "ReflectionProperty_op_overload.h"
|
#include "ReflectionProperty_op_overload.h"
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
using namespace B3D::Reflection;
|
using namespace B3D::Reflection;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
ReflectionProperty<T>::ReflectionProperty(void) {
|
||||||
|
this->key = "";
|
||||||
|
this->value = T();
|
||||||
|
this->type = TYPE_INVALID;
|
||||||
|
this->containerTable = NULL;
|
||||||
|
this->locked = false;
|
||||||
|
this->archivable = true;
|
||||||
|
this->propertyHidden = false;
|
||||||
|
this->extData = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
ReflectionProperty<T>::ReflectionProperty(std::string key, T * value, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false)
|
ReflectionProperty<T>::ReflectionProperty(std::string key, T * value, ReflectionType type, ReflectionDataTable * containerTable, void* extData = NULL, bool archivable = true, bool locked = false, bool propertyHidden = false)
|
||||||
{
|
{
|
||||||
@@ -28,15 +40,9 @@ ReflectionProperty<T>::ReflectionProperty(std::string key, T value, ReflectionTy
|
|||||||
containerTable->mapProperty(key, (ReflectionProperty<void*>*)this);
|
containerTable->mapProperty(key, (ReflectionProperty<void*>*)this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
ReflectionProperty<T>::ReflectionProperty(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
ReflectionProperty<T>::~ReflectionProperty(void)
|
ReflectionProperty<T>::~ReflectionProperty(void)
|
||||||
{
|
{
|
||||||
dispose();
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
template<class T>
|
template<class T>
|
||||||
@@ -59,18 +65,6 @@ void ReflectionProperty<T>::setProperty(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
template<class T>
|
|
||||||
void ReflectionProperty<T>::dispose()
|
|
||||||
{
|
|
||||||
//delete value;
|
|
||||||
//value = NULL;
|
|
||||||
if(extData)
|
|
||||||
{
|
|
||||||
//TODO why???
|
|
||||||
//delete extData;
|
|
||||||
extData = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T ReflectionProperty<T>::getValueClone()
|
T ReflectionProperty<T>::getValueClone()
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ LevelInstance::LevelInstance(void) : Instance("LevelService")
|
|||||||
highScoreIsGood = Reflection::ReflectionProperty<bool>("HighScoreIsGood", false, TYPE_BOOLEAN, this->dataTable);
|
highScoreIsGood = Reflection::ReflectionProperty<bool>("HighScoreIsGood", false, TYPE_BOOLEAN, this->dataTable);
|
||||||
runOnOpen = Reflection::ReflectionProperty<bool>("RunOnOpen", false, TYPE_BOOLEAN, this->dataTable);
|
runOnOpen = Reflection::ReflectionProperty<bool>("RunOnOpen", false, TYPE_BOOLEAN, this->dataTable);
|
||||||
timerUpAction = Reflection::ReflectionProperty<Enum::ActionType::Value>("TimerUpAction", Enum::ActionType::Nothing, TYPE_ENUM, this->dataTable,
|
timerUpAction = Reflection::ReflectionProperty<Enum::ActionType::Value>("TimerUpAction", Enum::ActionType::Nothing, TYPE_ENUM, this->dataTable,
|
||||||
new EnumMeta(Enum::ActionType::LENGTH, Enum::ActionType::STR_TABLE));
|
(void*)&Enum::ActionType::ENUM_META);
|
||||||
timerAffectsScore = Reflection::ReflectionProperty<Enum::AffectType::Value>("TimerAffectsScore", Enum::AffectType::NoChange, TYPE_ENUM, this->dataTable,
|
timerAffectsScore = Reflection::ReflectionProperty<Enum::AffectType::Value>("TimerAffectsScore", Enum::AffectType::NoChange, TYPE_ENUM, this->dataTable,
|
||||||
new EnumMeta(Enum::AffectType::LENGTH, Enum::AffectType::STR_TABLE));
|
(void*)&Enum::AffectType::ENUM_META);
|
||||||
|
|
||||||
canDelete = false;
|
canDelete = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ PVInstance::PVInstance(std::string className) : Instance(className)
|
|||||||
nameShown = Reflection::ReflectionProperty<bool>("NameShown", false, TYPE_BOOLEAN, this->dataTable);
|
nameShown = Reflection::ReflectionProperty<bool>("NameShown", false, TYPE_BOOLEAN, this->dataTable);
|
||||||
controllerFlagShown = Reflection::ReflectionProperty<bool>("ControllerFlagShown", true, TYPE_BOOLEAN, this->dataTable);
|
controllerFlagShown = Reflection::ReflectionProperty<bool>("ControllerFlagShown", true, TYPE_BOOLEAN, this->dataTable);
|
||||||
controller = Reflection::ReflectionProperty<Enum::Controller::Value>("Controller", Enum::Controller::None, TYPE_ENUM, this->dataTable,
|
controller = Reflection::ReflectionProperty<Enum::Controller::Value>("Controller", Enum::Controller::None, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::Controller::LENGTH, Enum::Controller::STR_TABLE));
|
(void*)&Enum::Controller::ENUM_META);
|
||||||
cFrame = Reflection::ReflectionProperty<CoordinateFrame>("CFrame", CoordinateFrame(), TYPE_CFRAME, this->dataTable);
|
cFrame = Reflection::ReflectionProperty<CoordinateFrame>("CFrame", CoordinateFrame(), TYPE_CFRAME, this->dataTable);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ PVInstance::PVInstance(void) : Instance("PVInstance")
|
|||||||
nameShown = Reflection::ReflectionProperty<bool>("NameShown", false, TYPE_BOOLEAN, this->dataTable);
|
nameShown = Reflection::ReflectionProperty<bool>("NameShown", false, TYPE_BOOLEAN, this->dataTable);
|
||||||
controllerFlagShown = Reflection::ReflectionProperty<bool>("ControllerFlagShown", true, TYPE_BOOLEAN, this->dataTable);
|
controllerFlagShown = Reflection::ReflectionProperty<bool>("ControllerFlagShown", true, TYPE_BOOLEAN, this->dataTable);
|
||||||
controller = Reflection::ReflectionProperty<Enum::Controller::Value>("Controller", Enum::Controller::None, TYPE_ENUM, this->dataTable,
|
controller = Reflection::ReflectionProperty<Enum::Controller::Value>("Controller", Enum::Controller::None, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::Controller::LENGTH, Enum::Controller::STR_TABLE));
|
(void*)&Enum::Controller::ENUM_META);
|
||||||
cFrame = Reflection::ReflectionProperty<CoordinateFrame>("CFrame", CoordinateFrame(), TYPE_CFRAME, this->dataTable);
|
cFrame = Reflection::ReflectionProperty<CoordinateFrame>("CFrame", CoordinateFrame(), TYPE_CFRAME, this->dataTable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,19 +24,19 @@ PartInstance::PartInstance(void) : PVInstance("Part")
|
|||||||
velocity = ReflectionProperty<Vector3>("Velocity", Vector3(0,0,0), TYPE_VECTOR3, this->dataTable);
|
velocity = ReflectionProperty<Vector3>("Velocity", Vector3(0,0,0), TYPE_VECTOR3, this->dataTable);
|
||||||
rotVelocity = ReflectionProperty<Vector3>("RotVelocity", Vector3(0,0,0), TYPE_VECTOR3, this->dataTable);
|
rotVelocity = ReflectionProperty<Vector3>("RotVelocity", Vector3(0,0,0), TYPE_VECTOR3, this->dataTable);
|
||||||
top = ReflectionProperty<Enum::SurfaceType::Value>("TopSurface", Enum::SurfaceType::Bumps, TYPE_ENUM, this->dataTable,
|
top = ReflectionProperty<Enum::SurfaceType::Value>("TopSurface", Enum::SurfaceType::Bumps, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::SurfaceType::LENGTH, Enum::SurfaceType::STR_TABLE));
|
(void*)&Enum::SurfaceType::ENUM_META);
|
||||||
front = ReflectionProperty<Enum::SurfaceType::Value>("FrontSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
front = ReflectionProperty<Enum::SurfaceType::Value>("FrontSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::SurfaceType::LENGTH, Enum::SurfaceType::STR_TABLE));
|
(void*)&Enum::SurfaceType::ENUM_META);
|
||||||
right = ReflectionProperty<Enum::SurfaceType::Value>("RightSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
right = ReflectionProperty<Enum::SurfaceType::Value>("RightSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::SurfaceType::LENGTH, Enum::SurfaceType::STR_TABLE));
|
(void*)&Enum::SurfaceType::ENUM_META);
|
||||||
back = ReflectionProperty<Enum::SurfaceType::Value>("BackSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
back = ReflectionProperty<Enum::SurfaceType::Value>("BackSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::SurfaceType::LENGTH, Enum::SurfaceType::STR_TABLE));
|
(void*)&Enum::SurfaceType::ENUM_META);
|
||||||
left = ReflectionProperty<Enum::SurfaceType::Value>("LeftSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
left = ReflectionProperty<Enum::SurfaceType::Value>("LeftSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::SurfaceType::LENGTH, Enum::SurfaceType::STR_TABLE));
|
(void*)&Enum::SurfaceType::ENUM_META);
|
||||||
bottom = ReflectionProperty<Enum::SurfaceType::Value>("BottomSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
bottom = ReflectionProperty<Enum::SurfaceType::Value>("BottomSurface", Enum::SurfaceType::Smooth, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::SurfaceType::LENGTH, Enum::SurfaceType::STR_TABLE));
|
(void*)&Enum::SurfaceType::ENUM_META);
|
||||||
shape = ReflectionProperty<Enum::Shape::Value>("Shape", Enum::Shape::Block, TYPE_ENUM, this->dataTable,
|
shape = ReflectionProperty<Enum::Shape::Value>("Shape", Enum::Shape::Block, TYPE_ENUM, this->dataTable,
|
||||||
(void*)new EnumMeta(Enum::Shape::LENGTH, Enum::Shape::STR_TABLE));
|
(void*)&Enum::Shape::ENUM_META);
|
||||||
|
|
||||||
// OnTouch
|
// OnTouch
|
||||||
singleShot = ReflectionProperty<bool>("SingleShot", true, TYPE_BOOLEAN, this->dataTable);
|
singleShot = ReflectionProperty<bool>("SingleShot", true, TYPE_BOOLEAN, this->dataTable);
|
||||||
@@ -45,6 +45,12 @@ PartInstance::PartInstance(void) : PVInstance("Part")
|
|||||||
changeScore = ReflectionProperty<int>("ChangeScore", 0, TYPE_INT, this->dataTable);
|
changeScore = ReflectionProperty<int>("ChangeScore", 0, TYPE_INT, this->dataTable);
|
||||||
changeTimer = ReflectionProperty<float>("ChangeTimer", 0.0f, TYPE_FLOAT, this->dataTable);
|
changeTimer = ReflectionProperty<float>("ChangeTimer", 0.0f, TYPE_FLOAT, this->dataTable);
|
||||||
|
|
||||||
|
|
||||||
|
onTouchAction = Reflection::ReflectionProperty<Enum::ActionType::Value>("OnTouchAction", Enum::ActionType::Nothing, TYPE_ENUM, this->dataTable,
|
||||||
|
(void*)&Enum::ActionType::ENUM_META);
|
||||||
|
onTouchSound = Reflection::ReflectionProperty<Enum::Sound::Value>("OnTouchSound", Enum::Sound::NoSound, TYPE_ENUM, this->dataTable,
|
||||||
|
(void*)&Enum::Sound::ENUM_META);
|
||||||
|
|
||||||
// Non-Reflective Properties
|
// Non-Reflective Properties
|
||||||
physBody = NULL;
|
physBody = NULL;
|
||||||
glList = glGenLists(1);
|
glList = glGenLists(1);
|
||||||
@@ -425,7 +431,7 @@ void PartInstance::onTouch()
|
|||||||
|
|
||||||
SoundService* sndService = getParentDataModel()->getSoundService();
|
SoundService* sndService = getParentDataModel()->getSoundService();
|
||||||
|
|
||||||
switch(OnTouchSound.getValue())
|
switch(onTouchSound.getValue())
|
||||||
{
|
{
|
||||||
case Enum::Sound::NoSound:
|
case Enum::Sound::NoSound:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ ReflectionDataTable::ReflectionDataTable(void)
|
|||||||
|
|
||||||
ReflectionDataTable::~ReflectionDataTable(void)
|
ReflectionDataTable::~ReflectionDataTable(void)
|
||||||
{
|
{
|
||||||
std::map<std::string, ReflectionProperty<void*>*>::iterator it;
|
// std::map<std::string, ReflectionProperty<void*>*>::iterator it;
|
||||||
for (it = propertyTable.begin(); it != propertyTable.end(); it++)
|
// for (it = propertyTable.begin(); it != propertyTable.end(); it++)
|
||||||
{
|
// {
|
||||||
it->second->dispose();
|
// it->second->dispose();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ReflectionDataTable::getClassName(void)
|
std::string ReflectionDataTable::getClassName(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user