+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
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
### 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
static GHashTable *info_hash = NULL;
static char*
-javacaps_to_uscore (const char *caps)
+wincaps_to_uscore (const char *caps)
{
const char *p;
GString *str;
}
static char*
-uscore_to_javacaps (const char *uscore)
+uscore_to_wincaps (const char *uscore)
{
const char *p;
GString *str;
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");
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");
/* 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);
/** @} */ /* end of public API */
#ifdef DBUS_BUILD_TESTS
+#include <stdlib.h>
/**
* @ingroup DBusGLibInternals
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;
}
--- /dev/null
+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