2003-09-03 Havoc Pennington <hp@pobox.com>
authorHavoc Pennington <hp@redhat.com>
Thu, 4 Sep 2003 00:21:36 +0000 (00:21 +0000)
committerHavoc Pennington <hp@redhat.com>
Thu, 4 Sep 2003 00:21:36 +0000 (00:21 +0000)
* test/glib/Makefile.am: add this with random glib-linked test
programs

* glib/Makefile.am: remove the random test programs from here,
leave only the unit tests

* glib/dbus-gobject.c (_dbus_gobject_test): add test for
uscore/javacaps conversion, and fix
(get_object_property, set_object_property): change to .NET
convention for mapping props to methods, set_FooBar/get_FooBar,
since one language has such a convention we may as well copy it.
Plus real methods in either getFooBar or get_foo_bar style won't
collide with this convention.

ChangeLog
configure.in
glib/Makefile.am
glib/dbus-gobject.c
test/Makefile.am
test/glib/Makefile.am [new file with mode: 0644]
test/glib/test-dbus-glib.c [moved from glib/test-dbus-glib.c with 100% similarity]
test/glib/test-profile.c [moved from glib/test-profile.c with 100% similarity]
test/glib/test-thread-client.c [moved from glib/test-thread-client.c with 100% similarity]
test/glib/test-thread-server.c [moved from glib/test-thread-server.c with 100% similarity]
test/glib/test-thread.h [moved from glib/test-thread.h with 100% similarity]

index d9557be..ccca8a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-09-03  Havoc Pennington  <hp@pobox.com>
+
+       * test/glib/Makefile.am: add this with random glib-linked test
+       programs
+
+       * glib/Makefile.am: remove the random test programs from here,
+       leave only the unit tests
+
+       * glib/dbus-gobject.c (_dbus_gobject_test): add test for 
+       uscore/javacaps conversion, and fix     
+       (get_object_property, set_object_property): change to .NET
+       convention for mapping props to methods, set_FooBar/get_FooBar, 
+       since one language has such a convention we may as well copy it. 
+       Plus real methods in either getFooBar or get_foo_bar style won't 
+       collide with this convention.
+
 2003-09-01  Havoc Pennington  <hp@pobox.com>
 
        * glib/dbus-gparser.c: implement
index 1125ef6..c403fd8 100644 (file)
@@ -826,6 +826,7 @@ mono/Makefile
 bus/Makefile
 tools/Makefile
 test/Makefile
+test/glib/Makefile
 doc/Makefile
 dbus-1.pc
 dbus-glib-1.pc
index f3b43ed..65d71cf 100644 (file)
@@ -34,30 +34,9 @@ dbus_glib_tool_LDADD= $(DBUS_GLIB_TOOL_LIBS) libdbus-glib-1.la $(top_builddir)/d
 
 if DBUS_BUILD_TESTS
 
-if HAVE_GLIB_THREADS
-THREAD_APPS=test-thread-server test-thread-client test-profile
-
-test_thread_server_SOURCES=                            \
-       test-thread-server.c                            \
-       test-thread.h
-
-test_thread_server_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la 
-
-test_thread_client_SOURCES=                            \
-       test-thread-client.c                            \
-       test-thread.h
-
-test_thread_client_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la 
-endif
-
 ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
 ## build even when not doing "make check"
-noinst_PROGRAMS= $(TESTS) test-dbus-glib $(THREAD_APPS)
-
-test_dbus_glib_SOURCES=                                \
-       test-dbus-glib.c
-
-test_dbus_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
+noinst_PROGRAMS= $(TESTS)
 
 ## note that TESTS has special meaning (stuff to use in make check)
 ## so if adding tests not to be run in make check, don't add them to 
@@ -74,15 +53,4 @@ else
 ### not building tests
 TESTS=
 
-if HAVE_GLIB_THREADS
-noinst_PROGRAMS=test-profile
-endif
-
 endif
-
-if HAVE_GLIB_THREADS
-test_profile_SOURCES=                          \
-       test-profile.c
-
-test_profile_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la 
-endif
\ No newline at end of file
index aa53265..b0f6c13 100644 (file)
@@ -35,7 +35,7 @@ static GStaticMutex info_hash_mutex = G_STATIC_MUTEX_INIT;
 static GHashTable *info_hash = NULL;
 
 static char*
-javacaps_to_uscore (const char *caps)
+wincaps_to_uscore (const char *caps)
 {
   const char *p;
   GString *str;
@@ -62,7 +62,7 @@ javacaps_to_uscore (const char *caps)
 }
 
 static char*
-uscore_to_javacaps (const char *uscore)
+uscore_to_wincaps (const char *uscore)
 {
   const char *p;
   GString *str;
@@ -233,11 +233,11 @@ handle_introspect (DBusConnection *connection,
 
       can_get = (spec->flags & G_PARAM_READABLE) != 0;
 
-      s = uscore_to_javacaps (spec->name);
+      s = uscore_to_wincaps (spec->name);
       
       if (can_set)
         {
-          g_string_append (xml, "    <method name=\"set");
+          g_string_append (xml, "    <method name=\"set_");
           g_string_append (xml, s);
           g_string_append (xml, "\">\n");
           
@@ -248,7 +248,7 @@ handle_introspect (DBusConnection *connection,
 
       if (can_get)
         {
-          g_string_append (xml, "    <method name=\"get");
+          g_string_append (xml, "    <method name=\"get_");
           g_string_append (xml, s);
           g_string_append (xml, "\">\n");
           
@@ -578,13 +578,13 @@ gobject_message_function (DBusConnection  *connection,
   /* If no metainfo, we can still do properties and signals
    * via standard GLib introspection
    */
-  setter = (member[0] == 's' && member[1] == 'e' && member[2] == 't');
-  getter = (member[0] == 'g' && member[1] == 'e' && member[2] == 't');
+  setter = (member[0] == 's' && member[1] == 'e' && member[2] == 't' && member[3] == '_');
+  getter = (member[0] == 'g' && member[1] == 'e' && member[2] == 't' && member[3] == '_');
 
   if (!(setter || getter))
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-  s = javacaps_to_uscore (&member[3]);
+  s = wincaps_to_uscore (&member[4]);
 
   pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
                                         s);
@@ -757,6 +757,7 @@ dbus_connection_register_gobject (DBusConnection        *connection,
 /** @} */ /* end of public API */
 
 #ifdef DBUS_BUILD_TESTS
+#include <stdlib.h>
 
 /**
  * @ingroup DBusGLibInternals
@@ -766,14 +767,48 @@ dbus_connection_register_gobject (DBusConnection        *connection,
 dbus_bool_t
 _dbus_gobject_test (const char *test_data_dir)
 {
-  static struct { const char *javacaps; const char *uscore; } name_pairs[] = {
-    { "setFoo", "set_foo" },
-    { "foo", "foo" },
-    { "getFooBar", "get_foo_bar" },
-    { "Hello", "hello" },
-    { "frobateUIHandler", "frobate_ui_handler" }
+  int i;
+  static struct { const char *wincaps; const char *uscore; } name_pairs[] = {
+    { "SetFoo", "set_foo" },
+    { "Foo", "foo" },
+    { "GetFooBar", "get_foo_bar" },
+    { "Hello", "hello" }
+    
+    /* Impossible-to-handle cases */
+    /* { "FrobateUIHandler", "frobate_ui_handler" } */
   };
 
+  i = 0;
+  while (i < (int) G_N_ELEMENTS (name_pairs))
+    {
+      char *uscore;
+      char *wincaps;
+
+      uscore = wincaps_to_uscore (name_pairs[i].wincaps);
+      wincaps = uscore_to_wincaps (name_pairs[i].uscore);
+
+      if (strcmp (uscore, name_pairs[i].uscore) != 0)
+        {
+          g_printerr ("\"%s\" should have been converted to \"%s\" not \"%s\"\n",
+                      name_pairs[i].wincaps, name_pairs[i].uscore,
+                      uscore);
+          exit (1);
+        }
+      
+      if (strcmp (wincaps, name_pairs[i].wincaps) != 0)
+        {
+          g_printerr ("\"%s\" should have been converted to \"%s\" not \"%s\"\n",
+                      name_pairs[i].uscore, name_pairs[i].wincaps,
+                      wincaps);
+          exit (1);
+        }
+      
+      g_free (uscore);
+      g_free (wincaps);
+
+      ++i;
+    }
+  
   return TRUE;
 }
 
index 04df351..ab04496 100644 (file)
@@ -1,6 +1,13 @@
 
+if HAVE_GLIB
+    GLIB_SUBDIR=glib
+endif
+
+SUBDIRS=$(GLIB_SUBDIR)
+
 INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS) 
 
+
 if DBUS_BUILD_TESTS
 TEST_BINARIES=test-service unbase64 break-loader spawn-test test-segfault test-exit test-sleep-forever
 else
diff --git a/test/glib/Makefile.am b/test/glib/Makefile.am
new file mode 100644 (file)
index 0000000..9f900b1
--- /dev/null
@@ -0,0 +1,44 @@
+INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) -I$(top_srcdir)/glib
+
+if DBUS_BUILD_TESTS
+
+if HAVE_GLIB_THREADS
+THREAD_APPS=test-thread-server test-thread-client test-profile
+
+test_thread_server_SOURCES=                            \
+       test-thread-server.c                            \
+       test-thread.h
+
+test_thread_server_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la 
+
+test_thread_client_SOURCES=                            \
+       test-thread-client.c                            \
+       test-thread.h
+
+test_thread_client_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la 
+endif
+
+## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we
+## build even when not doing "make check"
+noinst_PROGRAMS= test-dbus-glib $(THREAD_APPS)
+
+test_dbus_glib_SOURCES=                                \
+       test-dbus-glib.c
+
+test_dbus_glib_LDADD= $(top_builddir)/glib/libdbus-glib-1.la
+
+else
+### not building tests
+
+if HAVE_GLIB_THREADS
+noinst_PROGRAMS=test-profile
+endif
+
+endif
+
+if HAVE_GLIB_THREADS
+test_profile_SOURCES=                          \
+       test-profile.c
+
+test_profile_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la 
+endif
\ No newline at end of file
similarity index 100%
rename from glib/test-profile.c
rename to test/glib/test-profile.c
similarity index 100%
rename from glib/test-thread.h
rename to test/glib/test-thread.h