Changeset 192 in dev for trunk/jenga
- Timestamp:
- Jun 26, 2007, 5:04:29 AM (17 years ago)
- Location:
- trunk/jenga
- Files:
-
- 2 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/smoothie/Class.h
r190 r192 321 321 class Classes 322 322 { 323 protected: 323 324 int GetHashCode(const char *name) const; 324 325 void DestroyClass(CClass *pobj_c); … … 331 332 332 333 const CClass *Find( const string &fullName ) const; 333 const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const;334 virtual const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const = 0; 334 335 335 336 virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name) = 0; -
trunk/jenga/include/smoothie/Namespace.h
r170 r192 70 70 } 71 71 72 bool IsImported() const;73 74 72 bool IsLiving() const; 75 73 … … 82 80 bool IsCoverd( const string &name ) const; 83 81 bool IsCoverd( const NamespaceScopes &namespaceScopes ) const; 84 85 // 指定された名前空間が同一エリアと見なされるかどうかをチェック86 static bool IsSameArea( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes ){87 if( entryNamespaceScopes.size() ){88 if( baseNamespaceScopes.IsCoverd( entryNamespaceScopes ) ){89 // 包括しているときは同一と見なす90 return true;91 }92 }93 else{94 if( baseNamespaceScopes.size() ){95 // 名前空間の判断が必要なとき96 if( baseNamespaceScopes.IsImported()97 || baseNamespaceScopes.IsLiving() ){98 // Using指定があるとき99 // または100 // 指定された名前空間が現在の名前空間スコープと同一のとき101 return true;102 }103 }104 else{105 return true;106 }107 }108 109 return false;110 }111 82 }; 112 83 … … 128 99 return IsExist( NamespaceScopes( namespaceStr ) ); 129 100 } 101 102 bool IsImported( const NamespaceScopes &namespaceScopes ) const 103 { 104 const NamespaceScopesCollection &namespaceScopesCollection = *this; 105 BOOST_FOREACH( const NamespaceScopes &tempNamespaceScopes, namespaceScopesCollection ) 106 { 107 if( namespaceScopes.IsEqual( tempNamespaceScopes ) ) 108 { 109 return true; 110 } 111 } 112 return false; 113 } 114 130 115 void SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const; 131 132 bool Imports( const string &namespaceStr );133 116 134 117 static bool CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection ); -
trunk/jenga/include/smoothie/ObjectModule.h
r190 r192 1 1 #pragma once 2 2 3 #include "TypeDef.h"4 3 #include "Namespace.h" 5 4 #include "Procedure.h" … … 24 23 } 25 24 26 // 名前空間27 NamespaceScopesCollection namespaceScopesCollection;28 29 25 // クラス 30 26 virtual Classes &GetClasses() = 0; 31 27 virtual void SetClasses( Classes *pClasses ) = 0; 32 28 virtual bool AutoWrite( const std::string &filePath ) = 0; 33 34 // TypeDef35 TypeDefCollection typeDefs;36 29 37 30 // 関数ポインタ … … 40 33 return *pProcPointers; 41 34 } 42 43 // blittable型44 BlittableTypes blittableTypes;45 35 46 36 // XMLシリアライズ用 -
trunk/jenga/include/smoothie/Procedure.h
r181 r192 281 281 ~DllProc(){} 282 282 283 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;283 virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const = 0; 284 284 bool IsEqualSymbol( const string &name ) const; 285 285 -
trunk/jenga/include/smoothie/Prototype.h
r190 r192 51 51 52 52 // シンボル比較 53 bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;53 virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const = 0; 54 54 bool IsEqualSymbol( const Prototype &prototype ) const; 55 55 bool IsEqualSymbol( const string &name ) const; -
trunk/jenga/include/smoothie/Smoothie.h
r190 r192 17 17 Smoothie::isUnicode = isUnicode; 18 18 } 19 20 static Meta &GetMeta();21 19 22 20 class Lexical{ -
trunk/jenga/include/smoothie/Type.h
r173 r192 59 59 void SetIndex( LONG_PTR index ){ 60 60 this->index = index; 61 } 62 void SetClassPtr( const CClass *pClass ) 63 { 64 this->pClass = pClass; 61 65 } 62 66 void SetNull(){ … … 130 134 } 131 135 132 static Type String();133 134 136 135 137 private: … … 138 140 public: 139 141 static bool StringToBasicType( const std::string &typeName, int &basicType ); 140 static bool StringToType( const std::string &typeName,Type &type );142 static const char *Type::BasicTypeToCharPtr( const Type &type ); 141 143 static int GetBasicTypeFromSimpleName( const char *variable ); 142 144 }; -
trunk/jenga/include/smoothie/Variable.h
r173 r192 52 52 ~Variable(){} 53 53 54 const NamespaceScopes &GetNamespaceScopes() const 55 { 56 return namespaceScopes; 57 } 58 54 59 void SetArray( const int *pSubScripts ){ 55 60 isArray = true; … … 62 67 } 63 68 64 bool IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember = true ) const;69 virtual bool IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember = true ) const = 0; 65 70 66 71 void ConstOff(){ -
trunk/jenga/projects/smoothie/smoothie.vcproj
r187 r192 168 168 Name="VCCLCompilerTool" 169 169 AdditionalIncludeDirectories="..\..\..\;..\..\..\cpplibs\boost" 170 RuntimeLibrary=" 2"170 RuntimeLibrary="0" 171 171 WarningLevel="3" 172 172 Detect64BitPortabilityProblems="true" … … 184 184 <Tool 185 185 Name="VCLibrarianTool" 186 OutputFile="..\..\lib\x86\$(ProjectName) d.lib"186 OutputFile="..\..\lib\x86\$(ProjectName).lib" 187 187 /> 188 188 <Tool … … 318 318 </File> 319 319 <File 320 RelativePath="..\..\src\smoothie\TypeDef.cpp"321 >322 </File>323 <File324 320 RelativePath="..\..\src\smoothie\Variable.cpp" 325 321 > … … 396 392 </File> 397 393 <File 398 RelativePath="..\..\include\smoothie\TypeDef.h"399 >400 </File>401 <File402 394 RelativePath="..\..\include\smoothie\Variable.h" 403 395 > -
trunk/jenga/src/smoothie/Class.cpp
r190 r192 374 374 } 375 375 376 const CClass *Classes::Find( const NamespaceScopes &namespaceScopes, const string &name ) const377 {378 int key;379 key=GetHashCode(name.c_str());380 381 if( namespaceScopes.size() == 0 && name == "Object" ){382 return GetObjectClassPtr();383 }384 else if( namespaceScopes.size() == 0 && name == "String" ){385 return GetStringClassPtr();386 }387 388 if(pobj_ClassHash[key]){389 CClass *pobj_c;390 pobj_c=pobj_ClassHash[key];391 while(1){392 if( pobj_c->IsEqualSymbol( namespaceScopes, name ) ){393 //名前空間とクラス名が一致した394 return pobj_c;395 }396 397 if(pobj_c->pobj_NextClass==0) break;398 pobj_c=pobj_c->pobj_NextClass;399 }400 }401 402 // TypeDefも見る403 int index = Smoothie::GetMeta().typeDefs.GetIndex( namespaceScopes, name );404 if( index != -1 ){405 Type type = Smoothie::GetMeta().typeDefs[index].GetBaseType();406 if( type.IsObject() ){407 return &type.GetClass();408 }409 }410 411 return NULL;412 }413 376 const CClass *Classes::Find( const string &fullName ) const 414 377 { -
trunk/jenga/src/smoothie/Namespace.cpp
r186 r192 26 26 } 27 27 28 bool NamespaceScopes::IsImported() const29 {30 BOOST_FOREACH( const NamespaceScopes &namespaceScopes, Smoothie::Temp::importedNamespaces ){31 if( this->IsEqual( namespaceScopes ) ){32 return true;33 }34 }35 return false;36 }37 28 bool NamespaceScopes::IsLiving() const 38 29 { … … 104 95 lstrcpy( simpleName, fullName + lstrlen( namespaceStr ) + dotLength ); 105 96 } 106 bool NamespaceScopesCollection::Imports( const string &namespaceStr ){107 NamespaceScopes namespaceScopes( namespaceStr );108 if( !Smoothie::GetMeta().namespaceScopesCollection.IsExist( namespaceScopes ) ){109 return false;110 }111 112 this->push_back( namespaceScopes );113 114 return true;115 }116 97 bool NamespaceScopesCollection::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection ) 117 98 { -
trunk/jenga/src/smoothie/Procedure.cpp
r186 r192 37 37 } 38 38 39 bool DllProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const40 {41 if( GetName() != name ){42 return false;43 }44 return NamespaceScopes::IsSameArea( this->namespaceScopes, namespaceScopes );45 }46 39 bool DllProc::IsEqualSymbol( const string &fullName ) const 47 40 { -
trunk/jenga/src/smoothie/Prototype.cpp
r171 r192 2 2 #include <jenga/include/smoothie/Class.h> 3 3 4 bool Prototype::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const5 {6 if( GetName() != name ){7 return false;8 }9 10 return NamespaceScopes::IsSameArea( GetNamespaceScopes(), namespaceScopes );11 }12 4 bool Prototype::IsEqualSymbol( const Prototype &prototype ) const 13 5 { -
trunk/jenga/src/smoothie/Type.cpp
r186 r192 61 61 return false; 62 62 } 63 64 65 bool Type::StringToType( const string &typeName, Type &type ){ 66 type.index = -1; 67 68 if( typeName[0] == '*' ){ 69 if( typeName.size() >= 3 70 && typeName[1] == 1 && ( typeName[2] == ESC_FUNCTION || typeName[2] == ESC_SUB ) ){ 71 //関数ポインタ(*Function) 72 type.basicType = DEF_PTR_PROC; 73 type.index = Smoothie::GetMeta().GetProcPointers().Add( typeName ); 74 return true; 75 } 76 77 const string &nextTypeName = typeName.substr( 1 ); 78 79 if( !StringToType( nextTypeName, type ) ){ 80 return false; 81 } 82 83 type.PtrLevelUp(); 84 85 return true; 86 } 87 88 if( StringToBasicType( typeName, type.basicType ) ){ 89 // 基本型だったとき 90 return true; 91 } 92 93 94 // Object型だったとき 95 if( typeName == "Object" ){ 96 type.SetType( DEF_OBJECT, Smoothie::GetMeta().GetClasses().GetObjectClassPtr() ); 97 return true; 98 } 99 100 // String型だったとき 101 if( typeName == "String" ){ 102 type.SetType( DEF_OBJECT, Smoothie::GetMeta().GetClasses().GetStringClassPtr() ); 103 return true; 104 } 105 106 107 //////////////////// 108 // TypeDefされた型 109 //////////////////// 110 int i=Smoothie::GetMeta().typeDefs.GetIndex( typeName ); 111 if(i!=-1){ 112 type = Smoothie::GetMeta().typeDefs[i].GetBaseType(); 113 return true; 114 } 115 116 //クラス 117 const CClass *pobj_c = Smoothie::GetMeta().GetClasses().Find( typeName ); 118 if(pobj_c){ 119 type.pClass = pobj_c; 120 121 if( pobj_c->IsStructure() ){ 122 type.basicType = DEF_STRUCT; 123 } 124 else{ 125 type.basicType = DEF_OBJECT; 126 } 127 return true; 128 } 129 130 return false; 63 const char *Type::BasicTypeToCharPtr( const Type &type ) 64 { 65 for( int i=0; ; i++ ){ 66 if( basicTypeList[i] == DEF_NON ){ 67 break; 68 } 69 if( basicTypeList[i] == type.GetBasicType() ){ 70 return basicTypeNameList[i].c_str(); 71 } 72 } 73 return NULL; 131 74 } 132 75 … … 488 431 } 489 432 490 491 const string Type::ToString() const492 {493 if( PTR_LEVEL( basicType ) ){494 //ポインタレベルが1以上の場合495 Type type( *this );496 type.PtrLevelDown();497 498 return (string)"*" + type.ToString();499 }500 else if( IsObject() || IsStruct() ){501 //オブジェクトまたは構造体502 503 if( !( index == 0 || index == -1 ) ){504 if( pClass->GetNamespaceScopes().size() >= 1 )505 {506 return pClass->GetNamespaceScopes().ToString() + "." + pClass->GetName();507 }508 return pClass->GetName();509 }510 }511 else if( IsProcPtr() ){512 if( index == 0 || index == -1 ){513 return "VoidPtr";514 }515 else{516 if( Smoothie::GetMeta().GetProcPointers()[index]->ReturnType().IsNull() ){517 return "*Sub";518 }519 return "*Function";520 }521 }522 else{523 // 基本型524 525 for( int i=0; ; i++ ){526 if( basicTypeList[i] == DEF_NON ){527 break;528 }529 if( basicTypeList[i] == basicType ){530 return basicTypeNameList[i];531 }532 }533 }534 535 SmoothieException::Throw( 1 );536 537 return (string)"(null)";538 }539 540 Type Type::String(){541 return Type( DEF_OBJECT, *Smoothie::GetMeta().GetClasses().GetStringClassPtr() );542 }543 544 433 int Type::GetBasicTypeFromSimpleName( const char *variable ){ 545 434 extern char DefIntVari[26],DefSngVari[26],DefStrVari[26],divNum,dsvNum,dStrvNum; -
trunk/jenga/src/smoothie/Variable.cpp
r174 r192 1 1 #include <jenga/include/smoothie/Smoothie.h> 2 2 #include <jenga/include/smoothie/Class.h> 3 4 bool Variable::IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember ) const5 {6 if( GetName() == symbol.GetName()7 && NamespaceScopes::IsSameArea( this->namespaceScopes, symbol.GetNamespaceScopes() ) )8 {9 return true;10 }11 12 if( isSupportStaticMember && symbol.GetNamespaceScopes().size() >= 1 )13 {14 // 静的メンバを考慮15 NamespaceScopes namespaceScopes( symbol.GetNamespaceScopes() );16 string name = namespaceScopes[namespaceScopes.size()-1] + "." + symbol.GetName();17 namespaceScopes.pop_back();18 19 return IsEqualSymbol( Symbol( namespaceScopes, name ), false );20 }21 return false;22 }23 3 24 4
Note:
See TracChangeset
for help on using the changeset viewer.