⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfunctiontype.cc

📁 C++ Reflection & Service Library
💻 CC
字号:
/* C++ Reflection & Serice Library * Copyright (C) 2003  Marcus Perlick * mailto: riffraff@users.sf.net *  * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *  * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. *  * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * This file is part of the "C++ Reflection & Serice Library" */#include "CFunctionType.hh"#include <cassert>#include "Exception.hh"namespace rfl {  void  CFunctionType::addArg( const Type& argumentType )  {    name_.resize( name_.size() - 1 );    if ( *name_.rbegin() != '(' ) {      name_ += ',';    }    name_ += argumentType.getName();    name_ += ')';    argv_.push_back( &argumentType );  }  /** \todo Can we do better for function types than specifying void(*)(void)   *  as the type to avcall? */  void  CFunctionType::avStartCall( av_alist& avList,			     void* fnPtr,			     void *retVal ) const  {    av_start_ptr( avList, fnPtr, void(*)(void), retVal );  }    void  CFunctionType::avPutArg( av_alist& avList, void* arg ) const  {    av_ptr( avList, void(*)(void), arg );  }    const Type&  CFunctionType::getElmType( std::size_t idx ) const  {    Exception x( X_NOELM,		 _("cannot get element type for class \'%s\'."),		 getName().c_str() );    throw x;  }  void*  CFunctionType::getElmAddr( void* obj, std::size_t idx ) const  {    Exception x( X_NOELM,		 _("cannot get element address for class \'%s\'."),		 getName().c_str() );    throw x;  }//  Will this stack-fiddeling collied, if it's interleaved?//  void//  CFunctionType::call( void* retObj, void* fnPtr, va_list ap )//  {//    void** args = (void**)alloca( argv_.size() );//    void** end = args + argv_.size();//    //    for ( void** it = args; it < end; it++ ) {//      *it = va_arg( ap, void* );//    }//    //    // OK, stack is clean. Prepare function call//    av_alist fnCall;////    assert( ret_ != 0 );//    ret_->avStartCall( fnCall, fnPtr, retObj );//    for ( unsigned int i = 0; i < argv_.size(); i++ ) {//      argv_[ i ]->avPutArg( fnCall, args[ i ] );//    }////    av_call( fnCall );//  }  void  CFunctionType::vCall( void* retObj, void* fnPtr, va_list ap )  {    void* arg;    av_alist fnCall;    assert( ret_ != 0 );    ret_->avStartCall( fnCall, fnPtr, retObj );    for ( unsigned int i = 0; i < argv_.size(); i++ ) {      arg = va_arg( ap, void* );      argv_[ i ]->avPutArg( fnCall, arg );    }    av_call( fnCall );  }  void  CFunctionType::vaCall( void* retObj, void* fnPtr, ... )  {    va_list ap;    va_start( ap, fnPtr );    vCall( retObj, fnPtr, ap );    va_end( ap );  }} // namespace rfl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -