From 04c2565d7f5cd7112807b4dd2c7df3f379b064b0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 22 Mar 2017 15:44:54 +0100 Subject: [PATCH] - added Get/SetValue functions to PBool. --- src/dobjtype.cpp | 26 ++++++++++++++++++++++++++ src/dobjtype.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index ee1e03912..f681def3e 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -711,6 +711,32 @@ double PInt::GetValueFloat(void *addr) const IMPLEMENT_CLASS(PBool, false, false) +//========================================================================== +// +// PInt :: SetValue +// +//========================================================================== + +void PBool::SetValue(void *addr, int val) +{ + *(bool*)addr = !!val; +} + +void PBool::SetValue(void *addr, double val) +{ + *(bool*)addr = val != 0.; +} + +int PBool::GetValueInt(void *addr) const +{ + return *(bool *)addr; +} + +double PBool::GetValueFloat(void *addr) const +{ + return *(bool *)addr; +} + //========================================================================== // // PBool Default Constructor diff --git a/src/dobjtype.h b/src/dobjtype.h index 854a809de..bf6e9feb1 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -263,6 +263,10 @@ class PBool : public PInt DECLARE_CLASS(PBool, PInt); public: PBool(); + virtual void SetValue(void *addr, int val); + virtual void SetValue(void *addr, double val); + virtual int GetValueInt(void *addr) const; + virtual double GetValueFloat(void *addr) const; }; class PFloat : public PBasicType