XDispatch 0.7.0
 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-2012 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
00106 # define XDISPATCH_BLOCK_PERSIST(A) Block_copy(A)
00107 # define XDISPATCH_BLOCK_COPY(A) Block_copy(A)
00108 # define XDISPATCH_BLOCK_DELETE(A) Block_release(A)
00109 # define XDISPATCH_BLOCK_EXEC(A) (A)
00110   //typedef void (^dispatch_block_t)(void);
00111  typedef void (^dispatch_iteration_block_t)(size_t);
00112  typedef dispatch_block_t dispatch_block_store;
00113  typedef dispatch_iteration_block_t dispatch_iteration_block_store;
00114 # define XDISPATCH_HAS_BLOCKS
00115 # if defined(__cplusplus) && !defined(__clang__)
00116 #  warning "Sadly blocks are currently broken in C++ on this platform, we recommend using gcc 4.5.1 or clang 2.0 instead"
00117 # endif
00118 
00119 // visual studio 2010
00120 #elif _MSC_VER >= 1600
00121 
00122 # include <functional>
00123 # define XDISPATCH_BLOCK [=]
00124 # ifndef XDISPATCH_NO_KEYWORDS
00125 #  define $ [=]
00126 # endif
00127 # define XDISPATCH_BLOCK_PERSIST(A) (A)
00128 # define XDISPATCH_BLOCK_COPY(A) (A)
00129 # define XDISPATCH_BLOCK_DELETE(A) {}
00130 # define XDISPATCH_BLOCK_EXEC(A) (A)
00131  typedef const std::tr1::function< void (void) >& dispatch_block_t;
00132  typedef const std::tr1::function< void (size_t) >& dispatch_iteration_block_t;
00133  typedef std::tr1::function< void (void) > dispatch_block_store;
00134  typedef std::tr1::function< void (size_t) > dispatch_iteration_block_store;
00135 # define XDISPATCH_HAS_BLOCKS
00136 
00137 // gcc 4.5 with c++0x enabled
00138 #elif defined __GXX_EXPERIMENTAL_CXX0X__
00139 
00140 # include <tr1/functional>
00141 # define XDISPATCH_BLOCK [=]
00142 # ifndef XDISPATCH_NO_KEYWORDS
00143 #  define $ [=]
00144 # endif
00145 # define XDISPATCH_BLOCK_PERSIST(A) (A)
00146 # define XDISPATCH_BLOCK_COPY(A) (A)
00147 # define XDISPATCH_BLOCK_DELETE(A) {}
00148 # define XDISPATCH_BLOCK_EXEC(A) (A)
00149  typedef const std::tr1::function< void (void) >& dispatch_block_t;
00150  typedef const std::tr1::function< void (size_t) >& dispatch_iteration_block_t;
00151  typedef std::tr1::function< void (void) > dispatch_block_store;
00152  typedef std::tr1::function< void (size_t) > dispatch_iteration_block_store;
00153 # define XDISPATCH_HAS_BLOCKS
00154 
00155 #else
00156 
00157 # define XDISPATCH_BLOCK "No Block support!"
00158 
00159 #endif
00160 
00161 #endif /* XDISPATCH_DOXYGEN_RUN */
00162 
00163 #ifdef XDISPATCH_DOXYGEN_RUN
00164 # define $ [=]
00165 #endif
00166 
00169 #endif /* XDISPATCH_LAMBDA_BLOCKS_H_ */

Generated on Tue Jun 12 2012 14:11:47 for XDispatch by Doxygen 1.8.0
© 2010-2012 MLBA (about | privacy) All Rights reserved.