Skip to content

Commit

Permalink
Merge pull request stepmania#1837 from teejusb/5_1-new
Browse files Browse the repository at this point in the history
Integrate C++11 Branch into 5_1-new
  • Loading branch information
quietly-turning authored Jun 30, 2019
2 parents 708139f + f08d7d9 commit c9198db
Show file tree
Hide file tree
Showing 444 changed files with 19,505 additions and 21,001 deletions.
6 changes: 3 additions & 3 deletions extern/jsoncpp/src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ std::string valueToString( bool value )
std::string valueToQuotedString( const char *value )
{
// Not sure how to handle unicode...
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value ))
if (strpbrk(value, "\"\\\b\f\n\r\t") == nullptr && !containsControlCharacter( value ))
return std::string("\"") + value + "\"";
// We have to walk value and escape any special characters.
// Appending to std::string is not efficient, but this should be rare.
Expand Down Expand Up @@ -542,7 +542,7 @@ StyledWriter::normalizeEOL( const std::string &text )
// //////////////////////////////////////////////////////////////////

StyledStreamWriter::StyledStreamWriter( std::string indentation )
: document_(NULL)
: document_(nullptr)
, rightMargin_( 74 )
, indentation_( indentation )
{
Expand All @@ -559,7 +559,7 @@ StyledStreamWriter::write( std::ostream &out, const Value &root )
writeValue( root );
writeCommentAfterValueOnSameLine( root );
*document_ << "\n";
document_ = NULL; // Forget the stream, for safety.
document_ = nullptr; // Forget the stream, for safety.
}


Expand Down
43 changes: 21 additions & 22 deletions src/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "RageUtil.h"
#include "RageMath.h"
#include "RageLog.h"
#include "Foreach.h"
#include "XmlFile.h"
#include "LuaBinding.h"
#include "ThemeManager.h"
Expand Down Expand Up @@ -87,7 +86,7 @@ void Actor::InitState()
{
this->StopTweening();

m_pTempState = NULL;
m_pTempState = nullptr;

m_baseRotation = RageVector3( 0, 0, 0 );
m_baseScale = RageVector3( 1, 1, 1 );
Expand Down Expand Up @@ -162,8 +161,8 @@ Actor::Actor()

m_size = RageVector2( 1, 1 );
InitState();
m_pParent = NULL;
m_FakeParent= NULL;
m_pParent = nullptr;
m_FakeParent= nullptr;
m_bFirstUpdate = true;
m_tween_uses_effect_delta= false;
}
Expand All @@ -183,8 +182,8 @@ Actor::Actor( const Actor &cpy ):
MessageSubscriber( cpy )
{
/* Don't copy an Actor in the middle of rendering. */
ASSERT( cpy.m_pTempState == NULL );
m_pTempState = NULL;
ASSERT( cpy.m_pTempState == nullptr );
m_pTempState = nullptr;

#define CPY(x) x = cpy.x
CPY( m_sName );
Expand Down Expand Up @@ -457,7 +456,7 @@ void Actor::Draw()
this->SetInternalGlow(last_glow);
}
this->PreDraw();
ASSERT( m_pTempState != NULL );
ASSERT( m_pTempState != nullptr );
if(PartiallyOpaque())
{
this->BeginDraw();
Expand All @@ -475,16 +474,16 @@ void Actor::Draw()
}
abort_with_end_draw= true;
state->PostDraw();
state->m_pTempState= NULL;
state->m_pTempState= nullptr;
}

if(m_FakeParent)
{
m_FakeParent->EndDraw();
m_FakeParent->PostDraw();
m_FakeParent->m_pTempState= NULL;
m_FakeParent->m_pTempState= nullptr;
}
m_pTempState = NULL;
m_pTempState = nullptr;
}

void Actor::PostDraw() // reset internal diffuse and glow
Expand Down Expand Up @@ -1364,7 +1363,7 @@ void Actor::RunCommands( const LuaReference& cmds, const LuaReference *pParamTab
this->PushSelf( L );

// 2nd parameter
if( pParamTable == NULL )
if( pParamTable == nullptr )
lua_pushnil( L );
else
pParamTable->PushSelf( L );
Expand Down Expand Up @@ -1533,14 +1532,14 @@ void Actor::AddCommand( const RString &sCmdName, apActorCommands apac, bool warn

bool Actor::HasCommand( const RString &sCmdName ) const
{
return GetCommand(sCmdName) != NULL;
return GetCommand(sCmdName) != nullptr;
}

const apActorCommands *Actor::GetCommand( const RString &sCommandName ) const
{
map<RString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
if( it == m_mapNameToCommands.end() )
return NULL;
return nullptr;
return &it->second;
}

Expand All @@ -1552,7 +1551,7 @@ void Actor::HandleMessage( const Message &msg )
void Actor::PlayCommandNoRecurse( const Message &msg )
{
const apActorCommands *pCmd = GetCommand( msg.GetName() );
if(pCmd != NULL && (*pCmd)->IsSet() && !(*pCmd)->IsNil())
if(pCmd != nullptr && (*pCmd)->IsSet() && !(*pCmd)->IsNil())
{
RunCommands( *pCmd, &msg.GetParamTable() );
}
Expand Down Expand Up @@ -1584,7 +1583,7 @@ void Actor::SetParent( Actor *pParent )

Actor::TweenInfo::TweenInfo()
{
m_pTween = NULL;
m_pTween = nullptr;
}

Actor::TweenInfo::~TweenInfo()
Expand All @@ -1594,14 +1593,14 @@ Actor::TweenInfo::~TweenInfo()

Actor::TweenInfo::TweenInfo( const TweenInfo &cpy )
{
m_pTween = NULL;
m_pTween = nullptr;
*this = cpy;
}

Actor::TweenInfo &Actor::TweenInfo::operator=( const TweenInfo &rhs )
{
delete m_pTween;
m_pTween = (rhs.m_pTween? rhs.m_pTween->Copy():NULL);
m_pTween = (rhs.m_pTween? rhs.m_pTween->Copy():nullptr);
m_fTimeLeftInTween = rhs.m_fTimeLeftInTween;
m_fTweenTime = rhs.m_fTweenTime;
m_sCommandName = rhs.m_sCommandName;
Expand Down Expand Up @@ -1680,7 +1679,7 @@ class LunaActor : public Luna<Actor>
COMMON_RETURN_SELF;
}
ITween *pTween = ITween::CreateFromStack( L, 2 );
if(pTween != NULL)
if(pTween != nullptr)
{
p->BeginTweening(fTime, pTween);
}
Expand Down Expand Up @@ -1875,7 +1874,7 @@ class LunaActor : public Luna<Actor>
static int GetCommand( T* p, lua_State *L )
{
const apActorCommands *pCommand = p->GetCommand(SArg(1));
if( pCommand == NULL )
if( pCommand == nullptr )
lua_pushnil( L );
else
(*pCommand)->PushSelf(L);
Expand Down Expand Up @@ -1933,7 +1932,7 @@ class LunaActor : public Luna<Actor>
static int GetParent( T* p, lua_State *L )
{
Actor *pParent = p->GetParent();
if( pParent == NULL )
if( pParent == nullptr )
lua_pushnil( L );
else
pParent->PushSelf(L);
Expand All @@ -1942,7 +1941,7 @@ class LunaActor : public Luna<Actor>
static int GetFakeParent(T* p, lua_State *L)
{
Actor* fake= p->GetFakeParent();
if(fake == NULL)
if(fake == nullptr)
{
lua_pushnil(L);
}
Expand All @@ -1956,7 +1955,7 @@ class LunaActor : public Luna<Actor>
{
if(lua_isnoneornil(L, 1))
{
p->SetFakeParent(NULL);
p->SetFakeParent(nullptr);
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions src/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,11 @@ class Actor : public MessageSubscriber
void PlayCommandNoRecurse( const Message &msg );

// Commands by reference
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); }
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommands( *cmds, pParamTable ); } // convenience
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ) { RunCommands(cmds, pParamTable); }
// If we're a leaf, then execute this command.
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ) { RunCommands(cmds, pParamTable); }
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ) { RunCommands(cmds, pParamTable); }

// Messages
virtual void HandleMessage( const Message &msg );
Expand Down
50 changes: 24 additions & 26 deletions src/ActorFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "ActorUtil.h"
#include "RageDisplay.h"
#include "ScreenDimensions.h"
#include "Foreach.h"


/* Tricky: We need ActorFrames created in Lua to auto delete their children.
* We don't want classes that derive from ActorFrame to auto delete their
Expand Down Expand Up @@ -82,8 +82,7 @@ ActorFrame::ActorFrame( const ActorFrame &cpy ):

void ActorFrame::InitState()
{
FOREACH( Actor*, m_SubActors, a )
(*a)->InitState();
std::for_each(m_SubActors.begin(), m_SubActors.end(), [](Actor *a) { a->InitState(); });
Actor::InitState();
}

Expand Down Expand Up @@ -119,7 +118,7 @@ void ActorFrame::LoadChildrenFromNode( const XNode* pNode )
// Load children
const XNode* pChildren = pNode->GetChild("children");
bool bArrayOnly = false;
if( pChildren == NULL )
if( pChildren == nullptr )
{
bArrayOnly = true;
pChildren = pNode;
Expand All @@ -146,7 +145,7 @@ void ActorFrame::AddChild( Actor *pActor )
Dialog::OK( ssprintf("Actor \"%s\" adds child \"%s\" more than once", GetLineage().c_str(), pActor->GetName().c_str()) );
#endif

ASSERT( pActor != NULL );
ASSERT( pActor != nullptr );
ASSERT( (void*)pActor != (void*)0xC0000005 );
m_SubActors.push_back( pActor );

Expand All @@ -162,19 +161,18 @@ void ActorFrame::RemoveChild( Actor *pActor )

void ActorFrame::TransferChildren( ActorFrame *pTo )
{
FOREACH( Actor*, m_SubActors, i )
pTo->AddChild( *i );
std::for_each(m_SubActors.begin(), m_SubActors.end(), [&](Actor *a) { pTo->AddChild(a); });
RemoveAllChildren();
}

Actor* ActorFrame::GetChild( const RString &sName )
{
FOREACH( Actor*, m_SubActors, a )
for (Actor *a : m_SubActors)
{
if( (*a)->GetName() == sName )
return *a;
if( a->GetName() == sName )
return a;
}
return NULL;
return nullptr;
}

void ActorFrame::RemoveAllChildren()
Expand Down Expand Up @@ -374,15 +372,15 @@ static void AddToChildTable(lua_State* L, Actor* a)
void ActorFrame::PushChildrenTable( lua_State *L )
{
lua_newtable( L ); // stack: all_actors
FOREACH( Actor*, m_SubActors, a )
for (Actor *a: m_SubActors)
{
LuaHelpers::Push( L, (*a)->GetName() ); // stack: all_actors, name
LuaHelpers::Push( L, a->GetName() ); // stack: all_actors, name
lua_gettable(L, -2); // stack: all_actors, entry
if(lua_isnil(L, -1))
{
lua_pop(L, 1); // stack: all_actors
LuaHelpers::Push( L, (*a)->GetName() ); // stack: all_actors, name
(*a)->PushSelf( L ); // stack: all_actors, name, actor
LuaHelpers::Push( L, a->GetName() ); // stack: all_actors, name
a->PushSelf( L ); // stack: all_actors, name, actor
lua_rawset( L, -3 ); // stack: all_actors
}
else
Expand All @@ -391,14 +389,14 @@ void ActorFrame::PushChildrenTable( lua_State *L )
if(lua_objlen(L, -1) > 0)
{
// stack: all_actors, table_entry
AddToChildTable(L, *a); // stack: all_actors, table_entry
AddToChildTable(L, a); // stack: all_actors, table_entry
lua_pop(L, 1); // stack: all_actors
}
else
{
// stack: all_actors, old_entry
CreateChildTable(L, *a); // stack: all_actors, table_entry
LuaHelpers::Push(L, (*a)->GetName()); // stack: all_actors, table_entry, name
CreateChildTable(L, a); // stack: all_actors, table_entry
LuaHelpers::Push(L, a->GetName()); // stack: all_actors, table_entry, name
lua_insert(L, -2); // stack: all_actors, name, table_entry
lua_rawset(L, -3); // stack: all_actors
}
Expand All @@ -409,20 +407,20 @@ void ActorFrame::PushChildrenTable( lua_State *L )
void ActorFrame::PushChildTable(lua_State* L, const RString &sName)
{
int found= 0;
FOREACH(Actor*, m_SubActors, a)
for (Actor *a: m_SubActors)
{
if((*a)->GetName() == sName)
if(a->GetName() == sName)
{
switch(found)
{
case 0:
(*a)->PushSelf(L);
a->PushSelf(L);
break;
case 1:
CreateChildTable(L, *a);
CreateChildTable(L, a);
break;
default:
AddToChildTable(L, *a);
AddToChildTable(L, a);
break;
}
++found;
Expand All @@ -437,14 +435,14 @@ void ActorFrame::PushChildTable(lua_State* L, const RString &sName)
void ActorFrame::PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable )
{
const apActorCommands *pCmd = GetCommand( sCommandName );
if( pCmd != NULL )
if( pCmd != nullptr )
RunCommandsOnChildren( *pCmd, pParamTable );
}

void ActorFrame::PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable )
{
const apActorCommands *pCmd = GetCommand( sCommandName );
if( pCmd != NULL )
if( pCmd != nullptr )
RunCommandsOnLeaves( **pCmd, pParamTable );
}

Expand Down Expand Up @@ -720,7 +718,7 @@ class LunaActorFrame : public Luna<ActorFrame>
{
// this one is tricky, we need to get an Actor from Lua.
Actor *pActor = ActorUtil::MakeActor( SArg(1) );
if ( pActor == NULL )
if ( pActor == nullptr )
{
lua_pushboolean( L, 0 );
return 1;
Expand Down
16 changes: 8 additions & 8 deletions src/ActorFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class ActorFrame : public Actor
virtual void PushSelf( lua_State *L );
void PushChildrenTable( lua_State *L );
void PushChildTable( lua_State *L, const RString &sName );
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = NULL );
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = NULL );
void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = nullptr );
void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = nullptr );

virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */
void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */
virtual void RunCommandsRecursively( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ); /* but not on self */
void RunCommandsOnChildren( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommandsOnChildren( *cmds, pParamTable ); } // convenience
virtual void RunCommandsOnLeaves( const LuaReference& cmds, const LuaReference *pParamTable = nullptr ); /* but not on self */

virtual void UpdateInternal( float fDeltaTime );
virtual void BeginDraw();
Expand Down Expand Up @@ -92,8 +92,8 @@ class ActorFrame : public Actor
virtual float GetTweenTimeLeft() const;

virtual void HandleMessage( const Message &msg );
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = NULL );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = NULL ) { this->RunCommands( *cmds, pParamTable ); } // convenience
virtual void RunCommands( const LuaReference& cmds, const LuaReference *pParamTable = nullptr );
void RunCommands( const apActorCommands& cmds, const LuaReference *pParamTable = nullptr ) { this->RunCommands( *cmds, pParamTable ); } // convenience

protected:
void LoadChildrenFromNode( const XNode* pNode );
Expand Down
Loading

0 comments on commit c9198db

Please sign in to comment.