Переглянути джерело

WORK IN PROGRESS reflection updates.

Mark Sibly 9 роки тому
батько
коміт
824542f15b

+ 47 - 0
modules/monkey/native/bbdeclinfo.cpp

@@ -20,3 +20,50 @@ bbVariant bbDeclInfo::invoke( bbVariant instance,bbArray<bbVariant> params ){
 	bbRuntimeError( "Decl is not invokable" );
 	bbRuntimeError( "Decl is not invokable" );
 	return {};
 	return {};
 }
 }
+
+bbArray<bbString> bbDeclInfo::getMetaKeys(){
+
+	if( !meta.length() ) return {};
+
+	bbString eol="~\n";
+
+	int n=1,i0=0;
+	while( i0<meta.length() ){
+		int i1=meta.find( eol,i0 );
+		if( i1==-1 ) break;
+		i0=i1+2;
+		n+=1;
+	}
+	
+	bbArray<bbString> keys( n );
+	
+	i0=0;
+	for( int i=0;i<n;++i ){
+		int i1=meta.find( "=",i0 );
+		keys[i]=meta.slice( i0,i1 );
+		i0=meta.find( eol,i1+1 )+2;
+	}
+	
+	return keys;
+}
+
+bbString bbDeclInfo::getMetaValue( bbString key ){
+
+	if( !meta.length() ) return {};
+	
+	bbString eol="~\n";
+
+	key+="=";
+
+	int i0=0;
+	if( !meta.startsWith( key ) ){
+		i0=meta.find( eol+key )+2;
+		if( i0==1 ) return {};
+	}
+	
+	i0+=key.length();
+
+	int i1=meta.find( eol,i0 );
+	if( i1==-1 ) return meta.slice( i0 );
+	return meta.slice( i0,i1 );
+}

+ 125 - 25
modules/monkey/native/bbdeclinfo.h

@@ -5,11 +5,33 @@
 #include "bbtypeinfo.h"
 #include "bbtypeinfo.h"
 #include "bbvariant.h"
 #include "bbvariant.h"
 
 
+#define BB_DECL_PUBLIC		0x000001
+#define BB_DECL_PRIVATE		0x000002
+#define BB_DECL_PROTECTED	0x000004
+#define BB_DECL_INTERNAL	0x000008
+#define BB_DECL_VIRTUAL		0x000100
+#define BB_DECL_OVERRIDE	0x000200
+#define BB_DECL_ABSTRACT	0x000400
+#define BB_DECL_FINAL		0x000800
+#define BB_DECL_EXTERN		0x001000
+#define BB_DECL_EXTENSION	0x002000
+#define BB_DECL_DEFAULT		0x004000
+#define BB_DECL_GETTER		0x010000
+#define BB_DECL_SETTER		0x020000
+#define BB_DECL_OPERATOR	0x040000
+#define BB_DECL_IFACEMEMBER	0x080000
+
+#define BB_DECL_GETTABLE	0x10000000
+#define BB_DECL_SETTABLE	0x20000000
+#define BB_DECL_INVOKABLE	0x40000000
+
 struct bbDeclInfo{
 struct bbDeclInfo{
 
 
 	bbString name;
 	bbString name;
+	bbString meta;
 	bbString kind;
 	bbString kind;
 	bbTypeInfo *type;
 	bbTypeInfo *type;
+	int flags=0;
 	
 	
 	bbString getName(){
 	bbString getName(){
 		return name;
 		return name;
@@ -23,6 +45,18 @@ struct bbDeclInfo{
 		return type;
 		return type;
 	}
 	}
 	
 	
+	bbBool gettable(){ return flags & BB_DECL_GETTABLE; }
+
+	bbBool settable(){ return flags & BB_DECL_SETTABLE; }
+
+	bbBool invokable(){ return flags & BB_DECL_INVOKABLE; }
+
+	bbArray<bbString> getMetaKeys();
+	
+	bbArray<bbString> getMetaData();
+	
+	bbString getMetaValue( bbString key );
+	
 	virtual bbString toString();
 	virtual bbString toString();
 
 
 	virtual bbVariant get( bbVariant instance );
 	virtual bbVariant get( bbVariant instance );
@@ -38,10 +72,12 @@ template<class T> struct bbGlobalDeclInfo : public bbDeclInfo{
 
 
 	T *ptr;
 	T *ptr;
 	
 	
-	bbGlobalDeclInfo( bbString name,T *ptr ):ptr( ptr ){
+	bbGlobalDeclInfo( bbString name,T *ptr,bbString meta,bool isconst ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
-		this->kind="Global";
+		this->meta=meta;
+		this->kind=isconst ? "Const" : "Global";
 		this->type=bbGetType<T>();
 		this->type=bbGetType<T>();
+		this->flags=BB_DECL_GETTABLE|(isconst ? 0 : BB_DECL_SETTABLE);
 	}
 	}
 	
 	
 	bbVariant get( bbVariant instance ){
 	bbVariant get( bbVariant instance ){
@@ -59,10 +95,12 @@ template<class T> struct bbGlobalVarDeclInfo : public bbDeclInfo{
 
 
 	bbGCVar<T> *ptr;
 	bbGCVar<T> *ptr;
 	
 	
-	bbGlobalVarDeclInfo( bbString name,bbGCVar<T> *ptr ):ptr( ptr ){
+	bbGlobalVarDeclInfo( bbString name,bbGCVar<T> *ptr,bbString meta,bool isconst ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
-		this->kind="Global";
+		this->meta=meta;
+		this->kind=isconst ? "Const" : "Global";
 		this->type=bbGetType<T>();
 		this->type=bbGetType<T>();
+		this->flags=BB_DECL_GETTABLE|(isconst ? 0 : BB_DECL_SETTABLE);
 	}
 	}
 	
 	
 	bbVariant get( bbVariant instance ){
 	bbVariant get( bbVariant instance ){
@@ -77,14 +115,24 @@ template<class T> struct bbGlobalVarDeclInfo : public bbDeclInfo{
 };
 };
 
 
 
 
-template<class T> bbDeclInfo *bbGlobalDecl( bbString name,T *ptr ){
+template<class T> bbDeclInfo *bbGlobalDecl( bbString name,T *ptr,bbString meta="" ){
+
+	return new bbGlobalDeclInfo<T>( name,ptr,meta,false );
+}
+
+template<class T> bbDeclInfo *bbGlobalDecl( bbString name,bbGCVar<T> *ptr,bbString meta="" ){
 
 
-	return new bbGlobalDeclInfo<T>( name,ptr );
+	return new bbGlobalVarDeclInfo<T>( name,ptr,meta,false );
 }
 }
 
 
-template<class T> bbDeclInfo *bbGlobalDecl( bbString name,bbGCVar<T> *ptr ){
+template<class T> bbDeclInfo *bbConstDecl( bbString name,T *ptr,bbString meta="" ){
 
 
-	return new bbGlobalVarDeclInfo<T>( name,ptr );
+	return new bbGlobalDeclInfo<T>( name,ptr,meta,true );
+}
+
+template<class T> bbDeclInfo *bbConstDecl( bbString name,bbGCVar<T> *ptr,bbString meta="" ){
+
+	return new bbGlobalVarDeclInfo<T>( name,ptr,meta,true );
 }
 }
 
 
 // ***** Field *****
 // ***** Field *****
@@ -93,10 +141,12 @@ template<class C,class T> struct bbFieldDeclInfo : public bbDeclInfo{
 
 
 	T C::*ptr;
 	T C::*ptr;
 	
 	
-	bbFieldDeclInfo( bbString name,T C::*ptr ):ptr( ptr ){
+	bbFieldDeclInfo( bbString name,bbString meta,T C::*ptr ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
+		this->meta=meta;
 		this->kind="Field";
 		this->kind="Field";
 		this->type=bbGetType<T>();
 		this->type=bbGetType<T>();
+		this->flags=BB_DECL_GETTABLE|BB_DECL_SETTABLE;
 	}
 	}
 	
 	
 	bbVariant get( bbVariant instance ){
 	bbVariant get( bbVariant instance ){
@@ -118,10 +168,12 @@ template<class C,class T> struct bbFieldVarDeclInfo : public bbDeclInfo{
 
 
 	bbGCVar<T> C::*ptr;
 	bbGCVar<T> C::*ptr;
 	
 	
-	bbFieldVarDeclInfo( bbString name,bbGCVar<T> C::*ptr ):ptr( ptr ){
+	bbFieldVarDeclInfo( bbString name,bbString meta,bbGCVar<T> C::*ptr ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
+		this->meta=meta;
 		this->kind="Field";
 		this->kind="Field";
 		this->type=bbGetType<T*>();
 		this->type=bbGetType<T*>();
+		this->flags=BB_DECL_GETTABLE|BB_DECL_SETTABLE;
 	}
 	}
 	
 	
 	bbVariant get( bbVariant instance ){
 	bbVariant get( bbVariant instance ){
@@ -139,24 +191,26 @@ template<class C,class T> struct bbFieldVarDeclInfo : public bbDeclInfo{
 	}
 	}
 };
 };
 
 
-template<class C,class T> bbDeclInfo *bbFieldDecl( bbString name,T C::*ptr ){
+template<class C,class T> bbDeclInfo *bbFieldDecl( bbString name,T C::*ptr,bbString meta="" ){
 
 
-	return new bbFieldDeclInfo<C,T>( name,ptr );
+	return new bbFieldDeclInfo<C,T>( name,meta,ptr );
 }
 }
 
 
-template<class C,class T> bbDeclInfo *bbFieldDecl( bbString name,bbGCVar<T> C::*ptr ){
+template<class C,class T> bbDeclInfo *bbFieldDecl( bbString name,bbGCVar<T> C::*ptr,bbString meta="" ){
 
 
-	return new bbFieldVarDeclInfo<C,T>( name,ptr );
+	return new bbFieldVarDeclInfo<C,T>( name,meta,ptr );
 }
 }
 
 
 // ***** Constructor *****
 // ***** Constructor *****
 //
 //
 template<class C,class...A> struct bbCtorDeclInfo : public bbDeclInfo{
 template<class C,class...A> struct bbCtorDeclInfo : public bbDeclInfo{
 
 
-	bbCtorDeclInfo(){
+	bbCtorDeclInfo( bbString meta ){
 		this->name="New";
 		this->name="New";
+		this->meta=meta;
 		this->kind="Constructor";
 		this->kind="Constructor";
 		this->type=bbGetType<bbFunction<void(A...)>>();
 		this->type=bbGetType<bbFunction<void(A...)>>();
+		this->flags=BB_DECL_INVOKABLE;
 	}
 	}
 	
 	
 	template<int...I> C *invoke( bbArray<bbVariant> params,detail::seq<I...> ){
 	template<int...I> C *invoke( bbArray<bbVariant> params,detail::seq<I...> ){
@@ -170,9 +224,9 @@ template<class C,class...A> struct bbCtorDeclInfo : public bbDeclInfo{
 	}
 	}
 };
 };
 
 
-template<class C,class...A> bbDeclInfo *bbCtorDecl(){
+template<class C,class...A> bbDeclInfo *bbCtorDecl( bbString meta="" ){
 
 
-	return new bbCtorDeclInfo<C,A...>();
+	return new bbCtorDeclInfo<C,A...>( meta );
 }
 }
 
 
 // ***** Method *****
 // ***** Method *****
@@ -181,10 +235,12 @@ template<class C,class R,class...A> struct bbMethodDeclInfo : public bbDeclInfo{
 
 
 	R (C::*ptr)(A...);
 	R (C::*ptr)(A...);
 	
 	
-	bbMethodDeclInfo( bbString name,R (C::*ptr)(A...) ):ptr( ptr ){
+	bbMethodDeclInfo( bbString name,bbString meta,R (C::*ptr)(A...) ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
+		this->meta=meta;
 		this->kind="Method";
 		this->kind="Method";
 		this->type=bbGetType<bbFunction<R(A...)>>();
 		this->type=bbGetType<bbFunction<R(A...)>>();
+		this->flags=BB_DECL_INVOKABLE;
 	}
 	}
 	
 	
 	template<int...I> R invoke( C *p,bbArray<bbVariant> params,detail::seq<I...> ){
 	template<int...I> R invoke( C *p,bbArray<bbVariant> params,detail::seq<I...> ){
@@ -206,10 +262,12 @@ template<class C,class...A> struct bbMethodDeclInfo<C,void,A...> : public bbDecl
 
 
 	R (C::*ptr)(A...);
 	R (C::*ptr)(A...);
 	
 	
-	bbMethodDeclInfo( bbString name,R (C::*ptr)(A...) ):ptr( ptr ){
+	bbMethodDeclInfo( bbString name,bbString meta,R (C::*ptr)(A...) ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
+		this->meta=meta;
 		this->kind="Method";
 		this->kind="Method";
 		this->type=bbGetType<bbFunction<R(A...)>>();
 		this->type=bbGetType<bbFunction<R(A...)>>();
+		this->flags=BB_DECL_INVOKABLE;
 	}
 	}
 	
 	
 	template<int...I> R invoke( C *p,bbArray<bbVariant> params,detail::seq<I...> ){
 	template<int...I> R invoke( C *p,bbArray<bbVariant> params,detail::seq<I...> ){
@@ -227,9 +285,47 @@ template<class C,class...A> struct bbMethodDeclInfo<C,void,A...> : public bbDecl
 	}
 	}
 };
 };
 
 
-template<class C,class R,class...A> bbDeclInfo *bbMethodDecl( bbString name,R (C::*ptr)(A...) ){
+template<class C,class R,class...A> bbDeclInfo *bbMethodDecl( bbString name,R (C::*ptr)(A...),bbString meta="" ){
+
+	return new bbMethodDeclInfo<C,R,A...>( name,meta,ptr );
+}
+
+// ***** Property *****
+//
+template<class C,class T> struct bbPropertyDeclInfo : public bbDeclInfo{
+
+	T (C::*getter)();
+	
+	void (C::*setter)(T);
+	
+	bbPropertyDeclInfo( bbString name,bbString meta,T(C::*getter)(),void(C::*setter)(T) ):getter( getter ),setter( setter ){
+		this->name=name;
+		this->meta=meta;
+		this->kind="Property";
+		this->type=bbGetType<T>();
+		this->flags=(getter ? BB_DECL_GETTABLE : 0) | (setter ? BB_DECL_SETTABLE : 0);
+	}
+	
+	bbVariant get( bbVariant instance ){
+		if( !getter ) bbRuntimeError( "Property has not getter" );
+
+		C *p=instance.get<C*>();
+		
+		return bbVariant( (p->*getter)() );
+	}
+	
+	void set( bbVariant instance,bbVariant value ){
+		if( !setter ) bbRuntimeError( "Property has not setter" );
+		
+		C *p=instance.get<C*>();
+		
+		(p->*setter)( value.get<T>() );
+	}
+};
+
+template<class C,class T> bbDeclInfo *bbPropertyDecl( bbString name,T(C::*getter)(),void(C::*setter)(T),bbString meta="" ){
 
 
-	return new bbMethodDeclInfo<C,R,A...>( name,ptr );
+	return new bbPropertyDeclInfo<C,T>( name,meta,getter,setter );
 }
 }
 
 
 // ***** Function *****
 // ***** Function *****
@@ -238,10 +334,12 @@ template<class R,class...A> struct bbFunctionDeclInfo : public bbDeclInfo{
 
 
 	R (*ptr)(A...);
 	R (*ptr)(A...);
 	
 	
-	bbFunctionDeclInfo( bbString name,R (*ptr)(A...) ):ptr( ptr ){
+	bbFunctionDeclInfo( bbString name,bbString meta,R (*ptr)(A...) ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
+		this->meta=meta;
 		this->kind="Function";
 		this->kind="Function";
 		this->type=bbGetType<bbFunction<R(A...)>>();
 		this->type=bbGetType<bbFunction<R(A...)>>();
+		this->flags=BB_DECL_INVOKABLE;
 	}
 	}
 	
 	
 	template<int...I> R invoke( bbArray<bbVariant> params,detail::seq<I...> ){
 	template<int...I> R invoke( bbArray<bbVariant> params,detail::seq<I...> ){
@@ -261,10 +359,12 @@ template<class...A> struct bbFunctionDeclInfo<void,A...> : public bbDeclInfo{
 
 
 	R (*ptr)(A...);
 	R (*ptr)(A...);
 	
 	
-	bbFunctionDeclInfo( bbString name,R (*ptr)(A...) ):ptr( ptr ){
+	bbFunctionDeclInfo( bbString name,bbString meta,R (*ptr)(A...) ):ptr( ptr ){
 		this->name=name;
 		this->name=name;
+		this->meta=meta;
 		this->kind="Function";
 		this->kind="Function";
 		this->type=bbGetType<bbFunction<R(A...)>>();
 		this->type=bbGetType<bbFunction<R(A...)>>();
+		this->flags=BB_DECL_INVOKABLE;
 	}
 	}
 	
 	
 	template<int...I> R invoke( bbArray<bbVariant> params,detail::seq<I...> ){
 	template<int...I> R invoke( bbArray<bbVariant> params,detail::seq<I...> ){
@@ -280,9 +380,9 @@ template<class...A> struct bbFunctionDeclInfo<void,A...> : public bbDeclInfo{
 	}
 	}
 };
 };
 
 
-template<class R,class...A> bbDeclInfo *bbFunctionDecl( bbString name,R (*ptr)(A...) ){
+template<class R,class...A> bbDeclInfo *bbFunctionDecl( bbString name,R (*ptr)(A...),bbString meta="" ){
 
 
-	return new bbFunctionDeclInfo<R,A...>( name,ptr );
+	return new bbFunctionDeclInfo<R,A...>( name,meta,ptr );
 }
 }
 
 
 template<class...Ds> bbDeclInfo **bbMembers( Ds...ds ){
 template<class...Ds> bbDeclInfo **bbMembers( Ds...ds ){

+ 1 - 5
modules/monkey/native/bbmonkey.h

@@ -18,15 +18,11 @@
 #include "bbdeclinfo.h"
 #include "bbdeclinfo.h"
 
 
 extern int bb_argc;
 extern int bb_argc;
+
 extern char **bb_argv;
 extern char **bb_argv;
 
 
 extern void bb_print( bbString str );
 extern void bb_print( bbString str );
 
 
 extern void bb_printf( const char *fmt,...);
 extern void bb_printf( const char *fmt,...);
 
 
-template<class X,class Y> int bbCompare( X x,Y y ){
-	if( y>x ) return -1;
-	return x>y;
-}
-
 #endif
 #endif

+ 14 - 0
modules/monkey/native/bbobject.cpp

@@ -4,3 +4,17 @@
 #include "bbarray.h"
 #include "bbarray.h"
 
 
 bbNullCtor_t bbNullCtor;
 bbNullCtor_t bbNullCtor;
+
+// ***** bbObject *****
+
+bbObject::~bbObject(){
+}
+
+const char *bbObject::typeName()const{
+	return "monkey.Object";
+}
+
+// ***** bbInterface *****
+
+bbInterface::~bbInterface(){
+}

+ 3 - 7
modules/monkey/native/bbobject.h

@@ -14,16 +14,13 @@ struct bbObject : public bbGCNode{
 		bbGC::beginCtor( this );
 		bbGC::beginCtor( this );
 	}
 	}
 	
 	
-	virtual ~bbObject(){
-	}
+	virtual ~bbObject();
 
 
 	//implemented in bbtypeinfo.h
 	//implemented in bbtypeinfo.h
 	//	
 	//	
 	virtual bbTypeInfo *typeof()const;
 	virtual bbTypeInfo *typeof()const;
 	
 	
-	virtual const char *typeName()const{
-		return "monkey.Object";
-	}
+	virtual const char *typeName()const;
 	
 	
 	void *operator new( size_t size ){
 	void *operator new( size_t size ){
 		return bbGC::alloc( size );
 		return bbGC::alloc( size );
@@ -43,8 +40,7 @@ struct bbInterface{
 
 
 	typedef bbInterface *bb_object_type;
 	typedef bbInterface *bb_object_type;
 
 
-	virtual ~bbInterface(){
-	}
+	virtual ~bbInterface();
 };
 };
 
 
 struct bbNullCtor_t{
 struct bbNullCtor_t{

+ 20 - 0
modules/monkey/native/bbtypeinfo.cpp

@@ -7,6 +7,26 @@ namespace{
 	bbClassTypeInfo *_classes;
 	bbClassTypeInfo *_classes;
 }
 }
 
 
+#define BB_PRIM_GETTYPE( TYPE,ID ) bbTypeInfo *bbGetType( TYPE const& ){ \
+	static bbPrimTypeInfo info( ID ); \
+	return &info; \
+}
+
+BB_PRIM_GETTYPE( bbBool,"Bool" )
+BB_PRIM_GETTYPE( bbByte,"Byte" )
+BB_PRIM_GETTYPE( bbUByte,"UShort" )
+BB_PRIM_GETTYPE( bbShort,"Short" )
+BB_PRIM_GETTYPE( bbUShort,"UShort" )
+BB_PRIM_GETTYPE( bbInt,"Int" )
+BB_PRIM_GETTYPE( bbUInt,"UInt" )
+BB_PRIM_GETTYPE( bbLong,"Long" )
+BB_PRIM_GETTYPE( bbULong,"ULong" )
+BB_PRIM_GETTYPE( bbFloat,"Float" )
+BB_PRIM_GETTYPE( bbDouble,"Double" )
+BB_PRIM_GETTYPE( bbString,"String" )
+BB_PRIM_GETTYPE( bbCString,"CString" )
+BB_PRIM_GETTYPE( bbVariant,"Variant" )
+
 // ***** bbTypeInfo *****
 // ***** bbTypeInfo *****
 
 
 bbString bbTypeInfo::toString(){
 bbString bbTypeInfo::toString(){

+ 16 - 23
modules/monkey/native/bbtypeinfo.h

@@ -186,28 +186,24 @@ struct bbClassTypeInfo : public bbTypeInfo{
 	static bbClassTypeInfo *getNamespace( bbString name );
 	static bbClassTypeInfo *getNamespace( bbString name );
 };
 };
 
 
-#define BB_PRIM_TYPEINFO( TYPE,ID ) inline bbTypeInfo *bbGetType( TYPE const& ){ \
-	static bbPrimTypeInfo info( ID ); \
-	return &info; \
-}
-
-BB_PRIM_TYPEINFO( bbBool,"Bool" )
-BB_PRIM_TYPEINFO( bbByte,"Byte" )
-BB_PRIM_TYPEINFO( bbUByte,"UShort" )
-BB_PRIM_TYPEINFO( bbShort,"Short" )
-BB_PRIM_TYPEINFO( bbUShort,"UShort" )
-BB_PRIM_TYPEINFO( bbInt,"Int" )
-BB_PRIM_TYPEINFO( bbUInt,"UInt" )
-BB_PRIM_TYPEINFO( bbLong,"Long" )
-BB_PRIM_TYPEINFO( bbULong,"ULong" )
-BB_PRIM_TYPEINFO( bbFloat,"Float" )
-BB_PRIM_TYPEINFO( bbDouble,"Double" )
-BB_PRIM_TYPEINFO( bbString,"String" )
-BB_PRIM_TYPEINFO( bbCString,"CString" )
-BB_PRIM_TYPEINFO( bbVariant,"Variant" )
+#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& ){
 inline bbTypeInfo *bbGetType( bbObject* const& ){
-
 	return &bbObjectTypeInfo::instance;
 	return &bbObjectTypeInfo::instance;
 }
 }
 
 
@@ -244,17 +240,14 @@ template<class R,class...A> bbTypeInfo *bbGetType( bbFunction<R(A...)> const& ){
 }
 }
 
 
 template<class T> bbTypeInfo *bbGetType( bbGCVar<T> const& ){
 template<class T> bbTypeInfo *bbGetType( bbGCVar<T> const& ){
-
 	return bbGetType<T*>();
 	return bbGetType<T*>();
 }
 }
 
 
 template<> inline bbTypeInfo *bbGetType<void>(){
 template<> inline bbTypeInfo *bbGetType<void>(){
-
 	return &bbVoidTypeInfo::instance;
 	return &bbVoidTypeInfo::instance;
 }
 }
 
 
 template<class T> bbTypeInfo *bbGetType(){
 template<class T> bbTypeInfo *bbGetType(){
-
 	return bbGetType( *(T*)0 );
 	return bbGetType( *(T*)0 );
 }
 }
 
 

+ 5 - 4
modules/monkey/native/bbtypes.h

@@ -27,9 +27,7 @@ template<class T,int D=1> class bbArray;
 template<class T> struct bbGCVar;
 template<class T> struct bbGCVar;
 
 
 struct bbVariant;
 struct bbVariant;
-
 struct bbTypeInfo;
 struct bbTypeInfo;
-
 struct bbDeclInfo;
 struct bbDeclInfo;
 
 
 namespace detail{
 namespace detail{
@@ -45,8 +43,11 @@ namespace detail{
 	template<typename T> struct remove_pointer<T*> { typedef typename remove_pointer<T>::type type; };
 	template<typename T> struct remove_pointer<T*> { typedef typename remove_pointer<T>::type type; };
 }
 }
 
 
-template<class T> bbTypeInfo *bbGetType();
-
 bbString bbTypeName( const char *type );
 bbString bbTypeName( const char *type );
 
 
+template<class X,class Y> int bbCompare( X x,Y y ){
+	if( y>x ) return -1;
+	return x>y;
+}
+
 #endif
 #endif

+ 15 - 1
modules/monkey/native/bbvariant.cpp

@@ -1,4 +1,18 @@
 
 
 #include "bbvariant.h"
 #include "bbvariant.h"
 
 
-bbVariant::RepBase bbVariant::_null;
+bbVariant::RepBase bbVariant::_null;
+
+template struct bbVariant::Rep<bbBool>;
+template struct bbVariant::Rep<bbByte>;
+template struct bbVariant::Rep<bbUByte>;
+template struct bbVariant::Rep<bbShort>;
+template struct bbVariant::Rep<bbUShort>;
+template struct bbVariant::Rep<bbInt>;
+template struct bbVariant::Rep<bbUInt>;
+template struct bbVariant::Rep<bbLong>;
+template struct bbVariant::Rep<bbULong>;
+template struct bbVariant::Rep<bbFloat>;
+template struct bbVariant::Rep<bbDouble>;
+template struct bbVariant::Rep<bbString>;
+

+ 28 - 9
modules/monkey/native/bbvariant.h

@@ -68,6 +68,7 @@ struct bbVariant{
 		}
 		}
 	};
 	};
 	
 	
+/*	
 	template<class R,class...A> struct FuncRep : public Rep<bbFunction<R(A...)>>{
 	template<class R,class...A> struct FuncRep : public Rep<bbFunction<R(A...)>>{
 
 
 		FuncRep( bbFunction<R(A...)> func ):Rep<bbFunction<R(A...)>>( func ){
 		FuncRep( bbFunction<R(A...)> func ):Rep<bbFunction<R(A...)>>( func ){
@@ -101,6 +102,7 @@ struct bbVariant{
 			return {};
 			return {};
 		}
 		}
 	};
 	};
+*/
 	
 	
 	static RepBase _null;
 	static RepBase _null;
 	
 	
@@ -129,11 +131,13 @@ struct bbVariant{
 	template<class T> explicit bbVariant( const bbGCVar<T> &t ):_rep( new Rep<T*>( t.get() ) ){
 	template<class T> explicit bbVariant( const bbGCVar<T> &t ):_rep( new Rep<T*>( t.get() ) ){
 	}
 	}
 	
 	
+	/*
 	template<class R,class...A> explicit bbVariant( bbFunction<R(A...)> func ) : _rep( new FuncRep<R,A...>( func ) ){
 	template<class R,class...A> explicit bbVariant( bbFunction<R(A...)> func ) : _rep( new FuncRep<R,A...>( func ) ){
 	}
 	}
 	
 	
 	template<class R,class...A> explicit bbVariant( R(*func)(A...) ):_rep( new FuncRep<R,A...>( bbMakefunc( func ) ) ){
 	template<class R,class...A> explicit bbVariant( R(*func)(A...) ):_rep( new FuncRep<R,A...>( bbMakefunc( func ) ) ){
 	}
 	}
+	*/
 	
 	
 	~bbVariant(){
 	~bbVariant(){
 		release();
 		release();
@@ -147,9 +151,15 @@ struct bbVariant{
 	}
 	}
 	
 	
 	bbTypeInfo *getType()const{
 	bbTypeInfo *getType()const{
+		
 		return _rep->getType();
 		return _rep->getType();
 	}
 	}
 	
 	
+	operator bool()const{
+		
+		return _rep!=&_null;
+	}
+	
 	template<class T> T get()const{
 	template<class T> T get()const{
 	
 	
 		Rep<T> *p=dynamic_cast<Rep<T>*>( _rep );
 		Rep<T> *p=dynamic_cast<Rep<T>*>( _rep );
@@ -172,20 +182,29 @@ struct bbVariant{
 		return T{};
 		return T{};
 	}
 	}
 	
 	
-	bbVariant invoke( bbArray<bbVariant> params ){
-	
-		return _rep->invoke( params );
-	}
-	
-	operator bool()const{
-	
-		return _rep!=&_null;
-	}
 };
 };
 
 
+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 ){
 inline void bbGCMark( const bbVariant &v ){
 
 
 	v._rep->gcMark();
 	v._rep->gcMark();
 }
 }
 
 
+inline int bbCompare( const bbVariant &x,const bbVariant &y ){
+
+	return y._rep>x._rep ? -1 : x._rep>y._rep;
+}
+
 #endif
 #endif