This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 21f013df6c1f9ff561304ef0543589baefd79a9b (commit) from 8cfcfcb548e810bf75dd41fa38391a96b18b8907 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/21f013df6c1f9ff561304ef0543589baefd79...
commit 21f013df6c1f9ff561304ef0543589baefd79a9b Author: BlueBear jiri.bluebear.dluhos@gmail.com Date: Sun May 8 01:24:12 2011 +0200
Differentiated GP_CHECK and GP_ASSERT (thx gavento for pointing this out).
diff --git a/core/GP_Common.h b/core/GP_Common.h index b93e921..24039b6 100644 --- a/core/GP_Common.h +++ b/core/GP_Common.h @@ -50,13 +50,15 @@ })
/* - * Checks the condition and aborts immediately if it is true, + * Checks the condition and aborts immediately if it is not satisfied, * printing the condition and location in the source. + * (Intended for checking for bugs within the library itself. + * GP_CHECK is used for reporting user errors, like invalid arguments.) */ -#define GP_BUG_ON(test) do { - if ((test)) { - fprintf(stderr, "*** gfxprim: BUG: %s:%d: in %s: %sn", - __FILE__, __LINE__, __FUNCTION__, #test); +#define GP_ASSERT(cond) do { + if ((cond)) { + fprintf(stderr, "*** gfxprim: %s:%d: in %s: BUG - assertion failed: %sn", + __FILE__, __LINE__, __FUNCTION__, #cond); abort(); } } while (0) @@ -71,12 +73,15 @@ } while (0)
/* - * Perform a runtime check, on failure abort and print a message + * Perform a runtime check, on failure abort and print a message. + * (This macro is intended for checks for user-caused errors, + * like invalid arguments, leaving the library in improper state etc. + * For internal sanity checks, use GP_ASSERT.) */ -#define GP_CHECK(cond) do { +#define GP_CHECK(cond, msg) do { if (!(cond)) { - fprintf(stderr, "*** gfxprim: check failed: %s:%d: in %s: %sn", - __FILE__, __LINE__, __FUNCTION__, #cond); + fprintf(stderr, "*** gfxprim: %s:%d: in %s: %sn", + __FILE__, __LINE__, __FUNCTION__, #msg); abort(); } } while (0) diff --git a/core/GP_Context.h b/core/GP_Context.h index 65c14d0..67851b5 100644 --- a/core/GP_Context.h +++ b/core/GP_Context.h @@ -38,7 +38,7 @@ typedef struct GP_Context { uint8_t bpp; /* values: 1, 2, 4, 8, 16, 24, 32 */ uint32_t bytes_per_row; uint32_t w; /* width */ - uint32_t h; /* heigth */ + uint32_t h; /* height */
GP_PixelType pixel_type; /* hardware pixel format */
@@ -73,12 +73,20 @@ inline GP_PixelType GP_GetContextPixelType(const GP_Context *context);
/* Performs a series of sanity checks on context, aborting if any fails. */ #define GP_CHECK_CONTEXT(context) do { - GP_CHECK(context != NULL); - GP_CHECK(context->w > 0 && context->h > 0); - GP_CHECK(context->clip_w_min <= context->clip_w_max); - GP_CHECK(context->clip_h_min <= context->clip_h_max); - GP_CHECK(context->clip_w_max < context->w); - GP_CHECK(context->clip_h_max < context->h); + GP_CHECK(context, + "NULL passed as context"); + GP_CHECK(context->pixels, + "invalid context: NULL image pointer"); + GP_CHECK(context->bpp <= 32, + "invalid context: unsupported bits-per-pixel count"); + GP_CHECK(context->w > 0 && context->h > 0, + "invalid context: invalid image size"); + GP_CHECK(context->clip_w_min <= context->clip_w_max + && context->clip_h_min <= context->clip_h_max, + "invalid context: invalid clipping rectangle"); + GP_CHECK(context->clip_w_max < context->w + && context->clip_h_max < context->h, + "invalid context: clipping rectangle larger than image"); } while (0)
/* diff --git a/core/GP_Font.c b/core/GP_Font.c index 79a58c7..1c7d0a0 100644 --- a/core/GP_Font.c +++ b/core/GP_Font.c @@ -29,14 +29,14 @@
unsigned int GP_GetCharDataSize(const GP_Font *font) { - GP_CHECK(font != NULL); + GP_CHECK(font, "NULL font specified");
return sizeof(GP_CharData) + font->bytes_per_line * font->height; }
const GP_CharData *GP_GetCharData(const GP_Font *font, int c) { - GP_CHECK(font != NULL); + GP_CHECK(font, "NULL font specified");
/* characters before space are not encoded */ switch (font->charset) { @@ -70,7 +70,7 @@ int GP_GetCharCount(unsigned int charset)
unsigned int GP_GetFontDataSize(const GP_Font *font) { - GP_CHECK(font); + GP_CHECK(font, "NULL font specified");
return GP_GetCharCount(font->charset) * GP_GetCharDataSize(font); } diff --git a/core/GP_TextMetric.c b/core/GP_TextMetric.c index 7485d60..247f191 100644 --- a/core/GP_TextMetric.c +++ b/core/GP_TextMetric.c @@ -58,7 +58,8 @@ static unsigned int MaxCharsWidth(const GP_TextStyle *style, const char *str)
unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str) { - GP_CHECK(style != NULL && style->font != NULL && str != NULL); + GP_CHECK_TEXT_STYLE(style); + GP_CHECK(str, "NULL string specified"); unsigned int i, len = 0; unsigned int space = SpaceWidth(style); @@ -74,6 +75,8 @@ unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str)
unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len) { + GP_CHECK_TEXT_STYLE(style); + unsigned int space_width = SpaceWidth(style); unsigned int char_width = style->font->max_bounding_width * (style->pixel_xmul + style->pixel_xspace); @@ -87,6 +90,9 @@ unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len) unsigned int GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, unsigned int len) { + GP_CHECK_TEXT_STYLE(style); + GP_CHECK(str, "NULL string specified"); + unsigned int space_width = SpaceWidth(style); unsigned int char_width; @@ -100,7 +106,7 @@ unsigned int GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str,
unsigned int GP_TextHeight(const GP_TextStyle *style) { - GP_CHECK(style != NULL && style->font != NULL); + GP_CHECK_TEXT_STYLE(style);
return style->font->height * style->pixel_ymul + (style->font->height - 1) * style->pixel_yspace; @@ -108,7 +114,7 @@ unsigned int GP_TextHeight(const GP_TextStyle *style)
unsigned int GP_TextAscent(const GP_TextStyle *style) { - GP_CHECK(style != NULL && style->font != NULL); + GP_CHECK_TEXT_STYLE(style);
unsigned int h = style->font->height - style->font->baseline; return h * style->pixel_ymul + (h - 1) * style->pixel_yspace; @@ -116,7 +122,7 @@ unsigned int GP_TextAscent(const GP_TextStyle *style)
unsigned int GP_TextDescent(const GP_TextStyle *style) { - GP_CHECK(style != NULL && style->font != NULL); + GP_CHECK_TEXT_STYLE(style);
unsigned int h = style->font->baseline; return h * style->pixel_ymul + (h - 1) * style->pixel_yspace; diff --git a/core/GP_TextStyle.h b/core/GP_TextStyle.h index 7327ae4..8e33eb9 100644 --- a/core/GP_TextStyle.h +++ b/core/GP_TextStyle.h @@ -62,4 +62,9 @@ typedef struct { */ void GP_DefaultTextStyle(GP_TextStyle *style);
+#define GP_CHECK_TEXT_STYLE(style) do { + GP_CHECK(style, "NULL style specified"); + GP_CHECK(style->font, "NULL font specified in style"); +} while(0) + #endif /* GP_TEXTSTYLE_H */
-----------------------------------------------------------------------
Summary of changes: core/GP_Common.h | 23 ++++++++++++++--------- core/GP_Context.h | 22 +++++++++++++++------- core/GP_Font.c | 6 +++--- core/GP_TextMetric.c | 14 ++++++++++---- core/GP_TextStyle.h | 5 +++++ 5 files changed, 47 insertions(+), 23 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.