Skip to content

Commit

Permalink
Merge pull request xbmc#6412 from Memphiz/c++11
Browse files Browse the repository at this point in the history
Move to C++11; use as much std:: instead of boost:: as possible
  • Loading branch information
MartijnKaijser committed Feb 12, 2015
2 parents fd81a3e + 57b32ce commit c096e7e
Show file tree
Hide file tree
Showing 281 changed files with 960 additions and 580 deletions.
4 changes: 3 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AC_CONFIG_HEADERS([xbmc/config.h])
AH_TOP([#pragma once])
m4_include([m4/ax_prog_cc_for_build.m4])
m4_include([m4/ax_prog_cxx_for_build.m4])
m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
m4_include([m4/ax_python_devel.m4])
m4_include([m4/xbmc_arch.m4])

Expand Down Expand Up @@ -579,6 +580,7 @@ PASSED_CXXFLAGS=$CXXFLAGS # Hack to override autoconf default values
AC_PROG_CXX
AX_PROG_CXX_FOR_BUILD
CXXFLAGS="$PASSED_CXXFLAGS $DEFAULT_COMPILE_FLAGS"
AX_CXX_COMPILE_STDCXX_11(,[optional])
AC_PROG_LIBTOOL
AC_PROG_AWK
AC_PROG_LN_S
Expand Down Expand Up @@ -928,7 +930,7 @@ AC_CHECK_HEADER([sys/inotify.h], AC_DEFINE([HAVE_INOTIFY],[1],[Define if we have

# Checks for boost headers using CXX instead of CC
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([boost/shared_ptr.hpp],, AC_MSG_ERROR($missing_library))
AC_CHECK_HEADER([boost/circular_buffer.hpp],, AC_MSG_ERROR($missing_library))
AC_LANG_POP([C++])

# Python
Expand Down
2 changes: 1 addition & 1 deletion lib/cximage-6.0/CxImage/ximadsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3531,7 +3531,7 @@ bool CxImage::FloodFill(const long xStart, const long yStart, const RGBQUAD cFil
//------------------------------------- Begin of Flood Fill
POINT offset[4] = {{-1,0},{0,-1},{1,0},{0,1}};
std::queue<POINT> q;
POINT point = {xStart,yStart};
POINT point = {(int)xStart,(int)yStart};
q.push(point);

if (IsIndexed()){ //--- Generic indexed image, no tolerance OR Grayscale image with tolerance
Expand Down
4 changes: 2 additions & 2 deletions lib/cximage-6.0/CxImage/ximaico.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int nPageCount)
int nPages = nPageCount;
if (nPages<1) nPages = 1;

ICONHEADER icon_header={0,1,nPages};
ICONHEADER icon_header={0,1,(WORD)nPages};

if (!bAppend)
m_dwImageOffset = sizeof(ICONHEADER) + nPages * sizeof(ICONDIRENTRY);
Expand All @@ -345,7 +345,7 @@ bool CxImageICO::Encode(CxFile * hFile, bool bAppend, int nPageCount)
2*head.biHeight,
1,
(WORD)bitcount,
0, imagesize,
0, (DWORD)imagesize,
0, 0, 0, 0
};

Expand Down
142 changes: 142 additions & 0 deletions m4/ax_cxx_compile_stdcxx_11.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
#
# The first argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The second argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline C++11 support is required and that the macro
# should error out if no mode with that support is found. If specified
# 'optional', then configuration proceeds regardless, after defining
# HAVE_CXX11 if and only if a supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <[email protected]>
# Copyright (c) 2012 Zack Weinberg <[email protected]>
# Copyright (c) 2013 Roy Stogner <[email protected]>
# Copyright (c) 2014 Alexey Sokolov <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 4

m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
struct Base {
virtual void f() {}
};
struct Child : public Base {
virtual void f() {}
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
auto l = [](){};
]])

AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
ax_cv_cxx_compile_cxx11,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx11=yes],
[ax_cv_cxx_compile_cxx11=no])])
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
ac_success=yes
fi
m4_if([$1], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++11 -std=gnu++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=c++11 -std=c++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx11_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
fi
else
if test x$ac_success = xno; then
HAVE_CXX11=0
AC_MSG_NOTICE([No compiler with C++11 support was found])
else
HAVE_CXX11=1
AC_DEFINE(HAVE_CXX11,1,
[define if the compiler supports basic C++11 syntax])
fi
AC_SUBST(HAVE_CXX11)
fi
])
2 changes: 1 addition & 1 deletion tools/buildsteps/atv2/make-xbmc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ XBMC_PLATFORM_DIR=atv2

cd $WORKSPACE;make -j$BUILDTHREADS xcode_depends
cd $WORKSPACE;xcodebuild -project Kodi.xcodeproj -target Kodi-ATV2 -configuration $Configuration build \
ONLY_ACTIVE_ARCH=YES ARCHS=armv7 VALID_ARCHS=armv7 IPHONEOS_DEPLOYMENT_TARGET=4.2 \
ONLY_ACTIVE_ARCH=YES ARCHS=armv7 VALID_ARCHS=armv7 \
SDKROOT=iphoneos$SDK_VERSION XBMC_DEPENDS_ROOT=$XBMC_DEPENDS_ROOT CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
2 changes: 1 addition & 1 deletion tools/buildsteps/ios/make-xbmc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ XBMC_PLATFORM_DIR=ios

cd $WORKSPACE;make -j$BUILDTHREADS xcode_depends
cd $WORKSPACE;xcodebuild -project Kodi.xcodeproj -target Kodi-iOS -configuration $Configuration build \
ONLY_ACTIVE_ARCH=YES ARCHS=armv7 VALID_ARCHS=armv7 IPHONEOS_DEPLOYMENT_TARGET=4.2 \
ONLY_ACTIVE_ARCH=YES ARCHS=armv7 VALID_ARCHS=armv7 \
SDKROOT=iphoneos$SDK_VERSION XBMC_DEPENDS_ROOT=$XBMC_DEPENDS_ROOT CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

4 changes: 2 additions & 2 deletions tools/darwin/Configurations/App-OSX.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ ARCHS = i386 x86_64
ONLY_ACTIVE_ARCH = YES

SDKROOT = macosx
MACOSX_DEPLOYMENT_TARGET = 10.6
MACOSX_DEPLOYMENT_TARGET = 10.7



OTHER_LDFLAGS = -Wl,-search_paths_first $(XBMC_OTHER_LDFLAGS_COMMON) -lcdio -lfontconfig -lGLEW -lSDL

GCC_PREPROCESSOR_DEFINITIONS = TARGET_DARWIN_OSX $(inherited)
GCC_PREPROCESSOR_DEFINITIONS = TARGET_DARWIN_OSX $(inherited)
2 changes: 1 addition & 1 deletion tools/darwin/Configurations/App-iOS.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
PRODUCT_NAME = $(APP_NAME)
//build against latest
SDKROOT = iphoneos
IPHONEOS_DEPLOYMENT_TARGET = 4.2
IPHONEOS_DEPLOYMENT_TARGET = 5.1

ARCHS = armv7
VALID_ARCHS = armv7
Expand Down
3 changes: 2 additions & 1 deletion tools/darwin/Configurations/App.xcconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "$(SDKROOT)/System/Library/PrivateFramewor

XBMC_OTHER_LDFLAGS_COMMON = $(inherited) -Wl,-headerpad_max_install_names -Wl,-all_load -L$XBMC_DEPENDS/lib -lbz2 -lintl -lexpat -lssl -lgpg-error -lresolv -lffi -lssh -llzo2 -lpcre -lpcrecpp -lfribidi -lfreetype -lfontconfig -lsqlite3 -ltinyxml -lmicrohttpd -lsmbclient -lpython2.6 -lyajl -ljpeg -lcrypto -lgcrypt -lavdevice -lavfilter -lavcodec -lavformat -lpostproc -lavutil -lswresample -lswscale -ltag -L$XBMC_DEPENDS/lib/mysql -lmysqlclient -lxml2 -lxslt -lnettle -lgmp -lhogweed -lgnutls


CLANG_CXX_LANGUAGE_STANDARD = c++0x
CLANG_CXX_LIBRARY = libc++
6 changes: 3 additions & 3 deletions tools/depends/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ case $host in
AC_MSG_ERROR(error in configure of --with-arch=$use_cpu)
esac
platform_os="osx"
platform_min_version=macosx-version-min=10.6
platform_min_version=macosx-version-min=10.7
;;

arm-apple-darwin*)
Expand All @@ -260,7 +260,7 @@ case $host in
if test "$use_cpu" != "armv7"; then
AC_MSG_ERROR(error in configure of --with-arch=$use_cpu)
fi
platform_min_version="iphoneos-version-min=4.2"
platform_min_version="iphoneos-version-min=5.1"
found_sdk_version=[`$use_xcodebuild -showsdks | grep iphoneos | sort | tail -n 1 | awk '{ print $2}'`]
use_sdk="${use_sdk:-$found_sdk_version}"
sdk_name=iphoneos$use_sdk
Expand Down Expand Up @@ -293,7 +293,7 @@ case $host in
esac
platform_cflags+=" -arch $use_cpu -m$platform_min_version"
platform_ldflags+=" -arch $use_cpu -m$platform_min_version -isysroot $use_sdk_path"
platform_cxxflags+=" -arch $use_cpu -m$platform_min_version"
platform_cxxflags+=" -arch $use_cpu -m$platform_min_version -std=c++11 -stdlib=libc++"
platform_includes="-isysroot $use_sdk_path"
deps_dir=$sdk_name"_"$use_cpu-target
tool_dir=buildtools-native;
Expand Down
1 change: 1 addition & 0 deletions tools/depends/target/config.site.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jm_cv_func_gettimeofday_clobber=no
mac_cv_pkg_ldflags=-lz
if test "@platform_os@" = "osx"; then
ac_cv_func_strnlen_working=no
ac_cv_header_stdbool_h=yes
fi

#gnutls
Expand Down
11 changes: 11 additions & 0 deletions tools/depends/target/libplist/0003-fixc++1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/Dictionary.cpp.orig 2014-12-31 14:05:09.000000000 -0600
+++ b/src/Dictionary.cpp 2014-12-31 14:09:58.000000000 -0600
@@ -151,7 +151,7 @@
_map[key] = clone;
return _map.find(key);
}
- return iterator(NULL);
+ return iterator();
}

void Dictionary::Remove(Node* node)
1 change: 1 addition & 0 deletions tools/depends/target/libplist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $(PLATFORM): $(TARBALLS_LOCATION)/$(ARCHIVE) $(DEPS)
cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
cd $(PLATFORM); patch -p1 < ../0001-dontbuildswig.patch
cd $(PLATFORM); patch -p1 < ../0002-fixclang.diff
cd $(PLATFORM); patch -p1 < ../0003-fixc++1.patch
cd $(PLATFORM); sed -ie 's/TARGET_LINK_LIBRARIES( plist \(.*\))/TARGET_LINK_LIBRARIES( plist \1 z m) /' src/CMakeLists.txt
cd $(PLATFORM); rm -rf build; mkdir -p build
cd $(PLATFORM)/build; $(CMAKE) VERBOSE=1 -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_LD_FLAGS="$(LDFLAGS)" ..
Expand Down
1 change: 1 addition & 0 deletions xbmc/AppParamParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#ifndef TARGET_WINDOWS
#include "linux/XTimeUtils.h"
#endif
#include <stdlib.h>

CAppParamParser::CAppParamParser()
{
Expand Down
6 changes: 3 additions & 3 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ bool CApplication::LoadSkin(const std::string& skinID)
AddonPtr addon;
if (CAddonMgr::Get().GetAddon(skinID, addon, ADDON_SKIN))
{
if (LoadSkin(boost::dynamic_pointer_cast<ADDON::CSkinInfo>(addon)))
if (LoadSkin(std::dynamic_pointer_cast<ADDON::CSkinInfo>(addon)))
return true;
}
CLog::Log(LOGERROR, "failed to load requested skin '%s'", skinID.c_str());
Expand Down Expand Up @@ -1852,7 +1852,7 @@ void CApplication::UnloadSkin(bool forReload /* = false */)

g_infoManager.Clear();

// The g_SkinInfo boost shared_ptr ought to be reset here
// The g_SkinInfo shared_ptr ought to be reset here
// but there are too many places it's used without checking for NULL
// and as a result a race condition on exit can cause a crash.
}
Expand Down Expand Up @@ -2983,7 +2983,7 @@ bool CApplication::PlayMedia(const CFileItem& item, int iPlaylist)
CGUIDialogCache* dlgCache = new CGUIDialogCache(5000, g_localizeStrings.Get(10214), item.GetLabel());

//is or could be a playlist
auto_ptr<CPlayList> pPlayList (CPlayListFactory::Create(item));
unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(item));
bool gotPlayList = (pPlayList.get() && pPlayList->Load(item.GetPath()));

if (dlgCache)
Expand Down
4 changes: 2 additions & 2 deletions xbmc/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace ADDON
{
class CSkinInfo;
class IAddon;
typedef boost::shared_ptr<IAddon> AddonPtr;
typedef std::shared_ptr<IAddon> AddonPtr;
}

namespace MEDIA_DETECT
Expand Down Expand Up @@ -408,7 +408,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode);

bool LoadSkin(const std::string& skinID);
bool LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);
bool LoadSkin(const std::shared_ptr<ADDON::CSkinInfo>& skin);

/*!
\brief Delegates the action to all registered action handlers.
Expand Down
6 changes: 3 additions & 3 deletions xbmc/ApplicationMessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void CApplicationMessenger::Cleanup()
void CApplicationMessenger::SendMessage(ThreadMessage& message, bool wait)
{
message.waitEvent.reset();
boost::shared_ptr<CEvent> waitEvent;
std::shared_ptr<CEvent> waitEvent;
if (wait)
{ // check that we're not being called from our application thread, else we'll be waiting
// forever!
Expand Down Expand Up @@ -212,7 +212,7 @@ void CApplicationMessenger::ProcessMessages()
//Leave here as the message might make another
//thread call processmessages or sendmessage

boost::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
lock.Leave(); // <- see the large comment in SendMessage ^

ProcessMessage(pMsg);
Expand Down Expand Up @@ -879,7 +879,7 @@ void CApplicationMessenger::ProcessWindowMessages()

// leave here in case we make more thread messages from this one

boost::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
std::shared_ptr<CEvent> waitEvent = pMsg->waitEvent;
lock.Leave(); // <- see the large comment in SendMessage ^

ProcessMessage(pMsg);
Expand Down
4 changes: 2 additions & 2 deletions xbmc/ApplicationMessenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "guilib/WindowIDs.h"
#include "threads/Thread.h"
#include <boost/shared_ptr.hpp>
#include <memory>

#include <queue>
#include "utils/GlobalsHandling.h"
Expand Down Expand Up @@ -121,7 +121,7 @@ typedef struct
int param2;
std::string strParam;
std::vector<std::string> params;
boost::shared_ptr<CEvent> waitEvent;
std::shared_ptr<CEvent> waitEvent;
void* lpVoid;
}
ThreadMessage;
Expand Down
Loading

0 comments on commit c096e7e

Please sign in to comment.