Changeset 3304 for code/trunk/src/network/NetworkFunction.h
- Timestamp:
- Jul 18, 2009, 6:23:31 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/netp6 (added) merged: 3215,3226-3227,3229-3231,3240,3242,3251-3252,3256,3258-3259,3263-3264,3267-3268,3277,3283-3284,3289,3298-3299,3302
- Property svn:mergeinfo changed
-
code/trunk/src/network/NetworkFunction.h
r3214 r3304 37 37 #include <string> 38 38 #include <boost/preprocessor/cat.hpp> 39 #include <boost/static_assert.hpp> 39 40 40 41 #include "core/OrxonoxClass.h" … … 46 47 { 47 48 48 #if def ORXONOX_COMPILER_GCC49 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32) 49 50 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8; 50 #else //ORXONOX_COMPILER_GCC51 #else 51 52 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16; 52 53 #endif //ORXONOX_COMPILER_GCC … … 57 58 bool operator<(const NetworkFunctionPointer& b) const 58 59 { 59 #if def ORXONOX_COMPILER_GCC60 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32) 60 61 return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1]; 61 62 #else //ORXONOX_COMPILER_GCC … … 80 81 81 82 static inline void setNetworkID(const std::string& name, uint32_t id){ assert( nameMap_.find(name)!=nameMap_.end() ); nameMap_[name]->setNetworkID(id); } 83 84 static void destroyAllNetworkFunctions(); 82 85 83 86 protected: … … 193 196 template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr) 194 197 { 195 memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T)); 198 if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0) 199 memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T)); 196 200 T p2 = ptr; 197 201 memcpy( &destptr, &p2, sizeof(T) ); … … 202 206 template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name ) 203 207 { 208 BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above 204 209 NetworkFunctionPointer destptr; 205 210 copyPtr( ptr, destptr ); … … 210 215 template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name ) 211 216 { 217 BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above 212 218 NetworkFunctionPointer destptr; 213 219 copyPtr( ptr, destptr );
Note: See TracChangeset
for help on using the changeset viewer.