Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2015, 1:51:40 PM (9 years ago)
Author:
landauf
Message:

use the same interface for static an member functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/network/FunctionCall.cc

    r10471 r10472  
    4747
    4848bool FunctionCall::execute(){
    49   if( this->bIsStatic_ )
     49  NetworkFunctionBase* fct = static_cast<NetworkFunctionStatic*>(NetworkFunctionManager::getFunction( this->functionID_ ));
     50  assert( this->nrOfArguments_==this->arguments_.size() );
     51  switch(this->nrOfArguments_)
    5052  {
    51     NetworkFunctionStatic *fct = static_cast<NetworkFunctionStatic*>(NetworkFunctionManager::getFunction( this->functionID_ ));
    52     assert( this->nrOfArguments_==this->arguments_.size() );
    53     switch(this->nrOfArguments_)
    54     {
    55       case 0:
    56         fct->call();
    57         break;
    58       case 1:
    59         fct->call(this->arguments_[0]);
    60         break;
    61       case 2:
    62         fct->call(this->arguments_[0], this->arguments_[1]);
    63         break;
    64       case 3:
    65         fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2]);
    66         break;
    67       case 4:
    68         fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
    69         break;
    70       case 5:
    71         fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
    72         break;
    73       default:
    74         assert(0);
    75     }
     53    case 0:
     54      return !fct->call(this->objectID_);
     55    case 1:
     56      return !fct->call(this->objectID_, this->arguments_[0]);
     57    case 2:
     58      return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
     59    case 3:
     60      return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
     61    case 4:
     62      return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
     63    case 5:
     64      return !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
     65    default:
     66      assert(0);
     67      return true; // return true to avoid that this functions gets called over and over again
    7668  }
    77   else // not a static function, so also handle with the objectID
    78   {
    79     NetworkMemberFunctionBase *fct = static_cast<NetworkMemberFunctionBase*>(NetworkFunctionManager::getFunction( this->functionID_ ));
    80     switch(this->nrOfArguments_)
    81     {
    82       case 0:
    83         if( !fct->call(this->objectID_) )
    84           return false;
    85         break;
    86       case 1:
    87         if( !fct->call(this->objectID_, this->arguments_[0]) )
    88           return false;
    89         break;
    90       case 2:
    91         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) )
    92           return false;
    93         break;
    94       case 3:
    95         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) )
    96           return false;
    97         break;
    98       case 4:
    99         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) )
    100           return false;
    101         break;
    102       case 5:
    103         if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) )
    104           return false;
    105         break;
    106       default:
    107         assert(0);
    108     }
    109   }
    110   return true;
    11169}
    11270
     
    148106  this->nrOfArguments_ = nrOfArguments;
    149107  this->size_ = callsize;
    150   this->bIsStatic_ = true;
    151108  this->functionID_ = networkID;
    152109}
     
    188145  }
    189146  this->nrOfArguments_ = nrOfArguments;
    190   this->bIsStatic_ = false;
    191147  this->functionID_ = networkID;
    192148  this->size_ = callsize;
     
    197153{
    198154  this->functionID_ = *(uint32_t*)mem;
    199   this->bIsStatic_ = *(uint8_t*)(mem+sizeof(uint32_t));
    200   this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t));
    201   if( this->bIsStatic_ )
    202   {
    203     mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
    204   }
    205   else
    206   {
    207     this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t));
    208     mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
    209   }
     155  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t));
     156  this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t));
     157  mem += 3*sizeof(uint32_t);
    210158  for( unsigned int i=0; i<this->nrOfArguments_; ++i )
    211159  {
     
    219167  // now serialise the mt values and copy the function id and isStatic
    220168  *(uint32_t*)mem = this->functionID_;
    221   *(uint8_t*)(mem+sizeof(uint32_t)) = this->bIsStatic_;
    222   *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)) = this->nrOfArguments_;
    223   if( this->bIsStatic_ )
    224   {
    225     mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
    226   }
    227   else
    228   {
    229     *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)) = this->objectID_;
    230     mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
    231   }
     169  *(uint32_t*)(mem+sizeof(uint32_t)) = this->nrOfArguments_;
     170  *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_;
     171  mem += 3*sizeof(uint32_t);
    232172  for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
    233173  {
Note: See TracChangeset for help on using the changeset viewer.