Mercurial > projects > dbus-d
annotate dbus-d-javatests/dsrc/DBusTesting.d @ 6:963d271f7c25
disabled event stuff, to have working example
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 28 Oct 2007 19:35:38 +0100 |
parents | 7c2c75740370 |
children |
rev | line source |
---|---|
3 | 1 |
2 module DBusTesting; | |
3 | |
4 import tango.sys.Environment; | |
4 | 5 import tango.io.Stdout; |
6 import tango.core.Exception; | |
7 | |
8 import org.freedesktop.dbus.DBus; | |
3 | 9 |
10 import DBusTestingGen; | |
11 | |
4 | 12 bool exceptionsActive = false; |
13 char[][] called; | |
14 void checkCall( char[] name ){ | |
15 called ~= name.dup; | |
16 if( exceptionsActive ){ | |
17 throw new TracedException( "Test Exception thrown" ); | |
18 } | |
19 } | |
3 | 20 |
5 | 21 //pragma( msg, createDImplementation( "DImplBase", ["DBusInterface.dbustest.DImpl" ] ) ); |
22 mixin( createDImplementation( "DImplBase", ["DBusInterface.dbustest.DImpl" ] )); | |
23 | |
24 class Dimpl : DImplBase { | |
4 | 25 public void testV_V(){ |
26 checkCall( "testV_V" ); | |
27 } | |
28 public int testI_I( in int arg1 ){ | |
29 checkCall( "testI_I" ); | |
30 return arg1 + 1234; | |
31 } | |
5 | 32 public void testParamAllSimpleTyes( |
33 in bool i_bool, | |
34 out bool o_bool, | |
35 in byte i_byte, | |
36 out byte o_byte, | |
37 in short i_short, | |
38 out short o_short, | |
39 in ushort i_ushort, | |
40 out ushort o_ushort, | |
41 in int i_int, | |
42 out int o_int, | |
43 in uint i_uint, | |
44 out uint o_uint, | |
45 in long i_long, | |
46 out long o_long, | |
47 in ulong i_ulong, | |
48 out ulong o_ulong, | |
49 in double i_double, | |
50 out double o_double, | |
51 in char[] i_string, | |
52 out char[] o_string ) | |
53 { | |
54 checkCall( "testParamAllSimpleTyes" ); | |
55 o_bool = !i_bool; | |
56 o_byte = i_byte + 1; | |
57 o_short = i_short + 1; | |
58 o_ushort = i_ushort + 1; | |
59 o_int = i_int + 1; | |
60 o_uint = i_uint + 1; | |
61 o_long = i_long + 1; | |
62 o_ulong = i_ulong + 1; | |
63 o_double = i_double; | |
64 o_string = i_string.reverse; | |
65 } | |
6
963d271f7c25
disabled event stuff, to have working example
Frank Benoit <benoit@tionex.de>
parents:
5
diff
changeset
|
66 /+ |
5 | 67 public void triggerSignal( in int count ){ |
68 checkCall( "triggerSignal" ); | |
69 for( int i = 0; i < count; i++ ){ | |
70 testSigI.opCall( i ); | |
71 } | |
72 } | |
6
963d271f7c25
disabled event stuff, to have working example
Frank Benoit <benoit@tionex.de>
parents:
5
diff
changeset
|
73 +/ |
4 | 74 } |
3 | 75 |
5 | 76 //mixin( createJavaImplementation( "MyClass", ["DBusInterface.dbustest.DImpl" ] )); |
77 | |
3 | 78 |
79 | |
80 int main(char[][] args) { | |
81 | |
82 char[] address = Environment.get( "DBUS_ADDRESS" ); | |
83 if( ! address ){ | |
4 | 84 Stdout.formatln( "Environment variable DBUS_ADDRESS not set" ); |
3 | 85 return 1; |
86 } | |
4 | 87 Stdout.formatln( "D-App started"); |
5 | 88 DirectConnection dc = new DirectConnection( address ); |
4 | 89 Stdout.formatln("D-App connected"); |
5 | 90 auto o = new Dimpl(); |
91 o.registerDBusObject( dc.conn ); | |
92 Stdout.formatln("Export obj : {}", o.getDBusInstanceName() ); | |
3 | 93 dc.mainLoop(); |
4 | 94 Stdout.formatln("D-App disconnected"); |
3 | 95 return 0; |
96 } |