From: <z-...@us...> - 2008-02-22 00:04:03
|
Revision: 8041 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8041&view=rev Author: z-man Date: 2008-02-21 16:03:58 -0800 (Thu, 21 Feb 2008) Log Message: ----------- Further namespace work. Trouble with Templates + Masters + Namespaces, couldn't get "Std Vector With(Int)" to work yet. Modified Paths: -------------- private/z-man/clio/classname.hpp private/z-man/clio/iclassinfo.cpp private/z-man/clio/iclassinfo.hpp private/z-man/clio/ifunctioninfo.cpp private/z-man/clio/macros.hpp private/z-man/clio/namespace.cpp private/z-man/clio/namespace.hpp private/z-man/clio/std_container.hpp private/z-man/clio/tests/container.test/test.io Modified: private/z-man/clio/classname.hpp =================================================================== --- private/z-man/clio/classname.hpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/classname.hpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -268,7 +268,7 @@ else \ { \ s << ClassInfo< CLASS CLIO_TEMPLATE_ARGLIST_COMPLETE(SIGNATURE) > \ - ::Get().GetNamespace() << NAME; \ + ::Get().GetNameSpace() << NAME; \ } \ TemplateNameHelper< type >::Begin( s ); \ CLIO_TEMPLATE_ARGNAMES(SIGNATURE); \ Modified: private/z-man/clio/iclassinfo.cpp =================================================================== --- private/z-man/clio/iclassinfo.cpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/iclassinfo.cpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -123,7 +123,7 @@ if ( type == Name_IoComplete && GetName(Name_IoRaw).size() > 0 ) { // special case: compose the complete Io name from the raw io name and the namespace - name_[type] = GetNamespace() + name_[Name_IoRaw]; + name_[type] = GetNameSpace() + name_[Name_IoRaw]; } else if ( nameGetter_[type] ) { @@ -150,7 +150,7 @@ } // returns the name of the nesting parent with appended space, or an empty string -std::string IClassInfo::GetNamespace() const CLIO_NOTHROW +std::string IClassInfo::GetNameSpace() const CLIO_NOTHROW { if ( nestingParent_ ) { @@ -162,6 +162,16 @@ } } +IClassInfo & IClassInfo::SetNestingParent( IClassInfo * nestingParent ) CLIO_NOTHROW +{ + nestingParent_ = nestingParent; + if ( nestingParent && nestingParent->GetMinLevel() < GetMinLevel() ) + { + SetMinLevel( nestingParent->GetMinLevel() ); + } + return *this; +} + ClassRegistratorSet & IClassInfo::GetClassRegistratorSet() const CLIO_NOTHROW { return * registrators_; Modified: private/z-man/clio/iclassinfo.hpp =================================================================== --- private/z-man/clio/iclassinfo.hpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/iclassinfo.hpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -80,7 +80,7 @@ */ // returns the name of the nesting parent with appended space, or an empty string - std::string GetNamespace() const CLIO_NOTHROW; + std::string GetNameSpace() const CLIO_NOTHROW; // accessors for nesting parent (class or namespace this class is part of) IClassInfo * GetNestingParent() const CLIO_NOTHROW @@ -88,11 +88,7 @@ return nestingParent_; } - IClassInfo & SetNestingParent( IClassInfo * nestingParent ) CLIO_NOTHROW - { - nestingParent_ = nestingParent; - return *this; - } + IClassInfo & SetNestingParent( IClassInfo * nestingParent ) CLIO_NOTHROW; ClassRegistratorSet & GetClassRegistratorSet() const CLIO_NOTHROW; // returns the space where class dependant registrators can register themselves for later processing Modified: private/z-man/clio/ifunctioninfo.cpp =================================================================== --- private/z-man/clio/ifunctioninfo.cpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/ifunctioninfo.cpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -595,7 +595,9 @@ , callIsComingFromScript_( false ) , transferOwnership_( false ) , nonBreaking_( false ) -{} +{ + SetMinLevel( classInfo.GetMinLevel() ); +} // adds a function overload, returns representing function IFunctionInfo & IFunctionInfo::Get( char const * name, ArgumentsPtr arguments, IClassInfo & classInfo, ExecutePtr function, QualityPtr quality ) CLIO_NOTHROW Modified: private/z-man/clio/macros.hpp =================================================================== --- private/z-man/clio/macros.hpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/macros.hpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -232,7 +232,7 @@ info.SetName( IClassInfo::Name_IoRaw, ioName ); // register namespace - NameSpace * nameSpace = NameSpace::GetNameSpace( cName ); + NameSpace * nameSpace = NameSpace::GetNameSpaceByClassName( cName ); if ( nameSpace ) { info.SetNestingParent( nameSpace ); @@ -436,6 +436,9 @@ #define CLIO_CLASS_NESTED_IN_EX( PARENT ) clio::RegisterNestingParentClass< CLASS, PARENT >() #define CLIO_CLASS_NESTED_IN( PARENT ) CLIO_CLASS_NESTED_IN_EX(PARENT) +// inject class into namespace +#define CLIO_CLASS_NAMESPACE( NAME ) ClassInfo< CLASS >::Get().SetNestingParent( NameSpace::GetNameSpace( std::string( NAME ) ) ) + // change access level of class #define CLIO_CLASS_MIN_LEVEL( LEVEL ) ClassInfo< CLASS >::Get().SetMinLevel( LEVEL ) Modified: private/z-man/clio/namespace.cpp =================================================================== --- private/z-man/clio/namespace.cpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/namespace.cpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -51,6 +51,24 @@ static SpaceMap spaces; static AutoClearer clearer( spaces ); + // look for namespace in map + SpaceMap::iterator found = spaces.find( name ); + if ( found != spaces.end() ) + { + return (*found).second; + } + + // create new namespace and store it + NameSpace * & space = spaces[ name ]; + space = new NameSpace; + space->SetName( IClassInfo::Name_C , name ); + space->SetName( IClassInfo::Name_IoRaw, Uppercase( name.c_str() ) ); + return space; +} + +// gets a namespace of a given class name +NameSpace * NameSpace::GetNameSpaceByClassName( std::string const & name ) +{ // parse the class name std::istringstream s( name ); std::ostringstream nameSpaceName; @@ -69,15 +87,7 @@ } while( true ); - NameSpace * & space = spaces[ nameSpaceName.str() ]; - if ( !space ) - { - space = new NameSpace; - space->SetName( IClassInfo::Name_C , nameSpaceName.str() ); - space->SetName( IClassInfo::Name_IoRaw, Uppercase( nameSpaceName.str().c_str() ) ); - } - - return space; + return GetNameSpace( nameSpaceName.str() ); } } Modified: private/z-man/clio/namespace.hpp =================================================================== --- private/z-man/clio/namespace.hpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/namespace.hpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -11,6 +11,9 @@ { public: // gets a namespace of a given class name + static NameSpace * GetNameSpaceByClassName( std::string const & className ); + + // gets a namespace of a given class name static NameSpace * GetNameSpace( std::string const & name ); private: // returns the size of the wrapped object Modified: private/z-man/clio/std_container.hpp =================================================================== --- private/z-man/clio/std_container.hpp 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/std_container.hpp 2008-02-22 00:03:58 UTC (rev 8041) @@ -168,11 +168,12 @@ CLIO_TEMPLATE_CLASS_EX( std::vector, (1,(class)), "RawVector" ){} CLIO_TEMPLATE_SET_DEFAULTCONSTRUCTOR( clio::VectorWrapper, (1,(class)), true ); -CLIO_TEMPLATE_CLASS_EX( clio::VectorWrapper, (1,(class)), "StdVector" ) +CLIO_TEMPLATE_CLASS_EX( clio::VectorWrapper, (1,(class)), "Vector" ) { + CLIO_CLASS_NAMESPACE("std"); CLIO_CLASS_BASE( clio::VectorProxy< Wrapper< std::vector<T1> > > ); } -CLIO_TEMPLATE_CLASS_MASTER_EX( clio::VectorWrapper, (1,(class)), (1,(clio::IoObjectPointer) ), "StdVector", "With" ); +CLIO_TEMPLATE_CLASS_MASTER( clio::VectorWrapper, (1,(class)), (1,(clio::IoObjectPointer) ) ); CLIO_CONVERTAS_PROXY_TEMPLATE_COMPLETE( std::vector, (2,(class,class)), VectorProxy ); Modified: private/z-man/clio/tests/container.test/test.io =================================================================== --- private/z-man/clio/tests/container.test/test.io 2008-02-21 22:00:56 UTC (rev 8040) +++ private/z-man/clio/tests/container.test/test.io 2008-02-22 00:03:58 UTC (rev 8041) @@ -18,8 +18,12 @@ ints pop println ints pop println +x getInts clone type println +Std Vector clone type println +Std VectorWrapper clone type println +Clio VectorWrapper type println x getInts foreach(println) -x setInts( StdVector With(Int) clone append(5) ) +x setInts( Std Vector With(Int) clone append(5) ) x getInts foreach(println) x createFloats() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 10:54:08
|
Revision: 8044 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8044&view=rev Author: z-man Date: 2008-02-22 02:54:13 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Name of TEMPLATE_CLASS_MASTER defaults to the name set in TEMPLATE_CLASS. Modified Paths: -------------- private/z-man/clio/classinfo.hpp private/z-man/clio/classname.hpp private/z-man/clio/iclassinfo.hpp private/z-man/clio/ifunctioninfo.cpp private/z-man/clio/macros.hpp private/z-man/clio/tests/container.test/test.io Modified: private/z-man/clio/classinfo.hpp =================================================================== --- private/z-man/clio/classinfo.hpp 2008-02-22 09:36:59 UTC (rev 8043) +++ private/z-man/clio/classinfo.hpp 2008-02-22 10:54:13 UTC (rev 8044) @@ -120,8 +120,10 @@ ClassInfo() { + SetNameGetter( Name_Template , classname::ClassNameDefaultGetter< T, Name_Template >::Get ); SetNameGetter( Name_C , classname::ClassNameDefaultGetter< T, Name_C >::Get ); SetNameGetter( Name_IoComplete, classname::ClassNameDefaultGetter< T, Name_IoComplete >::Get ); + // GetName( Name_Template ); // instantiate (sneaky recursion: if anyone instantiates this template, // the code below triggers the clio glue instantiation, which makes this Modified: private/z-man/clio/classname.hpp =================================================================== --- private/z-man/clio/classname.hpp 2008-02-22 09:36:59 UTC (rev 8043) +++ private/z-man/clio/classname.hpp 2008-02-22 10:54:13 UTC (rev 8044) @@ -261,8 +261,13 @@ { \ static void Get( std::ostream & s ) \ { \ - if ( type == IClassInfo::Name_C ) \ + if ( type == IClassInfo::Name_Template ) \ { \ + s << NAME; \ + return; \ + } \ + else if ( type == IClassInfo::Name_C ) \ + { \ s << #CLASS; \ } \ else \ Modified: private/z-man/clio/iclassinfo.hpp =================================================================== --- private/z-man/clio/iclassinfo.hpp 2008-02-22 09:36:59 UTC (rev 8043) +++ private/z-man/clio/iclassinfo.hpp 2008-02-22 10:54:13 UTC (rev 8044) @@ -45,6 +45,7 @@ enum NameType { Name_C = 0, // the name of a class in C++ + Name_Template , // the base template name Name_IoRaw , // the name of the class in Io without namespace decoration Name_IoComplete , // the name you can use in Io to reach the class Name_Max Modified: private/z-man/clio/ifunctioninfo.cpp =================================================================== --- private/z-man/clio/ifunctioninfo.cpp 2008-02-22 09:36:59 UTC (rev 8043) +++ private/z-man/clio/ifunctioninfo.cpp 2008-02-22 10:54:13 UTC (rev 8044) @@ -147,7 +147,7 @@ StackResetter topMarker( & topOfStack_ ); // get self - IoObjectPointer self = selfWrapper.GetSelf(); + IoObject * self = selfWrapper.GetSelf(); assert( self ); // get state @@ -160,6 +160,7 @@ // fetch the arguments std::vector< IoObject * > arguments; std::vector< IoObjectPointer > argumentsRetained; // for bookkeeping: makes sure the evaluated arguments don't go out of scope + argumentsRetained.push_back( self ); int argCount = IoMessage_argCount(m); arguments.reserve( argCount ); argumentsRetained.reserve( argCount ); @@ -409,8 +410,7 @@ // IoObjectPointersender = IoObject_getSlot(call, IOSTRING("sender")); - IoObjectPointer ret = selfData->function->ExecuteInline_( targetWrapper, locals, m ); - return ret; + return selfData->function->ExecuteInline_( targetWrapper, locals, m ); } catch ( clio::Exception & e ) { Modified: private/z-man/clio/macros.hpp =================================================================== --- private/z-man/clio/macros.hpp 2008-02-22 09:36:59 UTC (rev 8043) +++ private/z-man/clio/macros.hpp 2008-02-22 10:54:13 UTC (rev 8044) @@ -355,7 +355,7 @@ } CLIO_FORCESEMICOLON(X) #define CLIO_TEMPLATE_CLASS_MASTER_EX( TEMPLATE, SIGNATURE, MASTER_SIGNATURE, MASTER_NAME, FUNCTION_NAME ) \ -CLIO_INSTANTIATE_TEMPLATE_EX( TEMPLATE, MASTER_SIGNATURE, clio::GetClassName( #TEMPLATE, MASTER_NAME ).c_str() ); \ +CLIO_INSTANTIATE_TEMPLATE_EX( TEMPLATE, MASTER_SIGNATURE, MASTER_NAME ); \ CLIO_TEMPLATE_CLASS_MASTER_BEGIN_EX( TEMPLATE, SIGNATURE, FUNCTION_NAME ) \ typedef TEMPLATE CLIO_TEMPLATE_ARGLIST_COMPLETE_SIGNATURE(MASTER_SIGNATURE) Master; \ CLIO_TEMPLATE_CLASS_MASTER_END_EX( TEMPLATE, SIGNATURE, FUNCTION_NAME ) @@ -377,14 +377,18 @@ #define CLIO_INSTANTIATE_EX( CLASS ) \ template class clio::InstantiatorHelperReal< clio::Instantiator< CLASS > > -#define CLIO_INSTANTIATE_TEMPLATE_EX_BASE( FULLNAME, NAME ) \ +#define CLIO_INSTANTIATE_TEMPLATE_EX_BASE( TEMPLATE, FULLNAME, NAME ) \ namespace clio { \ template<> \ struct InstantiatorTemplate< FULLNAME > \ { \ InstantiatorTemplate() \ { \ - ClassInfo< FULLNAME >::Get().SetName( IClassInfo::Name_IoRaw, NAME ); \ + ClassInfo< FULLNAME > & info = ClassInfo< FULLNAME >::Get(); \ + if ( strlen( NAME ) > 0 ) \ + info.SetName( IClassInfo::Name_IoRaw, NAME ); \ + else \ + info.SetName( IClassInfo::Name_IoRaw, info.GetName( IClassInfo::Name_Template ) ); \ } \ }; \ } \ @@ -392,7 +396,7 @@ template class clio::InstantiatorHelperReal< clio::InstantiatorTemplate< FULLNAME > > #define CLIO_INSTANTIATE_TEMPLATE_EX( TEMPLATE, SIGNATURE, NAME ) \ -CLIO_INSTANTIATE_TEMPLATE_EX_BASE( TEMPLATE CLIO_TEMPLATE_ARGLIST_COMPLETE_SIGNATURE(SIGNATURE), NAME ) +CLIO_INSTANTIATE_TEMPLATE_EX_BASE( TEMPLATE, TEMPLATE CLIO_TEMPLATE_ARGLIST_COMPLETE_SIGNATURE(SIGNATURE), NAME ) #define CLIO_INSTANTIATE_TEMPLATE( TEMPLATE, SIGNATURE, NAME ) CLIO_INSTANTIATE_TEMPLATE_EX( TEMPLATE, SIGNATURE, NAME ) Modified: private/z-man/clio/tests/container.test/test.io =================================================================== --- private/z-man/clio/tests/container.test/test.io 2008-02-22 09:36:59 UTC (rev 8043) +++ private/z-man/clio/tests/container.test/test.io 2008-02-22 10:54:13 UTC (rev 8044) @@ -18,12 +18,8 @@ ints pop println ints pop println -x getInts clone type println -Std Vector clone type println -Std VectorWrapper clone type println -Clio VectorWrapper type println -x getInts foreach(println) +x createFloats() + x setInts( Std Vector With(Int) clone append(5) ) x getInts foreach(println) -x createFloats() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 12:25:46
|
Revision: 8048 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8048&view=rev Author: z-man Date: 2008-02-22 04:25:50 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Avoid calling IoState_error_ from within fragile C++ stacks. Modified Paths: -------------- private/z-man/clio/gcmarker.cpp private/z-man/clio/ifunctioninfo.cpp Modified: private/z-man/clio/gcmarker.cpp =================================================================== --- private/z-man/clio/gcmarker.cpp 2008-02-22 11:51:34 UTC (rev 8047) +++ private/z-man/clio/gcmarker.cpp 2008-02-22 12:25:50 UTC (rev 8048) @@ -62,6 +62,7 @@ // removes a marker from this set void GCAutoMarkerBigSet::DoRemove( GCAutoMarker & marker ) { + assert( markers_.find( &marker ) != markers_.end() ); markers_.erase( &marker ); } @@ -152,8 +153,11 @@ if ( *iter == &marker ) { (*iter) = 0; + return; } } + + assert(0); } // called when the objects should be marked Modified: private/z-man/clio/ifunctioninfo.cpp =================================================================== --- private/z-man/clio/ifunctioninfo.cpp 2008-02-22 11:51:34 UTC (rev 8047) +++ private/z-man/clio/ifunctioninfo.cpp 2008-02-22 12:25:50 UTC (rev 8048) @@ -378,7 +378,7 @@ // and replace it with an inheritance check (look up IoCFunction_activate in IoCFunctio.c to // see the original) -IoObject *ClioFunction_activate(IoCFunction *self, IoObject *target, IoObject *locals, IoMessage *m, IoObject *slotContext) +IoObject *ClioFunction_activateNoError(IoCFunction *self, IoObject *target, IoObject *locals, IoMessage *m, IoObject *slotContext) { assert( self ); assert( locals ); @@ -400,20 +400,23 @@ ObjectWrapper & targetWrapper = IClassInfo::GetObjectWrapper( target ); // call function object stored in data - { + return selfData->function->ExecuteInline_( targetWrapper, locals, m ); +} + +IoObject *ClioFunction_activate(IoCFunction *self, IoObject *target, IoObject *locals, IoMessage *m, IoObject *slotContext) +{ try { - /* - IoObjectPointercall = IoObject_getSlot_(locals, IOSYMBOL("call")); - IoObjectPointersender = IoCall_sender(call, locals, m); - */ - - // IoObjectPointersender = IoObject_getSlot(call, IOSTRING("sender")); - - return selfData->function->ExecuteInline_( targetWrapper, locals, m ); + return ClioFunction_activateNoError( self, target, locals, m, slotContext ); } catch ( clio::Exception & e ) { + // access data + ClioFunctionData *selfData = DATA(self); + + // get state + IoState * state = IoObject_state( self ); + std::ostringstream out; out << "during call of C++ function '" << selfData->function->GetFullName() << "'"; @@ -421,38 +424,55 @@ return NULL; } - } } IoObject *ClioFunction_performOn(IoCFunction *self, IoObject *locals, IoMessage *m) { - assert( self ); - assert( locals ); - assert( m ); + try + { + assert( self ); + assert( locals ); + assert( m ); - IoObjectPointer bTarget = IoMessage_locals_valueArgAt_(m, locals, 0); - IoObjectPointer bLocals = locals; - IoObjectPointer bMessage = m; - IoObjectPointer bContext = bTarget; - int argCount = IoMessage_argCount(m); + IoObject * bTarget = IoMessage_locals_valueArgAt_(m, locals, 0); + IoObject * bLocals = locals; + IoObject * bMessage = m; + IoObject * bContext = bTarget; + int argCount = IoMessage_argCount(m); - if (argCount > 1) - { - bLocals = IoMessage_locals_valueArgAt_(m, locals, 1); - } + if (argCount > 1) + { + bLocals = IoMessage_locals_valueArgAt_(m, locals, 1); + } - if (argCount > 2) - { - bMessage = IoMessage_locals_valueArgAt_(m, locals, 2); - } + if (argCount > 2) + { + bMessage = IoMessage_locals_valueArgAt_(m, locals, 2); + } - if (argCount > 3) - { - bContext = IoMessage_locals_valueArgAt_(m, locals, 3); - } + if (argCount > 3) + { + bContext = IoMessage_locals_valueArgAt_(m, locals, 3); + } - BoolTempSetter tempSetter( callIsComingFromScriptSubclass ); - return ClioFunction_activate(self, bTarget, bLocals, bMessage, bContext); + BoolTempSetter tempSetter( callIsComingFromScriptSubclass ); + return ClioFunction_activate(self, bTarget, bLocals, bMessage, bContext); + } + catch ( clio::Exception & e ) + { + // access data + ClioFunctionData *selfData = DATA(self); + + // get state + IoState * state = IoObject_state( self ); + + std::ostringstream out; + out << "during call of C++ function '" << selfData->function->GetFullName() + << "'"; + IoState_error_( state, m, "%s", e.GetDescription( out.str() ).c_str() ); + + return NULL; + } } // And to do the replacing, we need to basically install a whole new version of the rest of @@ -460,7 +480,7 @@ IoCFunction *ClioFunction_rawClone(IoCFunction *proto) { - IoObjectPointer self = IoObject_rawClonePrimitive(proto); + IoObject * self = IoObject_rawClonePrimitive(proto); IoObject_setDataPointer_(self, cpalloc(DATA(proto), sizeof(ClioFunctionData))); IoObject_isActivatable_( self, 1 ); return self; @@ -480,7 +500,7 @@ IoCFunction * ClioFunction_proto(void *state) { - IoObjectPointer self = IoObject_new(state); + IoObject * self = IoObject_new(state); IoObject_tag_( self, ClioFunction_tag(state) ); IoObject_setDataPointer_(self, calloc(1, sizeof(ClioFunctionData))); @@ -546,7 +566,7 @@ IoObject * IoObject_addClioMethod_( IoObject *self, IoSymbol *slotName, IFunctionInfo *fp ) { IoTag *t = IoObject_tag( self ); - IoObjectPointer proto = IoState_protoWithInitFunction_(IOSTATE, IoObject_proto); + IoObject * proto = IoState_protoWithInitFunction_(IOSTATE, IoObject_proto); IoCFunction *f; if (t == IoObject_tag( proto ) ) @@ -675,7 +695,7 @@ void IFunctionInfo::DoRegister( IoState * state, ObjectWrapper * selfWrapper, ExtraInfo const & info ) CLIO_NOTHROW { // fetch Io Object - IoObjectPointer self = selfWrapper->GetSelf(); + IoObject * self = selfWrapper->GetSelf(); // get symbol matching function name IoSymbol * slotName = IOSYMBOL( name_.c_str() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 13:58:05
|
Revision: 8050 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8050&view=rev Author: z-man Date: 2008-02-22 05:58:09 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Everything clio now is in the namespace "Clio" on the io side. Adapted test expected outputs and Io code to that. Modified Paths: -------------- private/z-man/clio/classname.hpp private/z-man/clio/dataconversion_extended.hpp private/z-man/clio/gcpointer.hpp private/z-man/clio/iclassinfo.cpp private/z-man/clio/namespace.cpp private/z-man/clio/tests/container.test/output.txt private/z-man/clio/tests/container.test/test.io private/z-man/clio/tests/conversion.test/output.txt private/z-man/clio/tests/enum.test/output.txt private/z-man/clio/tests/namespace.test/output.txt private/z-man/clio/tests/namespace.test/test.cpp private/z-man/clio/tests/namespace.test/test.io private/z-man/clio/tests/overloads.test/output.txt private/z-man/clio/tests/stack.test/output.txt private/z-man/clio/tests/stack.test/test.io Modified: private/z-man/clio/classname.hpp =================================================================== --- private/z-man/clio/classname.hpp 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/classname.hpp 2008-02-22 13:58:09 UTC (rev 8050) @@ -256,17 +256,18 @@ #define CLIO_TEMPLATENAME( CLASS, SIGNATURE ) CLIO_TEMPLATENAME_EX( CLASS, SIGNATURE, #CLASS ) #define CLIO_TEMPLATENAME_EX( CLASS, SIGNATURE, NAME ) \ namespace clio{ namespace classname { \ -template< IClassInfo::NameType type CLIO_TEMPLATE_INNERSTATEMENT(SIGNATURE) > \ -struct ClassNameDefaultGetterBase<CLASS CLIO_TEMPLATE_ARGLIST_COMPLETE(SIGNATURE), type> \ +template< IClassInfo::NameType type2 CLIO_TEMPLATE_INNERSTATEMENT(SIGNATURE) > \ +struct ClassNameDefaultGetterBase<CLASS CLIO_TEMPLATE_ARGLIST_COMPLETE(SIGNATURE), type2> \ { \ static void Get( std::ostream & s ) \ { \ - if ( type == IClassInfo::Name_Template ) \ + static const IClassInfo::NameType type = ( type2 == IClassInfo::Name_IoRaw ) ? IClassInfo::Name_IoComplete : type2; \ + if ( type2 == IClassInfo::Name_Template ) \ { \ s << NAME; \ return; \ } \ - else if ( type == IClassInfo::Name_C ) \ + else if ( type2 == IClassInfo::Name_C ) \ { \ s << #CLASS; \ } \ @@ -292,7 +293,8 @@ // set with these macros. #define CLIO_C_CLASSNAME( CLASS ) CLIO_C_CLASSNAME_EX( CLASS, #CLASS ) #define CLIO_C_CLASSNAME_EX( CLASS, NAME ) CLIO_CLASSNAME_EX( CLASS, NAME, clio::IClassInfo::Name_C ) -#define CLIO_IO_CLASSNAME( CLASS, NAME ) CLIO_CLASSNAME_EX( CLASS, NAME, clio::IClassInfo::Name_IoComplete ) +#define CLIO_IO_RAW_CLASSNAME( CLASS, NAME ) CLIO_CLASSNAME_EX( CLASS, NAME, clio::IClassInfo::Name_IoRaw ) +#define CLIO_IO_COMPLETE_CLASSNAME( CLASS, NAME ) CLIO_CLASSNAME_EX( CLASS, NAME, clio::IClassInfo::Name_IoComplete ) #define CLIO_CLASSNAME_EX( CLASS, NAME, TYPE ) \ namespace clio{ namespace classname { \ @@ -322,7 +324,7 @@ CLIO_C_CLASSNAME_INT(long int); // or this, for io typenames -CLIO_IO_CLASSNAME( std::string, "Sequence" ); +CLIO_IO_COMPLETE_CLASSNAME( std::string, "Sequence" ); //CLIO_IO_CLASSNAME( float, "Number" ); //CLIO_IO_CLASSNAME( double, "Double" ); Modified: private/z-man/clio/dataconversion_extended.hpp =================================================================== --- private/z-man/clio/dataconversion_extended.hpp 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/dataconversion_extended.hpp 2008-02-22 13:58:09 UTC (rev 8050) @@ -132,6 +132,7 @@ #include "objectwrapperaware.hpp" #include "codeinjection.hpp" #include "ichained.hpp" +#include "gcpointer.hpp" // now comes the really fancy stuff. Here, we can already use clio's full wrapping power to // use C++ wrapper types as the objects converted to Io. @@ -275,10 +276,10 @@ extern char const * primitveProxyCode; +} + struct PrimitiveProxyNoMaster{}; -} - // let primitives be handled by their wrapper for template arguments template< class T > struct clioPrivate_classToTypeBase< T, true > { @@ -288,9 +289,9 @@ } #define CLIO_INSTANTIATE_PRIMITIVE( INT, NAME ) \ -CLIO_CLASSNAME_EX( clio::dataconversion::PrimitiveProxy<const INT>, "Const" NAME, clio::IClassInfo::Name_IoComplete ); \ -CLIO_CLASSNAME_EX( clio::dataconversion::PrimitiveProxy<INT>, NAME, clio::IClassInfo::Name_IoComplete ); \ -CLIO_IO_CLASSNAME( INT, NAME ) +CLIO_CLASSNAME_EX( clio::dataconversion::PrimitiveProxy<const INT>, "Clio Const" NAME, clio::IClassInfo::Name_IoComplete ); \ +CLIO_CLASSNAME_EX( clio::dataconversion::PrimitiveProxy<INT>, "Clio " NAME, clio::IClassInfo::Name_IoComplete ); \ +CLIO_IO_COMPLETE_CLASSNAME( INT, "Clio " NAME ) #define CLIO_INSTANTIATE_PRIMITIVE_INT( INT, NAME ) \ CLIO_INSTANTIATE_PRIMITIVE( INT, NAME ); \ @@ -308,11 +309,13 @@ CLIO_TEMPLATE_CLASS_EX( clio::dataconversion::PrimitiveProxyConstBase, (1,(class)), "ConstRef" ) { + CLIO_CLASS_NAMESPACE( "clio" ); CLIO_METHOD( Get ).NonBreaking(); } CLIO_TEMPLATE_CLASS_EX( clio::dataconversion::PrimitiveProxyNoConstBase, (1,(class)), "NoConstRef" ) { + CLIO_CLASS_NAMESPACE( "clio" ); typedef clio::dataconversion::PrimitiveProxyConstBase< T1 > Base; CLIO_CLASS_BASE( Base ); @@ -321,6 +324,7 @@ CLIO_TEMPLATE_CLASS_EX( clio::dataconversion::PrimitiveProxy, (1,(class)), "Ref" ) { + CLIO_CLASS_NAMESPACE( "clio" ); typedef typename CLASS::Base Base; CLIO_CLASS_BASE( Base ); @@ -330,8 +334,10 @@ CLIO_INJECTCODE( ::clio::dataconversion::primitveProxyCode ); } -CLIO_TEMPLATE_CLASS_NOMASTER_EX( clio::dataconversion::PrimitiveProxy, (1,(class)), clio::dataconversion::PrimitiveProxyNoMaster, "Ref", "With" ); +// CLIO_TEMPLATE_CLASS_NOMASTER_EX( clio::dataconversion::PrimitiveProxy, (1,(class)), clio::PrimitiveProxyNoMaster, "Ref", "With" ); +CLIO_TEMPLATE_CLASS_MASTER( clio::dataconversion::PrimitiveProxy, (1,(class)), (1,(clio::IoObjectPointer) ) ); + namespace clio { namespace dataconversion Modified: private/z-man/clio/gcpointer.hpp =================================================================== --- private/z-man/clio/gcpointer.hpp 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/gcpointer.hpp 2008-02-22 13:58:09 UTC (rev 8050) @@ -131,6 +131,6 @@ } -CLIO_IO_CLASSNAME( clio::IoObjectPointer, "Object" ); +CLIO_IO_COMPLETE_CLASSNAME( clio::IoObjectPointer, "Object" ); #endif Modified: private/z-man/clio/iclassinfo.cpp =================================================================== --- private/z-man/clio/iclassinfo.cpp 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/iclassinfo.cpp 2008-02-22 13:58:09 UTC (rev 8050) @@ -131,7 +131,14 @@ std::ostringstream s; (*nameGetter_[type] )( s ); name_[type] = s.str(); - + + /* + if ( type == Name_IoComplete ) + { + std::cout << "complete: " << name_[type] << "\n"; + } + */ + // make sure this expensive branch is never called again nameGetter_[type] = 0; } Modified: private/z-man/clio/namespace.cpp =================================================================== --- private/z-man/clio/namespace.cpp 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/namespace.cpp 2008-02-22 13:58:09 UTC (rev 8050) @@ -44,13 +44,38 @@ SpaceMap & map_; }; +// splits a name into namespace and class name +static std::pair< std::string, std::string > Split( std::string base ) +{ + // find the last : + size_t lastColon = base.rfind( ':'); + if ( lastColon >= base.size() ) + { + return std::pair< std::string, std::string >( "", base ); + } + + assert( lastColon > 0 && base[lastColon-1] == ':' ); + + // split the name + return std::pair< std::string, std::string > + ( base.substr( 0, lastColon-1 ), + base.substr( lastColon+1 ) ); +} + // gets a namespace of a given class name NameSpace * NameSpace::GetNameSpace( std::string const & name ) { + if ( name.size() == 0 ) + { + return NULL; + } + // map of namespaces static SpaceMap spaces; static AutoClearer clearer( spaces ); + std::pair< std::string, std::string > split = Split( name ); + // look for namespace in map SpaceMap::iterator found = spaces.find( name ); if ( found != spaces.end() ) @@ -62,7 +87,13 @@ NameSpace * & space = spaces[ name ]; space = new NameSpace; space->SetName( IClassInfo::Name_C , name ); - space->SetName( IClassInfo::Name_IoRaw, Uppercase( name.c_str() ) ); + space->SetName( IClassInfo::Name_IoRaw, Uppercase( split.second.c_str() ) ); + + // get parent namespace + if ( split.first.size() > 0 ) + { + space->SetNestingParent( GetNameSpace( split.first ) ); + } return space; } @@ -70,24 +101,7 @@ NameSpace * NameSpace::GetNameSpaceByClassName( std::string const & name ) { // parse the class name - std::istringstream s( name ); - std::ostringstream nameSpaceName; - - do - { - int c = s.get(); - if (c == ':' ) - break; - - // no scope, no namespace - if ( s.eof() ) - return 0; - - nameSpaceName.put(c); - } - while( true ); - - return GetNameSpace( nameSpaceName.str() ); + return GetNameSpace( Split( name ).first ); } } Modified: private/z-man/clio/tests/container.test/output.txt =================================================================== --- private/z-man/clio/tests/container.test/output.txt 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/container.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) @@ -37,7 +37,7 @@ <<<< x createFloats() -<<<< x setInts( Std Vector With(Int) clone append(5) ) +<<<< x setInts( Std Vector With(Clio Int) clone append(5) ) <<<< x getInts foreach(println) 5 Modified: private/z-man/clio/tests/container.test/test.io =================================================================== --- private/z-man/clio/tests/container.test/test.io 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/container.test/test.io 2008-02-22 13:58:09 UTC (rev 8050) @@ -20,6 +20,6 @@ x createFloats() -x setInts( Std Vector With(Int) clone append(5) ) +x setInts( Std Vector With(Clio Int) clone append(5) ) x getInts foreach(println) Modified: private/z-man/clio/tests/conversion.test/output.txt =================================================================== --- private/z-man/clio/tests/conversion.test/output.txt 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/conversion.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) @@ -2,7 +2,7 @@ <<<< x := DataConversion clone <<<< x f5( DataConversionDummy ) - Exception: 'Ref With(DataConversion)' expected, got 'DataConversionDummy' instead (parsing argument 0 of desired type 'DataConversion * *' during call of C++ function 'DataConversion::f5( DataConversion * * )') + Exception: 'Clio Ref With(DataConversion)' expected, got 'DataConversionDummy' instead (parsing argument 0 of desired type 'DataConversion * *' during call of C++ function 'DataConversion::f5( DataConversion * * )') <<<< DataConversion f1 <<<< DataConversion f2(true) println @@ -21,7 +21,7 @@ <<<< x f5_2( x ) 0 <<<< DataConversion f3_2(2) type println -ConstInt +Clio ConstInt <<<< DataConversion f3_2(2) set(3) Exception: Number does not respond to 'set' Modified: private/z-man/clio/tests/enum.test/output.txt =================================================================== --- private/z-man/clio/tests/enum.test/output.txt 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/enum.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) @@ -8,7 +8,7 @@ <<<< EnumTest get type println TestEnum <<<< EnumTest access type println -Ref With(TestEnum) +Clio Ref With(TestEnum) # testing access <<<< EnumTest get println @@ -32,7 +32,7 @@ <<<< r := Clio Ref With(TestEnum) <<<< r = r with( TestEnum value3 ) <<<< r type println -Ref With(TestEnum) +Clio Ref With(TestEnum) <<<< r println value3 Modified: private/z-man/clio/tests/namespace.test/output.txt =================================================================== --- private/z-man/clio/tests/namespace.test/output.txt 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/namespace.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) @@ -1,3 +1,4 @@ <<<< Space Test clone +<<<< Space Sub Test2 clone Modified: private/z-man/clio/tests/namespace.test/test.cpp =================================================================== --- private/z-man/clio/tests/namespace.test/test.cpp 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/namespace.test/test.cpp 2008-02-22 13:58:09 UTC (rev 8050) @@ -6,6 +6,13 @@ namespace space { + namespace sub + { + class Test2 + { + }; + } + class Test { }; @@ -15,6 +22,10 @@ { } +CLIO_CLASS( space::sub::Test2 ) +{ +} + void Test() { } Modified: private/z-man/clio/tests/namespace.test/test.io =================================================================== --- private/z-man/clio/tests/namespace.test/test.io 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/namespace.test/test.io 2008-02-22 13:58:09 UTC (rev 8050) @@ -1,2 +1,3 @@ Space Test clone +Space Sub Test2 clone Modified: private/z-man/clio/tests/overloads.test/output.txt =================================================================== --- private/z-man/clio/tests/overloads.test/output.txt 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/overloads.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) @@ -16,21 +16,21 @@ <<<< x g( x h_float ) h<float> - Exception: No fitting overload found for passed argument of type 'ConstFloat'. The candidates say: -test.cpp:74 : OverloadTest2::g( char const & ) : 'ConstChar' expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'char const &') -test.cpp:67 : OverloadTest2::g( string ) : Sequence expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'string') -test.cpp:68 : OverloadTest2::g( int ) : Number expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'int') -test.cpp:69 : OverloadTest2::g( float ) : Number expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'float') -test.cpp:70 : OverloadTest2::g( double ) : Number expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'double') -test.cpp:71 : OverloadTest2::g( double const & ) : 'ConstDouble' expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'double const &') -test.cpp:72 : OverloadTest2::g( int const & ) : 'ConstInt' expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'int const &') -test.cpp:73 : OverloadTest2::g( char const & ) : 'ConstChar' expected, got 'ConstFloat' instead (parsing argument 0 of desired type 'char const &') + Exception: No fitting overload found for passed argument of type 'Clio ConstFloat'. The candidates say: +test.cpp:74 : OverloadTest2::g( char const & ) : 'Clio ConstChar' expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'char const &') +test.cpp:67 : OverloadTest2::g( string ) : Sequence expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'string') +test.cpp:68 : OverloadTest2::g( int ) : Number expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'int') +test.cpp:69 : OverloadTest2::g( float ) : Number expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'float') +test.cpp:70 : OverloadTest2::g( double ) : Number expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'double') +test.cpp:71 : OverloadTest2::g( double const & ) : 'Clio ConstDouble' expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'double const &') +test.cpp:72 : OverloadTest2::g( int const & ) : 'Clio ConstInt' expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'int const &') +test.cpp:73 : OverloadTest2::g( char const & ) : 'Clio ConstChar' expected, got 'Clio ConstFloat' instead (parsing argument 0 of desired type 'char const &') (during call of C++ function 'OverloadTest2::g( char const & )') <<<< x g( x h_char ) h<char> - Exception: Too many equally fitting overloads found for passed argument of type 'ConstChar'. The candidates are: + Exception: Too many equally fitting overloads found for passed argument of type 'Clio ConstChar'. The candidates are: test.cpp:74 : OverloadTest2::g( char const & ) test.cpp:73 : OverloadTest2::g( char const & ) (during call of C++ function 'OverloadTest2::g( char const & )') Modified: private/z-man/clio/tests/stack.test/output.txt =================================================================== --- private/z-man/clio/tests/stack.test/output.txt 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/stack.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) @@ -36,7 +36,7 @@ 2 <<<< x getInts clone type println -Std Vector With(Int) +Std Vector With(Clio Int) <<<< Std Vector clone type println Std Vector <<<< Std VectorWrapper clone type println @@ -49,11 +49,11 @@ <<<< x getInts foreach(println) 1 -<<<< x setInts( Std VectorWrapper With(Int) clone append(5) ) +<<<< x setInts( Std VectorWrapper With(Clio Int) clone append(5) ) Exception: Std does not respond to 'VectorWrapper' -<<<< x setInts( Std Vector With(Int) clone append(5) ) +<<<< x setInts( Std Vector With(Clio Int) clone append(5) ) <<<< x getInts foreach(println) 5 <<<< x createFloats() Modified: private/z-man/clio/tests/stack.test/test.io =================================================================== --- private/z-man/clio/tests/stack.test/test.io 2008-02-22 12:26:47 UTC (rev 8049) +++ private/z-man/clio/tests/stack.test/test.io 2008-02-22 13:58:09 UTC (rev 8050) @@ -23,8 +23,8 @@ Std VectorWrapper clone type println Clio VectorWrapper type println x getInts foreach(println) -x setInts( Std VectorWrapper With(Int) clone append(5) ) -x setInts( Std Vector With(Int) clone append(5) ) +x setInts( Std VectorWrapper With(Clio Int) clone append(5) ) +x setInts( Std Vector With(Clio Int) clone append(5) ) x getInts foreach(println) x createFloats() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 14:45:07
|
Revision: 8051 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8051&view=rev Author: z-man Date: 2008-02-22 06:44:59 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Security levels now propagate from base to subclass and from namespace to contained classes. Modified Paths: -------------- private/z-man/clio/dataconversion_extended.cpp private/z-man/clio/iclassinfo.cpp private/z-man/clio/tests/codesize.test/test.cpp private/z-man/clio/tests/security.test/output.txt private/z-man/clio/tests/security.test/test.cpp private/z-man/clio/tests/security.test/test.io Modified: private/z-man/clio/dataconversion_extended.cpp =================================================================== --- private/z-man/clio/dataconversion_extended.cpp 2008-02-22 13:58:09 UTC (rev 8050) +++ private/z-man/clio/dataconversion_extended.cpp 2008-02-22 14:44:59 UTC (rev 8051) @@ -5,6 +5,7 @@ CLIO_CLASS( clio::dataconversion::DataConverterMutableCString::CharProxy ) { + CLIO_CLASS_NAMESPACE("clio"); } namespace clio Modified: private/z-man/clio/iclassinfo.cpp =================================================================== --- private/z-man/clio/iclassinfo.cpp 2008-02-22 13:58:09 UTC (rev 8050) +++ private/z-man/clio/iclassinfo.cpp 2008-02-22 14:44:59 UTC (rev 8051) @@ -172,10 +172,6 @@ IClassInfo & IClassInfo::SetNestingParent( IClassInfo * nestingParent ) CLIO_NOTHROW { nestingParent_ = nestingParent; - if ( nestingParent && nestingParent->GetMinLevel() < GetMinLevel() ) - { - SetMinLevel( nestingParent->GetMinLevel() ); - } return *this; } @@ -485,6 +481,8 @@ IoObject * IClassInfo::Create( IoState * state ) const CLIO_NOTHROW { IoObject * self = IoObject_new( state ); + // tell the garbage collector to let it live + Collector_retain_( state->collector, self ); IoObject_tag_( self, Tag( state ) ); IoObject_setDataPointer_( self, CreatePrototype( self ) ); @@ -718,6 +716,8 @@ void IClassInfo::DoPostRegister( IoState * state ) CLIO_NOTHROW { + // parent object to insert the class into. + // NULLify to avoid insertion. IoObject * parent = state->lobby; // get the parent class in nesting @@ -725,28 +725,28 @@ { ObjectWrapper * parentWrap = nestingParent_->GetPrototype( state ); if ( parentWrap ) + { parent = parentWrap->GetSelf(); - assert( parent ); + } } - IoObject * self = FetchPrototype( state ).GetSelf(); - - if ( name_[Name_IoRaw].size() > 0 ) + ObjectWrapper * wrapper = GetPrototype( state ); + if ( !wrapper ) { - // put it into a slot - IoObject_setSlot_to_( parent, IOSYMBOL( name_[Name_IoRaw].c_str() ), self ); + return; } - else + IoObject * self = wrapper->GetSelf(); + if ( !self ) { - // tell the garbage collector to let it live - Collector_retain_( state->collector, self ); + return; } - // store prototype object - // prototype_ = self; + ObjectWrapper * prototypeWrapper = prototypeMap_[ state ]; + if ( !prototypeWrapper ) + { + return; + } - ObjectWrapper * prototypeWrapper = prototypeMap_[ state ]; - assert( prototypeWrapper ); IoObject * prototype = prototypeWrapper->GetSelf(); assert( prototype ); @@ -765,11 +765,24 @@ IoObject_rawAppendProto_( prototype, prototypeBase ); } + else + { + // base class does not exist, refuse creation + parent = 0; + } // register more things from base class (methods) // base->GetClassRegistratorSet().RegisterAll( state, wrapper ); // not required, we can rely on Io's resolver to get the methods of base classes. } + + if ( parent && name_[Name_IoRaw].size() > 0 ) + { + // put it into a slot + IoObject_setSlot_to_( parent, IOSYMBOL( name_[Name_IoRaw].c_str() ), self ); + // tell the garbage collector to let it die later + Collector_stopRetaining_( state->collector, self ); + } } // clones an Io object derived from T, but instead of cloning the C++ core, the Modified: private/z-man/clio/tests/codesize.test/test.cpp =================================================================== --- private/z-man/clio/tests/codesize.test/test.cpp 2008-02-22 13:58:09 UTC (rev 8050) +++ private/z-man/clio/tests/codesize.test/test.cpp 2008-02-22 14:44:59 UTC (rev 8051) @@ -10,7 +10,7 @@ // using namespace clio; -#ifdef NDEBUG +// #ifdef NDEBUG #define TEST1 #define TEST2 @@ -24,7 +24,7 @@ //#define TEST10 //#define TEST11 -#endif +// #endif #define CLIO_FUNCTION_NAME V #include "virtual.hpp" Modified: private/z-man/clio/tests/security.test/output.txt =================================================================== --- private/z-man/clio/tests/security.test/output.txt 2008-02-22 13:58:09 UTC (rev 8050) +++ private/z-man/clio/tests/security.test/output.txt 2008-02-22 14:44:59 UTC (rev 8051) @@ -8,7 +8,8 @@ Secret::g() <<<< SecretDerived clone baseClone f() Secret::f() - +<<<< Hidden Test clone +Lower security level: <<<< Public clone f() Public::f() <<<< Secret clone f() @@ -25,7 +26,8 @@ Exception: Secret does not respond to 'f' - +<<<< Hidden Test clone +Really low security level: <<<< Public clone f() Public::f() <<<< Secret clone f() @@ -34,14 +36,17 @@ <<<< SecretDerived clone base f() - Exception: SecretDerived does not respond to 'f' + Exception: Object does not respond to 'SecretDerived' <<<< SecretDerived clone baseClone g() - Exception: Secret does not respond to 'g' + Exception: Object does not respond to 'SecretDerived' <<<< SecretDerived clone baseClone f() - Exception: Secret does not respond to 'f' + Exception: Object does not respond to 'SecretDerived' +<<<< Hidden Test clone + Exception: Object does not respond to 'Hidden' + Modified: private/z-man/clio/tests/security.test/test.cpp =================================================================== --- private/z-man/clio/tests/security.test/test.cpp 2008-02-22 13:58:09 UTC (rev 8050) +++ private/z-man/clio/tests/security.test/test.cpp 2008-02-22 14:44:59 UTC (rev 8051) @@ -34,6 +34,13 @@ }; }; +namespace hidden +{ + class Test + { + }; +} + // a class derived from the secret class using the secret class // with the user "forgetting" to also make it secret class SecretDerived: public Secret @@ -71,20 +78,26 @@ CLIO_METHOD( BaseClone ).TransferOwnership(); } +CLIO_CLASS( hidden::Test ) +{ +} + void Test() { + clio::NameSpace::GetNameSpace( "hidden" )->SetMinLevel(1); + + std::cout << "Lower security level:\n"; clio::State state; // register only low security objects clio::IStateRegistrator::RegisterAll( state, 1 ); - TestFile( state, ( std::string( argv_[0] ) + ".io").c_str() ); + std::cout << "Really low security level:\n"; clio::State state2; // register only very low security objects clio::IStateRegistrator::RegisterAll( state2, 100 ); - TestFile( state2, ( std::string(argv_[0] ) + ".io").c_str() ); } Modified: private/z-man/clio/tests/security.test/test.io =================================================================== --- private/z-man/clio/tests/security.test/test.io 2008-02-22 13:58:09 UTC (rev 8050) +++ private/z-man/clio/tests/security.test/test.io 2008-02-22 14:44:59 UTC (rev 8051) @@ -3,3 +3,4 @@ SecretDerived clone base f() SecretDerived clone baseClone g() SecretDerived clone baseClone f() +Hidden Test clone \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 15:33:08
|
Revision: 8052 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8052&view=rev Author: z-man Date: 2008-02-22 07:33:02 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Added support for default namespace. Modified Paths: -------------- private/z-man/clio/iclassinfo.cpp private/z-man/clio/macros.hpp private/z-man/clio/namespace.cpp private/z-man/clio/namespace.hpp private/z-man/clio/tests/namespace.test/output.txt private/z-man/clio/tests/namespace.test/test.cpp private/z-man/clio/tests/namespace.test/test.io private/z-man/clio/tests/security.test/test.cpp Modified: private/z-man/clio/iclassinfo.cpp =================================================================== --- private/z-man/clio/iclassinfo.cpp 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/iclassinfo.cpp 2008-02-22 15:33:02 UTC (rev 8052) @@ -12,6 +12,7 @@ #include "factory.hpp" #include "ifunctioninfo.hpp" #include "state.hpp" +#include "namespace.hpp" #include <deque> #include <iostream> @@ -710,8 +711,17 @@ void IClassInfo::DoPreRegister( IoState * state ) CLIO_NOTHROW { - // clear prototype - // prototype_ = 0; + // set/unset sefault namespace + NameSpace & def = NameSpace::GetDefaultNameSpace(); + bool useDef = def.GetName( Name_IoRaw ).size() > 0 && &def != this; + if ( !nestingParent_ && useDef ) + { + nestingParent_ = &def; + } + else if ( nestingParent_ == &def && !useDef ) + { + nestingParent_ = 0; + } } void IClassInfo::DoPostRegister( IoState * state ) CLIO_NOTHROW Modified: private/z-man/clio/macros.hpp =================================================================== --- private/z-man/clio/macros.hpp 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/macros.hpp 2008-02-22 15:33:02 UTC (rev 8052) @@ -441,7 +441,7 @@ #define CLIO_CLASS_NESTED_IN( PARENT ) CLIO_CLASS_NESTED_IN_EX(PARENT) // inject class into namespace -#define CLIO_CLASS_NAMESPACE( NAME ) ClassInfo< CLASS >::Get().SetNestingParent( NameSpace::GetNameSpace( std::string( NAME ) ) ) +#define CLIO_CLASS_NAMESPACE( NAME ) ClassInfo< CLASS >::Get().SetNestingParent( NameSpace::GetNameSpaceNoWarn( std::string( NAME ) ) ) // change access level of class #define CLIO_CLASS_MIN_LEVEL( LEVEL ) ClassInfo< CLASS >::Get().SetMinLevel( LEVEL ) Modified: private/z-man/clio/namespace.cpp =================================================================== --- private/z-man/clio/namespace.cpp 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/namespace.cpp 2008-02-22 15:33:02 UTC (rev 8052) @@ -1,6 +1,7 @@ #include "namespace.hpp" #include "namemangling.hpp" +#include <iostream> #include <sstream> #include <memory> @@ -62,12 +63,46 @@ base.substr( lastColon+1 ) ); } +NameSpace & NameSpace::GetDefaultNameSpace() +{ + static NameSpace def; + return def; +} + +// sets the name of the default namespace. Everyhing will be put +// into that namespace, including the Clio builtins. +void NameSpace::SetDefaultNameSpace( std::string const & name ) +{ + GetDefaultNameSpace().SetName( Name_IoRaw, name ); +} + // gets a namespace of a given class name -NameSpace * NameSpace::GetNameSpace( std::string const & name ) +NameSpace & NameSpace::GetNameSpace( std::string const & name ) { + NameSpace * ret = GetNameSpace( name, true ); + + if ( !ret ) + { + ret = &GetDefaultNameSpace(); + } + + return *ret; +} + +// gets a namespace of a given class name +NameSpace * NameSpace::GetNameSpace( std::string const & name, bool warn ) +{ if ( name.size() == 0 ) { - return NULL; + NameSpace & def = GetDefaultNameSpace(); + if ( def.GetName( Name_IoRaw ).size() > 0 ) + { + return &def; + } + else + { + return NULL; + } } // map of namespaces @@ -83,6 +118,11 @@ return (*found).second; } + if ( warn ) + { + std::cerr << "Warning: creating new namespace \'" << name << "\', this is probably undesired.\n"; + } + // create new namespace and store it NameSpace * & space = spaces[ name ]; space = new NameSpace; @@ -92,7 +132,7 @@ // get parent namespace if ( split.first.size() > 0 ) { - space->SetNestingParent( GetNameSpace( split.first ) ); + space->SetNestingParent( GetNameSpace( split.first, false ) ); } return space; } @@ -101,7 +141,7 @@ NameSpace * NameSpace::GetNameSpaceByClassName( std::string const & name ) { // parse the class name - return GetNameSpace( Split( name ).first ); + return GetNameSpace( Split( name ).first, false ); } } Modified: private/z-man/clio/namespace.hpp =================================================================== --- private/z-man/clio/namespace.hpp 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/namespace.hpp 2008-02-22 15:33:02 UTC (rev 8052) @@ -10,12 +10,29 @@ class NameSpace: public IClassInfo { public: + // sets the name of the default namespace. Everyhing will be put + // into that namespace, including the Clio builtins. + // This has to be called before calling clio::IStateRegistrator::RegisterAll(). + static void SetDefaultNameSpace( std::string const & name ); + // gets a namespace of a given class name static NameSpace * GetNameSpaceByClassName( std::string const & className ); + // returns the default namespace + static NameSpace & GetDefaultNameSpace(); + // gets a namespace of a given class name - static NameSpace * GetNameSpace( std::string const & name ); + static NameSpace & GetNameSpace( std::string const & name ); + + // gets a namespace of a given class name without warning about creating new namespaces, and with the possibility of a NULL return value + static NameSpace * GetNameSpaceNoWarn( std::string const & name ) + { + return GetNameSpace( name, false ); + } private: + // gets a namespace of a given class name + static NameSpace * GetNameSpace( std::string const & name, bool warn ); + // returns the size of the wrapped object virtual size_t DoGetSize() const CLIO_NOTHROW; Modified: private/z-man/clio/tests/namespace.test/output.txt =================================================================== --- private/z-man/clio/tests/namespace.test/output.txt 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/tests/namespace.test/output.txt 2008-02-22 15:33:02 UTC (rev 8052) @@ -1,4 +1,47 @@ +<<<< Plain clone <<<< Space Test clone <<<< Space Sub Test2 clone +#expecting error (with default namespace not set) +<<<< Test Space Test clone + Exception: Object does not respond to 'Test' + + + +Testing modified script with default namespace: +<<<< Test Plain clone +<<<< Test Space Test clone +<<<< Test Space Sub Test2 clone +<<<< Test Clio Int + +Testing original script with default namespace: +<<<< Plain clone + + Exception: Object does not respond to 'Plain' + +<<<< Space Test clone + + Exception: Object does not respond to 'Space' + +<<<< Space Sub Test2 clone + + Exception: Object does not respond to 'Space' + + +#expecting error (with default namespace not set) +<<<< Test Space Test clone + + +resetting default namespace: +<<<< Plain clone +<<<< Space Test clone +<<<< Space Sub Test2 clone + +#expecting error (with default namespace not set) +<<<< Test Space Test clone + + Exception: Object does not respond to 'Test' + + + Modified: private/z-man/clio/tests/namespace.test/test.cpp =================================================================== --- private/z-man/clio/tests/namespace.test/test.cpp 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/tests/namespace.test/test.cpp 2008-02-22 15:33:02 UTC (rev 8052) @@ -4,6 +4,10 @@ // proto // **************************** +class Plain +{ +}; + namespace space { namespace sub @@ -18,6 +22,10 @@ }; } +CLIO_CLASS( Plain ) +{ +} + CLIO_CLASS( space::Test ) { } @@ -28,5 +36,19 @@ void Test() { + clio::NameSpace::SetDefaultNameSpace( "Test" ); + + clio::State state; + clio::IStateRegistrator::RegisterAll( state ); + std::cout << "Testing modified script with default namespace:\n"; + TestFile( state, ( std::string( argv_[0] ) + "2.io").c_str() ); + std::cout << "Testing original script with default namespace:\n"; + TestFile( state, ( std::string( argv_[0] ) + ".io").c_str() ); + + std::cout << "resetting default namespace:\n"; + clio::NameSpace::SetDefaultNameSpace( "" ); + clio::State state2; + clio::IStateRegistrator::RegisterAll( state2 ); + TestFile( state2, ( std::string( argv_[0] ) + ".io").c_str() ); } Modified: private/z-man/clio/tests/namespace.test/test.io =================================================================== --- private/z-man/clio/tests/namespace.test/test.io 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/tests/namespace.test/test.io 2008-02-22 15:33:02 UTC (rev 8052) @@ -1,3 +1,7 @@ +Plain clone Space Test clone Space Sub Test2 clone +#expecting error (with default namespace not set) +Test Space Test clone + Modified: private/z-man/clio/tests/security.test/test.cpp =================================================================== --- private/z-man/clio/tests/security.test/test.cpp 2008-02-22 14:44:59 UTC (rev 8051) +++ private/z-man/clio/tests/security.test/test.cpp 2008-02-22 15:33:02 UTC (rev 8052) @@ -84,7 +84,7 @@ void Test() { - clio::NameSpace::GetNameSpace( "hidden" )->SetMinLevel(1); + clio::NameSpace::GetNameSpace( "hidden" ).SetMinLevel(1); std::cout << "Lower security level:\n"; clio::State state; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 15:44:20
|
Revision: 8054 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8054&view=rev Author: z-man Date: 2008-02-22 07:44:23 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Whoops, forgot to adapt output. Using test result to transfer "Clio Ref" back no non-master template. Modified Paths: -------------- private/z-man/clio/dataconversion_extended.hpp private/z-man/clio/tests/templates.test/output.txt Modified: private/z-man/clio/dataconversion_extended.hpp =================================================================== --- private/z-man/clio/dataconversion_extended.hpp 2008-02-22 15:41:54 UTC (rev 8053) +++ private/z-man/clio/dataconversion_extended.hpp 2008-02-22 15:44:23 UTC (rev 8054) @@ -132,7 +132,6 @@ #include "objectwrapperaware.hpp" #include "codeinjection.hpp" #include "ichained.hpp" -#include "gcpointer.hpp" // now comes the really fancy stuff. Here, we can already use clio's full wrapping power to // use C++ wrapper types as the objects converted to Io. @@ -334,10 +333,8 @@ CLIO_INJECTCODE( ::clio::dataconversion::primitveProxyCode ); } -// CLIO_TEMPLATE_CLASS_NOMASTER_EX( clio::dataconversion::PrimitiveProxy, (1,(class)), clio::PrimitiveProxyNoMaster, "Ref", "With" ); +CLIO_TEMPLATE_CLASS_NOMASTER( clio::dataconversion::PrimitiveProxy, (1,(class)), clio::PrimitiveProxyNoMaster ); -CLIO_TEMPLATE_CLASS_MASTER( clio::dataconversion::PrimitiveProxy, (1,(class)), (1,(clio::IoObjectPointer) ) ); - namespace clio { namespace dataconversion Modified: private/z-man/clio/tests/templates.test/output.txt =================================================================== --- private/z-man/clio/tests/templates.test/output.txt 2008-02-22 15:41:54 UTC (rev 8053) +++ private/z-man/clio/tests/templates.test/output.txt 2008-02-22 15:44:23 UTC (rev 8054) @@ -1,19 +1,19 @@ <<<< testObject := TemplateTest With( Number ) clone <<<< testObject2 := TemplateTest With( Sequence ) clone <<<< testObject3 := TemplateTest clone -<<<< testObject4 := TemplateTestBase clone +<<<< testObject4 := Base TemplateTestBase clone <<<< writeln("Expecting error") Expecting error <<<< testObject4 h() - Exception: TemplateTestBase does not respond to 'h' + Exception: Base TemplateTestBase does not respond to 'h' -<<<< testObject4 := TemplateTestBase With( Sequence, Sequence, 2 ) clone +<<<< testObject4 := Base TemplateTestBase With( Sequence, Sequence, 2 ) clone <<<< testObject4 type println TemplateTestBase With(Sequence,Sequence,2) <<<< testObject4 h() println 2 -<<<< testObject4 := TemplateTestBase With( Sequence, Sequence, 3 ) clone +<<<< testObject4 := Base TemplateTestBase With( Sequence, Sequence, 3 ) clone <<<< testObject4 type println TemplateTestBase_Sequence_Object_3 <<<< testObject4 h() println This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <z-...@us...> - 2008-02-22 17:46:09
|
Revision: 8055 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=8055&view=rev Author: z-man Date: 2008-02-22 09:46:12 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Phew, finally fully fixed the template master name generation. The template master is now always generated according to the specifications in the template, the CLIO_TEMPLATE_MASTER statement and especially the dummy class used for CLIO_TEMPLATE_NOMASTER have nothing to say. Modified Paths: -------------- private/z-man/clio/macros.cpp private/z-man/clio/macros.hpp private/z-man/clio/namespace.cpp private/z-man/clio/tests/templates.test/output.txt private/z-man/clio/tests/templates.test/test.cpp private/z-man/clio/tests/templates.test/test.io Modified: private/z-man/clio/macros.cpp =================================================================== --- private/z-man/clio/macros.cpp 2008-02-22 15:44:23 UTC (rev 8054) +++ private/z-man/clio/macros.cpp 2008-02-22 17:46:12 UTC (rev 8055) @@ -3,10 +3,26 @@ #include "namespace.hpp" #include <ctype.h> +#include <iostream> namespace clio { +void TransferToMasterBase::Transfer( IClassInfo const & instance, IClassInfo & master ) +{ + // std::cout << instance.GetName( IClassInfo::Name_C ) << " -> " << master.GetName( IClassInfo::Name_C ) << "\n"; + + // copy info from template this class is supposed to be the master of + // master name is always the template name + master.SetName( IClassInfo::Name_IoRaw, instance.GetName( IClassInfo::Name_Template ) ); + + // master lives in the template's namespace + master.SetNestingParent( instance.GetNestingParent() ); + + // clear full IO name to have it regenerated + master.SetName( IClassInfo::Name_IoComplete, "" ); +} + // determines a classname automatically or from a user supplied name std::string GetClassName( char const * automatic, char const * usersupplied ) { Modified: private/z-man/clio/macros.hpp =================================================================== --- private/z-man/clio/macros.hpp 2008-02-22 15:44:23 UTC (rev 8054) +++ private/z-man/clio/macros.hpp 2008-02-22 17:46:12 UTC (rev 8055) @@ -10,6 +10,7 @@ #include "templatearglist.hpp" #include "codeinjection.hpp" #include "namespace.hpp" +#include "namemangling.hpp" #include <string> #include <ctype.h> @@ -17,6 +18,22 @@ namespace clio { +// transfers data from template to its master +struct TransferToMasterBase +{ + static void Transfer( IClassInfo const & instance, IClassInfo & master ); +}; + +// transfers data from template to master +template< class INSTANCE, class MASTER > +struct TransferToMaster: public TransferToMasterBase +{ + static void Transfer() + { + TransferToMasterBase::Transfer( ClassInfo< INSTANCE >::Get(), ClassInfo< MASTER >::Get() ); + } +}; + // determines a classname automatically or from a user supplied name std::string GetClassName( char const * automatic, char const * usersupplied ); // same for a function name @@ -225,17 +242,23 @@ { // fetch relevant class info IClassInfo & info = ClassInfo< CLASS >::Get(); - MasterClassInfoRegistrator<CLASS>::Register(); - // set the names - info.SetName( IClassInfo::Name_C , cName ); - info.SetName( IClassInfo::Name_IoRaw, ioName ); + // set the names (make sure they have not already been set by a slave class) + if ( strlen(cName) > 0 ) + { + info.SetName( IClassInfo::Name_C , cName ); + } - // register namespace - NameSpace * nameSpace = NameSpace::GetNameSpaceByClassName( cName ); - if ( nameSpace ) + if( info.GetName( IClassInfo::Name_IoRaw ).size() == 0 && !info.GetNestingParent() ) { - info.SetNestingParent( nameSpace ); + info.SetName( IClassInfo::Name_IoRaw, ioName ); + + // register namespace + NameSpace * nameSpace = NameSpace::GetNameSpaceByClassName( info.GetName( IClassInfo::Name_C ) ); + if ( nameSpace ) + { + info.SetNestingParent( nameSpace ); + } } // create a basic default factory @@ -243,6 +266,9 @@ // process user defined class definition ((WRAPPER*)(0))->template clioPrivate_RegisterUser<WRAPPER>(); + + // register as master + MasterClassInfoRegistrator<CLASS>::Register(); } }; @@ -349,30 +375,31 @@ } \ static void Register() \ { \ - clio::RegisterOverloadedFunction< Master >( CLIO_FUNCTION_SIGNATURE_EX( <Master>,, &MasterClassInfoRegistrator::With, template ), INSTANTIATION ); \ + clio::TransferToMaster< Class, Master >::Transfer(); \ + clio::RegisterOverloadedFunction< Master >( CLIO_FUNCTION_SIGNATURE_EX( <Master>,, &MasterClassInfoRegistrator::With, template ), INSTANTIATION ); \ } \ }; \ } CLIO_FORCESEMICOLON(X) -#define CLIO_TEMPLATE_CLASS_MASTER_EX( TEMPLATE, SIGNATURE, MASTER_SIGNATURE, MASTER_NAME, FUNCTION_NAME ) \ -CLIO_INSTANTIATE_TEMPLATE_EX( TEMPLATE, MASTER_SIGNATURE, MASTER_NAME ); \ +#define CLIO_TEMPLATE_CLASS_MASTER_EX( TEMPLATE, SIGNATURE, MASTER_SIGNATURE, FUNCTION_NAME ) \ +CLIO_INSTANTIATE_TEMPLATE_EX( TEMPLATE, MASTER_SIGNATURE, "" ); \ CLIO_TEMPLATE_CLASS_MASTER_BEGIN_EX( TEMPLATE, SIGNATURE, FUNCTION_NAME ) \ typedef TEMPLATE CLIO_TEMPLATE_ARGLIST_COMPLETE_SIGNATURE(MASTER_SIGNATURE) Master; \ CLIO_TEMPLATE_CLASS_MASTER_END_EX( TEMPLATE, SIGNATURE, FUNCTION_NAME ) #define CLIO_TEMPLATE_CLASS_MASTER( TEMPLATE, SIGNATURE, MASTER_SIGNATURE ) \ -CLIO_TEMPLATE_CLASS_MASTER_EX( TEMPLATE, SIGNATURE, MASTER_SIGNATURE, "", "With" ) +CLIO_TEMPLATE_CLASS_MASTER_EX( TEMPLATE, SIGNATURE, MASTER_SIGNATURE, "With" ) -#define CLIO_TEMPLATE_CLASS_NOMASTER_EX( TEMPLATE, SIGNATURE, MASTER, MASTER_NAME, FUNCTION_NAME ) \ +#define CLIO_TEMPLATE_CLASS_NOMASTER_EX( TEMPLATE, SIGNATURE, MASTER, FUNCTION_NAME ) \ CLIO_CLASS_SET_ABSTRACT( MASTER, true ); \ CLIO_CLASS_HEADER( MASTER ); \ -CLIO_CLASS_END_TEX( MASTER, (0,()), #TEMPLATE, MASTER_NAME, inline ){} \ +CLIO_CLASS_END_TEX( MASTER, (0,()), #TEMPLATE, "", inline ){} \ CLIO_TEMPLATE_CLASS_MASTER_BEGIN_EX( TEMPLATE, SIGNATURE, FUNCTION_NAME ) \ typedef MASTER Master; \ CLIO_TEMPLATE_CLASS_MASTER_END_EX( TEMPLATE, SIGNATURE, FUNCTION_NAME ) #define CLIO_TEMPLATE_CLASS_NOMASTER( TEMPLATE, SIGNATURE, MASTER ) \ -CLIO_TEMPLATE_CLASS_NOMASTER_EX( TEMPLATE, SIGNATURE, MASTER, "", "With" ) +CLIO_TEMPLATE_CLASS_NOMASTER_EX( TEMPLATE, SIGNATURE, MASTER, "With" ) #define CLIO_INSTANTIATE_EX( CLASS ) \ template class clio::InstantiatorHelperReal< clio::Instantiator< CLASS > > @@ -388,7 +415,7 @@ if ( strlen( NAME ) > 0 ) \ info.SetName( IClassInfo::Name_IoRaw, NAME ); \ else \ - info.SetName( IClassInfo::Name_IoRaw, info.GetName( IClassInfo::Name_Template ) ); \ + info.SetName( IClassInfo::Name_IoRaw, Uppercase( info.GetName( IClassInfo::Name_Template ).c_str() ) ); \ } \ }; \ } \ Modified: private/z-man/clio/namespace.cpp =================================================================== --- private/z-man/clio/namespace.cpp 2008-02-22 15:44:23 UTC (rev 8054) +++ private/z-man/clio/namespace.cpp 2008-02-22 17:46:12 UTC (rev 8055) @@ -48,8 +48,31 @@ // splits a name into namespace and class name static std::pair< std::string, std::string > Split( std::string base ) { - // find the last : - size_t lastColon = base.rfind( ':'); + // find the last :, take care of <> + size_t lastColon = base.size(); + int templateDepth = 0; + for( int i = base.size()-1; i > 0; --i ) + { + switch(base[i]) + { + case '>': + templateDepth++; + break; + case '<': + templateDepth--; + break; + case ':': + if ( templateDepth == 0 ) + { + lastColon = i; + i = 0; + break; + } + default: + break; + } + } + if ( lastColon >= base.size() ) { return std::pair< std::string, std::string >( "", base ); Modified: private/z-man/clio/tests/templates.test/output.txt =================================================================== --- private/z-man/clio/tests/templates.test/output.txt 2008-02-22 15:44:23 UTC (rev 8054) +++ private/z-man/clio/tests/templates.test/output.txt 2008-02-22 17:46:12 UTC (rev 8055) @@ -1,3 +1,53 @@ +# testing whether template masters were correctly handled +<<<< B XX With(Clio Int) clone type println +B X_int +<<<< B YY With(Clio Int) clone type println +B Y_int +<<<< NN With(Clio Int) clone type println +NN_int +<<<< B X_int type println +B X_int +<<<< B Y_int type println +B Y_int + +# expecting errors on the next command block +<<<< A Y + + Exception: A does not respond to 'Y' + +<<<< A YY + + Exception: A does not respond to 'YY' + +<<<< A Z +<<<< A ZZ + + Exception: A does not respond to 'ZZ' + +<<<< B ZZ + + Exception: B does not respond to 'ZZ' + +<<<< TemplateTestBase + + Exception: Object does not respond to 'TemplateTestBase' + + +# some typename tests +<<<< B XX type println +B XX +<<<< B YY type println +B YY +<<<< Clio Ref type println +Clio Ref +<<<< Base TemplateTestBase_Sequence_Object_3 type println +Base TemplateTestBase_Sequence_Object_3 +<<<< TemplateTestBase_Sequence_Object_3 type println + + Exception: Object does not respond to 'TemplateTestBase_Sequence_Object_3' + + + <<<< testObject := TemplateTest With( Number ) clone <<<< testObject2 := TemplateTest With( Sequence ) clone <<<< testObject3 := TemplateTest clone @@ -2,2 +52,4 @@ <<<< testObject4 := Base TemplateTestBase clone +<<<< testObject4 type println +Base TemplateTestBase <<<< writeln("Expecting error") @@ -10,12 +62,12 @@ <<<< testObject4 := Base TemplateTestBase With( Sequence, Sequence, 2 ) clone <<<< testObject4 type println -TemplateTestBase With(Sequence,Sequence,2) +Base TemplateTestBase With(Sequence,Sequence,2) <<<< testObject4 h() println 2 <<<< testObject4 := Base TemplateTestBase With( Sequence, Sequence, 3 ) clone <<<< testObject4 type println -TemplateTestBase_Sequence_Object_3 +Base TemplateTestBase_Sequence_Object_3 <<<< testObject4 h() println 3 <<<< testObject f(1) println Modified: private/z-man/clio/tests/templates.test/test.cpp =================================================================== --- private/z-man/clio/tests/templates.test/test.cpp 2008-02-22 15:44:23 UTC (rev 8054) +++ private/z-man/clio/tests/templates.test/test.cpp 2008-02-22 17:46:12 UTC (rev 8055) @@ -46,11 +46,28 @@ TemplateTest< float > g(){ return TemplateTest< float >(); } }; +// test namespace transfer of (non)master templatre +namespace a +{ + template< class T > class X{}; + template< class T > class Y{}; + template< class T > class Z{}; +} +template< class T > class NONAME{}; + CLIO_TEMPLATE_SET_POLYMORPHIC( base::TemplateTestBase, (3,(class,class,int)), false ); CLIO_TEMPLATE_SET_POLYMORPHIC( TemplateTest, (1,(class)), true ); +void breakp() +{ + int x; + x = 0; +} + CLIO_TEMPLATE_CLASS( base::TemplateTestBase, (3,(class,class,int))) { + breakp(); + CLIO_METHOD( h ); CLIO_METHOD( Create ); } @@ -68,10 +85,12 @@ namespace blurb { -struct NoMaster{}; +struct NoMaster1{}; +struct NoMaster2{}; +struct NoMaster3{}; } -CLIO_TEMPLATE_CLASS_NOMASTER( base::TemplateTestBase, (3,(class,class,int)), blurb::NoMaster ); +CLIO_TEMPLATE_CLASS_NOMASTER( base::TemplateTestBase, (3,(class,class,int)), blurb::NoMaster1 ); CLIO_TEMPLATE_CLASS_MASTER( TemplateTest, (1,(class)), (1,(clio::IoObjectPointer)) ); @@ -81,6 +100,18 @@ CLIO_INSTANTIATE_TEMPLATE(base::TemplateTestBase,(3,(std::string,clio::IoObjectPointer,3)),"TemplateTestBase_Sequence_Object_3"); +CLIO_TEMPLATE_CLASS_EX( a::X, (1,(class)), "XX" ){ CLIO_CLASS_NAMESPACE("b"); } +CLIO_TEMPLATE_CLASS_EX( a::Y, (1,(class)), "YY" ){ CLIO_CLASS_NAMESPACE("b"); } +CLIO_TEMPLATE_CLASS_EX( a::Z, (1,(class)), "ZZ" ){ CLIO_CLASS_NAMESPACE("b"); } +CLIO_TEMPLATE_CLASS_EX( NONAME, (1,(class)), "NN" ){} +CLIO_TEMPLATE_CLASS_MASTER( NONAME, (1,(class)),(1,(clio::IoObjectPointer)) ); +CLIO_TEMPLATE_CLASS_MASTER( a::X, (1,(class)),(1,(clio::IoObjectPointer)) ); +CLIO_TEMPLATE_CLASS_NOMASTER( a::Y, (1,(class)), blurb::NoMaster2 ); +CLIO_TEMPLATE_CLASS_NOMASTER( a::Z, (1,(class)), blurb::NoMaster3 ); +CLIO_INSTANTIATE_TEMPLATE( NONAME,(1,(int)),"NN_int"); +CLIO_INSTANTIATE_TEMPLATE( a::X,(1,(int)),"X_int"); +CLIO_INSTANTIATE_TEMPLATE( a::Y,(1,(int)),"Y_int"); + void Test() { // clio::ClassInfo< TemplateTestBase< std::string, std::string, 2 > >::Get(); Modified: private/z-man/clio/tests/templates.test/test.io =================================================================== --- private/z-man/clio/tests/templates.test/test.io 2008-02-22 15:44:23 UTC (rev 8054) +++ private/z-man/clio/tests/templates.test/test.io 2008-02-22 17:46:12 UTC (rev 8055) @@ -1,3 +1,26 @@ +# testing whether template masters were correctly handled +B XX With(Clio Int) clone type println +B YY With(Clio Int) clone type println +NN With(Clio Int) clone type println +B X_int type println +B Y_int type println + +# expecting errors on the next command block +A Y +A YY +A Z +A ZZ +B ZZ +TemplateTestBase + +# some typename tests +B XX type println +B YY type println +Clio Ref type println +Base TemplateTestBase_Sequence_Object_3 type println +TemplateTestBase_Sequence_Object_3 type println + + testObject := TemplateTest With( Number ) clone testObject2 := TemplateTest With( Sequence ) clone testObject3 := TemplateTest clone @@ -2,2 +25,3 @@ testObject4 := Base TemplateTestBase clone +testObject4 type println writeln("Expecting error") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |