LuaReference and apActorCommands are the same thing; apActorCommands
just sticks the result in AutoPtrCopyOnWrite. apActorCommands might be eliminated; it's reference counting a garbage collected object. (It used to be more useful, when we stored actual command lists; now I'm not sure whether it is. Need to benchmark LuaRef copying to see.) So, we shouldn't be treating them differently, but we are: GetMetric(apActorCommands) parses actor commands, and GetMetric(LuaRef) does not. I don't like that distinction; actor commands can be passed around as a LuaReference, and other references can be put in apActorCommands. "Whether it's in a smart pointer" is a strange way to decide which overload to use. Also, we should have a consistent way to know whether a metric is to be parsed as a command or as a Lua expression, based on the data itself and not the code being used to read it. Let's use the name: all commands end with "Command". We already depend on this elsewhere, in ActorUtil::LoadAllCommandsFromName. Note that "actor commands" are not specific to the Actor system, other than a few compatibility hacks; they're just a shorthand for writing Lua functions.
This commit is contained in:
@@ -989,15 +989,23 @@ void ThemeManager::GetMetric( const RString &sClassName, const RString &sValueNa
|
||||
{
|
||||
RString sValue = GetMetricRaw( g_pLoadedThemeData->iniMetrics, sClassName, sValueName );
|
||||
|
||||
LuaHelpers::PrepareExpression( sValue );
|
||||
valueOut.SetFromExpression( sValue );
|
||||
if( EndsWith(sValueName, "Command") )
|
||||
{
|
||||
ActorUtil::ParseActorCommands( sValue, valueOut );
|
||||
}
|
||||
else
|
||||
{
|
||||
LuaHelpers::PrepareExpression( sValue );
|
||||
valueOut.SetFromExpression( sValue );
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(SMPACKAGE)
|
||||
apActorCommands ThemeManager::GetMetricA( const RString &sClassName, const RString &sValueName )
|
||||
{
|
||||
RString sValue = GetMetricRaw( g_pLoadedThemeData->iniMetrics, sClassName, sValueName );
|
||||
return ActorUtil::ParseActorCommands( sValue );
|
||||
LuaReference *pRef = new LuaReference;
|
||||
GetMetric( sClassName, sValueName, *pRef );
|
||||
return apActorCommands( pRef );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user