XDispatch 0.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
lambda_blocks.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
00003 * Copyright (c) 2011-2013 MLBA-Team. All rights reserved.
00004 *
00005 * @MLBA_OPEN_LICENSE_HEADER_START@
00006 *
00007 * Licensed under the Apache License, Version 2.0 (the "License");
00008 * you may not use this file except in compliance with the License.
00009 * You may obtain a copy of the License at
00010 * 
00011 *     http://www.apache.org/licenses/LICENSE-2.0
00012 * 
00013 * Unless required by applicable law or agreed to in writing, software
00014 * distributed under the License is distributed on an "AS IS" BASIS,
00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 * See the License for the specific language governing permissions and
00017 * limitations under the License.
00018 *
00019 * @MLBA_OPEN_LICENSE_HEADER_END@
00020 */
00021 
00022 
00023 /* When building on 10.6 with gcc 4.5.1 we can bypass
00024     Apple's lambda functions implementation in C++ as we have lambdas.
00025        This prevents a lot of errors from occuring
00026        */
00027 
00028 #ifndef XDISPATCH_LAMBDA_BLOCKS_H_
00029 #define XDISPATCH_LAMBDA_BLOCKS_H_
00030 
00036 #ifndef __XDISPATCH_INDIRECT__
00037 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00038 #endif
00039 
00096 #ifndef XDISPATCH_DOXYGEN_RUN
00097 
00098 // clang 2.0, gcc 4.3 from mac os 10.6
00099 #ifdef __BLOCKS__
00100 # include <Block.h>
00101 # include <stddef.h>
00102 # define XDISPATCH_BLOCK ^
00103 # ifndef XDISPATCH_NO_KEYWORDS
00104 #  define $ ^
00105 # endif // XDISPATCH_NO_KEYWORDS
00106   //typedef void (^dispatch_block_t)(void);
00107  typedef void (^dispatch_iteration_block_t)(size_t);
00108 # define XDISPATCH_HAS_BLOCKS 1
00109 # if defined(__cplusplus) && !defined(__clang__)
00110 #  warning "Sadly blocks are currently broken in C++ on this platform, we recommend using gcc 4.5.1 or clang 2.0 instead"
00111 # endif
00112 #endif // __BLOCKS__
00113 
00114 // visual studio 2010
00115 #if _MSC_VER >= 1600
00116 
00117 # include <functional>
00118 # define XDISPATCH_BLOCK [=]
00119 # ifndef XDISPATCH_NO_KEYWORDS
00120 #  define $ [=]
00121 # endif
00122 
00123 __XDISPATCH_BEGIN_NAMESPACE
00124  typedef ::std::tr1::function< void (void) > lambda_function;
00125  typedef ::std::tr1::function< void (size_t) > iteration_lambda_function;
00126 __XDISPATCH_END_NAMESPACE
00127 
00128 # define XDISPATCH_HAS_LAMBDAS 1
00129 # define XDISPATCH_HAS_FUNCTION 1
00130 
00131 // visual studio 2008 sp1
00132 #elif _MSC_VER >= 1500
00133 
00134 # include <functional>
00135 
00136 __XDISPATCH_BEGIN_NAMESPACE
00137  typedef ::std::tr1::function< void (void) > lambda_function;
00138  typedef ::std::tr1::function< void (size_t) > iteration_lambda_function;
00139 __XDISPATCH_END_NAMESPACE
00140 
00141 # define XDISPATCH_HAS_FUNCTION 1
00142 
00143 // g++,clang++ / gnu compiler collection
00144 #elif defined(__GNUC__) || defined(__clang__)
00145 
00146 // gcc 4.5 with c++0x enabled
00147 # if defined(__GXX_EXPERIMENTAL_CXX0X__)
00148 #  ifndef XDISPATCH_HAS_BLOCKS
00149 #   define XDISPATCH_BLOCK [=]
00150 #   ifndef XDISPATCH_NO_KEYWORDS
00151 #    define $ [=]
00152 #   endif // XDISPATCH_NO_KEYWORDS
00153 #  endif // XDISPATCH_HAS_BLOCKS
00154 #  define XDISPATCH_HAS_LAMBDAS 1
00155 # endif // __GXX_EXPERIMENTAL_CXX0X__
00156 
00157 #  include <tr1/functional>
00158 
00159 __XDISPATCH_BEGIN_NAMESPACE
00160  typedef ::std::tr1::function< void (void) > lambda_function;
00161  typedef ::std::tr1::function< void (size_t) > iteration_lambda_function;
00162 __XDISPATCH_END_NAMESPACE
00163 
00164 # define XDISPATCH_HAS_FUNCTION 1
00165 
00166 #else
00167 
00168 # error "Unsupported compiler version"
00169 
00170 #endif
00171 
00172 #endif /* XDISPATCH_DOXYGEN_RUN */
00173 
00174 #ifdef XDISPATCH_DOXYGEN_RUN
00175 # define $ [=]
00176 #endif
00177 
00180 #endif /* XDISPATCH_LAMBDA_BLOCKS_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sun Jan 27 2013 21:21:52 for XDispatch by Doxygen 1.7.6.1
© 2010-2013 MLBA (about | privacy) All Rights reserved.