Changeset 735 in dev for trunk/ab5.0/abdev/ab_common/src/Lexical
- Timestamp:
- Aug 25, 2008, 5:26:44 PM (16 years ago)
- Location:
- trunk/ab5.0/abdev/ab_common/src/Lexical
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp
r728 r735 1 1 #include "stdafx.h" 2 2 #include <algorithm> 3 #include <boost/checked_delete.hpp> 3 4 4 5 CClass::CClass( const Symbol &symbol, const NamespaceScopesCollection &importedNamespaces ) … … 74 75 CClass::~CClass() 75 76 { 77 using std::for_each; 78 using boost::checked_deleter; 76 79 // 動的メンバ 77 BOOST_FOREACH( Member *member, dynamicMembers ) 78 { 79 delete member; 80 } 81 80 for_each( dynamicMembers.begin(), dynamicMembers.end(), checked_deleter<Member>() ); 82 81 // 静的メンバ 83 BOOST_FOREACH( Member *member, staticMembers ) 84 { 85 delete member; 86 } 87 82 for_each( staticMembers.begin(), staticMembers.end(), checked_deleter<Member>() ); 88 83 // インターフェイス 89 BOOST_FOREACH( ::Interface *pInterface, interfaces ) 90 { 91 delete pInterface; 92 } 93 84 for_each( interfaces.begin(), interfaces.end(), checked_deleter<::Interface>() ); 94 85 // テンプレート展開済みのクラス 95 BOOST_FOREACH( ExpandedTemplateClass *pExpandedTemplateClass, expandedTemplateClasses ) 96 { 97 delete pExpandedTemplateClass; 98 } 86 for_each( expandedTemplateClasses.begin(), expandedTemplateClasses.end(), checked_deleter<ExpandedTemplateClass>() ); 99 87 } 100 88 … … 233 221 { 234 222 //メソッドをコピー 235 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClass.GetDynamicMethods() ){ 223 const Methods& inheritsClassMethods = inheritsClass.GetDynamicMethods(); 224 GetDynamicMethods().reserve( inheritsClassMethods.size() ); 225 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClassMethods ){ 236 226 CMethod *pMethod = new DynamicMethod( *pBaseMethod ); 237 227 … … 264 254 265 255 // インターフェイスを引き継ぐ 266 BOOST_FOREACH( ::Interface *pInterface, inheritsClass.GetInterfaces() ) 256 const Interfaces& inheritsClassInterfaces = inheritsClass.GetInterfaces(); 257 interfaces.reserve( inheritsClassInterfaces.size() ); 258 BOOST_FOREACH( const ::Interface *pInterface, inheritsClassInterfaces ) 267 259 { 268 260 interfaces.push_back( new ::Interface( *pInterface ) ); … … 307 299 //メソッド 308 300 BOOST_FOREACH( const CMethod *pMethod, GetDynamicMethods() ){ 309 if( lstrcmp( name, pMethod->GetUserProc().GetName().c_str() ) == 0){301 if( name == pMethod->GetUserProc().GetName() ){ 310 302 return 1; 311 303 } … … 328 320 329 321 // 動的メンバ 330 BOOST_FOREACH( Member *pMember, dynamicMembers )322 BOOST_FOREACH( const Member *pMember, dynamicMembers ) 331 323 { 332 324 if( GetName() == pMember->GetName() ) … … 438 430 if( this->HasSuperClass() ) 439 431 { 432 const CClass& super = this->GetSuperClass(); 440 433 // 基底クラスのサイズを追加 441 resultSize += this->GetSuperClass().GetSize();434 resultSize += super.GetSize(); 442 435 443 436 // 基底クラスのアラインメントを取得 444 alignment = this->GetSuperClass().GetAlignment();437 alignment = super.GetAlignment(); 445 438 } 446 439 else … … 455 448 BOOST_FOREACH( Member *pMember, dynamicMembers ) 456 449 { 450 const Type& memberType = pMember->GetType(); 457 451 // メンバサイズ 458 int tempMemberSize = pMember->GetType().GetSize();452 int tempMemberSize = memberType.GetSize(); 459 453 460 454 // 一時アラインメントを算出 461 455 int tempAlignment = tempMemberSize; 462 if( pMember->GetType().IsStruct() )456 if( memberType.IsStruct() ) 463 457 { 464 458 // メンバが構造体の場合は、メンバのアラインメントを取得 465 tempAlignment = pMember->GetType().GetClass().GetAlignment();459 tempAlignment = memberType.GetClass().GetAlignment(); 466 460 } 467 461 … … 484 478 if( tempMemberSize == 0 ) 485 479 { 486 if( ! pMember->GetType().IsStruct() )480 if( !memberType.IsStruct() ) 487 481 { 488 482 throw; … … 847 841 if( result.size() ) 848 842 { 849 result += ",";850 } 851 852 result += "\"" + pMember->GetName() + "\"";843 result += ','; 844 } 845 846 result += '\"' + pMember->GetName() + '\"'; 853 847 } 854 848 … … 863 857 if( result.size() ) 864 858 { 865 result += ",";859 result += ','; 866 860 } 867 861 … … 869 863 870 864 char temporary[255]; 871 itoa( offset, temporary, 16 );865 _itoa( offset, temporary, 16 ); 872 866 873 867 result += (std::string)"&H" + temporary; -
trunk/ab5.0/abdev/ab_common/src/Lexical/Source.cpp
r706 r735 6 6 7 7 class CDefine{ 8 std ::vector<std::string> names;8 stdext::hash_set<std::string> names; 9 9 public: 10 void Free();10 // void Free(); 11 11 void Init( bool isDebug, bool isDll, bool isUnicode, int majorVer ); 12 12 13 BOOLadd(char const *name);14 BOOLundef(char const *name);15 BOOLcheck(char const *name);13 bool add(char const *name); 14 bool undef(char const *name); 15 bool check(char const *name); 16 16 void preprocessor_ifdef(char *buffer,bool isNot); 17 17 void DirectiveIfdef(char *buffer); … … 84 84 add(temporary); 85 85 } 86 BOOLCDefine::add(char const *name)86 bool CDefine::add(char const *name) 87 87 { 88 //重複チェック 89 if(check(name)) return 0; 90 91 //追加 92 names.push_back( name ); 93 94 return 1; 95 } 96 BOOL CDefine::undef(char const *name){ 97 std::vector<std::string>::iterator i = names.begin(); 98 BOOST_FOREACH( const std::string &temp, names ){ 99 if( temp == name ){ 100 names.erase( i ); 101 return 1; 102 } 103 i++; 104 } 105 106 return 0; 107 } 108 BOOL CDefine::check(char const *name){ 109 110 //重複チェック 111 BOOST_FOREACH( const std::string &temp, names ){ 112 if( temp == name ){ 113 return 1; 114 } 115 } 116 return 0; 88 return names.insert(name).second; 89 } 90 bool CDefine::undef(char const *name){ 91 return names.erase(name) > 0; 92 } 93 bool CDefine::check(char const *name){ 94 return names.find(name) != names.end(); 117 95 } 118 96 … … 167 145 168 146 //#ifdefの行を消去 169 Text::SlideString(buffer+i,-i); 170 i=0; 147 memset(buffer,' ',static_cast<size_t>(i)); 171 148 172 149 BOOL bElse=0; … … 304 281 temporary[i3]=buffer[i2]; 305 282 } 306 307 283 add(temporary); 308 309 i2-=i;310 311 284 //ディレクティブを消去 312 Text::SlideString(buffer+i+i2,-i2); 285 memset(buffer+i,' ',static_cast<size_t>(i2-i)); 286 i=i2; 313 287 } 314 288 if(memicmp(buffer+i,"#undef",6)==0){ 315 i2=i+ 7;289 i2=i+6; 316 290 while(buffer[i2]==' '||buffer[i2]=='\t') i2++; 317 291 … … 323 297 temporary[i3]=buffer[i2]; 324 298 } 325 326 299 undef(temporary); 327 328 i2-=i;329 330 300 //ディレクティブを消去 331 Text::SlideString(buffer+i+i2,-i2); 301 memset(buffer+i,' ',static_cast<size_t>(i2-i)); 302 i=i2; 332 303 } 333 304 else if(memicmp(buffer+i,"#ifdef",6)==0){ … … 367 338 368 339 return true; 340 } 341 342 //改行コードのCRLFをLFに変換 343 int ChangeReturnCodeImpl(char *buffer) 344 { 345 int i; 346 for(i=0;buffer[i]!='\0';i++){ 347 if(buffer[i]=='\r'&&buffer[i+1]=='\n'){ 348 buffer[i]=' '; 349 } 350 } 351 return i; 369 352 } 370 353 … … 418 401 #endif 419 402 420 //改行コードのCRLFをLFに変換 421 for(i=0,i2=0;;i++,i2++){ 422 if(buffer[i]=='\r'&&buffer[i+1]=='\n') i++; 423 buffer[i2]=buffer[i]; 424 if(buffer[i]=='\0') break; 425 } 403 ChangeReturnCodeImpl(buffer); 426 404 427 405 length = i; … … 471 449 if(buffer[i]=='\0') break; 472 450 } 473 st rcpy(buffer,temporary);451 std::swap(buffer,temporary); 474 452 free(temporary); 475 453 } … … 683 661 //カッコ'('直下の改行 684 662 while(buffer[0]=='\n'){ 685 Text::SlideString(buffer+1,-1);663 buffer[0]=' '; 686 664 (*pRnum)++; 687 665 }
Note:
See TracChangeset
for help on using the changeset viewer.