Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed Jan 7, 2015
2 parents 5adbc25 + db7b373 commit da6fbd1
Show file tree
Hide file tree
Showing 5,723 changed files with 451,991 additions and 326,538 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 7 additions & 7 deletions .travis.yml
Expand Up @@ -10,7 +10,7 @@ before_install:
- ./scripts/copyright_check.sh

# g++4.8.1
- if [ "$CXX" == "g++" ]; then
- if [ "$CXX" == "g++" ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
&& export CXX;
fi
Expand All @@ -24,14 +24,14 @@ before_install:
- sudo apt-get -qq update

install:
# CMake 3.0
# CMake 3.1
- sudo apt-get -qq install libc6-i386
&& wget http://www.cmake.org/files/v3.0/cmake-3.0.2-Linux-i386.tar.gz
&& tar -xzf cmake-3.0.2-Linux-i386.tar.gz
&& sudo cp -fR cmake-3.0.2-Linux-i386/* /usr
&& wget http://www.cmake.org/files/v3.1/cmake-3.1.0-Linux-i386.tar.gz
&& tar -xzf cmake-3.1.0-Linux-i386.tar.gz
&& sudo cp -fR cmake-3.1.0-Linux-i386/* /usr

# g++4.8.1
- if [ "$CXX" = "g++" ]; then
- if [ "$CXX" = "g++" ]; then
sudo apt-get install -qq gcc-4.8 g++-4.8
&& export CXX="g++-4.8"
&& sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
Expand Down Expand Up @@ -59,7 +59,7 @@ script:
- sudo cpack || (cat _CPack_Packages/Linux/TGZ/InstallOutput.log; exit 1)

# Build examples from installed Autowiring
- cd examples
- cd examples
&& cmake . -Dautowiring_ARCHITECTURE=x64
&& make
&& cd ..
Expand Down
23 changes: 16 additions & 7 deletions CMakeLists.txt
Expand Up @@ -59,7 +59,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
message(FATAL_ERROR "GCC version 4.8 minimum is required to build Autowiring")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif (MSVC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18.0")
message(FATAL_ERROR "MSVC 2013 minimum is required to build Autowiring")
endif()
Expand All @@ -73,7 +73,7 @@ if(NOT WIN32)
endif()

# Clang needs special additional flags to build with C++11
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead
if(autowiring_USE_LIBCXX)
message(STATUS "AppleClang C++11")
Expand All @@ -84,10 +84,10 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "Clang C++11")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "GCC C++11")
endif()

Expand Down Expand Up @@ -117,7 +117,7 @@ if(AUTOWIRING_IS_EMBEDDED)
set(AUTOWIRING_BUILD_TESTS_DEFAULT OFF)
else()
set(AUTOWIRING_BUILD_TESTS_DEFAULT ON)

# All of our binaries go to one place: The binaries output directory. We only want to tinker
# with this if we're building by ourselves, otherwise we just do whatever the enclosing project
# wants us to do.
Expand Down Expand Up @@ -213,12 +213,21 @@ if(NOT AUTOWIRING_IS_EMBEDDED)

# Install public header files
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/autowiring/
DESTINATION include/autowiring
DIRECTORY ${PROJECT_SOURCE_DIR}/autowiring
DESTINATION include
COMPONENT autowiring
FILES_MATCHING PATTERN "*.h"
)

# Install autoboost headers
if(NOT autowiring_USE_LIBCXX)
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/contrib/autoboost/autoboost
DESTINATION include
COMPONENT autowiring
)
endif()

# Targets file is needed in order to describe how to link Autowiring to the rest of the system
install(EXPORT AutowiringTargets FILE AutowiringTargets.cmake COMPONENT autowiring NAMESPACE Autowiring:: DESTINATION cmake CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})

Expand Down
23 changes: 19 additions & 4 deletions autowiring-configVersion.cmake.in
@@ -1,4 +1,7 @@
set(PACKAGE_VERSION "@autowiring_VERSION@")
set(PACKAGE_VERSION_MAJOR "@autowiring_VERSION_MAJOR@")
set(PACKAGE_VERSION_MINOR "@autowiring_VERSION_MINOR@")
set(PACKAGE_VERSION_PATCH "@autowiring_VERSION_PATCH@")

if(autowiring_DEBUG)
message(STATUS "Debug mode on")
Expand Down Expand Up @@ -69,7 +72,7 @@ endforeach()

# Determine whether the user's request (either implied or explicit) for libstdc++ can
# be met by this verison of Autowiring
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# If this value isn't defined, then we assume the user's request is "on"
if(NOT DEFINED autowiring_USE_LIBCXX)
SET(autowiring_USE_LIBCXX ON)
Expand All @@ -92,12 +95,24 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
endif()
endif()

# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
if(autowiring_DEBUG)
message(STATUS "Our version is less than the requested one, trivially incompatible")
endif()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
elseif(NOT PACKAGE_FIND_VERSION_MINOR EQUAL PACKAGE_VERSION_MINOR)
if(autowiring_DEBUG)
message(STATUS "Minor version mismatch, requested minor is ${PACKAGE_FIND_VERSION_MINOR}, this version is ${PACKAGE_VERSION_MINOR}")
endif()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
elseif(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR)
if(autowiring_DEBUG)
message(STATUS "Major version mismatch, failure.")
endif()
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
if (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()

Expand Down
22 changes: 10 additions & 12 deletions autowiring/AutoConfigManager.h
Expand Up @@ -2,11 +2,12 @@
#pragma once
#include "autowiring_error.h"
#include "ConfigRegistry.h"
#include "ContextMember.h"
#include <string>
#include <sstream>
#include <vector>
#include STL_UNORDERED_MAP
#include STL_UNORDERED_SET
#include MUTEX_HEADER
#include MEMORY_HEADER

struct AnySharedPointer;
Expand Down Expand Up @@ -43,6 +44,10 @@ class AutoConfigManager:
// map of callbacks registered for a key
std::unordered_map<std::string, std::vector<t_callback>> m_callbacks;

// Exception throwers:
void ThrowKeyNotFoundException(const std::string& key) const;
void ThrowTypeMismatchException(const std::string& key, const std::type_info& ti) const;

public:
/// <summary>
/// Check if this key has been set
Expand Down Expand Up @@ -73,18 +78,11 @@ class AutoConfigManager:
template<class T>
void Set(const std::string& key, const T& value) {

if (!s_registry.count(key)) {
std::stringstream ss;
ss << "No configuration found for key '" << key << "'";
throw autowiring_error(ss.str());
}
if (!s_registry.count(key))
ThrowKeyNotFoundException(key);

if (!s_registry.find(key)->second->verifyType(typeid(T))) {
std::stringstream ss;
ss << "Attempting to set config '" << key << "' with incorrect type '"
<< autowiring::demangle(typeid(T)) << "'";
throw autowiring_error(ss.str());
}
if (!s_registry.find(key)->second->verifyType(typeid(T)))
ThrowTypeMismatchException(key, typeid(T));

// Set value in this AutoConfigManager
SetRecursive(key, AnySharedPointer(std::make_shared<T>(value)));
Expand Down
3 changes: 0 additions & 3 deletions autowiring/AutoFilterDescriptor.h
Expand Up @@ -8,9 +8,6 @@
#include "has_autofilter.h"
#include "is_shared_ptr.h"
#include MEMORY_HEADER
#include FUNCTIONAL_HEADER
#include STL_UNORDERED_SET
#include STL_UNORDERED_MAP

class AutoPacket;
class Deferred;
Expand Down
19 changes: 8 additions & 11 deletions autowiring/AutoPacket.h
Expand Up @@ -6,20 +6,16 @@
#include "AutoCheckout.h"
#include "DecorationDisposition.h"
#include "demangle.h"
#include "hash_tuple.h"
#include "is_any.h"
#include "is_shared_ptr.h"
#include "MicroAutoFilter.h"
#include "ObjectPool.h"
#include "TeardownNotifier.h"
#include <list>
#include <sstream>
#include <typeinfo>
#include CHRONO_HEADER
#include MEMORY_HEADER
#include TYPE_INDEX_HEADER
#include STL_UNORDERED_MAP
#include EXCEPTION_PTR_HEADER
#include MUTEX_HEADER

class AutoPacket;
class AutoPacketInternal;
Expand Down Expand Up @@ -176,6 +172,11 @@ class AutoPacket:
/// </remarks>
std::list<DecorationDisposition> GetDispositions(const std::type_info& ti) const;

/// <summary>
/// Throws a formatted runtime error corresponding to the case where an absent decoration was demanded
/// </summary>
static void ThrowNotDecoratedException(const std::type_info& ti);

public:
/// <returns>
/// True if this packet posesses a decoration of the specified type
Expand All @@ -198,12 +199,8 @@ class AutoPacket:
static_assert(!std::is_same<T, AnySharedPointer>::value, "Oops!");

const T* retVal;
if(!Get(retVal)) {
std::stringstream ss;
ss << "Attempted to obtain a type " << autowiring::demangle(retVal)
<< " which was not decorated on this packet";
throw std::runtime_error(ss.str());
}
if (!Get(retVal))
ThrowNotDecoratedException(typeid(auto_id<T>));
return *retVal;
}

Expand Down
15 changes: 2 additions & 13 deletions autowiring/AutoPacketFactory.h
@@ -1,20 +1,16 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include "Autowired.h"
#include "AutoPacket.h"
#include "AutoFilterDescriptor.h"
#include "ContextMember.h"
#include "CoreRunnable.h"
#include "TypeRegistry.h"
#include <list>
#include <vector>
#include CHRONO_HEADER
#include TYPE_INDEX_HEADER
#include TYPE_TRAITS_HEADER
#include STL_UNORDERED_SET

struct AdjacencyEntry;
class AutoPacketFactory;
class Deferred;
class DispatchQueue;
class AutoPacketInternal;

Expand All @@ -33,9 +29,6 @@ class AutoPacketFactory:
~AutoPacketFactory(void);

private:
// Parent packet factory, if one exists:
Autowired<AutoPacketFactory> m_parent;

// Lock for this type
mutable std::mutex m_lock;

Expand All @@ -60,9 +53,6 @@ class AutoPacketFactory:
// Returns the internal outstanding count, for use with AutoPacket
std::shared_ptr<void> GetInternalOutstanding(void);

// Recursive invalidation routine, causes AutoPacket object pools to be dumped to the root
void Invalidate(void);

// Utility override, does nothing
void AddSubscriber(std::false_type) {}

Expand Down Expand Up @@ -177,8 +167,7 @@ class AutoPacketFactory:

// Extern explicit template instantiation declarations added to prevent
// exterior instantation of internally used template instances
extern template class ObjectPool<AutoPacket>;
extern template class RegType<AutoPacketFactory>;
extern template struct SlotInformationStump<AutoPacketFactory, false>;
extern template const std::shared_ptr<AutoPacketFactory>& SharedPointerSlot::as<AutoPacketFactory>(void) const;
extern template std::shared_ptr<AutoPacketFactory> autowiring::fast_pointer_cast<AutoPacketFactory, Object>(const std::shared_ptr<Object>& Other);
extern template class RegType<AutoPacketFactory>;
47 changes: 38 additions & 9 deletions autowiring/AutowirableSlot.h
Expand Up @@ -125,8 +125,7 @@ class AutowirableSlot:
typedef T value_type;

AutowirableSlot(const std::shared_ptr<CoreContext>& ctxt) :
DeferrableAutowiring(AnySharedPointerT<T>(), ctxt),
m_fast_pointer_cast(&autowiring::fast_pointer_cast<T, Object>)
DeferrableAutowiring(AnySharedPointerT<T>(), ctxt)
{
SlotInformationStackLocation::RegisterSlot(this);
}
Expand All @@ -135,18 +134,40 @@ class AutowirableSlot:
CancelAutowiring();
}

std::shared_ptr<T>(*const m_fast_pointer_cast)(const std::shared_ptr<Object>&);

/// <remarks>
/// Shadowing GetType call, provided here as a virtual function optimization
/// </remarks>
const std::type_info& GetType(void) const {
return typeid(T);
}

bool IsAutowired(void) const { return !!get(); }
bool IsAutowired(void) const {
// If the user wishes to know if this type is instantiated, we will require that a full definition
// of this type MUST be available. The reason for this is that, if the user wishes to know if a
// type is autowired, they are required at a minimum to know what that type's inheritance relations
// are to other types in the system.
(void) autowiring::fast_pointer_cast_initializer<T, Object>::sc_init;
return !!get();
}

/// <remarks>
/// Obtains a pointer to the underlying type, if autowired
/// </remarks>
T* get(void) const {
// For now, we require that the full type be available to use this method
(void) autowiring::fast_pointer_cast_initializer<T, Object>::sc_init;
return get_unsafe();
}

/// <remarks>
/// Obtains a pointer to the underlying type, if autowired
/// </remarks>
/// <remarks>
/// Users are STRONGLY discouraged from making use of this routine. This function does not cause
/// any runtime type information about T to wind up in any of Autowiring's type registries, and
/// this may prevent the type from ever being detected as autowirable as a result.
/// </remarks>
T* get_unsafe(void) const {
return
static_cast<const AnySharedPointerT<T>*>(
static_cast<const AnySharedPointer*>(
Expand All @@ -155,15 +176,23 @@ class AutowirableSlot:
)->slot()->get().get();
}

T* operator->(void) const {
return get();
}

explicit operator bool(void) const {
return IsAutowired();
}

T* operator->(void) const {
// Initialize any blind fast casts to the actually desired type. This is one of a few points
// where we can guarantee that the type will be completely defined, because the user is about
// to make use of this type.
(void) autowiring::fast_pointer_cast_initializer<T, Object>::sc_init;
return get();
}

T& operator*(void) const {
// We have to initialize here, in the operator context, because we don't actually know if the
// user will be making use of this type.
(void) autowiring::fast_pointer_cast_initializer<T, Object>::sc_init;

return *get();
}

Expand Down

0 comments on commit da6fbd1

Please sign in to comment.