Browse Source

Fixed new typeinfo stuff for gcc.

Mark Sibly 7 years ago
parent
commit
da74339755

+ 2 - 2
modules/monkey/native/bbtypeinfo.cpp

@@ -118,11 +118,11 @@ bbArray<bbDeclInfo*> bbTypeInfo::getDecls( bbString name ){
 	}
 	if( !n ) return {};
 	
-	bbArray<bbDeclInfo*> rdecls;
+	bbArray<bbDeclInfo*> rdecls( n );
 	
 	int j=0;
 	for( int i=0;i<decls.length();++i ){
-		if( decls[i]->name==name) rdecls[j++]=decls[i];
+		if( decls[i]->name==name ) rdecls[j++]=decls[i];
 	}
 	return rdecls;
 }

+ 19 - 144
modules/monkey/native/bbtypeinfo.h

@@ -60,107 +60,6 @@ struct bbTypeInfo{
 	static bbArray<bbTypeInfo*> getTypes();
 };
 
-template<class T> bbTypeInfo *bbGetType();
-
-struct bbUnknownTypeInfo : public bbTypeInfo{
-
-	bbUnknownTypeInfo();
-};
-
-struct bbVoidTypeInfo : public bbTypeInfo{
-
-	static bbVoidTypeInfo instance;
-
-	bbVoidTypeInfo();
-};
-
-struct bbObjectTypeInfo : public bbTypeInfo{
-
-	static bbObjectTypeInfo instance;
-
-	bbObjectTypeInfo();
-	
-	bbTypeInfo *superType();
-	
-	bbBool extendsType( bbTypeInfo *type );
-	
-	bbArray<bbDeclInfo*> getDecls();
-};
-
-/*
-
-template<class T> struct bbPrimTypeInfo : public bbTypeInfo{
-
-	bbPrimTypeInfo( bbString name ){
-		this->name=name;
-		this->kind="Primitive";
-	}
-	
-};
-
-template<class T> struct bbPointerTypeInfo : public bbTypeInfo{
-
-	bbPointerTypeInfo(){
-		this->name=bbGetType<T>()->name+" Ptr";
-		this->kind="Pointer";
-	}
-
-	bbTypeInfo *pointeeType(){
-		return bbGetType<T>();
-	}
-	
-};
-
-template<class T,int D> struct bbArrayTypeInfo : public bbTypeInfo{
-
-	bbArrayTypeInfo(){
-		this->name=bbGetType<T>()->name+"["+BB_T(",").dup(D-1)+"]";
-		this->kind="Array";
-	}
-	
-	bbTypeInfo *elementType(){
-		return bbGetType<T>();
-	}
-	
-	int arrayRank(){
-		return D;
-	}
-};
-
-template<class R,class...A> struct bbFunctionTypeInfo : public bbTypeInfo{
-
-	bbFunctionTypeInfo(){
-		this->name=bbGetType<R>()->name+"("+BB_T(",").join( bbArray<bbString>( { bbGetType<A>()->name... },int(sizeof...(A)) ) )+")";
-		this->kind="Function";
-	}
-	
-	bbTypeInfo *returnType(){
-		return bbGetType<R>();
-	}
-	
-	bbArray<bbTypeInfo*> paramTypes(){
-		return bbArray<bbTypeInfo*>( { bbGetType<A>()... },int(sizeof...(A)) );
-	}
-
-};
-
-template<class...A> struct bbFunctionTypeInfo<void,A...> : public bbTypeInfo{
-
-	bbFunctionTypeInfo(){
-		this->name=BB_T("Void(")+BB_T(",").join( bbArray<bbString>( { bbGetType<A>()->name... },int(sizeof...(A)) ) )+")";
-		this->kind="Function";
-	}
-	
-	bbTypeInfo *returnType(){
-		return &bbVoidTypeInfo::instance;
-	}
-	
-	bbArray<bbTypeInfo*> paramTypes(){
-		return bbArray<bbTypeInfo*>( { bbGetType<A>()... },int(sizeof...(A)) );
-	}
-
-};
-
 #define BB_GETTYPE_DECL( TYPE ) bbTypeInfo *bbGetType( TYPE const& );
 
 BB_GETTYPE_DECL( bbBool )
@@ -178,58 +77,34 @@ BB_GETTYPE_DECL( bbString )
 BB_GETTYPE_DECL( bbCString )
 BB_GETTYPE_DECL( bbVariant )
 
-inline bbTypeInfo *bbGetType( bbObject* const& ){
-	return &bbObjectTypeInfo::instance;
-}
-
-template<class T> bbTypeInfo *bbGetUnknownType(){
- 	static bbUnknownTypeInfo info;
-	
-	return &info;
-}
-
-template<class T> bbTypeInfo *bbGetType( T const& ){
-	return bbGetUnknownType<T>();
-}
-
-template<class T> bbTypeInfo *bbGetType( T* const& ){
-	static bbPointerTypeInfo<T> info;
-	
-	return &info;
-}
+template<class T> bbTypeInfo *bbGetType(){
 
-template<class T,int D> bbTypeInfo *bbGetType( bbArray<T,D> const& ){
-	static bbArrayTypeInfo<T,D> info;
-	
-	return &info;
+	return bbGetType( *(T*)0 );
 }
 
-template<class R,class...A> bbTypeInfo *bbGetFuncType(){
-	static bbFunctionTypeInfo<R,A...> info;
+struct bbUnknownTypeInfo : public bbTypeInfo{
 	
-	return &info;
-}
+	bbUnknownTypeInfo();
+};
 
-template<class R,class...A> bbTypeInfo *bbGetType( R(*)(A...) ){
-	return bbGetFuncType<R,A...>();
-}
+struct bbVoidTypeInfo : public bbTypeInfo{
 
-template<class R,class...A> bbTypeInfo *bbGetType( bbFunction<R(A...)> const& ){
-	return bbGetFuncType<R,A...>();
-}
+	static bbVoidTypeInfo instance;
 
-template<class T> bbTypeInfo *bbGetType( bbGCVar<T> const& ){
-	return bbGetType<T*>();
-}
+	bbVoidTypeInfo();
+};
 
-template<> inline bbTypeInfo *bbGetType<void>(){
-	return &bbVoidTypeInfo::instance;
-}
+struct bbObjectTypeInfo : public bbTypeInfo{
 
-template<class T> bbTypeInfo *bbGetType(){
-	return bbGetType( *(T*)0 );
-}
+	static bbObjectTypeInfo instance;
 
-*/
+	bbObjectTypeInfo();
+	
+	bbTypeInfo *superType();
+	
+	bbBool extendsType( bbTypeInfo *type );
+	
+	bbArray<bbDeclInfo*> getDecls();
+};
 
 #endif

+ 0 - 21
modules/monkey/native/bbtypeinfo_t.h

@@ -93,23 +93,6 @@ template<class...A> struct bbFunctionTypeInfo<void,A...> : public bbTypeInfo{
 	}
 };
 
-#define BB_GETTYPE_DECL( TYPE ) bbTypeInfo *bbGetType( TYPE const& );
-
-BB_GETTYPE_DECL( bbBool )
-BB_GETTYPE_DECL( bbByte )
-BB_GETTYPE_DECL( bbUByte )
-BB_GETTYPE_DECL( bbShort )
-BB_GETTYPE_DECL( bbUShort )
-BB_GETTYPE_DECL( bbInt )
-BB_GETTYPE_DECL( bbUInt )
-BB_GETTYPE_DECL( bbLong )
-BB_GETTYPE_DECL( bbULong )
-BB_GETTYPE_DECL( bbFloat )
-BB_GETTYPE_DECL( bbDouble )
-BB_GETTYPE_DECL( bbString )
-BB_GETTYPE_DECL( bbCString )
-BB_GETTYPE_DECL( bbVariant )
-
 inline bbTypeInfo *bbGetType( bbObject* const& ){
 	return &bbObjectTypeInfo::instance;
 }
@@ -158,8 +141,4 @@ template<> inline bbTypeInfo *bbGetType<void>(){
 	return &bbVoidTypeInfo::instance;
 }
 
-template<class T> bbTypeInfo *bbGetType(){
-	return bbGetType( *(T*)0 );
-}
-
 #endif

+ 0 - 13
modules/monkey/native/bbvariant.h

@@ -171,19 +171,6 @@ struct bbVariant{
 	
 };
 
-extern template struct bbVariant::Rep<bbBool>;
-extern template struct bbVariant::Rep<bbByte>;
-extern template struct bbVariant::Rep<bbUByte>;
-extern template struct bbVariant::Rep<bbShort>;
-extern template struct bbVariant::Rep<bbUShort>;
-extern template struct bbVariant::Rep<bbInt>;
-extern template struct bbVariant::Rep<bbUInt>;
-extern template struct bbVariant::Rep<bbLong>;
-extern template struct bbVariant::Rep<bbULong>;
-extern template struct bbVariant::Rep<bbFloat>;
-extern template struct bbVariant::Rep<bbDouble>;
-extern template struct bbVariant::Rep<bbString>;
-
 inline void bbGCMark( const bbVariant &v ){
 
 	v._rep->gcMark();

+ 1 - 1
modules/monkey/types.monkey2

@@ -551,7 +551,7 @@ Class @TypeInfo Extends Void="bbTypeInfo"
 	
 	#rem monkeydoc Type kind.
 	
-	Will be one of: Unknown, Primitve, Pointer, Array, Function, Class, Interface, Struct, Namespace.
+	Will be one of: Unknown, Primitive, Pointer, Array, Function, Class, Interface, Struct, Namespace.
 	
 	#end
 	Property Kind:String()="getKind"