Skip to content

Commit

Permalink
format --style=ansi --indent=spaces=4 --align-pointer=type --align-re…
Browse files Browse the repository at this point in the history
…ference=type --max-code-length=150 --indent-col1-comments --break-blocks --pad-oper --pad-paren-in --pad-header --unpad-paren --break-closing-brackets --delete-empty-lines --add-brackets --convert-tabs --break-after-logical
  • Loading branch information
brinkqiang committed Apr 5, 2018
1 parent f70d293 commit ebdf7af
Show file tree
Hide file tree
Showing 126 changed files with 79,792 additions and 68,062 deletions.
80 changes: 42 additions & 38 deletions include/dmlua/dmconsole.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

// Copyright (c) 2018 brinkqiang
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -28,75 +28,80 @@
class IDMConsoleSink
{
public:
virtual ~IDMConsoleSink(){};
virtual ~IDMConsoleSink() {};

virtual void OnCloseEvent(){};
virtual void OnCloseEvent() {};
};

class HDMConsoleMgr : public TSingleton<HDMConsoleMgr>
{
friend class TSingleton<HDMConsoleMgr>;
public:
void SetHandlerHook(IDMConsoleSink* pSink)
void SetHandlerHook( IDMConsoleSink* pSink )
{
m_pConsoleSink = pSink;

#ifdef WIN32
if (0 == SetConsoleCtrlHandler((PHANDLER_ROUTINE)&HDMConsoleMgr::OnConsoleEvent, true))

if ( 0 == SetConsoleCtrlHandler( ( PHANDLER_ROUTINE )&HDMConsoleMgr::OnConsoleEvent, true ) )
{
DMASSERT(0);
DMASSERT( 0 );
}

#else
m_phSigHandler = signal(SIGINT, &HDMConsoleMgr::OnConsoleEvent);
if (SIG_ERR == m_phSigHandler)
m_phSigHandler = signal( SIGINT, &HDMConsoleMgr::OnConsoleEvent );

if ( SIG_ERR == m_phSigHandler )
{
DMASSERT(0);
DMASSERT( 0 );
}

#endif
}

void OnCloseEvent()
{
if (m_bOnce && m_pConsoleSink)
if ( m_bOnce && m_pConsoleSink )
{
m_bOnce = false;
m_pConsoleSink->OnCloseEvent();
}
}

#ifdef WIN32
static BOOL WINAPI OnConsoleEvent(UINT32 dwEventType)
static BOOL WINAPI OnConsoleEvent( UINT32 dwEventType )
{
switch (dwEventType)
switch ( dwEventType )
{
case CTRL_C_EVENT:
case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
{
case CTRL_C_EVENT:
case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
{
HDMConsoleMgr::Instance()->OnCloseEvent();
}
break;
default:
DMASSERT(0);
break;
HDMConsoleMgr::Instance()->OnCloseEvent();
}
break;

default:
DMASSERT( 0 );
break;
}

return TRUE;
}
#else
static void OnConsoleEvent(int nEventType)
static void OnConsoleEvent( int nEventType )
{
switch(nEventType)
switch ( nEventType )
{
case SIGINT:
{
case SIGINT:
{
HDMConsoleMgr::Instance()->OnCloseEvent();
}
break;
default:
DMASSERT(0);
break;
HDMConsoleMgr::Instance()->OnCloseEvent();
}
break;

default:
DMASSERT( 0 );
break;
}
}
private:
Expand All @@ -118,11 +123,10 @@ class HDMConsoleMgr : public TSingleton<HDMConsoleMgr>

~HDMConsoleMgr()
{

}

private:
IDMConsoleSink * m_pConsoleSink;
IDMConsoleSink* m_pConsoleSink;
bool m_bOnce;
};

Expand Down
6 changes: 3 additions & 3 deletions include/dmlua/dmlua.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

// Copyright (c) 2018 brinkqiang
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down
Loading

0 comments on commit ebdf7af

Please sign in to comment.