diff options
author | Akira TAGOH <akira@tagoh.org> | 2011-02-04 16:47:29 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2011-02-04 16:47:29 +0900 |
commit | a0f1752c8520fd05e7beca7b04eeabe4a4b0c1de (patch) | |
tree | a53d8e4ea44e94b933a93c9e52808e49f9a7fbaf | |
parent | acba4f3bedcfac3630b44228a866cff9aaf12579 (diff) |
replace glib's log handler to the own
39 files changed, 805 insertions, 617 deletions
@@ -21,9 +21,11 @@ core.* depcomp install-sh intltool-* -hieroglyph/hglineedit.c -hieroglyph/hgscanner.c -hieroglyph/hgversion.h +hieroglyph/hgconfig\.h +hieroglyph/hgconfig-stamp +hieroglyph/hglineedit\.c +hieroglyph/hgscanner\.c +hieroglyph/hgversion\.h libtool ltmain\.sh missing diff --git a/configure.ac b/configure.ac index cd4291f..6af655a 100644 --- a/configure.ac +++ b/configure.ac @@ -18,6 +18,7 @@ AC_PROG_LEX AC_PROG_CC AM_PROG_CC_C_O +AC_PROG_CXX GNOME_COMPILE_WARNINGS @@ -89,6 +90,43 @@ AC_CHECK_ALIGNOF(long) AC_CHECK_ALIGNOF(void *) AC_CHECK_ALIGNOF(long long) +dnl check for flavours of varargs macros +AC_MSG_CHECKING(for ISO C99 varargs macros in C) +_save_cflags=$CFLAGS +CFLAGS=$(sed -e 's/\-Werror//g') +AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(...) a(1,__VA_ARGS__) +call_a(2,3); +],have_iso_c_varargs=yes,have_iso_c_varargs=no) +CFLAGS=$_save_cflags +AC_MSG_RESULT($have_iso_c_varargs) + +AC_MSG_CHECKING(for ISO C99 varargs macros in C++) +if test "$CXX" = ""; then + have_iso_cxx_varargs=no +else + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(...) a(1,__VA_ARGS__) +call_a(2,3); +],have_iso_cxx_varargs=yes,have_iso_cxx_varargs=no) + AC_LANG_C +fi +AC_MSG_RESULT($have_iso_cxx_varargs) + +AC_MSG_CHECKING(for GNUC varargs macros) +_save_cflags=$CFLAGS +CFLAGS=$(sed -e 's/\-Werror//g') +AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(params...) a(1,params) +call_a(2,3); +],have_gnuc_varargs=yes,have_gnuc_varargs=no) +CFLAGS=$_save_cflags +AC_MSG_RESULT($have_gnuc_varargs) + dnl ====================================================================== dnl functions testing dnl ====================================================================== @@ -197,6 +235,75 @@ AM_CONDITIONAL(ENABLE_CAIRO, test x$with_cairo != xno) dnl ====================================================================== dnl output dnl ====================================================================== +AC_CONFIG_COMMANDS([hieroglyph/hgconfig.h], +[ + outfile=hieroglyph/hgconfig.h-tmp + cat > $outfile <<\_______EOF +/* + * hgconfig.h + * + * This is a genereated file. Please modify 'configure.ac' + */ +#ifndef __HIEROGLYPH_HGCONFIG_H__ +#define __HIEROGLYPH_HGCONFIG_H__ + +#include <hieroglyph/hgmacros.h> + +_______EOF + + cat >> $outfile <<_______EOF + +HG_BEGIN_DECLS + +_______EOF + + if test x$hg_have_iso_c_varargs = xyes; then + cat >>$outfile <<_______EOF +#ifndef __cplusplus +# define HG_HAVE_ISO_VARARGS 1 +#endif +_______EOF + fi + if test x$hg_have_iso_cxx_varargs = xyes; then + cat >>$outfile <<_______EOF +#ifdef __cplusplus +# define HG_HAVE_ISO_VARARGS 1 +#endif +_______EOF + fi + if test x$hg_have_gnuc_varargs = xyes; then + cat >>$outfile <<_______EOF + +/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi + * is passed ISO vararg support is turned off, and there is no work + * around to turn it on, so we unconditionally turn it off. + */ +#if __GNUC__ == 2 && __GNUC_MINOR__ == 95 +# undef HG_HAVE_ISO_VARARGS +#endif + +#define HG_HAVE_GNUC_VARARGS 1 +_______EOF + fi + + cat >>$outfile <<_______EOF + +HG_END_DECLS + +#endif /* __HIEROGLYPH_HGCONFIG_H__ */ +_______EOF + + if cmp -s $outfile hieroglyph/hgconfig.h; then + AC_MSG_NOTICE([hieroglyph/hgconfig.h is unchanged]) + rm -f $outfile + else + mv $outfile hieroglyph/hgconfig.h + fi +],[ +hg_have_gnuc_varargs=$have_gnuc_varargs +hg_have_iso_c_varargs=$have_iso_c_varargs +hg_have_iso_cxx_varargs=$have_iso_cxx_varargs +]) AC_CONFIG_FILES([ Makefile build_tools/Makefile diff --git a/devices/cairo/cairo-main.c b/devices/cairo/cairo-main.c index 2fe4140..a68dc8a 100644 --- a/devices/cairo/cairo-main.c +++ b/devices/cairo/cairo-main.c @@ -278,7 +278,7 @@ _hg_cairo_device_set_line_cap(hg_cairo_device_t *device, cap = CAIRO_LINE_CAP_SQUARE; break; default: - g_warning("unknown line cap"); + hg_warning("unknown line cap"); cap = CAIRO_LINE_CAP_BUTT; break; } @@ -302,7 +302,7 @@ _hg_cairo_device_set_line_join(hg_cairo_device_t *device, join = CAIRO_LINE_JOIN_BEVEL; break; default: - g_warning("unknown line join"); + hg_warning("unknown line join"); join = CAIRO_LINE_JOIN_MITER; break; } diff --git a/hieroglyph.pc.in b/hieroglyph.pc.in index b20a229..0f16f44 100644 --- a/hieroglyph.pc.in +++ b/hieroglyph.pc.in @@ -7,5 +7,5 @@ Name: Hieroglyph Description: PostScript rendering library Version: @VERSION@ Requires: glib-2.0 +Cflags: -I${libdir}/hieroglyph/include Libs: -L${libdir} -lhieroglyph - diff --git a/hieroglyph/Makefile.am b/hieroglyph/Makefile.am index df35e7d..6a0afa4 100644 --- a/hieroglyph/Makefile.am +++ b/hieroglyph/Makefile.am @@ -26,9 +26,14 @@ CLEANFILES = \ hglineedit.c \ hgscanner.c \ $(NULL) +DISTCLEANFILES = \ + hgconfig-stamp \ + hgconfig.h \ + $(NULL) BUILT_SOURCES = \ $(hg_built_headers) \ $(hg_built_sources) \ + hgconfig-stamp \ $(NULL) ## @@ -49,7 +54,7 @@ hg_public_headers = \ hgmark.h \ hgmatrix.h \ hgmem.h \ - hgmessage.h \ + hgmessages.h \ hgname.h \ hgnull.h \ hgpath.h \ @@ -100,7 +105,7 @@ hg_sources = \ hggstate.c \ hgmatrix.c \ hgmem.c \ - hgmessage.c \ + hgmessages.c \ hgname.c \ hgpath.c \ hgobject.c \ @@ -129,6 +134,10 @@ LEX_OUTPUT_ROOT=lex.$(basename $<) $(AM_V_GEN)[[ ! -f $(<:.c=.l) ]] && $(top_srcdir)/build_tools/genfuncdecls.sh $< > gfp || $(top_srcdir)/build_tools/genfuncdecls.sh $(<:.c=.l) > gfp; \ (cmp -s gfp $@ || cp gfp $@) \ && rm -f gfp +hgconfig-stamp: $(top_builddir)/config.status + $(AM_V_GEN) cd $(top_builddir) && \ + $(SHELL) ./config.status hieroglyph/hgconfig.h + @touch hgconfig-stamp ## # Target platform @@ -147,6 +156,11 @@ noinst_HEADERS = \ $(hg_built_private_headers) \ $(NULL) # +configexecincludedir = $(libdir)/hieroglyph/include +nodist_configexecinclude_HEADERS = \ + hgconfig.h \ + $(NULL) +# libhieroglyph_la_SOURCES = \ $(hg_sources) \ $(hg_lex_sources) \ diff --git a/hieroglyph/hgallocator-private.h b/hieroglyph/hgallocator-private.h index 86a227c..cf9b52f 100644 --- a/hieroglyph/hgallocator-private.h +++ b/hieroglyph/hgallocator-private.h @@ -26,6 +26,7 @@ #include <hieroglyph/hgtypes.h> #include <hieroglyph/hgerror.h> +#include <hieroglyph/hgmessages.h> #include <hieroglyph/hgquark.h> HG_BEGIN_DECLS diff --git a/hieroglyph/hgallocator.c b/hieroglyph/hgallocator.c index 0e76e6a..2dd4437 100644 --- a/hieroglyph/hgallocator.c +++ b/hieroglyph/hgallocator.c @@ -30,6 +30,7 @@ /* GLib is still needed for the mutex lock */ #include <glib.h> #include "hgerror.h" +#include "hgmessages.h" #include "hgquark.h" #include "hgallocator.h" #include "hgallocator-private.h" @@ -609,7 +610,7 @@ _hg_allocator_realloc(hg_allocator_data_t *data, } } else { #if defined(HG_DEBUG) && defined(HG_MEM_DEBUG) - g_warning("%lx isn't the allocated object.\n", qdata); + hg_warning("%lx isn't the allocated object.\n", qdata); #endif } @@ -634,7 +635,7 @@ _hg_allocator_free(hg_allocator_data_t *data, _hg_allocator_bitmap_free(priv->bitmap, index_, block->size); } else { #if defined(HG_DEBUG) && defined(HG_MEM_DEBUG) - g_warning("%lx isn't the allocated object.\n", index_); + hg_warning("%lx isn't the allocated object.\n", index_); #endif } } @@ -663,9 +664,7 @@ _hg_allocator_get_internal_block_from_page_and_index(hg_allocator_private_t *pri if (page >= hg_allocator_get_max_page() || idx > priv->bitmap->size[page]) { - gchar *s = hg_get_stacktrace(); - - g_warning("Invalid quark to access: [page: %d, index: %d\nStack trace:\n%s", page, idx, s); + hg_warning("Invalid quark to access: [page: %d, index: %d]", page, idx); return NULL; } retval = (hg_allocator_block_t *)((gulong)priv->heaps[page] + ((idx - 1) * BLOCK_SIZE)); @@ -765,7 +764,7 @@ _hg_allocator_gc_init(hg_allocator_data_t *data) gsize i, max_page = hg_allocator_get_max_page(); if (G_UNLIKELY (priv->slave_bitmap)) { - g_warning("GC is already ongoing."); + hg_warning("GC is already ongoing."); return FALSE; } priv->slave_bitmap = _hg_allocator_bitmap_new(priv->bitmap->size[0] * BLOCK_SIZE); @@ -824,10 +823,10 @@ _hg_allocator_gc_mark(hg_allocator_data_t *data, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = FALSE; @@ -843,7 +842,7 @@ _hg_allocator_gc_finish(hg_allocator_data_t *data, hg_allocator_private_t *priv = (hg_allocator_private_t *)data; if (G_UNLIKELY (!priv->slave_bitmap)) { - g_warning("GC isn't yet started."); + hg_warning("GC isn't yet started."); return FALSE; } @@ -876,8 +875,8 @@ _hg_allocator_gc_finish(hg_allocator_data_t *data, if (!_hg_allocator_bitmap_is_marked(priv->slave_bitmap, i, j + 1)) { used_size -= block->size; if (block->lock_count > 0) { - g_warning("[BUG] locked block without references [page: %d, index: %d, size: %ld, count: %d]\n", - i, j + 1, block->size, block->lock_count); + hg_warning("[BUG] locked block without references [page: %d, index: %d, size: %ld, count: %d]\n", + i, j + 1, block->size, block->lock_count); #if defined (HG_DEBUG) && defined (HG_GC_DEBUG) abort(); #endif diff --git a/hieroglyph/hgarray.c b/hieroglyph/hgarray.c index d91bafa..16bb1ee 100644 --- a/hieroglyph/hgarray.c +++ b/hieroglyph/hgarray.c @@ -134,10 +134,10 @@ _hg_object_array_copy(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); if (a) @@ -246,10 +246,10 @@ _hg_object_array_gc_mark(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = FALSE; @@ -476,10 +476,10 @@ hg_array_set(hg_array_t *array, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -542,10 +542,10 @@ hg_array_get(hg_array_t *array, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -730,7 +730,7 @@ hg_array_set_name(hg_array_t *array, len = strlen(name); array->qname = hg_mem_alloc(array->o.mem, len, (gpointer *)&p); if (array->qname == Qnil) { - g_warning("%s: Unable to allocate memory.", __PRETTY_FUNCTION__); + hg_warning("%s: Unable to allocate memory.", __PRETTY_FUNCTION__); } else { memcpy(p, name, len); } @@ -789,10 +789,10 @@ hg_array_make_subarray(hg_array_t *array, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } diff --git a/hieroglyph/hgdevice.c b/hieroglyph/hgdevice.c index 6e320dd..02abdf8 100644 --- a/hieroglyph/hgdevice.c +++ b/hieroglyph/hgdevice.c @@ -141,7 +141,7 @@ _hg_device_open(hg_mem_t *mem, g_module_symbol(module, "hg_module_finalize", &dev_fini); if (!dev_init || !dev_fini) { - g_warning(g_module_error()); + hg_warning(g_module_error()); g_module_close(module); return NULL; @@ -157,7 +157,7 @@ _hg_device_open(hg_mem_t *mem, } #if defined (HG_DEBUG) && defined (HG_MODULE_DEBUG) } else { - g_warning(g_module_error()); + hg_warning(g_module_error()); #endif /* HG_DEBUG && HG_MODULE_DEBUG */ } @@ -265,7 +265,7 @@ hg_device_open(hg_mem_t *mem, g_free(fullname); } if (retval == NULL) { - g_warning("No such device module: %s", basename); + hg_warning("No such device module: %s", basename); } g_free(modulename); @@ -502,7 +502,7 @@ hg_device_get_page_params(hg_device_t *device, if ((q = device->get_page_param(device, i)) != Qnil) break; } - g_warning("Unknown pagedevice parameter: %d\n", i); + hg_warning("Unknown pagedevice parameter: %d\n", i); break; } if (q != Qnil) { @@ -524,10 +524,10 @@ hg_device_get_page_params(hg_device_t *device, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); hg_object_free(d->o.mem, retval); @@ -649,10 +649,10 @@ hg_device_eofill(hg_device_t *device, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -698,10 +698,10 @@ hg_device_fill(hg_device_t *device, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -747,10 +747,10 @@ hg_device_stroke(hg_device_t *device, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } diff --git a/hieroglyph/hgdict.c b/hieroglyph/hgdict.c index bb18172..eacbe11 100644 --- a/hieroglyph/hgdict.c +++ b/hieroglyph/hgdict.c @@ -376,10 +376,10 @@ _hg_object_dict_node_gc_mark(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = FALSE; @@ -1040,10 +1040,10 @@ hg_dict_add(hg_dict_t *dict, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); @@ -1119,10 +1119,10 @@ hg_dict_remove(hg_dict_t *dict, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -1190,10 +1190,10 @@ hg_dict_lookup(hg_dict_t *dict, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -1261,10 +1261,10 @@ hg_dict_foreach(hg_dict_t *dict, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -1298,10 +1298,10 @@ hg_dict_first_item(hg_dict_t *dict, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); diff --git a/hieroglyph/hgencoding.c b/hieroglyph/hgencoding.c index 52c1de1..8565502 100644 --- a/hieroglyph/hgencoding.c +++ b/hieroglyph/hgencoding.c @@ -27,6 +27,7 @@ #include <glib.h> #include "hgerror.h" +#include "hgmessages.h" #include "hgencoding.h" #include "hgencoding.proto.h" diff --git a/hieroglyph/hgerror.c b/hieroglyph/hgerror.c index 0ca47e3..1e3f9ae 100644 --- a/hieroglyph/hgerror.c +++ b/hieroglyph/hgerror.c @@ -25,88 +25,12 @@ #include "config.h" #endif -#include <execinfo.h> -#include <stdlib.h> #include <glib.h> #include "hgerror.h" #include "hgerror.proto.h" -static gboolean __hg_stacktrace_feature = TRUE; - -/** - * hg_get_stacktrace: - * - * FIXME - * - * Returns: FIXME - */ -gchar * -hg_get_stacktrace(void) -{ - void *traces[256]; - GPtrArray *array; - GString *retval; - int size, i; - char **strings; - - if (__hg_stacktrace_feature == FALSE) - return g_strdup(""); - - array = g_ptr_array_new(); - retval = g_string_new(NULL); - do { - size = backtrace(traces, 256); - for (i = 0; i < size; i++) - g_ptr_array_add(array, traces[i]); - } while (size == 256); - strings = backtrace_symbols(array->pdata, array->len); - - for (i = 1; i < array->len; i++) { - g_string_append_printf(retval, " %d. ", i); - g_string_append(retval, strings[i]); - g_string_append_c(retval, '\n'); - } - free(strings); - g_ptr_array_free(array, TRUE); - - return g_string_free(retval, FALSE); -} - -/** - * hg_use_stacktrace: - * @flag: if %TRUE the stacktrace feature is enabled. - * - * FIXME - */ -void -hg_use_stacktrace(gboolean flag) -{ -#ifdef HG_DEBUG - __hg_stacktrace_feature = flag; -#else - g_warning("The stacktrace feature are entirely disabled at the build time."); -#endif -} - -/** - * hg_is_stacktrace_enabled: - * - * FIXME - * - * Returns: %TRUE if the stacktrace feature is enabled. otherwise %FALSE. - */ -gboolean -hg_is_stacktrace_enabled(void) -{ -#ifdef HG_DEBUG - return __hg_stacktrace_feature; -#else - return FALSE; -#endif -} - /** * hg_error_quark: * diff --git a/hieroglyph/hgerror.h b/hieroglyph/hgerror.h index 2032bfa..195c2d0 100644 --- a/hieroglyph/hgerror.h +++ b/hieroglyph/hgerror.h @@ -31,13 +31,30 @@ #include <stdio.h> #include <errno.h> #include <glib.h> -#include <hieroglyph/hgmacros.h> +#include <hieroglyph/hgtypes.h> HG_BEGIN_DECLS -#define HG_ERROR hg_error_quark() - -typedef enum _hg_vm_error_t hg_vm_error_t; +#define HG_ERROR_VM_STATUS_MASK_SHIFT 8 +#define HG_ERROR_VM_STATUS_MASK ((1 << HG_ERROR_VM_STATUS_MASK_SHIFT) - 1) + +#define HG_ERROR_GET_VM_STATUS(_e_) \ + ((_e_) & HG_ERROR_VM_STATUS_MASK) +#define HG_ERROR_SET_VM_STATUS(_e_,_t_) \ + (((_e_) & ~HG_ERROR_VM_STATUS_MASK) | \ + ((_t_) & HG_ERROR_VM_STATUS_MASK)) +#define HG_ERROR_GET_REASON(_e_) \ + (((_e_) & ~(HG_ERROR_VM_STATUS_MASK)) >> HG_ERROR_VM_STATUS_MASK_SHIFT) +#define HG_ERROR_SET_REASON(_e_,_t_) \ + (((_e_) & HG_ERROR_STATUS_MASK) | ((_t_) << HG_ERROR_VM_STATUS_MASK_SHIFT)) +#define HG_ERROR (hg_error_quark()) +#define HG_ERROR_(_status_,_reason_) \ + (hg_error_t)(HG_ERROR_SET_VM_STATUS (0, (_status_)) | \ + HG_ERROR_SET_REASON (0, (_reason_))) + +typedef hg_int_t hg_error_t; +typedef enum _hg_vm_error_t hg_vm_error_t; +typedef enum _hg_error_reason_t hg_error_reason_t; enum _hg_vm_error_t { HG_VM_e_dictfull = 1, @@ -70,129 +87,10 @@ enum _hg_vm_error_t { HG_VM_e_undefinedresource, HG_VM_e_END }; +enum _hg_error_reason_t { + HG_e_END +}; -#ifdef HG_DEBUG -/* evaluate x if the debugging build */ -#define d(x) x - -#define hg_stacktrace() \ - HG_STMT_START { \ - if (hg_is_stacktrace_enabled()) { \ - gchar *__stacktrace__ = hg_get_stacktrace(); \ - \ - g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ - "Stacktrace:\n%s\n", __stacktrace__); \ - g_free(__stacktrace__); \ - } \ - } HG_STMT_END -#else /* !HG_DEBUG */ -/* ignore x if not in the debugging build */ -#define d(x) - -#define hg_stacktrace() - -#endif /* HG_DEBUG */ - -#ifdef __GNUC__ -#define _hg_return_if_fail_warning(__domain__,__func__,__expr__) \ - HG_STMT_START { \ - g_return_if_fail_warning(__domain__, \ - __func__, \ - __expr__); \ - } HG_STMT_END -#define _hg_return_after_eval_if_fail(__expr__,__eval__) \ - HG_STMT_START { \ - if (G_LIKELY(__expr__)) { \ - } else { \ - _hg_return_if_fail_warning(G_LOG_DOMAIN, \ - __PRETTY_FUNCTION__, \ - #__expr__); \ - __eval__; \ - return; \ - } \ - } HG_STMT_END -#define _hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) \ - HG_STMT_START { \ - if (G_LIKELY(__expr__)) { \ - } else { \ - _hg_return_if_fail_warning(G_LOG_DOMAIN, \ - __PRETTY_FUNCTION__, \ - #__expr__); \ - __eval__; \ - return (__val__); \ - } \ - } HG_STMT_END -#define _hg_gerror_on_fail(__expr__,__err__,__code__) \ - HG_STMT_START { \ - hg_stacktrace(); \ - if ((__err__)) { \ - g_set_error((__err__), HG_ERROR, __code__, \ - "%s: assertion `%s' failed", \ - __PRETTY_FUNCTION__, \ - #__expr__); \ - } \ - } HG_STMT_END -#else /* !__GNUC__ */ -#define _hg_return_after_eval_if_fail(__expr__,__eval__) \ - HG_STMT_START { \ - if (__expr__) { \ - } else { \ - g_log(G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d: assertion `%s' failed", \ - __FILE__, \ - __LINE__, \ - #__expr__); \ - __eval__; \ - return; \ - } \ - } HG_STMT_END -#define _hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) \ - HG_STMT_START { \ - if (__expr__) { \ - } else { \ - g_log(G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d: assertion `%s' failed", \ - __FILE__, \ - __LINE__, \ - #__expr__); \ - __eval__; \ - return (__val__); \ - } \ - } HG_STMT_END -#define _hg_error_if_fail(__expr__,__err__) \ - HG_STMT_START { \ - hg_stacktrace(); \ - if ((__err__)) { \ - g_set_error((__err__), HG_ERROR, HG_VM_e_VMerror, \ - "file %s: line %d: assertion `%s' failed", \ - __FILE__, \ - __LINE__, \ - #__expr__); \ - } \ - } HG_STMT_END -#endif /* __GNUC__ */ - -#define hg_return_if_fail(__expr__) \ - _hg_return_after_eval_if_fail(__expr__,hg_stacktrace()) -#define hg_return_val_if_fail(__expr__,__val__) \ - _hg_return_val_after_eval_if_fail(__expr__,__val__,hg_stacktrace()) -#define hg_return_after_eval_if_fail(__expr__,__eval__) \ - _hg_return_after_eval_if_fail(__expr__,hg_stacktrace();__eval__) -#define hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) \ - _hg_return_val_after_eval_if_fail(__expr__,__val__,hg_stacktrace();__eval__) -#define hg_return_with_gerror_if_fail(__expr__,__err__,__code__) \ - _hg_return_after_eval_if_fail(__expr__,_hg_gerror_on_fail(__expr__,__err__,__code__)) -#define hg_return_val_with_gerror_if_fail(__expr__,__val__,__err__,__code__) \ - _hg_return_val_after_eval_if_fail(__expr__,__val__,_hg_gerror_on_fail(__expr__,__err__,__code__)) -#define hg_return_val_with_gerror_after_eval_if_fail(__expr__,__val__,__eval__,__err__,__code__) \ - _hg_return_val_after_eval_if_fail(__expr__,__val__,_hg_gerror_on_fail(__expr__,__err__,__code__);__eval__) - - -gchar *hg_get_stacktrace (void) G_GNUC_MALLOC; -void hg_use_stacktrace (gboolean flag); -gboolean hg_is_stacktrace_enabled(void); GQuark hg_error_quark (void); diff --git a/hieroglyph/hgfile.c b/hieroglyph/hgfile.c index f9d69d9..c0eea61 100644 --- a/hieroglyph/hgfile.c +++ b/hieroglyph/hgfile.c @@ -167,10 +167,10 @@ _hg_object_file_initialize(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } } g_error_free(err); @@ -191,10 +191,10 @@ _hg_object_file_free(hg_object_t *object) if (!file->is_closed) file->vtable->close(file, file->user_data, &err); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -269,10 +269,10 @@ _hg_object_file_gc_mark(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -1532,10 +1532,10 @@ hg_file_append_vprintf(hg_file_t *file, retval = hg_file_write(file, buffer, sizeof (gchar), strlen(buffer), &err); g_free(buffer); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } @@ -1688,7 +1688,7 @@ hg_file_set_error(GError **error, e = HG_VM_e_VMerror; break; default: - g_warning("No matching error code for: %s", msg); + hg_warning("No matching error code for: %s", msg); e = HG_VM_e_VMerror; break; } diff --git a/hieroglyph/hggstate.c b/hieroglyph/hggstate.c index 7e7ee0b..56d07e5 100644 --- a/hieroglyph/hggstate.c +++ b/hieroglyph/hggstate.c @@ -103,10 +103,10 @@ _hg_object_gstate_copy(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); hg_object_free(g->o.mem, retval); @@ -149,10 +149,10 @@ _hg_object_gstate_gc_mark(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = FALSE; @@ -365,10 +365,10 @@ hg_gstate_save(hg_gstate_t *gstate, hg_mem_unlock_object(gstate->o.mem, retval); error: if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); hg_object_free(gstate->o.mem, diff --git a/hieroglyph/hglineedit.l b/hieroglyph/hglineedit.l index 43999ac..ff67a58 100644 --- a/hieroglyph/hglineedit.l +++ b/hieroglyph/hglineedit.l @@ -186,10 +186,10 @@ _hg_lineedit_real_get_line(hg_lineedit_t *lineedit, return NULL; } - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); break; } diff --git a/hieroglyph/hgmacros.h b/hieroglyph/hgmacros.h index a2dc4f1..3adcc8e 100644 --- a/hieroglyph/hgmacros.h +++ b/hieroglyph/hgmacros.h @@ -53,6 +53,31 @@ #define HG_STMT_END while (0) #endif +/* + * The HG_LIKELY and HG_UNLIKELY macros let the programmer give hints to + * the compiler about the expected result of an expression. Some compilers + * can use this information for optimizations. + * + * The _HG_BOOLEAN_EXPR macro is intended to trigger a gcc warning when + * putting assignments in hg_return_if_fail() + */ +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +#define _HG_BOOLEAN_EXPR(_e_) \ + __extension__ ({ \ + int __bool_var__; \ + if (_e_) \ + __bool_var__ = 1; \ + else \ + __bool_var__ = 0; \ + __bool_var__; \ + }) +#define HG_LIKELY(_e_) (__builtin_expect (_HG_BOOLEAN_EXPR (_e_), 1)) +#define HG_UNLIKELY(_e_) (__builtin_expect (_HG_BOOLEAN_EXPR (_e_), 0)) +#else +#define HG_LIKELY(_e_) (_e_) +#define HG_UNLIKELY(_e_) (_e_) +#endif + /* boolean */ #ifndef FALSE #define FALSE (0) diff --git a/hieroglyph/hgmatrix.c b/hieroglyph/hgmatrix.c index afad911..3e3cdd5 100644 --- a/hieroglyph/hgmatrix.c +++ b/hieroglyph/hgmatrix.c @@ -28,6 +28,7 @@ #include <math.h> #include <string.h> #include "hgerror.h" +#include "hgmessages.h" #include "hgmatrix.h" #include "hgmatrix.proto.h" diff --git a/hieroglyph/hgmem.c b/hieroglyph/hgmem.c index d55f397..85d4f62 100644 --- a/hieroglyph/hgmem.c +++ b/hieroglyph/hgmem.c @@ -47,7 +47,7 @@ G_INLINE_FUNC void _hg_mem_gc_init(hg_mem_t *mem) { if (mem->slave_finalizer_table) { - g_warning("%s: slave instance already created.", __PRETTY_FUNCTION__); + hg_warning("%s: slave instance already created.", __PRETTY_FUNCTION__); g_hash_table_destroy(mem->slave_finalizer_table); } mem->slave_finalizer_table = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -73,7 +73,7 @@ _hg_mem_gc_finish(hg_mem_t *mem, gboolean was_error) { if (!mem->slave_finalizer_table) { - g_warning("%s: no slave instance created.", __PRETTY_FUNCTION__); + hg_warning("%s: no slave instance created.", __PRETTY_FUNCTION__); return; } if (!was_error) { @@ -171,7 +171,7 @@ hg_mem_new_with_allocator(hg_mem_vtable_t *allocator, if (_hg_typebit_round_value(retval->id, HG_TYPEBIT_MEM_ID, HG_TYPEBIT_MEM_ID_END) != retval->id) { - g_warning("too many memory spooler being created."); + hg_warning("too many memory spooler being created."); g_free(retval); return NULL; @@ -825,8 +825,8 @@ hg_mem_reserved_spool_add(hg_mem_t *mem, p = HGQUARK_TO_POINTER (hg_quark_get_hash(qdata)); count = GPOINTER_TO_INT (g_hash_table_lookup(mem->reserved_spool, p)); if ((count + 1) < 0) - g_warning("[BUG] the reference count of %lx on the reserved_spool being overflowed", - qdata); + hg_warning("[BUG] the reference count of %lx on the reserved_spool being overflowed", + qdata); g_hash_table_replace(mem->reserved_spool, p, GINT_TO_POINTER (count + 1)); } diff --git a/hieroglyph/hgmem.h b/hieroglyph/hgmem.h index c7706fc..f648921 100644 --- a/hieroglyph/hgmem.h +++ b/hieroglyph/hgmem.h @@ -30,6 +30,7 @@ #include <hieroglyph/hgtypes.h> #include <hieroglyph/hgerror.h> +#include <hieroglyph/hgmessages.h> #include <hieroglyph/hgallocator.h> HG_BEGIN_DECLS @@ -150,9 +151,9 @@ hg_mem_lock_object_with_gerror(hg_mem_t *mem, if (error) { *error = g_error_copy(err); } else { - g_warning("%s (code: %d)", - err->message, - err->code); + hg_warning("%s (code: %d)", + err->message, + err->code); } g_error_free(err); } diff --git a/hieroglyph/hgmessage.h b/hieroglyph/hgmessage.h deleted file mode 100644 index 22447c3..0000000 --- a/hieroglyph/hgmessage.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * hgmessage.h - * Copyright (C) 2006-2011 Akira TAGOH - * - * Authors: - * Akira TAGOH <akira@tagoh.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#if !defined (__HG_H_INSIDE__) && !defined (HG_COMPILATION) -#error "Only <hieroglyph/hg.h> can be included directly." -#endif - -#ifndef __HIEROGLYPH_HGMESSAGE_H__ -#define __HIEROGLYPH_HGMESSAGE_H__ - -#include <stdarg.h> -#include <hieroglyph/hgtypes.h> - -HG_BEGIN_DECLS - -typedef enum _hg_message_type_t hg_message_type_t; -typedef enum _hg_message_category_t hg_message_category_t; -typedef enum _hg_message_catmask_t hg_message_catmask_t; -typedef void (* hg_message_func_t) (hg_message_type_t type, - hg_message_category_t category, - const hg_char_t *message, - hg_pointer_t user_data); - -enum _hg_message_type_t { - HG_MSG_0 = 0, - HG_MSG_FATAL, - HG_MSG_CRITICAL, - HG_MSG_WARNING, - HG_MSG_INFO, - HG_MSG_DEBUG, - HG_MSG_END -}; -enum _hg_message_category_t { - HG_MSGCAT_0 = 0, - HG_MSGCAT_END -}; -enum _hg_message_catmask_t { - HG_MSGCAT_MASK_END -}; - - -hg_message_func_t hg_message_set_default_handler(hg_message_func_t func, - hg_pointer_t user_data); -hg_message_func_t hg_message_set_handler (hg_message_type_t type, - hg_message_func_t func, - hg_pointer_t user_data); -void hg_message_printf (hg_message_type_t type, - hg_message_category_t category, - const hg_char_t *format, - ...); -void hg_message_vprintf (hg_message_type_t type, - hg_message_category_t category, - const hg_char_t *format, - va_list args); - -HG_END_DECLS - -#endif /* __HIEROGLYPH_HGMESSAGE_H__ */ diff --git a/hieroglyph/hgmessage.c b/hieroglyph/hgmessages.c index 1d157bf..10f4b15 100644 --- a/hieroglyph/hgmessage.c +++ b/hieroglyph/hgmessages.c @@ -25,12 +25,13 @@ #include "config.h" #endif +#include <execinfo.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "hgmessage.h" +#include "hgmessages.h" -#include "hgmessage.proto.h" +#include "hgmessages.proto.h" static hg_message_func_t __hg_message_default_handler = _hg_message_default_handler; static hg_pointer_t __hg_message_default_handler_data = NULL; @@ -53,12 +54,14 @@ _hg_message_get_prefix(hg_message_type_t type, }; const hg_char_t *category_string[HG_MSGCAT_END + 1] = { NULL, + "TRACE", NULL }; const hg_char_t unknown_type[] = "?: "; const hg_char_t unknown_cat[] = "???"; + const hg_char_t no_cat[] = ""; const hg_char_t *ts, *cs; - hg_char_t *retval = NULL; + hg_char_t *retval = NULL, *catstring = NULL; hg_usize_t tlen = 0, clen = 0, len; if (type >= HG_MSG_END) @@ -73,20 +76,53 @@ _hg_message_get_prefix(hg_message_type_t type, tlen = strlen(ts); if (category_string[category]) { cs = category_string[category]; + } else if (category == 0) { + cs = no_cat; } else { cs = unknown_cat; } clen = strlen(cs); - len = tlen + clen + 6; + if (clen > 0) { + catstring = malloc(sizeof (hg_char_t) * (clen + 6)); + snprintf(catstring, clen + 6, "[%s]: ", cs); + clen = strlen(catstring); + } + len = tlen + clen + 1; retval = malloc(sizeof (hg_char_t) * len); if (retval) { - snprintf(retval, len, "%s[%s]: ", ts, cs); + snprintf(retval, len, "%s%s ", ts, catstring ? catstring : ""); } + if (catstring) + free(catstring); return retval; } static void +_hg_message_stacktrace(void) +{ + void *traces[1024]; + char **strings; + int size, i; + + size = backtrace(traces, 1024); + if (size > 0) { + strings = backtrace_symbols(traces, size); + hg_debug(HG_MSGCAT_TRACE, "Stacktrace:"); + /* 0.. here. + * 1.. _hg_message_default_handler + * 2.. hg_message_vprintf + * 3.. hg_message_printf + * 4.. hg_* macros + */ + for (i = 4; i < size; i++) { + hg_debug(HG_MSGCAT_TRACE, " %d. %s", i - 3, strings[i]); + } + free(strings); + } +} + +static void _hg_message_default_handler(hg_message_type_t type, hg_message_category_t category, const hg_char_t *message, @@ -106,6 +142,8 @@ _hg_message_default_handler(hg_message_type_t type, } prefix = _hg_message_get_prefix(type, category); fprintf(stderr, "%s%s\n", prefix, message); + if (category != HG_MSGCAT_TRACE) + _hg_message_stacktrace(); if (prefix) free(prefix); @@ -219,3 +257,21 @@ hg_message_vprintf(hg_message_type_t type, __hg_message_default_handler(type, category, buffer, __hg_message_default_handler_data); } } + +/** + * hg_return_if_fail_warning: + * @pretty_function: + * @expression: + * + * FIXME + */ +void +hg_return_if_fail_warning(const hg_char_t *pretty_function, + const hg_char_t *expression) +{ + hg_message_printf(HG_MSG_CRITICAL, + 0, + "%s: assertion `%s' failed", + pretty_function, + expression); +} diff --git a/hieroglyph/hgmessages.h b/hieroglyph/hgmessages.h new file mode 100644 index 0000000..b1ac072 --- /dev/null +++ b/hieroglyph/hgmessages.h @@ -0,0 +1,246 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * hgmessage.h + * Copyright (C) 2006-2011 Akira TAGOH + * + * Authors: + * Akira TAGOH <akira@tagoh.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#if !defined (__HG_H_INSIDE__) && !defined (HG_COMPILATION) +#error "Only <hieroglyph/hg.h> can be included directly." +#endif + +#ifndef __HIEROGLYPH_HGMESSAGE_H__ +#define __HIEROGLYPH_HGMESSAGE_H__ + +#include <stdarg.h> +#include <hieroglyph/hgtypes.h> + +HG_BEGIN_DECLS + +typedef enum _hg_message_type_t hg_message_type_t; +typedef enum _hg_message_category_t hg_message_category_t; +typedef void (* hg_message_func_t) (hg_message_type_t type, + hg_message_category_t category, + const hg_char_t *message, + hg_pointer_t user_data); + +enum _hg_message_type_t { + HG_MSG_0 = 0, + HG_MSG_FATAL, + HG_MSG_CRITICAL, + HG_MSG_WARNING, + HG_MSG_INFO, + HG_MSG_DEBUG, + HG_MSG_END +}; +enum _hg_message_category_t { + HG_MSGCAT_0 = 0, + HG_MSGCAT_TRACE, + HG_MSGCAT_END +}; + + +hg_message_func_t hg_message_set_default_handler(hg_message_func_t func, + hg_pointer_t user_data); +hg_message_func_t hg_message_set_handler (hg_message_type_t type, + hg_message_func_t func, + hg_pointer_t user_data); +void hg_message_printf (hg_message_type_t type, + hg_message_category_t category, + const hg_char_t *format, + ...); +void hg_message_vprintf (hg_message_type_t type, + hg_message_category_t category, + const hg_char_t *format, + va_list args); +void hg_return_if_fail_warning (const hg_char_t *pretty_function, + const hg_char_t *expression); + + +#ifdef HG_HAVE_ISO_VARARGS +/* for(;;) ; so that GCC knows that control doesn't go past hg_fatal(). + * Put space before ending semicolon to avoid C++ build warnings. + */ +#define hg_fatal(...) \ + HG_STMT_START { \ + hg_message_printf(HG_MSG_FATAL, \ + 0, \ + __VA_ARGS__); \ + for (;;) ; \ + } HG_STMT_END +#define hg_critical(...) \ + hg_message_printf(HG_MSG_CRITICAL, \ + 0, \ + __VA_ARGS__) +#define hg_warning(...) \ + hg_message_printf(HG_MSG_WARNING, \ + 0, \ + __VA_ARGS__) +#define hg_info(...) \ + hg_message_printf(HG_MSG_INFO, \ + 0, \ + __VA_ARGS__) +#define hg_debug(...) \ + hg_message_printf(HG_MSG_DEBUG, \ + __VA_ARGS__) + +#elif defined(HG_HAVE_GNUC_VARARGS) + +#define hg_fatal(format...) \ + HG_STMT_START { \ + hg_message_printf(HG_MSG_FATAL, \ + 0, \ + format); \ + for (;;) ; \ + } HG_STMT_END +#define hg_critical(format...) \ + hg_message_printf(HG_MSG_CRITICAL, \ + 0, \ + format) +#define hg_warning(format...) \ + hg_message_printf(HG_MSG_WARNING, \ + 0, \ + format) +#define hg_info(format...) \ + hg_message_printf(HG_MSG_INFO, \ + 0, \ + format) +#define hg_debug(format...) \ + hg_message_printf(HG_MSG_DEBUG, \ + format) +#else +static void +hg_fatal(const hg_char_t *format, + ...) +{ + va_list args; + + va_start(args, format); + hg_message_vprintf(HG_MSG_FATAL, 0, format, args); + va_end(args); + + for (;;) ; +} +static void +hg_critical(const hg_char_t *format, + ...) +{ + va_list args; + + va_start(args, format); + hg_message_vprintf(HG_MSG_CRITICAL, 0, format, args); + va_end(args); +} +static void +hg_warning(const hg_char_t *format, + ...) +{ + va_list args; + + va_start(args, format); + hg_message_vprintf(HG_MSG_WARNING, 0, format, args); + va_end(args); +} +static void +hg_info(const hg_char_t *format, + ...) +{ + va_list args; + + va_start(args, format); + hg_message_vprintf(HG_MSG_INFO, 0, format, args); + va_end(args); +} +static void +hg_debug(hg_message_category_t category, + const hg_char_t *format, + ...) +{ + va_list args; + + va_start(args, format); + hg_message_vprintf(HG_MSG_DEBUG, category, format, args); + va_end(args); +} +#endif + +#ifdef __GNUC__ +#define _hg_return_after_eval_if_fail(__expr__,__eval__) \ + HG_STMT_START { \ + if (HG_LIKELY(__expr__)) { \ + } else { \ + hg_return_if_fail_warning(__PRETTY_FUNCTION__, \ + #__expr__); \ + __eval__; \ + return; \ + } \ + } HG_STMT_END +#define _hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) \ + HG_STMT_START { \ + if (HG_LIKELY(__expr__)) { \ + } else { \ + hg_return_if_fail_warning(__PRETTY_FUNCTION__, \ + #__expr__); \ + __eval__; \ + return (__val__); \ + } \ + } HG_STMT_END +#else /* !__GNUC__ */ +#define _hg_return_after_eval_if_fail(__expr__,__eval__) \ + HG_STMT_START { \ + if (__expr__) { \ + } else { \ + hg_critical("file %s: line %d: assertion `%s' failed", \ + __FILE__, \ + __LINE__, \ + #__expr__); \ + __eval__; \ + return; \ + } \ + } HG_STMT_END +#define _hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) \ + HG_STMT_START { \ + if (__expr__) { \ + } else { \ + hg_critical("file %s: line %d: assertion `%s' failed", \ + __FILE__, \ + __LINE__, \ + #__expr__); \ + __eval__; \ + return (__val__); \ + } \ + } HG_STMT_END +#endif /* __GNUC__ */ + +#define hg_return_if_fail(__expr__) \ + _hg_return_after_eval_if_fail(__expr__,{}) +#define hg_return_val_if_fail(__expr__,__val__) \ + _hg_return_val_after_eval_if_fail(__expr__,__val__,{}) +#define hg_return_after_eval_if_fail(__expr__,__eval__) \ + _hg_return_after_eval_if_fail(__expr__,__eval__) +#define hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) \ + _hg_return_val_after_eval_if_fail(__expr__,__val__,__eval__) +#define hg_return_with_gerror_if_fail(__expr__,__err__,__code__) \ + _hg_return_after_eval_if_fail(__expr__,if(__err__){g_set_error((__err__),HG_ERROR,(__code__),__PRETTY_FUNCTION__);}) +#define hg_return_val_with_gerror_if_fail(__expr__,__val__,__err__,__code__) \ + _hg_return_val_after_eval_if_fail(__expr__,__val__,if(__err__){g_set_error((__err__),HG_ERROR, (__code__), __PRETTY_FUNCTION__);}) + +HG_END_DECLS + +#endif /* __HIEROGLYPH_HGMESSAGE_H__ */ diff --git a/hieroglyph/hgobject.c b/hieroglyph/hgobject.c index 0ae6d93..3268ec2 100644 --- a/hieroglyph/hgobject.c +++ b/hieroglyph/hgobject.c @@ -486,10 +486,10 @@ hg_object_quark_copy(hg_mem_t *mem, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = Qnil; diff --git a/hieroglyph/hgoperator.c b/hieroglyph/hgoperator.c index 70c42c9..eaf51df 100644 --- a/hieroglyph/hgoperator.c +++ b/hieroglyph/hgoperator.c @@ -543,7 +543,7 @@ DEFUNC_OPER (private_applyparams) q = HG_QSTRING (hg_vm_get_mem(vm), v->u.string); break; default: - g_warning("Unknown parameter type: %d", v->type); + hg_warning("Unknown parameter type: %d", v->type); break; } if (q != Qnil) @@ -7528,7 +7528,7 @@ DEFUNC_OPER (stop) break; } if (i == edepth) { - g_warning("No /stopped operator found."); + hg_warning("No /stopped operator found."); q = hg_stack_pop(estack, error); STACK_PUSH (estack, HG_QOPER (HG_enc_private_abort)); STACK_PUSH (estack, q); diff --git a/hieroglyph/hgoperator.h b/hieroglyph/hgoperator.h index c363786..b1185db 100644 --- a/hieroglyph/hgoperator.h +++ b/hieroglyph/hgoperator.h @@ -175,7 +175,7 @@ typedef hg_bool_t (* hg_operator_func_t) (hg_vm_t *vm, OPER_FUNC_NAME (_n_) (hg_vm_t *vm, \ GError **error) \ { \ - g_warning("%s isn't yet implemented.", #_n_); \ + hg_warning("%s isn't yet implemented.", #_n_); \ hg_vm_set_error(vm, \ hg_stack_index(vm->stacks[HG_VM_STACK_ESTACK], 0, error), \ HG_VM_e_VMerror); \ diff --git a/hieroglyph/hgpath.c b/hieroglyph/hgpath.c index 98c7d28..8f7d9a7 100644 --- a/hieroglyph/hgpath.c +++ b/hieroglyph/hgpath.c @@ -118,10 +118,10 @@ _hg_object_path_copy(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); hg_object_free(p->o.mem, retval); @@ -163,10 +163,10 @@ _hg_object_path_gc_mark(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = FALSE; @@ -256,8 +256,8 @@ _hg_path_add(hg_path_t *path, case HG_PATH_UCACHE: break; default: - g_warning("%s: Unknown path type: %d", - __PRETTY_FUNCTION__, type); + hg_warning("%s: Unknown path type: %d", + __PRETTY_FUNCTION__, type); retval = FALSE; goto finalize; } @@ -952,8 +952,8 @@ hg_path_operate(hg_path_t *path, g_assert("XXX: not yet implemented."); break; default: - g_warning("%s: Unknown path type: %d", - __PRETTY_FUNCTION__, node[i].type); + hg_warning("%s: Unknown path type: %d", + __PRETTY_FUNCTION__, node[i].type); retval = FALSE; goto finalize; } diff --git a/hieroglyph/hgplugin.c b/hieroglyph/hgplugin.c index 1ad54f4..ce4b693 100644 --- a/hieroglyph/hgplugin.c +++ b/hieroglyph/hgplugin.c @@ -76,10 +76,10 @@ _hg_plugin_load(hg_mem_t *mem, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -180,10 +180,10 @@ hg_plugin_open(hg_mem_t *mem, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -276,10 +276,10 @@ hg_plugin_load(hg_plugin_t *plugin, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -322,10 +322,10 @@ hg_plugin_unload(hg_plugin_t *plugin, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } diff --git a/hieroglyph/hgquark.c b/hieroglyph/hgquark.c index 0e0c17f..48bf99a 100644 --- a/hieroglyph/hgquark.c +++ b/hieroglyph/hgquark.c @@ -163,8 +163,8 @@ hg_quark_set_readable(hg_quark_t *quark, (flag == TRUE ? 1 : 0)); } else { #ifdef HG_DEBUG - g_warning("%s: Access disallowed for modification", - __PRETTY_FUNCTION__); + hg_warning("%s: Access disallowed for modification", + __PRETTY_FUNCTION__); #endif } } @@ -215,8 +215,8 @@ hg_quark_set_writable(hg_quark_t *quark, (flag == TRUE ? 1 : 0)); } else { #ifdef HG_DEBUG - g_warning("%s: Access disallowed for modification", - __PRETTY_FUNCTION__); + hg_warning("%s: Access disallowed for modification", + __PRETTY_FUNCTION__); #endif } } @@ -268,8 +268,8 @@ hg_quark_set_executable(hg_quark_t *quark, (flag == TRUE ? 1 : 0)); } else { #ifdef HG_DEBUG - g_warning("%s: Access disallowed for modification", - __PRETTY_FUNCTION__); + hg_warning("%s: Access disallowed for modification", + __PRETTY_FUNCTION__); #endif } } diff --git a/hieroglyph/hgscanner.l b/hieroglyph/hgscanner.l index 7fb1826..61f06f2 100644 --- a/hieroglyph/hgscanner.l +++ b/hieroglyph/hgscanner.l @@ -374,7 +374,7 @@ HEXDIGITS [0-9a-fA-F] } [\x80-\xa1]+ { /* binary tokens */ - g_warning("XXX: binary token appears"); + hg_warning("XXX: binary token appears"); } \r\n { /* ignore */ diff --git a/hieroglyph/hgstring.c b/hieroglyph/hgstring.c index 60c8f00..c5b3e09 100644 --- a/hieroglyph/hgstring.c +++ b/hieroglyph/hgstring.c @@ -106,10 +106,10 @@ _hg_object_string_copy(hg_object_t *object, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -438,10 +438,10 @@ hg_string_append_c(hg_string_t *string, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -523,10 +523,10 @@ hg_string_append(hg_string_t *string, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -585,10 +585,10 @@ hg_string_overwrite_c(hg_string_t *string, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -942,10 +942,10 @@ hg_string_make_substring(hg_string_t *string, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } diff --git a/hieroglyph/hgtypebit-private.h b/hieroglyph/hgtypebit-private.h index 69c8f23..6c95feb 100644 --- a/hieroglyph/hgtypebit-private.h +++ b/hieroglyph/hgtypebit-private.h @@ -26,6 +26,7 @@ #include <hieroglyph/hgtypes.h> #include <hieroglyph/hgerror.h> +#include <hieroglyph/hgmessages.h> HG_BEGIN_DECLS diff --git a/hieroglyph/hgtypes.h b/hieroglyph/hgtypes.h index 6f776ac..d4534d3 100644 --- a/hieroglyph/hgtypes.h +++ b/hieroglyph/hgtypes.h @@ -31,6 +31,7 @@ #include <stdint.h> #include <sys/types.h> #include <glib.h> +#include <hgconfig.h> #include <hieroglyph/hgmacros.h> HG_BEGIN_DECLS diff --git a/hieroglyph/hgvm.c b/hieroglyph/hgvm.c index fe02233..7a17d38 100644 --- a/hieroglyph/hgvm.c +++ b/hieroglyph/hgvm.c @@ -97,7 +97,7 @@ _hg_vm_get_mem(hg_vm_t *vm, } else if (vm->mem_id[HG_VM_MEM_LOCAL] == id) { retval = vm->mem[HG_VM_MEM_LOCAL]; } else { - g_warning("Unknown memory spooler id: %d, quark: %lx", id, quark); + hg_warning("Unknown memory spooler id: %d, quark: %lx", id, quark); } return retval; @@ -310,7 +310,7 @@ hg_vm_stepi_in_exec_array(hg_vm_t *vm, } qexecobj = qresult; } else { - g_warning("Immediately evaluated name object somehow doesn't have a exec bit turned on: %s", hg_name_lookup(qexecobj)); + hg_warning("Immediately evaluated name object somehow doesn't have a exec bit turned on: %s", hg_name_lookup(qexecobj)); } case HG_TYPE_NULL: case HG_TYPE_INT: @@ -467,16 +467,16 @@ hg_vm_stepi_in_exec_array(hg_vm_t *vm, } break; default: - g_warning("Unknown object type: %d\n", hg_quark_get_type(qexecobj)); + hg_warning("Unknown object type: %d\n", hg_quark_get_type(qexecobj)); return FALSE; } finalize: if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); if (!hg_vm_has_error(vm)) hg_vm_set_error(vm, qexecobj, HG_VM_e_VMerror); g_error_free(err); @@ -586,7 +586,7 @@ _hg_vm_quark_complex_compare(hg_quark_t q1, s2 = _HG_VM_LOCK (vm, q2, NULL); if (s1 == NULL || s2 == NULL) { - g_warning("%s: Unable to obtain the actual object.", __PRETTY_FUNCTION__); + hg_warning("%s: Unable to obtain the actual object.", __PRETTY_FUNCTION__); } else { retval = hg_string_compare(s1, s2); } @@ -661,10 +661,10 @@ _hg_vm_rs_gc(hg_mem_t *mem, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -1604,10 +1604,10 @@ hg_vm_setup(hg_vm_t *vm, if (dict) _HG_VM_UNLOCK (vm, vm->qsystemdict); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } @@ -1818,7 +1818,7 @@ hg_vm_stepi(hg_vm_t *vm, qexecobj = qresult; goto evaluate; } - g_warning("Immediately evaluated name object somehow doesn't have a exec bit turned on: %s", hg_name_lookup(qexecobj)); + hg_warning("Immediately evaluated name object somehow doesn't have a exec bit turned on: %s", hg_name_lookup(qexecobj)); goto push_stack; case HG_TYPE_NAME: /* /foo ... nope @@ -2051,7 +2051,7 @@ hg_vm_stepi(hg_vm_t *vm, } break; default: - g_warning("Unknown object type: %d\n", hg_quark_get_type(qexecobj)); + hg_warning("Unknown object type: %d\n", hg_quark_get_type(qexecobj)); return FALSE; } @@ -2184,7 +2184,7 @@ hg_vm_eval(hg_vm_t *vm, lang = hg_vm_get_language_level(vm); o = _HG_VM_LOCK (vm, old_systemdict, error); if (o == NULL) { - g_warning("Unable to protect systemdict."); + hg_warning("Unable to protect systemdict."); return FALSE; } vm->qsystemdict = hg_dict_new(o->o.mem, @@ -2192,7 +2192,7 @@ hg_vm_eval(hg_vm_t *vm, o->raise_dictfull, (gpointer *)&d); if (vm->qsystemdict == Qnil) { - g_warning("Unable to duplicate systemdict."); + hg_warning("Unable to duplicate systemdict."); flag = FALSE; goto fini_systemdict; } @@ -2212,7 +2212,7 @@ hg_vm_eval(hg_vm_t *vm, vm->qsystemdict, FALSE, error)) { - g_warning("Unable to reregister systemdict"); + hg_warning("Unable to reregister systemdict"); flag = FALSE; goto fini_systemdict; } @@ -2349,10 +2349,10 @@ hg_vm_eval_from_cstring(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -2412,15 +2412,15 @@ hg_vm_eval_from_file(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } } else { - g_warning("Unable to find a file `%s'", initfile); + hg_warning("Unable to find a file `%s'", initfile); } g_free(filename); @@ -2484,7 +2484,7 @@ hg_vm_startjob(hg_vm_t *vm, /* initialize VM */ if (!hg_vm_setup(vm, lang_level, Qnil, Qnil, Qnil)) { - g_warning("Unable to initialize PostScript VM"); + hg_warning("Unable to initialize PostScript VM"); return FALSE; } @@ -2510,7 +2510,7 @@ hg_vm_startjob(hg_vm_t *vm, /* make systemdict read-only */ dict = _HG_VM_LOCK (vm, vm->qsystemdict, &err); if (dict == NULL) { - g_warning("Unable to obtain systemdict"); + hg_warning("Unable to obtain systemdict"); return FALSE; } hg_vm_quark_set_writable(vm, &vm->qsystemdict, FALSE); @@ -2519,7 +2519,7 @@ hg_vm_startjob(hg_vm_t *vm, vm->qsystemdict, FALSE, NULL)) { - g_warning("Unable to update the entry for systemdict"); + hg_warning("Unable to update the entry for systemdict"); return FALSE; } _HG_VM_UNLOCK (vm, vm->qsystemdict); @@ -2533,7 +2533,7 @@ hg_vm_startjob(hg_vm_t *vm, vm->device = hg_device_null_new(vm->mem[HG_VM_MEM_LOCAL]); hg_device_install(vm->device, vm, &err); if (err) { - g_warning(err->message); + hg_warning(err->message); return FALSE; } hg_vm_eval_from_cstring(vm, "initgraphics", -1, NULL, NULL, NULL, FALSE, NULL); @@ -2687,10 +2687,10 @@ hg_vm_get_user_params(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); hg_object_free(d->o.mem, retval); @@ -2735,10 +2735,10 @@ hg_vm_set_user_params(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3058,7 +3058,7 @@ hg_vm_set_error_from_gerror(hg_vm_t *vm, /* no error */ } else { #ifdef HG_DEBUG - g_warning("%s", error->message); + hg_warning("%s", error->message); #endif return hg_vm_set_error(vm, qdata, error->code); } @@ -3118,7 +3118,7 @@ hg_vm_add_plugin(hg_vm_t *vm, hg_return_val_with_gerror_if_fail (name != NULL, FALSE, error, HG_VM_e_VMerror); if (g_hash_table_lookup(vm->plugin_table, name) != NULL) { - g_warning("%s plugin is already loaded", name); + hg_warning("%s plugin is already loaded", name); return TRUE; } plugin = hg_plugin_open(vm->mem[HG_VM_MEM_LOCAL], @@ -3155,10 +3155,10 @@ hg_vm_load_plugins(hg_vm_t *vm) GError *err = NULL; if (!hg_plugin_load(p, vm, &err)) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_clear_error(&err); } } @@ -3186,7 +3186,7 @@ hg_vm_remove_plugin(hg_vm_t *vm, hg_return_val_with_gerror_if_fail (name != NULL, FALSE, error, HG_VM_e_VMerror); if ((l = g_hash_table_lookup(vm->plugin_table, name)) == NULL) { - g_warning("No such plugins loaded: %s", name); + hg_warning("No such plugins loaded: %s", name); return FALSE; } @@ -3330,10 +3330,10 @@ hg_vm_array_set(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3394,10 +3394,10 @@ hg_vm_array_get(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3598,10 +3598,10 @@ hg_vm_dict_add(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3655,10 +3655,10 @@ hg_vm_dict_remove(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3715,10 +3715,10 @@ hg_vm_dict_lookup(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3766,10 +3766,10 @@ hg_vm_quark_gc_mark(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -3817,10 +3817,10 @@ hg_vm_quark_copy(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } else { @@ -3997,10 +3997,10 @@ hg_vm_quark_to_string(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); retval = Qnil; @@ -4110,10 +4110,10 @@ hg_vm_quark_set_acl(hg_vm_t *vm, _HG_VM_UNLOCK (vm, *qdata); } if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } } } @@ -4144,10 +4144,10 @@ hg_vm_quark_set_readable(hg_vm_t *vm, _HG_VM_UNLOCK (vm, *qdata); } if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4176,10 +4176,10 @@ hg_vm_quark_is_readable(hg_vm_t *vm, if (acl != -1) { hg_quark_set_acl(qdata, acl); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4216,10 +4216,10 @@ hg_vm_quark_set_writable(hg_vm_t *vm, _HG_VM_UNLOCK (vm, *qdata); } if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4248,10 +4248,10 @@ hg_vm_quark_is_writable(hg_vm_t *vm, if (acl != -1) { hg_quark_set_acl(qdata, acl); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4288,10 +4288,10 @@ hg_vm_quark_set_executable(hg_vm_t *vm, _HG_VM_UNLOCK (vm, *qdata); } if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4320,10 +4320,10 @@ hg_vm_quark_is_executable(hg_vm_t *vm, if (acl != -1) { hg_quark_set_acl(qdata, acl); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4360,10 +4360,10 @@ hg_vm_quark_set_accessible(hg_vm_t *vm, _HG_VM_UNLOCK (vm, *qdata); } if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4392,10 +4392,10 @@ hg_vm_quark_is_accessible(hg_vm_t *vm, if (acl != -1) { hg_quark_set_acl(qdata, acl); if (err) { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); g_error_free(err); } } @@ -4504,10 +4504,10 @@ hg_vm_string_get_cstr(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } @@ -4557,10 +4557,10 @@ hg_vm_string_length(hg_vm_t *vm, if (error) { *error = g_error_copy(err); } else { - g_warning("%s: %s (code: %d)", - __PRETTY_FUNCTION__, - err->message, - err->code); + hg_warning("%s: %s (code: %d)", + __PRETTY_FUNCTION__, + err->message, + err->code); } g_error_free(err); } diff --git a/plugins/libedit/Makefile.am b/plugins/libedit/Makefile.am index a245d04..7cc9ff5 100644 --- a/plugins/libedit/Makefile.am +++ b/plugins/libedit/Makefile.am @@ -6,7 +6,6 @@ INCLUDES = \ $(LIBEDIT_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/hieroglyph \ - -DHG_COMPILATION \ $(NULL) LIBS = \ @LDFLAGS@ \ diff --git a/plugins/libedit/libedit-main.c b/plugins/libedit/libedit-main.c index fa20a0c..ad85cce 100644 --- a/plugins/libedit/libedit-main.c +++ b/plugins/libedit/libedit-main.c @@ -32,11 +32,7 @@ #include <readline.h> #include <glib.h> #define PLUGIN -#include "hgdict.h" -#include "hgplugin.h" -#include "hgoperator.h" -#include "hgstack.h" -#include "hgvm.h" +#include "hg.h" static gchar *_libedit_get_line (hg_lineedit_t *lineedit, @@ -232,7 +228,7 @@ _libedit_load(hg_plugin_t *plugin, gint i; if (plugin->user_data != NULL) { - g_warning("plugin is already loaded."); + hg_warning("plugin is already loaded."); return TRUE; } plugin->user_data = vm->lineedit; @@ -269,7 +265,7 @@ _libedit_unload(hg_plugin_t *plugin, hg_vm_t *vm = vm_; if (plugin->user_data == NULL) { - g_warning("plugin not loaded."); + hg_warning("plugin not loaded."); return FALSE; } hg_lineedit_destroy(vm->lineedit); diff --git a/plugins/unittest/Makefile.am b/plugins/unittest/Makefile.am index 8b30185..ea615e3 100644 --- a/plugins/unittest/Makefile.am +++ b/plugins/unittest/Makefile.am @@ -5,7 +5,6 @@ INCLUDES = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/hieroglyph \ - -DHG_COMPILATION \ $(NULL) LIBS = \ @LDFLAGS@ \ diff --git a/plugins/unittest/unittest-main.c b/plugins/unittest/unittest-main.c index 2b09b90..e422279 100644 --- a/plugins/unittest/unittest-main.c +++ b/plugins/unittest/unittest-main.c @@ -27,13 +27,7 @@ #include <glib.h> #define PLUGIN -#include "hgarray.h" -#include "hgbool.h" -#include "hgdict.h" -#include "hgint.h" -#include "hgplugin.h" -#include "hgoperator.h" -#include "hgvm.h" +#include "hg.h" PROTO_PLUGIN (unittest); @@ -217,7 +211,7 @@ _unittest_load(hg_plugin_t *plugin, hg_stack_t *estack; if (plugin->user_data != NULL) { - g_warning("plugin is already loaded."); + hg_warning("plugin is already loaded."); return TRUE; } plugin->user_data = plugin; /* dummy */ @@ -252,7 +246,7 @@ _unittest_unload(hg_plugin_t *plugin, GError **error) { if (plugin->user_data == NULL) { - g_warning("plugin not loaded."); + hg_warning("plugin not loaded."); return FALSE; } plugin->user_data = NULL; diff --git a/src/hgs/Makefile.am b/src/hgs/Makefile.am index a4331d0..3e7a823 100644 --- a/src/hgs/Makefile.am +++ b/src/hgs/Makefile.am @@ -4,6 +4,7 @@ NULL = INCLUDES = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ + -I$(top_srcdir)/hieroglyph \ -DHG_COMPILATION \ $(NULL) LIBS = \ |