Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 18, 2009, 6:23:31 PM (16 years ago)
Author:
rgrieder
Message:

Merged netp6 branch back to the trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/NetworkFunction.h

    r3214 r3304  
    3737#include <string>
    3838#include <boost/preprocessor/cat.hpp>
     39#include <boost/static_assert.hpp>
    3940
    4041#include "core/OrxonoxClass.h"
     
    4647{
    4748
    48 #ifdef ORXONOX_COMPILER_GCC
     49#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    4950static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
    50 #else //ORXONOX_COMPILER_GCC
     51#else
    5152static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
    5253#endif //ORXONOX_COMPILER_GCC
     
    5758  bool operator<(const NetworkFunctionPointer& b) const
    5859  {
    59 #ifdef ORXONOX_COMPILER_GCC
     60#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    6061    return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
    6162#else //ORXONOX_COMPILER_GCC
     
    8081   
    8182    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();
    8285   
    8386  protected:
     
    193196template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
    194197{
    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));
    196200  T p2 = ptr;
    197201  memcpy( &destptr, &p2, sizeof(T) );
     
    202206template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
    203207{
     208  BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
    204209  NetworkFunctionPointer destptr;
    205210  copyPtr( ptr, destptr );
     
    210215template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
    211216{
     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
    212218  NetworkFunctionPointer destptr;
    213219  copyPtr( ptr, destptr );
Note: See TracChangeset for help on using the changeset viewer.