Changeset 190 in dev
- Timestamp:
- Jun 26, 2007, 12:05:36 AM (17 years ago)
- Location:
- trunk/jenga
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/common/BoostXmlSupport.h
r189 r190 8 8 #include <boost/archive/xml_oarchive.hpp> 9 9 #include <boost/archive/xml_iarchive.hpp> 10 #include <boost/serialization/serialization.hpp> 11 #include <boost/serialization/string.hpp> 12 #include <boost/serialization/access.hpp> 13 #include <boost/serialization/export.hpp> 14 #include <boost/serialization/level.hpp> 15 #include <boost/serialization/vector.hpp> 16 #include <boost/serialization/map.hpp> 17 #include <boost/serialization/nvp.hpp> 18 #include <boost/serialization/version.hpp> 19 #include <boost/serialization/is_abstract.hpp> 10 20 11 21 namespace Jenga{ -
trunk/jenga/include/smoothie/Class.h
r181 r190 1 1 #pragma once 2 3 #include <jenga/include/common/BoostXmlSupport.h> 2 4 3 5 #include "Prototype.h" … … 83 85 84 86 CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ); 87 CClass() 88 : Prototype() 89 { 90 } 85 91 ~CClass(); 86 92 … … 259 265 CClass *pobj_NextClass; 260 266 261 267 // XMLシリアライズ用 268 private: 269 friend class boost::serialization::access; 270 template<class Archive> void serialize(Archive& ar, const unsigned int version) 271 { 272 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Prototype ); 273 ar & BOOST_SERIALIZATION_NVP( classType ); 274 } 275 276 277 public: 262 278 static bool SplitName( const char *desc, char *object, char *member, CClass::RefType &refType ){ 263 279 int lastIndex = -1; … … 305 321 class Classes 306 322 { 307 int hash(const char *name) const;323 int GetHashCode(const char *name) const; 308 324 void DestroyClass(CClass *pobj_c); 309 325 public: … … 318 334 319 335 virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name) = 0; 336 bool Insert( CClass *pClass ); 320 337 CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); 321 338 … … 360 377 ///////////////////// 361 378 private: 362 CClass **ppobj_IteClass;363 int iIteMaxNum;364 int iIteNextNum;365 public: 366 void Iterator_Init( void);367 void Iterator_Reset( void);368 BOOL Iterator_HasNext( void);369 CClass *Iterator_GetNext( void);370 int Iterator_GetMaxCount( void);379 mutable CClass **ppobj_IteClass; 380 mutable int iIteMaxNum; 381 mutable int iIteNextNum; 382 public: 383 void Iterator_Init() const; 384 void Iterator_Reset() const; 385 BOOL Iterator_HasNext() const; 386 CClass *Iterator_GetNext() const; 387 int Iterator_GetMaxCount() const; 371 388 }; -
trunk/jenga/include/smoothie/ObjectModule.h
r187 r190 1 1 #pragma once 2 3 #include <jenga/include/common/BoostXmlSupport.h>4 2 5 3 #include "TypeDef.h" … … 9 7 10 8 // プロジェクト中に存在するメタ情報 11 class Meta : public Jenga::Common::BoostXmlSupport<Meta>9 class Meta 12 10 { 13 Classes *pClasses;14 11 ProcPointers *pProcPointers; 15 12 public: 16 13 17 Meta( Classes *pNewClasses, ProcPointers *pNewProcPointers ) 18 : pClasses( pNewClasses ) 19 , pProcPointers( pNewProcPointers ) 14 Meta( ProcPointers *pNewProcPointers ) 15 : pProcPointers( pNewProcPointers ) 16 { 17 } 18 Meta() 20 19 { 21 20 } 22 21 ~Meta() 23 22 { 24 delete pClasses;25 23 delete pProcPointers; 26 24 } … … 30 28 31 29 // クラス 32 Classes &GetClasses() 33 { 34 return *pClasses; 35 } 36 void SetClasses( Classes *pClasses ) 37 { 38 this->pClasses = pClasses; 39 } 30 virtual Classes &GetClasses() = 0; 31 virtual void SetClasses( Classes *pClasses ) = 0; 32 virtual bool AutoWrite( const std::string &filePath ) = 0; 40 33 41 34 // TypeDef … … 53 46 // XMLシリアライズ用 54 47 private: 55 virtual const char *RootTagName() const56 {57 return "meta";58 }59 48 friend class boost::serialization::access; 60 49 template<class Archive> void serialize(Archive& ar, const unsigned int version) 61 50 { 62 //ar & BOOST_SERIALIZATION_NVP( pClasses );63 51 } 64 52 }; 65 66 67 #define DEF_XML_SCHEMA( node ) BOOST_CLASS_IMPLEMENTATION( node, boost::serialization::object_serializable );68 69 // ノード クラスを追加したらここでも定義する70 DEF_XML_SCHEMA( Meta )71 72 #undef DEF_XML_SCHEMA -
trunk/jenga/include/smoothie/Prototype.h
r170 r190 4 4 #include <vector> 5 5 6 #include "Namespace.h" 6 #include <jenga/include/common/BoostXmlSupport.h> 7 8 #include "Symbol.h" 7 9 8 10 using namespace std; … … 11 13 class UserProc; 12 14 13 class Prototype 15 class Prototype : public Symbol 14 16 { 15 17 public: … … 22 24 23 25 private: 24 // 名前空間25 NamespaceScopes namespaceScopes;26 27 //名前28 string name;29 30 26 mutable bool isUsing; 31 27 … … 33 29 34 30 Prototype( const NamespaceScopes &namespaceScopes, const string &name ) 35 : namespaceScopes( namespaceScopes ) 36 , name( name ) 31 : Symbol( namespaceScopes, name ) 37 32 , isUsing( false ) 33 { 34 } 35 Prototype() 36 : Symbol() 38 37 { 39 38 } 40 39 ~Prototype() 41 40 { 42 }43 44 // 名前空間45 const NamespaceScopes &GetNamespaceScopes() const46 {47 return namespaceScopes;48 }49 50 const string &GetName() const51 {52 return name;53 41 } 54 42 … … 75 63 { 76 64 isUsing = true; 65 } 66 67 // XMLシリアライズ用 68 private: 69 friend class boost::serialization::access; 70 template<class Archive> void serialize(Archive& ar, const unsigned int version) 71 { 72 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Symbol ); 77 73 } 78 74 -
trunk/jenga/include/smoothie/Smoothie.h
r181 r190 7 7 class Smoothie{ 8 8 static bool isUnicode; 9 10 static Meta meta;11 9 public: 12 10 … … 20 18 } 21 19 22 static Meta &GetMeta() 23 { 24 return meta; 25 } 20 static Meta &GetMeta(); 26 21 27 22 class Lexical{ -
trunk/jenga/include/smoothie/Symbol.h
r170 r190 3 3 #include <vector> 4 4 #include <string> 5 6 #include <jenga/include/common/BoostXmlSupport.h> 5 7 6 8 #include "Namespace.h" … … 20 22 Symbol( const char *fullName ); 21 23 Symbol( const string &fullName ); 24 Symbol() 25 { 26 } 22 27 23 28 const NamespaceScopes &GetNamespaceScopes() const … … 29 34 return name; 30 35 } 36 37 private: 38 friend class boost::serialization::access; 39 template<class Archive> void serialize(Archive& ar, const unsigned int version) 40 { 41 //ar & BOOST_SERIALIZATION_NVP( namespaceScopes ); 42 ar & BOOST_SERIALIZATION_NVP( name ); 43 } 31 44 }; -
trunk/jenga/src/smoothie/Class.cpp
r186 r190 310 310 311 311 312 int Classes:: hash(const char *name) const{312 int Classes::GetHashCode(const char *name) const{ 313 313 int key; 314 314 … … 377 377 { 378 378 int key; 379 key= hash(name.c_str());379 key=GetHashCode(name.c_str()); 380 380 381 381 if( namespaceScopes.size() == 0 && name == "Object" ){ … … 420 420 } 421 421 422 bool Classes::Insert( CClass *pClass ) 423 { 424 ///////////////////////////////// 425 // ハッシュデータに追加 426 ///////////////////////////////// 427 428 int key; 429 key=GetHashCode( pClass->GetName().c_str() ); 430 431 if(pobj_ClassHash[key]){ 432 CClass *pobj_c2; 433 pobj_c2=pobj_ClassHash[key]; 434 while(1){ 435 if( pobj_c2->IsEqualSymbol( *pClass ) ){ 436 //名前空間及びクラス名が重複した場合 437 SmoothieException::Throw(15,pClass->GetName()); 438 return false; 439 } 440 441 if(pobj_c2->pobj_NextClass==0) break; 442 pobj_c2=pobj_c2->pobj_NextClass; 443 } 444 pobj_c2->pobj_NextClass=pClass; 445 } 446 else{ 447 pobj_ClassHash[key]=pClass; 448 } 449 return true; 450 } 422 451 CClass *Classes::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){ 423 452 ////////////////////////////////////////////////////////////////////////// … … 426 455 ////////////////////////////////////////////////////////////////////////// 427 456 428 CClass *p obj_c= Create(namespaceScopes, importedNamespaces, name);457 CClass *pClass = Create(namespaceScopes, importedNamespaces, name); 429 458 430 459 if(lstrcmp(name,"String")==0){ 431 460 //Stringクラス 432 pStringClass=p obj_c;461 pStringClass=pClass; 433 462 } 434 463 if( lstrcmp( name, "Object" ) == 0 ){ 435 pObjectClass = pobj_c; 436 } 437 438 439 ///////////////////////////////// 440 // ハッシュデータに追加 441 ///////////////////////////////// 442 443 int key; 444 key=hash(name); 445 446 if(pobj_ClassHash[key]){ 447 CClass *pobj_c2; 448 pobj_c2=pobj_ClassHash[key]; 449 while(1){ 450 if( pobj_c2->IsEqualSymbol( namespaceScopes, name ) ){ 451 //名前空間及びクラス名が重複した場合 452 SmoothieException::Throw(15,name,nowLine); 453 return 0; 454 } 455 456 if(pobj_c2->pobj_NextClass==0) break; 457 pobj_c2=pobj_c2->pobj_NextClass; 458 } 459 pobj_c2->pobj_NextClass=pobj_c; 460 } 461 else{ 462 pobj_ClassHash[key]=pobj_c; 463 } 464 465 return pobj_c; 464 pObjectClass = pClass; 465 } 466 467 if( !Insert( pClass ) ) 468 { 469 return NULL; 470 } 471 472 return pClass; 466 473 } 467 474 … … 517 524 ////////////////////// 518 525 519 void Classes::Iterator_Init(void){ 526 void Classes::Iterator_Init() const 527 { 520 528 if(ppobj_IteClass) free(ppobj_IteClass); 521 529 … … 540 548 } 541 549 } 542 void Classes::Iterator_Reset(void){ 550 void Classes::Iterator_Reset() const 551 { 543 552 iIteNextNum = 0; 544 553 } 545 BOOL Classes::Iterator_HasNext(void){ 554 BOOL Classes::Iterator_HasNext() const 555 { 546 556 if(iIteNextNum<iIteMaxNum) return 1; 547 557 return 0; 548 558 } 549 CClass *Classes::Iterator_GetNext(void){ 559 CClass *Classes::Iterator_GetNext() const 560 { 550 561 CClass *pobj_c; 551 562 pobj_c=ppobj_IteClass[iIteNextNum]; … … 553 564 return pobj_c; 554 565 } 555 int Classes::Iterator_GetMaxCount(void){ 566 int Classes::Iterator_GetMaxCount() const 567 { 556 568 return iIteMaxNum; 557 569 } -
trunk/jenga/src/smoothie/Source.cpp
r186 r190 1 #include <stdio.h> 2 1 3 #include <boost/foreach.hpp> 2 4
Note:
See TracChangeset
for help on using the changeset viewer.