Index: trunk/jenga/src/smoothie/Class.cpp
===================================================================
--- trunk/jenga/src/smoothie/Class.cpp	(revision 180)
+++ trunk/jenga/src/smoothie/Class.cpp	(revision 181)
@@ -4,64 +4,4 @@
 #include <jenga/include/smoothie/Class.h>
 #include <jenga/include/smoothie/SmoothieException.h>
-
-
-class CLoopRefCheck{
-	char **names;
-	int num;
-	void init(){
-		int i;
-		for(i=0;i<num;i++){
-			free(names[i]);
-		}
-		free(names);
-	}
-public:
-	CLoopRefCheck()
-	{
-		names=(char **)malloc(1);
-		num=0;
-	}
-	~CLoopRefCheck()
-	{
-		init();
-	}
-	void add(const char *lpszInheritsClass)
-	{
-		names=(char **)realloc(names,(num+1)*sizeof(char *));
-		names[num]=(char *)malloc(lstrlen(lpszInheritsClass)+1);
-		lstrcpy(names[num],lpszInheritsClass);
-		num++;
-	}
-	void del(const char *lpszInheritsClass)
-	{
-		int i;
-		for(i=0;i<num;i++){
-			if(lstrcmp(names[i],lpszInheritsClass)==0){
-				free(names[i]);
-				break;
-			}
-		}
-		if(i!=num){
-			num--;
-			for(;i<num;i++){
-				names[i]=names[i+1];
-			}
-		}
-	}
-	BOOL check(const CClass &inheritsClass) const
-	{
-		//ループ継承チェック
-		int i;
-		for(i=0;i<num;i++){
-			if( inheritsClass.GetName() == names[i] ){
-				return 1;
-			}
-		}
-		return 0;
-	}
-};
-CLoopRefCheck *pobj_LoopRefCheck;
-
-
 
 
@@ -125,218 +65,4 @@
 }
 
-bool CClass::Inherits( const char *inheritNames, int nowLine ){
-	int i = 0;
-	bool isInheritsClass = false;
-	while( true ){
-
-		char temporary[VN_SIZE];
-		for( int i2=0;; i++, i2++ ){
-			if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){
-				temporary[i2] = 0;
-				break;
-			}
-			temporary[i2] = inheritNames[i];
-		}
-
-		//継承元クラスを取得
-		const CClass *pInheritsClass = Smoothie::meta.GetClasses().Find(temporary);
-		if( !pInheritsClass ){
-			throw SmoothieException(106,temporary,nowLine);
-			return false;
-		}
-
-		if( pInheritsClass->IsInterface() ){
-			// インターフェイスはあとで継承する
-		}
-		else if( pInheritsClass->IsClass() ){
-			// クラスを継承する
-			isInheritsClass = true;
-
-			if( !InheritsClass( *pInheritsClass, nowLine ) ){
-				return false;
-			}
-		}
-		else{
-			throw SmoothieException(135,NULL,nowLine);
-			return false;
-		}
-
-		if( inheritNames[i] == '\0' ){
-			break;
-		}
-		i++;
-	}
-
-	if( !isInheritsClass ){
-		// クラスを一つも継承していないとき
-		const CClass *pObjectClass = Smoothie::meta.GetClasses().Find("Object");
-		if( !pObjectClass ){
-			throw SmoothieException(106,"Object",i);
-			return false;
-		}
-
-		if( !InheritsClass( *pObjectClass, nowLine ) ){
-			return false;
-		}
-	}
-
-	i=0;
-	while( true ){
-
-		char temporary[VN_SIZE];
-		for( int i2=0;; i++, i2++ ){
-			if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){
-				temporary[i2] = 0;
-				break;
-			}
-			temporary[i2] = inheritNames[i];
-		}
-
-		//継承元クラスを取得
-		const CClass *pInheritsClass = Smoothie::meta.GetClasses().Find(temporary);
-		if( !pInheritsClass ){
-			throw SmoothieException(106,temporary,nowLine);
-			return false;
-		}
-
-		if( pInheritsClass->IsInterface() ){
-			// インターフェイスを継承する
-			if( !InheritsInterface( *pInheritsClass, nowLine ) ){
-				return false;
-			}
-		}
-		else if( pInheritsClass->IsClass() ){
-			// クラスはさっき継承した
-		}
-		else{
-			throw SmoothieException(135,NULL,nowLine);
-			return false;
-		}
-
-		if( inheritNames[i] == '\0' ){
-			break;
-		}
-		i++;
-	}
-
-	return true;
-}
-/*
-bool CClass::InheritsClass( const CClass &inheritsClass, int nowLine ){
-
-	//ループ継承でないかをチェック
-	if(pobj_LoopRefCheck->check(inheritsClass)){
-		throw SmoothieException(123,inheritsClass.GetName(),nowLine);
-		return false;
-	}
-
-	if( !inheritsClass.IsReady() ){
-		//継承先が読み取られていないとき
-		pobj_LoopRefCheck->add(this->GetName().c_str());
-		Smoothie::meta.GetClasses().GetClass_recur(inheritsClass.GetName().c_str());
-		pobj_LoopRefCheck->del(this->GetName().c_str());
-	}
-
-	//メンバをコピー
-	BOOST_FOREACH( CMember *inheritsClassDynamicMember, inheritsClass.dynamicMembers ){
-		CMember *pMember = new CMember( *inheritsClassDynamicMember );
-
-		// アクセシビリティ
-		if( inheritsClassDynamicMember->IsPrivate() ){
-			pMember->SetAccessibility( Prototype::None );
-		}
-		else{
-			pMember->SetAccessibility( inheritsClassDynamicMember->GetAccessibility() );
-		}
-
-		dynamicMembers.push_back( pMember );
-	}
-
-	//メソッドをコピー
-	BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClass.methods ){
-		CMethod *pMethod = new DynamicMethod( *pBaseMethod );
-
-		// アクセシビリティ
-		if(pBaseMethod->GetAccessibility() == Prototype::Private){
-			pMethod->SetAccessibility( Prototype::None );
-		}
-		else{
-			pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );
-		}
-
-		//pobj_Inherits
-		// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-		if(pBaseMethod->GetInheritsClassPtr()==0){
-			pMethod->SetInheritsClassPtr( &inheritsClass );
-		}
-		else{
-			pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
-		}
-
-		methods.push_back( pMethod );
-	}
-
-	//仮想関数の数
-	AddVtblNum( inheritsClass.GetVtblNum() );
-
-	//継承先のクラスをメンバとして保持する
-	pobj_InheritsClass = &inheritsClass;
-
-	return true;
-}
-bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){
-
-	//ループ継承でないかをチェック
-	if(pobj_LoopRefCheck->check(inheritsInterface)){
-		throw SmoothieException(123,inheritsInterface.GetName(),nowLine);
-		return false;
-	}
-
-	if( !inheritsInterface.IsReady() ){
-		//継承先が読み取られていないとき
-		pobj_LoopRefCheck->add(this->GetName().c_str());
-		Smoothie::meta.GetClasses().GetClass_recur(inheritsInterface.GetName().c_str());
-		pobj_LoopRefCheck->del(this->GetName().c_str());
-	}
-
-	//メソッドをコピー
-	BOOST_FOREACH( const CMethod *pBaseMethod, inheritsInterface.methods ){
-		CMethod *pMethod = new DynamicMethod( *pBaseMethod );
-
-		// アクセシビリティ
-		if(pBaseMethod->GetAccessibility() == Prototype::Private){
-			pMethod->SetAccessibility( Prototype::None );
-		}
-		else{
-			pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );
-		}
-
-		//pobj_Inherits
-		// ※継承元のClassIndexをセット（入れ子継承を考慮する）
-		if(pBaseMethod->GetInheritsClassPtr()==0){
-			pMethod->SetInheritsClassPtr( &inheritsInterface );
-		}
-		else{
-			pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
-		}
-
-		methods.push_back( pMethod );
-	}
-
-	interfaces.push_back( InheritedInterface( const_cast<CClass *>(&inheritsInterface), vtblNum ) );
-
-	//仮想関数の数
-	AddVtblNum( inheritsInterface.GetVtblNum() );
-
-	return true;
-}
-void CClass::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer ){
-	CMember *pMember = new CMember( this, accessibility, isConst, isRef, buffer );
-	dynamicMembers.push_back( pMember );
-}
-void CClass::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){
-	CMember *pMember = new CMember( this, accessibility, isConst, isRef, buffer, nowLine );
-	staticMembers.push_back( pMember );
-}*/
 BOOL CClass::DupliCheckAll(const char *name){
 	//重複チェック
@@ -505,63 +231,5 @@
 	return n;
 }
-/*
-LONG_PTR CClass::GetVtblGlobalOffset(void) const
-{
-
-	//既に存在する場合はそれを返す
-	if(vtbl_offset!=-1) return vtbl_offset;
-
-
-
-	//////////////////////////////////////
-	// 存在しないときは新たに生成する
-	//////////////////////////////////////
-
-	UserProc **ppsi;
-	ppsi=(UserProc **)malloc(GetVtblNum()*sizeof(GlobalProc *));
-
-	//関数テーブルに値をセット
-	int i2 = 0;
-	BOOST_FOREACH( const CMethod *pMethod, methods ){
-		if(pMethod->IsVirtual()){
-			pMethod->pUserProc->Using();
-
-			if(pMethod->IsAbstract()){
-				extern int cp;
-				throw SmoothieException(300,NULL,cp);
-
-				ppsi[i2]=0;
-			}
-			else{
-				ppsi[i2]=pMethod->pUserProc;
-			}
-			i2++;
-		}
-	}
-
-	vtbl_offset=dataTable.AddBinary((void *)ppsi,GetVtblNum()*sizeof(LONG_PTR));
-
-	for( int i=0; i < GetVtblNum(); i++ ){
-		pobj_Reloc->AddSchedule_DataSection(vtbl_offset+i*sizeof(LONG_PTR));
-	}
-
-	free(ppsi);
-
-	return vtbl_offset;
-}
-void CClass::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){
-	if(vtbl_offset==-1) return;
-
-	LONG_PTR *pVtbl;
-	pVtbl=(LONG_PTR *)((char *)dataTable.GetPtr()+vtbl_offset);
-
-	int i;
-	for(i=0;i<GetVtblNum();i++){
-		GlobalProc *pUserProc;
-		pUserProc=(GlobalProc *)pVtbl[i];
-		if(!pUserProc) continue;
-		pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection;
-	}
-}*/
+
 bool CClass::IsAbstract() const
 {
@@ -669,4 +337,5 @@
 	iIteNextNum( 0 )
 {
+	memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) );
 	Clear();
 }
@@ -681,5 +350,9 @@
 	}
 
-	if(ppobj_IteClass) free(ppobj_IteClass);
+	if(ppobj_IteClass)
+	{
+		free(ppobj_IteClass);
+		ppobj_IteClass = NULL;
+	}
 	memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) );
 }
@@ -728,7 +401,7 @@
 
 	// TypeDefも見る
-	int index = Smoothie::meta.typeDefs.GetIndex( namespaceScopes, name );
+	int index = Smoothie::GetMeta().typeDefs.GetIndex( namespaceScopes, name );
 	if( index != -1 ){
-		Type type = Smoothie::meta.typeDefs[index].GetBaseType();
+		Type type = Smoothie::GetMeta().typeDefs[index].GetBaseType();
 		if( type.IsObject() ){
 			return &type.GetClass();
@@ -747,5 +420,5 @@
 }
 
-CClass *Classes::AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){
+CClass *Classes::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){
 	//////////////////////////////////////////////////////////////////////////
 	// クラスを追加
@@ -753,6 +426,5 @@
 	//////////////////////////////////////////////////////////////////////////
 
-	CClass *pobj_c;
-	pobj_c=new CClass(namespaceScopes, importedNamespaces, name);
+	CClass *pobj_c = Create(namespaceScopes, importedNamespaces, name);
 
 	if(lstrcmp(name,"String")==0){
