?? type.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 "Type.hh"#include "Exception.hh"namespace rfl { void Type::create( void* addr ) const { if ( create_ ) { create_( this, addr ); } else { Exception x( X_NO_STD_CTOR, _("class %s has no standard constructor."), name_.c_str() ); throw x; } } void Type::create( void* addr, const void* obj ) const { if ( cCreate_ ) { cCreate_( this, addr, obj ); } else { Exception x( X_NO_CPY_CTOR, _("class %s has no copy constructor."), name_.c_str() ); throw x; } } void Type::destroy( void* obj ) const { if ( destroy_ ) { destroy_( this, obj ); } else { Exception x( X_NO_DESTROY, _("class %s has no destructor."), name_.c_str() ); throw x; } } void Type::assign( void* dst, const void* src ) const { if ( assign_ ) { assign_( this, dst, src ); } else { Exception x( X_NO_ASSIGN, _("class %s ha no assignment operator"), name_.c_str() ); throw x; } } void* Type::newObj( void ) const { if ( newObj_ ) { return newObj_( this ); } void* ret = std::malloc( getSize() ); if ( ret ) { create( ret ); } return ret; } void* Type::newObj( const void* obj ) const { if ( newCopy_ ) { return newCopy_( this, obj ); } void* ret = std::malloc( getSize() ); if ( ret ) { create( ret, obj ); } return ret; } void Type::delObj( void* obj ) const { if ( delObj_ ) { delObj_( this, obj ); } else if ( !newObj_ && !newCopy_ ) { destroy( obj ); std::free( obj ); } else { Exception x( X_MISS_DELETE, _("trying to call std::free() for object of class %s "\ "that might have been allocated another way."), name_.c_str() ); throw x; } } class VoidType : public Type { public: VoidType( void ) : Type( ID_VOID, "void", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) {} virtual void avStartCall( av_alist& avList, void* fnPtr, void* ) const; virtual void avPutArg( av_alist& avList, void* arg ) const; virtual const Type& getElmType( std::size_t idx ) const; virtual void* getElmAddr( void* obj, std::size_t idx ) const; virtual unsigned long hash( void ) const { return getId(); } virtual bool operator==( const Type& type ) const { return type.getId() == ID_VOID; } }; void VoidType::avStartCall( av_alist& avList, void* fnPtr, void* ) const { av_start_void( avList, fnPtr ); } void VoidType::avPutArg( av_alist& avList, void* arg ) const { Exception x( X_AV_VOIDARG, _("it's not allowed to pass a void argument to a reflected "\ "function.") ); throw x; } const Type& VoidType::getElmType( std::size_t idx ) const { Exception x( X_NOELM, _("cannot get element type for class \'void\'.") ); throw x; } void* VoidType::getElmAddr( void* obj, std::size_t idx ) const { Exception x( X_NOELM, _("cannot get element address for class \'void\'.") ); throw x; } static VoidType theVoid_t; const Type& TypeVoid = theVoid_t;} // namespace rfl
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -