From 93b5a19c9f0979b5f227760af2ce5a0d076521f9 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 22 Jun 2003 05:53:06 +0000 Subject: 2003-06-22 Havoc Pennington * mono/*, gcj/*, configure.in, Makefile.am: Check in makefiles and subdirs for mono and gcj bindings. Neither binding actually exists, just trying to get through all the build and other boring bits. --- mono/.cvsignore | 14 ++++++++++++++ mono/Makefile.am | 25 +++++++++++++++++++++++++ mono/Message.cs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ mono/Test.cs | 12 ++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 mono/.cvsignore create mode 100644 mono/Makefile.am create mode 100644 mono/Message.cs create mode 100644 mono/Test.cs (limited to 'mono') diff --git a/mono/.cvsignore b/mono/.cvsignore new file mode 100644 index 00000000..7657837d --- /dev/null +++ b/mono/.cvsignore @@ -0,0 +1,14 @@ +.deps +.libs +Makefile +Makefile.in +*.lo +*.la +*.bb +*.bbg +*.gcov +*.da +.dbus-keyrings +*.dll +*.exe +test-dbus-sharp diff --git a/mono/Makefile.am b/mono/Makefile.am new file mode 100644 index 00000000..d81bcc28 --- /dev/null +++ b/mono/Makefile.am @@ -0,0 +1,25 @@ +DESTDIR= + +DLLS=dbus-sharp.dll +NOINST_EXES=test-dbus-sharp + +DBUS_SHARP_FILES=Message.cs +TEST_DBUS_SHARP_FILES=Test.cs + +all: $(DLLS) $(NOINST_EXES) + +dbus-sharp.dll: $(DBUS_SHARP_FILES) + $(MCS) $(MCSFLAGS) --unsafe --target library -o dbus-sharp.dll --recurse '$(DBUS_SHARP_FILES)' + +test-dbus-sharp: $(TEST_DBUS_SHARP_FILES) + $(MCS) $(MCSFLAGS) --unsafe --target exe -L . -r dbus-sharp.dll -o test-dbus-sharp --recurse '$(TEST_DBUS_SHARP_FILES)' + +clean: + rm -f $(DLLS) $(NOINST_EXES) + +install: all + ../mkinstalldirs $(DESTDIR)$(prefix)/lib && \ + cp $(DLLS) $(DESTDIR)$(prefix)/lib || exit 1 + +EXTRA_DIST=$(DBUS_SHARP_FILES) + diff --git a/mono/Message.cs b/mono/Message.cs new file mode 100644 index 00000000..84bd12ec --- /dev/null +++ b/mono/Message.cs @@ -0,0 +1,50 @@ +namespace DBus { + + using System; + using System.Runtime.InteropServices; + + public class Message { + + public Message (string name, + string dest_service) { + raw = dbus_message_new (name, dest_service); + } + + public string Name { + get { + return dbus_message_get_name (raw); + } + } + + IntPtr raw; + + ~Message () { + dbus_message_unref (raw); + } + + Message (IntPtr r) { + raw = r; + dbus_message_ref (r); + } + + // static constructor runs before any methods + static Message () { + + } + + const string libname = "libdbus-1.so.0"; + + [DllImport (libname, EntryPoint="dbus_message_new")] + private extern static IntPtr dbus_message_new (string name, + string dest_service); + + [DllImport (libname, EntryPoint="dbus_message_unref")] + private extern static void dbus_message_unref (IntPtr ptr); + + [DllImport (libname, EntryPoint="dbus_message_ref")] + private extern static void dbus_message_ref (IntPtr ptr); + + [DllImport (libname, EntryPoint="dbus_message_get_name")] + private extern static string dbus_message_get_name (IntPtr ptr); + } +} diff --git a/mono/Test.cs b/mono/Test.cs new file mode 100644 index 00000000..ffe7d0a6 --- /dev/null +++ b/mono/Test.cs @@ -0,0 +1,12 @@ + +using System; + +class Test { + static void Main() { + DBus.Message m; + + m = new DBus.Message ("org.freedesktop.Foo", null); + + Console.WriteLine ("Message name is {0}\n", m.Name); + } +} -- cgit