# HG changeset patch # User Frank Benoit # Date 1192901373 -7200 # Node ID 5fb77a7e7d64c4154d5f9a287511f5258db78efc # Parent 65fb7ef02c5067a92e35b97334bffc24517941a7 building CreateInterface and add bustest.xml diff -r 65fb7ef02c50 -r 5fb77a7e7d64 .hgignore --- a/.hgignore Sat Oct 20 19:29:06 2007 +0200 +++ b/.hgignore Sat Oct 20 19:29:33 2007 +0200 @@ -1,8 +1,12 @@ syntax: regexp -^bin + +^dbus-d/dsrc/dsss.last +^dbus-d/dsrc/dsss_objs +^dbus-d/CreateInterface + ^dbus-d-javahelper/bin +^dbus-d-javatests/bin -^dbus-d-javatests/bin ^dbus-d-javatests/dsrc/dsss_objs ^dbus-d-javatests/dsrc/dsss.last ^dbus-d-javatests/dsrc/DHelper diff -r 65fb7ef02c50 -r 5fb77a7e7d64 dbus-d-javatests/README.txt --- a/dbus-d-javatests/README.txt Sat Oct 20 19:29:06 2007 +0200 +++ b/dbus-d-javatests/README.txt Sat Oct 20 19:29:33 2007 +0200 @@ -1,3 +1,43 @@ + +With dbus-d, an interface is defined with a XML file that follows the DBus introspection data. +The tool CreateInterfaces is used to read this file and generate a D module with all +the interfaces from the XML file and with the needed supporting code. + +1. Build the "createinterface" tool. + in the dbus-d directory: + + $ cd dbus-d + $ dsss build org/freedesktop/dbus/tools/CreateInterface.d + +2. Goto the directory of your applications source code ,call the CreateInterface tool + and pipe the output to a file matching your module name. + + $ cd ../dbus-d-javatests/dsrc + $ ../../dbus-d/CreateInterface ../dbustest.xml DBusTestingGen > DBusTestingGen.d + +3. Implement interfaces in D. If the introspection.xml has an interface called "a.b.C" + you need to implement the interface "DBusInterface.a.b.C" which is part of the generated + module. + + To make an object accessible, you need to either export it or return it from another + another method call. + + + + + + + + + + + + + + + + + To compile and run this example, it is required to have the following jars in the classpath: @@ -8,7 +48,10 @@ org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar org.eclipse.swt_3.3.0.v3346.jar +These can be found in the eclipse/plugin directory Probably other versions will work also :) -I placed them into a 'lib' called subdirectory. + + + diff -r 65fb7ef02c50 -r 5fb77a7e7d64 dbus-d-javatests/dbustest.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dbus-d-javatests/dbustest.xml Sat Oct 20 19:29:33 2007 +0200 @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 65fb7ef02c50 -r 5fb77a7e7d64 dbus-d-javatests/dsrc/DBusTestingGen.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dbus-d-javatests/dsrc/DBusTestingGen.d Sat Oct 20 19:29:33 2007 +0200 @@ -0,0 +1,437 @@ +/** + * Generated with TioLink + * TioLink was written by Frank Benoit + * http://www.dsource.org/projects/tiolink + * + * File type: D programming language source code + */ +module DBusTestingGen; + +public import org.freedesktop.dbus.Struct; +public import org.freedesktop.dbus.Variant; + +import tango.core.Signal; +import org.freedesktop.dbus.DBus; +import org.freedesktop.dbus.c.Connection : DBusConnection; +import org.freedesktop.dbus.c.Message : DBusMessage; +import org.freedesktop.dbus.c.Shared : DBusHandlerResult; + + +// DBus interfaces +public interface DBusInterface { + // org + public interface org { + // org.freedesktop + public interface freedesktop { + // org.freedesktop.DBus + public interface DBus { + // org.freedesktop.DBus.Peer + public interface Peer { + public void Ping(); + public char[] GetMachineId(); + } + // org.freedesktop.DBus.Introspectable + public interface Introspectable { + public char[] Introspect(); + } + // org.freedesktop.DBus.Properties + public interface Properties { + public DBusVariant Get( in char[] intf_name, in char[] prop_name ); + public void Set( in char[] intf_name, in char[] prop_name, in DBusVariant prop ); + public DBusVariant[ char[] ] GetAll( in char[] intf_name ); + } + } + } + } + // dbustest + public interface dbustest { + // dbustest.OtherInterface + public interface OtherInterface { + public void dummy( in char[] arg1 ); + } + // dbustest.TestControl + public interface TestControl { + public char[] getName(); + } + // dbustest.TestListener + public interface TestListener { + public char[] getName(); + } + // dbustest.JavaImpl + public interface JavaImpl { + public void testV_V(); + public int testI_I( in int arg1 ); + } + // dbustest.DImpl + public interface DImpl { + public void testV_V(); + public int testI_I( in int arg1 ); + } + } +} + + +// DBusObject +public class DBusObject : DBusObjectImpl, DBusInterface.org.freedesktop.DBus.Introspectable { + this(){ + super(); + } + public char[] Introspect(){ + return super.Introspect(); + } +} + + +private void init_introspectionData(){ + registerIntrospectionData( + DBusInterface.org.freedesktop.DBus.Peer.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.org.freedesktop.DBus.Introspectable.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.org.freedesktop.DBus.Properties.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.dbustest.OtherInterface.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.dbustest.TestControl.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.dbustest.TestListener.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.dbustest.JavaImpl.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); + registerIntrospectionData( + DBusInterface.dbustest.DImpl.classinfo, + "\\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + " \\n" + "\\n"); +} +private DBusHandlerResult intfHandler__org_freedesktop_DBus_Peer( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.org.freedesktop.DBus.Peer o = cast(DBusInterface.org.freedesktop.DBus.Peer)cast(Object)user_data; + if( o is null || !checkIntf( "org.freedesktop.DBus.Peer", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "Ping|": + { + o.Ping(); + sendReply( conn, message ); + } + break; + case "GetMachineId|": + { + Struct!( char[] ) po; + po.t[0] = o.GetMachineId(); + sendReplyData!( char[] )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__org_freedesktop_DBus_Introspectable( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.org.freedesktop.DBus.Introspectable o = cast(DBusInterface.org.freedesktop.DBus.Introspectable)cast(Object)user_data; + if( o is null || !checkIntf( "org.freedesktop.DBus.Introspectable", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "Introspect|": + { + Struct!( char[] ) po; + po.t[0] = o.Introspect(); + sendReplyData!( char[] )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__org_freedesktop_DBus_Properties( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.org.freedesktop.DBus.Properties o = cast(DBusInterface.org.freedesktop.DBus.Properties)cast(Object)user_data; + if( o is null || !checkIntf( "org.freedesktop.DBus.Properties", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "Get|ss": + { + Struct!( char[], char[] ) pi = getCallValues!( char[], char[] )( message ); + Struct!( DBusVariant ) po; + po.t[0] = o.Get( pi.t[0], pi.t[1] ); + sendReplyData!( DBusVariant )( conn, message, po ); + } + break; + case "Set|ssv": + { + Struct!( char[], char[], DBusVariant ) pi = getCallValues!( char[], char[], DBusVariant )( message ); + o.Set( pi.t[0], pi.t[1], pi.t[2] ); + sendReply( conn, message ); + } + break; + case "GetAll|s": + { + Struct!( char[] ) pi = getCallValues!( char[] )( message ); + Struct!( DBusVariant[ char[] ] ) po; + po.t[0] = o.GetAll( pi.t[0] ); + sendReplyData!( DBusVariant[ char[] ] )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__dbustest_OtherInterface( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.dbustest.OtherInterface o = cast(DBusInterface.dbustest.OtherInterface)cast(Object)user_data; + if( o is null || !checkIntf( "dbustest.OtherInterface", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "dummy|s": + { + Struct!( char[] ) pi = getCallValues!( char[] )( message ); + o.dummy( pi.t[0] ); + sendReply( conn, message ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__dbustest_TestControl( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.dbustest.TestControl o = cast(DBusInterface.dbustest.TestControl)cast(Object)user_data; + if( o is null || !checkIntf( "dbustest.TestControl", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "getName|": + { + Struct!( char[] ) po; + po.t[0] = o.getName(); + sendReplyData!( char[] )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__dbustest_TestListener( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.dbustest.TestListener o = cast(DBusInterface.dbustest.TestListener)cast(Object)user_data; + if( o is null || !checkIntf( "dbustest.TestListener", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "getName|": + { + Struct!( char[] ) po; + po.t[0] = o.getName(); + sendReplyData!( char[] )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__dbustest_JavaImpl( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.dbustest.JavaImpl o = cast(DBusInterface.dbustest.JavaImpl)cast(Object)user_data; + if( o is null || !checkIntf( "dbustest.JavaImpl", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "testV_V|": + { + o.testV_V(); + sendReply( conn, message ); + } + break; + case "testI_I|i": + { + Struct!( int ) pi = getCallValues!( int )( message ); + Struct!( int ) po; + po.t[0] = o.testI_I( pi.t[0] ); + sendReplyData!( int )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private DBusHandlerResult intfHandler__dbustest_DImpl( DBusConnection* conn, DBusMessage* message, void* user_data ){ + DBusInterface.dbustest.DImpl o = cast(DBusInterface.dbustest.DImpl)cast(Object)user_data; + if( o is null || !checkIntf( "dbustest.DImpl", message) ) + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + try{ + char[METHOD_SIG_MAXLENGTH] buf; + switch( methodSignature( message, buf ) ){ + case "testV_V|": + { + o.testV_V(); + sendReply( conn, message ); + } + break; + case "testI_I|i": + { + Struct!( int ) pi = getCallValues!( int )( message ); + Struct!( int ) po; + po.t[0] = o.testI_I( pi.t[0] ); + sendReplyData!( int )( conn, message, po ); + } + break; + default: + return DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + } + catch( Exception e ){ + sendException( conn, message, e ); + } + return DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; +} + +private void init_handlers(){ + registerHandler( + DBusInterface.org.freedesktop.DBus.Peer.classinfo, + & intfHandler__org_freedesktop_DBus_Peer ); + registerHandler( + DBusInterface.org.freedesktop.DBus.Introspectable.classinfo, + & intfHandler__org_freedesktop_DBus_Introspectable ); + registerHandler( + DBusInterface.org.freedesktop.DBus.Properties.classinfo, + & intfHandler__org_freedesktop_DBus_Properties ); + registerHandler( + DBusInterface.dbustest.OtherInterface.classinfo, + & intfHandler__dbustest_OtherInterface ); + registerHandler( + DBusInterface.dbustest.TestControl.classinfo, + & intfHandler__dbustest_TestControl ); + registerHandler( + DBusInterface.dbustest.TestListener.classinfo, + & intfHandler__dbustest_TestListener ); + registerHandler( + DBusInterface.dbustest.JavaImpl.classinfo, + & intfHandler__dbustest_JavaImpl ); + registerHandler( + DBusInterface.dbustest.DImpl.classinfo, + & intfHandler__dbustest_DImpl ); +} + +static this(){ + init_introspectionData(); + init_handlers(); +} + diff -r 65fb7ef02c50 -r 5fb77a7e7d64 dbus-d/dsrc/dsss.conf --- a/dbus-d/dsrc/dsss.conf Sat Oct 20 19:29:06 2007 +0200 +++ b/dbus-d/dsrc/dsss.conf Sat Oct 20 19:29:33 2007 +0200 @@ -11,10 +11,7 @@ target=DClient.exe [org/freedesktop/dbus/tool/CreateInterface.d] -target=../bin/dbus-createinterface -buildflags+=-I/Dater/ext/tango -buildflags+=-I/Dater/ext -buildflags+=/Dater/ext/flectioned/flectioned.d +target=../CreateInterface