--45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline A few cleanups and the addition of "excludeself" to dcopidl, and an optional option excludeself to emitDCOPsignal to match the nice API in dcopsignals.* ciao, Alex -- Eidetica kelletta@eidetica.com Kruislaan 400 tel +31 20 888 4090 fax 4001 NL 1098 SM Amsterdam http://www.eidetica.com/ Alexander Kellett vim: tw=70 cindent! --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="kdelibs-dcop.cvsdiff.patch" ? more Index: dcopclient.cpp =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopclient.cpp,v retrieving revision 1.115 diff -u -3 -p -r1.115 dcopclient.cpp --- dcopclient.cpp 2001/07/16 19:15:02 1.115 +++ dcopclient.cpp 2001/09/30 22:39:30 @@ -1576,16 +1576,16 @@ DCOPClient::endTransaction( DCOPClientTr } void -DCOPClient::emitDCOPSignal( const QCString &object, const QCString &signal, const QByteArray &data) +DCOPClient::emitDCOPSignal( const QCString &object, const QCString &signal, const QByteArray &data, bool excludeSelf) { // We hack the sending object name into the signal name - send("DCOPServer", "emit", object+"#"+normalizeFunctionSignature(signal), data); + send("DCOPServer", "emit", object+"#"+normalizeFunctionSignature(signal), data, excludeSelf); } void -DCOPClient::emitDCOPSignal( const QCString &signal, const QByteArray &data) +DCOPClient::emitDCOPSignal( const QCString &signal, const QByteArray &data, bool excludeSelf) { - emitDCOPSignal(0, signal, data); + emitDCOPSignal(0, signal, data, excludeSelf); } bool Index: dcopclient.h =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopclient.h,v retrieving revision 1.59 diff -u -3 -p -r1.59 dcopclient.h --- dcopclient.h 2001/07/17 21:06:15 1.59 +++ dcopclient.h 2001/09/30 22:39:31 @@ -275,12 +275,14 @@ class DCOPClient : public QObject /** * Emit @p signal as DCOP signal from object @p object with @p data as * arguments + * @param excludeSelf if true application that sends will not recieve the signal */ void emitDCOPSignal( const QCString &object, const QCString &signal, - const QByteArray &data); + const QByteArray &data, bool excludeSelf = false); /* For backwards compatibility */ - void emitDCOPSignal( const QCString &signal, const QByteArray &data); + void emitDCOPSignal( const QCString &signal, const QByteArray &data, + bool excludeSelf = false); /** * Connect to a DCOP signal Index: dcopobject.h =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopobject.h,v retrieving revision 1.32 diff -u -3 -p -r1.32 dcopobject.h --- dcopobject.h 2001/01/28 23:37:30 1.32 +++ dcopobject.h 2001/09/30 22:39:31 @@ -42,6 +42,8 @@ public: \ private: #define k_dcop public +#define k_dcop_signals public +#define excludeself #define ASYNC void /** Index: dcopidl/dcopidl_test.h =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopidl/dcopidl_test.h,v retrieving revision 1.10 diff -u -3 -p -r1.10 dcopidl_test.h --- dcopidl/dcopidl_test.h 2001/04/11 18:35:17 1.10 +++ dcopidl/dcopidl_test.h 2001/09/30 22:39:31 @@ -44,7 +44,12 @@ k_dcop: virtual DCOPRef getPage( int num ); int getPageOfObj( int obj ); void setCell( const int& point = 3 ); + void setCell( const int& point = QString::null ); QValueList getWindows(); + +k_dcop_signals: + static void blah_signal(); + static int blah_signal() excludeself; private: Test3 *doc(); Index: dcopidl/scanner.ll =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopidl/scanner.ll,v retrieving revision 1.25 diff -u -3 -p -r1.25 scanner.ll --- dcopidl/scanner.ll 2001/04/25 18:24:02 1.25 +++ dcopidl/scanner.ll 2001/09/30 22:39:31 @@ -210,6 +210,7 @@ class return T_CLASS; struct return T_STRUCT; operator return T_FUNOPERATOR; virtual return T_VIRTUAL; +excludeself return T_EXCLUDESELF; public return T_PUBLIC; inline return T_INLINE; static return T_STATIC; @@ -230,6 +231,7 @@ false return T_FALSE; TRUE return T_TRUE; FALSE return T_FALSE; "k_dcop" return T_DCOP_AREA; +"k_dcop_signals" return T_DCOP_SIGNAL_AREA; typedef return T_TYPEDEF; K_DCOP return T_DCOP; Q_OBJECT ; Index: dcopidl/yacc.yy =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopidl/yacc.yy,v retrieving revision 1.40 diff -u -3 -p -r1.40 yacc.yy --- dcopidl/yacc.yy 2001/05/03 11:59:46 1.40 +++ dcopidl/yacc.yy 2001/09/30 22:39:31 @@ -39,6 +39,7 @@ extern int idl_line_no; extern int function_mode; static int dcop_area = 0; +static int dcop_signal_area = 0; static QString in_namespace( "" ); @@ -81,6 +82,7 @@ void yyerror( const char *s ) %token T_TRIPE_DOT %token T_PRIVATE %token T_VIRTUAL +%token T_EXCLUDESELF %token T_CONST %token T_INLINE %token T_FRIEND @@ -116,6 +118,7 @@ void yyerror( const char *s ) %token T_CHAR %token T_DCOP %token T_DCOP_AREA +%token T_DCOP_SIGNAL_AREA %token T_SIGNED %token T_UNSIGNED %token T_LONG @@ -141,6 +144,7 @@ void yyerror( const char *s ) %type <_str> int_type %type <_int> const_qualifier %type <_int> virtual_qualifier +%type <_int> excludeself_qualifier %type <_str> Identifier %type <_int> dcoptag @@ -242,10 +246,12 @@ nodcop_area_begin : nodcop_area sigslot T_COLON { dcop_area = 0; + dcop_signal_area = 0; } | sigslot T_COLON { dcop_area = 0; + dcop_signal_area = 0; } dcop_area_begin @@ -254,6 +260,12 @@ dcop_area_begin dcop_area = 1; } +dcop_signal_area_begin + : T_DCOP_SIGNAL_AREA T_COLON + { + dcop_signal_area = 1; + } + Identifier : T_IDENTIFIER { $$ = $1; @@ -330,6 +342,10 @@ body { $$ = $2; } + | dcop_signal_area_begin body + { + $$ = $2; + } | dcop_area_begin body { $$ = $2; @@ -606,6 +622,10 @@ default_value } ; +excludeself_qualifier + : /* empty */ { $$ = 0; } + | T_EXCLUDESELF { $$ = 1; } + virtual_qualifier : /* empty */ { $$ = 0; } | T_VIRTUAL { $$ = 1; } @@ -614,27 +634,34 @@ operator : T_MISCOPERATOR | T_GREATER | T_LESS | T_EQUAL ; function_header - : type Identifier T_LEFT_PARANTHESIS params T_RIGHT_PARANTHESIS const_qualifier + : type Identifier T_LEFT_PARANTHESIS params T_RIGHT_PARANTHESIS const_qualifier excludeself_qualifier { - if (dcop_area) { + if (dcop_area || dcop_signal_area) { QString* tmp = 0; - if ( $6 ) - tmp = new QString( - " \n" - " %2\n" - " %1" - "%3\n" - " \n"); - else - tmp = new QString( - " \n" - " %2\n" - " %1" - "%3\n" - " \n"); + tmp = new QString( + " <%4>\n" + " %2\n" + " %1" + "%3\n" + " \n"); *tmp = tmp->arg( *($2) ); *tmp = tmp->arg( *($1) ); - *tmp = tmp->arg( *($4) ); + if ($6) { + *tmp = tmp->arg( *($4) + " qual=\"const\">" ); + } else { + *tmp = tmp->arg( *($4) ); + } + + QString tagname = ""; + QString attr = ""; + if (dcop_signal_area) { + tagname = "SIGNAL"; + if ($7) attr = " excludeself=\"true\""; + } else { + tagname = "FUNC"; + } + *tmp = tmp->arg( QString("%1%2").arg(tagname).arg(attr) ); + *tmp = tmp->arg( QString("%1").arg(tagname) ); $$ = tmp; } else $$ = new QString(""); @@ -665,39 +692,56 @@ init_list function : function_header function_body { + if (dcop_signal_area) + yyerror("functions in k_dcop_signal sections must be static."); $$ = $1; } | T_VIRTUAL function_header T_EQUAL T_NULL function_body { + if (dcop_signal_area) + yyerror("functions in k_dcop_signal sections must be static."); $$ = $2; } | T_VIRTUAL function_header function_body { + if (dcop_signal_area) + yyerror("functions in k_dcop_signal sections must be static."); $$ = $2; } | Identifier T_LEFT_PARANTHESIS params T_RIGHT_PARANTHESIS function_body { + if (dcop_signal_area) + yyerror("functions in k_dcop_signal sections must be static."); /* The constructor */ assert(!dcop_area); $$ = new QString(""); } | Identifier T_LEFT_PARANTHESIS params T_RIGHT_PARANTHESIS T_COLON init_list function_body { + if (dcop_signal_area) + yyerror("functions in k_dcop_signal sections must be static."); /* The constructor */ assert(!dcop_area); $$ = new QString(""); } | virtual_qualifier T_TILDE Identifier T_LEFT_PARANTHESIS T_RIGHT_PARANTHESIS function_body { + if (dcop_signal_area) + yyerror("functions in k_dcop_signal sections must be static."); /* The destructor */ assert(!dcop_area); $$ = new QString(""); } | T_STATIC function_header function_body { - if (dcop_area) - yyerror("static is not allowed in dcop area!"); - $$ = new QString(); + if (dcop_area) { + if (!dcop_signal_area) { + yyerror("static is not allowed in dcop area!"); + $$ = new QString(); + } else { + $$ = $2; + } + } } function_begin : T_LEFT_CURLY_BRACKET Index: dcopidl2cpp/main.cpp =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopidl2cpp/main.cpp,v retrieving revision 1.16 diff -u -3 -p -r1.16 main.cpp --- dcopidl2cpp/main.cpp 2000/07/20 17:06:28 1.16 +++ dcopidl2cpp/main.cpp 2001/09/30 22:39:31 @@ -111,7 +111,7 @@ int main( int argc, char** argv ) pos = header.findRev('/'); if ( pos != -1 ) header = header.mid( pos+1 ); - generateStubImpl( idl, header, base + "_stub." + suffix, de ); + generateStubImpl( idl, header, base+".h", base + "_stub." + suffix, de ); } return 0; Index: dcopidl2cpp/main.h =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopidl2cpp/main.h,v retrieving revision 1.2 diff -u -3 -p -r1.2 main.h --- dcopidl2cpp/main.h 2000/07/16 01:43:48 1.2 +++ dcopidl2cpp/main.h 2001/09/30 22:39:31 @@ -36,5 +36,5 @@ void generateStub( const QString& idl, c /** * Writes the stub implementation */ -void generateStubImpl( const QString& idl, const QString& header, const QString& filename, QDomElement de ); +void generateStubImpl( const QString& idl, const QString& header, const QString& headerBase, const QString& filename, QDomElement de ); Index: dcopidl2cpp/stubimpl.cpp =================================================================== RCS file: /home/kde/kdelibs/dcop/dcopidl2cpp/stubimpl.cpp,v retrieving revision 1.11 diff -u -3 -p -r1.11 stubimpl.cpp --- dcopidl2cpp/stubimpl.cpp 2000/12/04 12:40:53 1.11 +++ dcopidl2cpp/stubimpl.cpp 2001/09/30 22:39:31 @@ -55,7 +55,7 @@ int isIntType( const QString& t) /** * Writes the stub implementation */ -void generateStubImpl( const QString& idl, const QString& header, const QString& filename, QDomElement de ) +void generateStubImpl( const QString& idl, const QString& header, const QString& headerBase, const QString& filename, QDomElement de ) { QFile impl( filename ); if ( !impl.open( IO_WriteOnly ) ) @@ -72,16 +72,21 @@ void generateStubImpl( const QString& id str << "*****************************************************************************/" << endl; str << endl; - str << "#include \"" << header << "\"" << endl; + str << "#include \"" << header << "\"" << endl; str << "#include " << endl << endl; str << "#include " << endl << endl; + // if signal + str << "#include " << endl << endl; + str << "#include \"" << headerBase << "\"" << endl << endl; + QDomElement e = de.firstChild().toElement(); for( ; !e.isNull(); e = e.nextSibling().toElement() ) { if ( e.tagName() == "CLASS" ) { QDomElement n = e.firstChild().toElement(); ASSERT( n.tagName() == "NAME" ); - QString className = n.firstChild().toText().data() + "_stub"; + QString classNameBase = n.firstChild().toText().data(); + QString className = classNameBase + "_stub"; // find dcop parent ( rightmost super class ) QString DCOPParent; @@ -135,7 +140,8 @@ void generateStubImpl( const QString& id // Write marshalling code s = e.firstChild().toElement(); for( ; !s.isNull(); s = s.nextSibling().toElement() ) { - if ( s.tagName() == "FUNC" ) { + if ( s.tagName() == "FUNC" || s.tagName() == "SIGNAL" ) { + bool signal = (s.tagName() == "SIGNAL"); QDomElement r = s.firstChild().toElement(); ASSERT( r.tagName() == "TYPE" ); QString result = r.firstChild().toText().data(); @@ -153,7 +159,7 @@ void generateStubImpl( const QString& id r = r.nextSibling().toElement(); ASSERT ( r.tagName() == "NAME" ); QString funcName = r.firstChild().toText().data(); - str << className << "::" << funcName << "("; + str << ( signal ? classNameBase : className ) << "::" << funcName << "("; QStringList args; QStringList argtypes; @@ -183,6 +189,8 @@ void generateStubImpl( const QString& id str << " "; str << ")"; + QString excludeself = s.attribute("excludeself","false"); + if ( s.hasAttribute("qual") ) str << " " << s.attribute("qual"); str << endl; @@ -199,12 +207,18 @@ void generateStubImpl( const QString& id funcName += *it; } funcName += ")"; + + if ( async || signal ) { + + if ( signal && (result != "void") ) + qFatal("Sorry DCOP signals can not return values."); - if ( async ) { - str << " if ( !dcopClient() ) {"<< endl; - str << "\tsetStatus( CallFailed );" << endl; - str << "\treturn;" << endl; - str << " }" << endl; + if (!signal) { + str << " if ( !dcopClient() ) {"<< endl; + str << "\tsetStatus( CallFailed );" << endl; + str << "\treturn;" << endl; + str << " }" << endl; + } str << " QByteArray data;" << endl; if ( !args.isEmpty() ) { @@ -213,10 +227,15 @@ void generateStubImpl( const QString& id str << " arg << " << *args_count << ";" << endl; } } - str << " dcopClient()->send( app(), obj(), \"" << funcName << "\", data );" << endl; - str << " setStatus( CallSucceeded );" << endl; + if (signal) + str << " kapp->dcopClient()->emitDCOPSignal( \"" << funcName << "\", data," << excludeself << " );" << endl; + else { + str << " dcopClient()->send( app(), obj(), \"" << funcName << "\", data );" << endl; + str << " setStatus( CallSucceeded );" << endl; + } + } else { - + if ( result != "void" ) { str << " " << result << " result"; if (isIntType( result )) --45Z9DzgjV8m4Oswq--