changeset 2:5fb77a7e7d64

building CreateInterface and add bustest.xml
author Frank Benoit <benoit@tionex.de>
date Sat, 20 Oct 2007 19:29:33 +0200
parents 65fb7ef02c50
children c8f7d77e4d4a
files .hgignore dbus-d-javatests/README.txt dbus-d-javatests/dbustest.xml dbus-d-javatests/dsrc/DBusTestingGen.d dbus-d/dsrc/dsss.conf
diffstat 5 files changed, 542 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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.
 
 
+
+
+
--- /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 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+
+    <interface name="dbustest.OtherInterface">
+        <method name="dummy">
+            <arg name="arg1" type="s" direction="in"/>
+        </method>
+    </interface>
+    
+    <interface name="dbustest.TestControl">
+        <method name="getName">
+            <annotation name="org.dsource.tiolink.Returns" value="res"/>
+            <arg name="res" type="s" direction="out"/>
+        </method>
+    </interface>
+
+    <interface name="dbustest.TestListener">
+        <method name="getName">
+            <annotation name="org.dsource.tiolink.Returns" value="res"/>
+            <arg name="res" type="s" direction="out"/>
+        </method>
+    </interface>
+
+    <interface name="dbustest.JavaImpl">
+    
+        <method name="testV_V">
+        </method>
+
+        <method name="testI_I">
+            <annotation name="org.dsource.tiolink.Returns" value="res"/>
+            <arg name="res"  type="i" direction="out"/>
+            <arg name="arg1" type="i" direction="in" />
+        </method>
+        
+    </interface>
+
+    <interface name="dbustest.DImpl">
+    
+        <method name="testV_V">
+        </method>
+
+        <method name="testI_I">
+            <annotation name="org.dsource.tiolink.Returns" value="res"/>
+            <arg name="res"  type="i" direction="out"/>
+            <arg name="arg1" type="i" direction="in" />
+        </method>
+        
+    </interface>
+
+</node>
+
+
+
+
--- /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 <benoit@tionex.de>
+ * 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,
+            "<interface name=\"org.freedesktop.DBus.Peer\">\\n"
+            "  <method name=\"Ping\">\\n"
+            "  </method>\\n"
+            "  <method name=\"GetMachineId\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"machine_uuid\" />\\n"
+            "    <arg  name=\"machine_uuid\" type=\"s\" direction=\"out\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.org.freedesktop.DBus.Introspectable.classinfo,
+            "<interface name=\"org.freedesktop.DBus.Introspectable\">\\n"
+            "  <method name=\"Introspect\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"xml_data\" />\\n"
+            "    <arg  name=\"xml_data\" type=\"s\" direction=\"out\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.org.freedesktop.DBus.Properties.classinfo,
+            "<interface name=\"org.freedesktop.DBus.Properties\">\\n"
+            "  <method name=\"Get\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"prop\" />\\n"
+            "    <arg  name=\"intf_name\" type=\"s\" direction=\"in\" />\\n"
+            "    <arg  name=\"prop_name\" type=\"s\" direction=\"in\" />\\n"
+            "    <arg  name=\"prop\" type=\"v\" direction=\"out\" />\\n"
+            "  </method>\\n"
+            "  <method name=\"Set\">\\n"
+            "    <arg  name=\"intf_name\" type=\"s\" direction=\"in\" />\\n"
+            "    <arg  name=\"prop_name\" type=\"s\" direction=\"in\" />\\n"
+            "    <arg  name=\"prop\" type=\"v\" direction=\"in\" />\\n"
+            "  </method>\\n"
+            "  <method name=\"GetAll\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"allprops\" />\\n"
+            "    <arg  name=\"intf_name\" type=\"s\" direction=\"in\" />\\n"
+            "    <arg  name=\"allprops\" type=\"a{sv}\" direction=\"out\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.dbustest.OtherInterface.classinfo,
+            "<interface name=\"dbustest.OtherInterface\">\\n"
+            "  <method name=\"dummy\">\\n"
+            "    <arg  name=\"arg1\" type=\"s\" direction=\"in\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.dbustest.TestControl.classinfo,
+            "<interface name=\"dbustest.TestControl\">\\n"
+            "  <method name=\"getName\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"res\" />\\n"
+            "    <arg  name=\"res\" type=\"s\" direction=\"out\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.dbustest.TestListener.classinfo,
+            "<interface name=\"dbustest.TestListener\">\\n"
+            "  <method name=\"getName\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"res\" />\\n"
+            "    <arg  name=\"res\" type=\"s\" direction=\"out\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.dbustest.JavaImpl.classinfo,
+            "<interface name=\"dbustest.JavaImpl\">\\n"
+            "  <method name=\"testV_V\">\\n"
+            "  </method>\\n"
+            "  <method name=\"testI_I\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"res\" />\\n"
+            "    <arg  name=\"res\" type=\"i\" direction=\"out\" />\\n"
+            "    <arg  name=\"arg1\" type=\"i\" direction=\"in\" />\\n"
+            "  </method>\\n"
+            "</interface>\\n");
+    registerIntrospectionData(
+        DBusInterface.dbustest.DImpl.classinfo,
+            "<interface name=\"dbustest.DImpl\">\\n"
+            "  <method name=\"testV_V\">\\n"
+            "  </method>\\n"
+            "  <method name=\"testI_I\">\\n"
+            "        <annotation name=\"org.dsource.tiolink.Returns\" value=\"res\" />\\n"
+            "    <arg  name=\"res\" type=\"i\" direction=\"out\" />\\n"
+            "    <arg  name=\"arg1\" type=\"i\" direction=\"in\" />\\n"
+            "  </method>\\n"
+            "</interface>\\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();
+}
+
--- 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