From 5696489a786224631c3ded48f810164ee2c9ff25 Mon Sep 17 00:00:00 2001 From: mrwastl Date: Mon, 3 Oct 2011 01:04:48 +0200 Subject: functions (cSkinFunction) now evaluate parameters with variables and/or tokens too --- glcdskin/function.c | 17 +++++++++++++++-- glcdskin/type.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'glcdskin') diff --git a/glcdskin/function.c b/glcdskin/function.c index c6089bc..6d96c57 100644 --- a/glcdskin/function.c +++ b/glcdskin/function.c @@ -360,8 +360,21 @@ cType cSkinFunction::Evaluate(void) const case variable: { cSkinVariable * variable = mSkin->GetVariable(mVariableId); - if (variable) - return variable->Value(); + if (variable) { + cType rv = variable->Value(); + if (rv.IsString()) { + std::string val = rv; + if (val.find("{") != std::string::npos || val.find("#") != std::string::npos) { + cSkinString *result = new cSkinString(mObject, false); + if (result->Parse(val)) { + val = (std::string) result->Evaluate(); + rv = cType(val); + } + delete result; + } + } + return rv; + } return false; } diff --git a/glcdskin/type.h b/glcdskin/type.h index ad02a15..4d54de8 100644 --- a/glcdskin/type.h +++ b/glcdskin/type.h @@ -54,6 +54,10 @@ public: void SetUpdate(uint32_t UpdateIn) { mUpdateIn = UpdateIn; } uint32_t UpdateIn(void) const { return mUpdateIn; } + bool IsString(void) const { return (mType == string); } + bool IsNumber(void) const { return (mType == number); } + bool IsBoolean(void) const { return (mType == boolean); } + operator std::string () const { return String(); } operator int () const { return Number(); } operator bool () const; -- cgit v1.2.3