From 8ba750c2d52b9db90c8274020c6053a32441ed43 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 20 Dec 2012 00:13:45 +0000 Subject: gensigs.bld now generates SignalList classes in addition to Signal classes. They're pretty nifty. --- gensigs.bld | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'gensigs.bld') diff --git a/gensigs.bld b/gensigs.bld index c452356..6cdd5d5 100644 --- a/gensigs.bld +++ b/gensigs.bld @@ -18,6 +18,7 @@ function genSigs( outName ) "\n" "#include \"bu/util.h\"\n" "#include \"bu/exceptionbase.h\"\n" + "#include \"bu/list.h\"\n" "\n" "namespace Bu\n" "{\n" @@ -28,9 +29,11 @@ function genSigs( outName ) for i in range( 0, 10 ) do { templParams = "typename ret"; + templSpecParams = ""; funcParams = ""; funcAnonParams = ""; templCallParams = "ret"; + templSpecCallParams = ""; funcCallParams = ""; if i >= 1 then { @@ -41,11 +44,14 @@ function genSigs( outName ) funcCallParams << ", "; funcParams << ", "; funcAnonParams << ", "; + templSpecParams << ", "; } templParams << ", typename p${p}t"; + templSpecParams << "typename p${p}t"; funcParams << "p${p}t p${p}"; funcAnonParams << "p${p}t"; templCallParams << ", p${p}t"; + templSpecCallParams << ", p${p}t"; funcCallParams << "p${p}"; } } @@ -156,6 +162,53 @@ function genSigs( outName ) " new __Slot${i}F<${templCallParams}>( pFnc )\n" " );\n" " }\n" + " \n" + " template<${templParams}>\n" + " class SignalList${i} : public Bu::List >\n" + " {\n" + " typedef Bu::List > MyType;\n" + " public:\n" + " SignalList${i}()\n" + " {\n" + " }\n" + " \n" + " using MyType::iterator;\n" + " using MyType::const_iterator;\n" + " \n" + " ret operator()( ${funcParams} )\n" + " {\n" + " typename MyType::iterator i, n;\n" + " for(i = MyType::begin(); i; i=n)\n" + " {\n" + " n = i;\n" + " n++;\n" + " if( n )\n" + " (*i)( ${funcCallParams} );\n" + " else\n" + " return (*i)( ${funcCallParams} );\n" + " }\n" + " throw Bu::ExceptionBase(\"Empty SignalList with non-void return value called.\");\n" + " }\n" + " };\n" + " \n" + " template<${templSpecParams}>\n" + " class SignalList${i} : public Bu::List >\n" + " {\n" + " typedef Bu::List > MyType;\n" + " public:\n" + " SignalList${i}()\n" + " {\n" + " }\n" + " \n" + " using MyType::iterator;\n" + " using MyType::const_iterator;\n" + " \n" + " void operator()( ${funcParams} )\n" + " {\n" + " for( typename MyType::iterator i = MyType::begin(); i; i++ )\n" + " (*i)( ${funcCallParams} );\n" + " }\n" + " };\n" "#endif // BU_SIGNAL_PARAM_COUNT_${i}\n" "\n" ); -- cgit v1.2.3