📄 functiontype.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 "FunctionType.hh"#include <cstdarg>#include <cassert>#include "align.hh"namespace rfl { mpu::String mkFnName( const Type& returnType ) { mpu::String tmp = returnType.getName(); tmp += "(*)()"; return tmp; } /** \todo Can we do better for function types than specifying void(*)(void) * as the type to avcall? */ FunctionType::FunctionType( const Type& returnType ): Type( ID_FUNCTION, mkFnName( returnType ), sizeof(void(*)(void)), AlignmentOf<void(*)(void)>::is(), 0, 0, 0, 0, 0, 0, 0, 0 ), ret_( &returnType ) {} unsigned long FunctionType::hash( void ) const { unsigned long ret = ID_FUNCTION; assert( ret_ != 0 ); updateHash( ret, ret_->hash() ); ArgVector::const_iterator end = argv_.end(); for ( ArgVector::const_iterator it = argv_.begin(); it != end; ++it ) { assert( *it != 0 ); updateHash( ret, (*it)->hash() ); } return ret; } bool FunctionType::operator==( const Type& type ) const { if ( type.getId() != ID_FUNCTION ) return false; assert( ret_ != 0 ); assert( static_cast<const FunctionType&>(type).ret_ != 0 ); const FunctionType& fty = static_cast<const FunctionType&>(type); if ( *ret_ != *fty.ret_ ) return false; ArgVector::const_iterator end = argv_.end(); ArgVector::const_iterator fIt = fty.argv_.end(); for ( ArgVector::const_iterator it = argv_.begin(); it != end; ++it ) { if ( (**it) != (**fIt) ) return false; } return true; }} // namespace rfl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -