Skip to content

Commit

Permalink
Fixed code with clang.
Browse files Browse the repository at this point in the history
  • Loading branch information
cschreib committed Jan 29, 2014
1 parent 375d5b2 commit fe63104
Show file tree
Hide file tree
Showing 17 changed files with 443 additions and 427 deletions.
68 changes: 47 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ project(lxgui)

# setup version numbers
set(VERSION_MAJOR 1)
set(VERSION_MINOR 1)
set(VERSION_MINOR 2)

# check compiler version for C++11 features
if(CMAKE_COMPILER_IS_GNUCXX)
Expand All @@ -34,12 +34,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)

execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)

string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
set(GCC_VERSION ${GCC_MAJOR}.${GCC_MINOR})
set(GCC_VERSION ${GCC_MAJOR}.${GCC_MINOR})

if(GCC_VERSION VERSION_EQUAL 4.6)
message(STATUS "gcc version >= 4.6 (${GCC_VERSION})")
add_definitions(-std=c++0x)
Expand All @@ -58,28 +58,54 @@ elseif(MSVC)
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(/Zi)
endif()

if(MSVC_VERSION VERSION_EQUAL 1600)
add_definitions(/DNO_CPP11_EXPLICIT_CONV)
add_definitions(/DNO_CPP11_DELETE_FUNCTION)
add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT)
add_definitions(/DNO_CPP11_CONSTEXPR)
add_definitions(/DNO_CPP11_UNICODE_LITTERAL)
add_definitions(/D_CRT_SECURE_NO_DEPRECATE)

add_definitions(/DNO_CPP11_EXPLICIT_CONV)
add_definitions(/DNO_CPP11_DELETE_FUNCTION)
add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT)
add_definitions(/DNO_CPP11_CONSTEXPR)
add_definitions(/DNO_CPP11_UNICODE_LITTERAL)
add_definitions(/D_CRT_SECURE_NO_DEPRECATE)

if(NOT (MSVC_VERSION VERSION_LESS 1600))
message(STATUS "Using MSVC 2010: some C++11 features are not supported by this compiler. Workarounds are used but never perfectly mimic the C++11 code.")
elseif(MSVC_VERSION VERSION_GREATER 1600)
add_definitions(/DNO_CPP11_EXPLICIT_CONV)
add_definitions(/DNO_CPP11_DELETE_FUNCTION)
add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT)
add_definitions(/DNO_CPP11_CONSTEXPR)
add_definitions(/DNO_CPP11_UNICODE_LITTERAL)
add_definitions(/D_CRT_SECURE_NO_DEPRECATE)
message(STATUS "Using MSVC > 2010: some C++11 features are not supported by this compiler. Workarounds are used but never perfectly mimic the C++11 code.")
else()
message(ERROR ": lxgui requires advanced features from the C++11 norm that are only available with MSVC 2010 or higher (your version: ${MSVC_VERSION}). Please upgrade your compiler.")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.99)
message(STATUS "clang version >= 3.0 (${CMAKE_CXX_COMPILER_VERSION})")
else()
message(ERROR ": lxgui requires advanced features from the C++11 norm that are only available with clang 3.0 or higher (your version: ${CMAKE_CXX_COMPILER_VERSION}). Please upgrade your compiler.")
endif()

add_definitions(-Weverything)
add_definitions(-Wno-c++98-compat-pedantic)
add_definitions(-Wno-c++98-compat)
add_definitions(-Wno-unused-parameter)
add_definitions(-Wno-sign-conversion)
add_definitions(-Wno-conversion)
add_definitions(-Wno-missing-variable-declarations)
add_definitions(-Wno-missing-prototypes)
add_definitions(-Wno-padded)
add_definitions(-Wno-float-equal)
add_definitions(-Wno-unused-variable)
add_definitions(-Wno-global-constructors)
add_definitions(-Wno-exit-time-destructors)
add_definitions(-Wno-weak-vtables)
add_definitions(-Wno-covered-switch-default)
add_definitions(-Wno-documentation-unknown-command)
add_definitions(-Wno-unneeded-internal-declaration)
add_definitions(-Wno-unused-function)
add_definitions(-Wno-unused-macros)
add_definitions(-Wno-switch-enum)
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-g)
else()
add_definitions(-O3)
endif()
add_definitions(-std=c++11)
else()
message(STATUS "Warning: your compiler has not been setup by the CMake script, do not expect it to work")
message(WARNING "Warning: your compiler has not been setup by the CMake script, do not expect it to work")
endif()

# set OS preprocessor defines
Expand Down
16 changes: 8 additions & 8 deletions gui/src/gui_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,9 @@ void frame::notify_script_defined(const std::string& sScriptName, bool bDefined)

if (bDefined)
{
std::map<std::string, handler>::iterator iter = lDefinedHandlerList_.find(sScriptName);
if (iter != lDefinedHandlerList_.end())
lDefinedHandlerList_.erase(iter);
std::map<std::string, handler>::iterator iter2 = lDefinedHandlerList_.find(sScriptName);
if (iter2 != lDefinedHandlerList_.end())
lDefinedHandlerList_.erase(iter2);

lDefinedScriptList_[sCutScriptName] = "";
} else
Expand Down Expand Up @@ -1330,14 +1330,14 @@ void frame::on(const std::string& sScriptName, event* pEvent)
// that will print the actual line numbers in the XML file.
pErrorFunc = pLua->get_lua_error_function();

std::map<std::string, script_info>::const_iterator iter = lXMLScriptInfoList_.find(sScriptName);
if (iter != lXMLScriptInfoList_.end())
std::map<std::string, script_info>::const_iterator iter2 = lXMLScriptInfoList_.find(sScriptName);
if (iter2 != lXMLScriptInfoList_.end())
{
sFile = pLua->get_global_string("_xml_file_name", false, "");
uiLineNbr = pLua->get_global_int("_xml_line_nbr", false, 0);

pLua->push_string(iter->second.sFile); pLua->set_global("_xml_file_name");
pLua->push_number(iter->second.uiLineNbr); pLua->set_global("_xml_line_nbr");
pLua->push_string(iter2->second.sFile); pLua->set_global("_xml_file_name");
pLua->push_number(iter2->second.uiLineNbr); pLua->set_global("_xml_line_nbr");

pLua->set_lua_error_function(l_xml_error);
}
Expand Down Expand Up @@ -1561,7 +1561,7 @@ void frame::set_parent(uiobject* pParent)
gui::out << gui::error << "gui::" << lType_.back() << " : Cannot call set_parent(this)." << std::endl;
return;
}

if (pParent != pParent_)
{
if (!pParentFrame_ && uiID_ != uint(-1))
Expand Down
16 changes: 8 additions & 8 deletions gui/src/gui_frame_glues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ int lua_frame::_register_event(lua_State* pLua)
int lua_frame::_register_for_drag(lua_State* pLua)
{
if (!check_parent_())
return 0;
return 0;

lua::function mFunc("Frame:register_for_drag", pLua);
mFunc.add(0, "button 1", lua::TYPE_STRING, true);
Expand All @@ -733,7 +733,7 @@ int lua_frame::_register_for_drag(lua_State* pLua)
std::vector<std::string> lButtonList;
for (uint i = 0; i < 3; ++i)
{
if (mFunc.is_provided(i))
if (mFunc.is_provided(i))
lButtonList.push_back(mFunc.get(i)->get_string());
else
break;
Expand Down Expand Up @@ -891,7 +891,7 @@ int lua_frame::_set_backdrop_color(lua_State* pLua)
}
}
else
mColor = color(mFunc.get(0)->get_string());
mColor = color(mFunc.get(0)->get_string());

pBackdrop->set_background_color(mColor);
}
Expand Down Expand Up @@ -1121,18 +1121,18 @@ int lua_frame::_set_script(lua_State* pLua)
std::string sScriptName = mFunc.get(0)->get_string();
if (pFrameParent_->can_use_script(sScriptName))
{
lua::state* pLua = mFunc.get_state();
lua::state* pState = mFunc.get_state();
utils::wptr<lua::argument> pArg = mFunc.get(1);
if (pArg->is_provided() && pArg->get_type() == lua::TYPE_FUNCTION)
{
pLua->push_value(pArg->get_index());
pLua->set_global(pFrameParent_->get_name() + ":" + sScriptName);
pState->push_value(pArg->get_index());
pState->set_global(pFrameParent_->get_name() + ":" + sScriptName);
pFrameParent_->notify_script_defined(sScriptName, true);
}
else
{
pLua->push_nil();
pLua->set_global(pFrameParent_->get_name() + ":" + sScriptName);
pState->push_nil();
pState->set_global(pFrameParent_->get_name() + ":" + sScriptName);
pFrameParent_->notify_script_defined(sScriptName, false);
}
}
Expand Down
Loading

0 comments on commit fe63104

Please sign in to comment.