[beast/devel: 51/77] SFI: remove Birnet/Sfi Msg uses
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 51/77] SFI: remove Birnet/Sfi Msg uses
- Date: Wed, 1 May 2013 17:31:37 +0000 (UTC)
commit 35b56f78d4d1fac5c1a9d7de3e7c231abf2e82b2
Author: Tim Janik <timj gnu org>
Date: Thu Apr 11 02:06:44 2013 +0200
SFI: remove Birnet/Sfi Msg uses
sfi/sfiwrapper.cc | 130 ------------------------------------------------
sfi/sfiwrapper.hh | 84 ++-----------------------------
sfi/tests/misctests.cc | 22 +-------
3 files changed, 7 insertions(+), 229 deletions(-)
---
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index b6d8d66..5cb7409 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -88,136 +88,6 @@ birnet_file_equals (const char *file1,
{
return Birnet::Path::equals (file1 ? file1 : "", file2 ? file2 : "");
}
-/* --- message handling --- */
-SfiMsgType
-sfi_msg_type_register (const gchar *ident,
- SfiMsgType default_ouput,
- const gchar *label)
-{
- BIRNET_STATIC_ASSERT (Birnet::Msg::NONE == (uint) SFI_MSG_NONE);
- BIRNET_STATIC_ASSERT (Birnet::Msg::ALWAYS == (uint) SFI_MSG_ALWAYS);
- BIRNET_STATIC_ASSERT (Birnet::Msg::ERROR == (uint) SFI_MSG_ERROR);
- BIRNET_STATIC_ASSERT (Birnet::Msg::WARNING == (uint) SFI_MSG_WARNING);
- BIRNET_STATIC_ASSERT (Birnet::Msg::SCRIPT == (uint) SFI_MSG_SCRIPT);
- BIRNET_STATIC_ASSERT (Birnet::Msg::INFO == (uint) SFI_MSG_INFO);
- BIRNET_STATIC_ASSERT (Birnet::Msg::DIAG == (uint) SFI_MSG_DIAG);
- BIRNET_STATIC_ASSERT (Birnet::Msg::DEBUG == (uint) SFI_MSG_DEBUG);
- return (SfiMsgType) Birnet::Msg::register_type (ident, Birnet::Msg::Type (default_ouput), label);
-}
-bool
-sfi_msg_check (SfiMsgType mtype)
-{
- return Birnet::Msg::check (Birnet::Msg::Type (mtype));
-}
-void
-sfi_msg_enable (SfiMsgType mtype)
-{
- return Birnet::Msg::enable (Birnet::Msg::Type (mtype));
-}
-void
-sfi_msg_disable (SfiMsgType mtype)
-{
- return Birnet::Msg::disable (Birnet::Msg::Type (mtype));
-}
-void
-sfi_msg_allow (const gchar *ident_list)
-{
- return Birnet::Msg::allow_msgs (ident_list);
-}
-void
-sfi_msg_deny (const gchar *ident_list)
-{
- return Birnet::Msg::deny_msgs (ident_list);
-}
-const char*
-sfi_msg_type_ident (SfiMsgType mtype)
-{
- return Birnet::Msg::type_ident (Birnet::Msg::Type (mtype));
-}
-const char*
-sfi_msg_type_label (SfiMsgType mtype)
-{
- return Birnet::Msg::type_label (Birnet::Msg::Type (mtype));
-}
-SfiMsgType
-sfi_msg_lookup_type (const char *ident)
-{
- return (SfiMsgType) Birnet::Msg::lookup_type (ident);
-}
-SfiMsgPart*
-sfi_msg_part_printf (uint8 msg_part_id,
- const char *format,
- ...)
-{
- int saved_errno = errno;
- /* construct message */
- va_list args;
- va_start (args, format);
- char *text = g_strdup_vprintf (format, args);
- va_end (args);
- Birnet::Msg::Part *part;
- switch (msg_part_id)
- {
- case '0': part = new Birnet::Msg::Text0 (Birnet::String (text)); break;
- case '1': part = new Birnet::Msg::Text1 (Birnet::String (text)); break;
- case '2': part = new Birnet::Msg::Text2 (Birnet::String (text)); break;
- case '3': part = new Birnet::Msg::Text3 (Birnet::String (text)); break;
- case 'c': part = new Birnet::Msg::Check (Birnet::String (text)); break;
- default: part = new Birnet::Msg::Custom (msg_part_id, Birnet::String (text)); break;
- }
- g_free (text);
- errno = saved_errno;
- return (SfiMsgPart*) part;
-}
-void
-sfi_msg_display_parts (const char *log_domain,
- SfiMsgType mtype,
- guint n_mparts,
- SfiMsgPart **mparts)
-{
- int saved_errno = errno;
- std::vector<Birnet::Msg::Part> parts;
- for (uint i = 0; i < n_mparts; i++)
- {
- Birnet::Msg::Part *part = (Birnet::Msg::Part*) mparts[i];
- parts.push_back (*part);
- delete part;
- }
- Birnet::Msg::display_parts (log_domain, Birnet::Msg::Type (mtype), parts);
- errno = saved_errno;
-}
-/**
- * @param log_domain log domain
- * @param level one of SFI_MSG_ERROR, SFI_MSG_WARNING, SFI_MSG_INFO, SFI_MSG_DIAG or SFI_MSG_DEBUG
- * @param format printf-like format
- * @param ... printf-like arguments
- *
- * Log a message through SFIs logging mechanism. The current
- * value of errno is preserved around calls to this function.
- * Usually this function isn't used directly, but through one
- * of sfi_debug(), sfi_diag(), sfi_info(), sfi_warn() or sfi_error().
- * The @a log_domain indicates the calling module and relates to
- * G_LOG_DOMAIN as used by g_log().
- * This function is MT-safe and may be called from any thread.
- */
-void
-sfi_msg_display_printf (const char *log_domain,
- SfiMsgType mtype,
- const char *format,
- ...)
-{
- int saved_errno = errno;
- /* construct message */
- va_list args;
- va_start (args, format);
- char *primary = g_strdup_vprintf (format, args);
- va_end (args);
- std::vector<Birnet::Msg::Part> parts;
- parts.push_back (Birnet::Msg::Primary (std::string (primary)));
- g_free (primary);
- Birnet::Msg::display_parts (log_domain, Birnet::Msg::Type (mtype), parts);
- errno = saved_errno;
-}
/* --- url handling --- */
void
diff --git a/sfi/sfiwrapper.hh b/sfi/sfiwrapper.hh
index f5c1b91..ea4afaf 100644
--- a/sfi/sfiwrapper.hh
+++ b/sfi/sfiwrapper.hh
@@ -75,75 +75,12 @@ bool birnet_file_check (const char *file,
bool birnet_file_equals (const char *file1,
const char *file2);
/* --- messaging --- */
-typedef enum {
- SFI_MSG_NONE = 0, /* always off */
- SFI_MSG_ALWAYS = 1, /* always on */
- SFI_MSG_ERROR,
- SFI_MSG_WARNING,
- SFI_MSG_SCRIPT,
- SFI_MSG_INFO,
- SFI_MSG_DIAG,
- SFI_MSG_DEBUG
-} SfiMsgType;
-typedef enum {
- SFI_MSG_TO_STDERR = 1,
- SFI_MSG_TO_STDLOG = 2,
- SFI_MSG_TO_HANDLER = 4,
-} SfiMsgLogFlags;
-#define sfi_error(...) sfi_msg_printf (SFI_MSG_ERROR, __VA_ARGS__)
-#define sfi_warning(...) sfi_msg_printf (SFI_MSG_WARNING, __VA_ARGS__)
-#define sfi_info(...) sfi_msg_printf (SFI_MSG_INFO, __VA_ARGS__)
-#define sfi_diag(...) sfi_msg_printf (SFI_MSG_DIAG, __VA_ARGS__)
-#define sfi_debug(lvl, ...) sfi_msg_printf (lvl, __VA_ARGS__)
+#define sfi_error(...) RAPICORN_FATAL (__VA_ARGS__)
+#define sfi_warning(...) RAPICORN_CRITICAL (__VA_ARGS__)
+#define sfi_info(...) BSE_DEBUG (__VA_ARGS__)
+#define sfi_diag(...) BSE_DEBUG (__VA_ARGS__)
+#define sfi_debug(lvl, ...) BSE_DEBUG (__VA_ARGS__)
#define sfi_nodebug(lvl, ...) do { /* nothing */ } while (0)
-bool sfi_msg_check (SfiMsgType mtype);
-void sfi_msg_enable (SfiMsgType mtype);
-void sfi_msg_disable (SfiMsgType mtype);
-void sfi_msg_allow (const char *ident_list);
-void sfi_msg_deny (const char *ident_list);
-const char* sfi_msg_type_ident (SfiMsgType mtype);
-const char* sfi_msg_type_label (SfiMsgType mtype);
-SfiMsgType sfi_msg_lookup_type (const char *ident);
-SfiMsgType sfi_msg_type_register (const char *ident,
- SfiMsgType default_ouput,
- const char *label);
-#define sfi_msg_printf(level, ...) SFI_MSG_PRINTF (level, __VA_ARGS__) /* level,
printf_format, ... */
-#define sfi_msg_display(level, ...) SFI_MSG_DISPLAY (level, __VA_ARGS__) /* level, part,
part, ... */
-#define SFI_MSG_TEXT0(...) sfi_msg_part_printf ('0', __VA_ARGS__) /* message title */
-#define SFI_MSG_TEXT1(...) sfi_msg_part_printf ('1', __VA_ARGS__) /* primary message */
-#define SFI_MSG_TEXT2(...) sfi_msg_part_printf ('2', __VA_ARGS__) /* secondary message
*/
-#define SFI_MSG_TEXT3(...) sfi_msg_part_printf ('3', __VA_ARGS__) /* message details */
-#define SFI_MSG_CHECK(...) sfi_msg_part_printf ('c', __VA_ARGS__) /* user switch */
-#define SFI_MSG_TITLE SFI_MSG_TEXT0 /* alias */
-#define SFI_MSG_PRIMARY SFI_MSG_TEXT1 /* alias */
-#define SFI_MSG_SECONDARY SFI_MSG_TEXT2 /* alias */
-#define SFI_MSG_DETAIL SFI_MSG_TEXT3 /* alias */
-#define SFI_MSG_TYPE_DEFINE(variable, ident, default_ouput, label) SFI_MSG__TYPEDEF (variable,
ident, default_ouput, label)
-
-/* --- messaging implementation --- */
-typedef struct SfiMsgPart SfiMsgPart;
-SfiMsgPart* sfi_msg_part_printf (uint8 msg_part_id,
- const char *format,
- ...) G_GNUC_PRINTF (2, 3);
-void sfi_msg_display_parts (const char *log_domain,
- SfiMsgType mtype,
- guint n_mparts,
- SfiMsgPart **mparts);
-void sfi_msg_display_printf (const char *log_domain,
- SfiMsgType mtype,
- const char *format,
- ...) G_GNUC_PRINTF (3, 4);
-#define SFI_MSG_PRINTF(lvl, ...) do { SfiMsgType __mt = lvl; if (sfi_msg_check (__mt)) \
- sfi_msg_display_printf (BIRNET_LOG_DOMAIN, __mt, __VA_ARGS__);
} while (0)
-#define SFI_MSG_DISPLAY(lvl, ...) do { SfiMsgType __mt = lvl; if (sfi_msg_check (__mt)) { \
- SfiMsgPart *__pa[] = { __VA_ARGS__ }; \
- sfi_msg_display_parts (BIRNET_LOG_DOMAIN, __mt, \
- BIRNET_ARRAY_SIZE (__pa), __pa); } } while (0)
-#define SFI_MSG__TYPEDEF(variable, identifier, default_ouput, label) \
- SfiMsgType variable = (SfiMsgType) 0; \
- static void BIRNET_CONSTRUCTOR \
- BIRNET_CPP_PASTE4 (__sfi_msg_type__init, __LINE__, __, variable) (void) \
- { variable = sfi_msg_type_register (identifier, default_ouput, label); }
/* --- url handling --- */
void sfi_url_show (const char *url);
@@ -155,17 +92,6 @@ bool sfi_url_test_show_with_cookie (const char *url,
const char *url_title,
const char *cookie);
-#ifndef BIRNET__RUNTIME_PROBLEM
-#define BIRNET__RUNTIME_PROBLEM(ErrorWarningReturnAssertNotreach,domain,file,line,funcname,...) \
- sfi_runtime_problem (ErrorWarningReturnAssertNotreach, domain, file, line, funcname, __VA_ARGS__)
-#endif
-void sfi_runtime_problem (char ewran_tag,
- const char *domain,
- const char *file,
- int line,
- const char *funcname,
- const char *msgformat,
- ...) BIRNET_PRINTF (6, 7);
BIRNET_EXTERN_C_END();
#endif /* __SFI_WRAPPER_H__ */
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index 892b5d5..83e17ec 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -27,24 +27,7 @@ test_misc (void)
TASSERT (0 == 0);
TDONE ();
}
-static void
-test_messages (void)
-{
- TSTART ("Messaging");
- TASSERT (sfi_msg_check (SFI_MSG_NONE) == false);
- TASSERT (sfi_msg_check (SFI_MSG_ALWAYS) == true);
- TDONE();
- if (0)
- {
- /* check compilability */
- sfi_info ("First info message test.");
- sfi_info ("Second info message test: %d", 42);
- sfi_msg_display (SFI_MSG_INFO,
- SFI_MSG_TITLE ("Third info message test"),
- SFI_MSG_PRIMARY ("Third info primary message."),
- SFI_MSG_SECONDARY ("Third info secondary message: %d", 42));
- }
-}
+
static void
test_time (void)
{
@@ -495,7 +478,7 @@ test_notes (void)
sfi_note_examine (i, &octave, &semitone, &black_semitone, &letter);
TASSERT (octave == SFI_NOTE_OCTAVE (i));
TASSERT (semitone == SFI_NOTE_SEMITONE (i));
- TASSERT (SFI_NOTE_GENERIC (octave, semitone) == i);
+ TASSERT (SFI_NOTE_GENERIC (octave, semitone) == int (i));
}
sfi_note_from_string_err ("NeverNote", &error);
TASSERT (error != NULL);
@@ -755,7 +738,6 @@ main (int argc,
test_vmarshals ();
test_com_ports ();
test_sfidl_seq ();
- test_messages();
test_misc ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]