Re: [PATCH 05/51] core: helper function for converting cairo_status_t to human-readable text (like strerror)

Bill Spitzak <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAL-8oAhepXg4j=KobJgPJmuE4L+LsfCpKxcBwf8KYWsW0AtnLQ@mail.gmail.com>
I think LAST_STATUS should print a number, not a message.

On Fri, Dec 18, 2015 at 5:28 AM, Enrico Weigelt, metux IT consult <
[email protected]> wrote:

> Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
> ---
>  src/cairo-error.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/cairo.h       |  2 ++
>  2 files changed, 52 insertions(+)
>
> diff --git a/src/cairo-error.c b/src/cairo-error.c
> index 1b9bd76..6f13c77 100644
> --- a/src/cairo-error.c
> +++ b/src/cairo-error.c
> @@ -71,3 +71,53 @@ _cairo_error (cairo_status_t status)
>  }
>
>  COMPILE_TIME_ASSERT ((int)CAIRO_INT_STATUS_LAST_STATUS ==
> (int)CAIRO_STATUS_LAST_STATUS);
> +
> +const char* cairo_status_text(cairo_status_t status)
> +{
> +    switch (status) {
> +       case CAIRO_STATUS_SUCCESS:                      return "SUCCESS";
> +       case CAIRO_STATUS_NO_MEMORY:                    return "NO_MEMORY";
> +       case CAIRO_STATUS_INVALID_RESTORE:              return
> "INVALID_RESTORE";
> +       case CAIRO_STATUS_INVALID_POP_GROUP:            return
> "INVALID_POP_GROUP";
> +       case CAIRO_STATUS_NO_CURRENT_POINT:             return
> "NO_CURRENT_POINT";
> +       case CAIRO_STATUS_INVALID_MATRIX:               return
> "INVALID_MATRIX";
> +       case CAIRO_STATUS_INVALID_STATUS:               return
> "INVALID_STATUS";
> +       case CAIRO_STATUS_NULL_POINTER:                 return
> "NULL_POINTER";
> +       case CAIRO_STATUS_INVALID_STRING:               return
> "INVALID_STATUS";
> +       case CAIRO_STATUS_INVALID_PATH_DATA:            return
> "INVALID_PATH_DATA";
> +       case CAIRO_STATUS_READ_ERROR:                   return
> "READ_ERROR";
> +       case CAIRO_STATUS_WRITE_ERROR:                  return
> "WRITE_ERROR";
> +       case CAIRO_STATUS_SURFACE_FINISHED:             return
> "SURFACE_FINISHED";
> +       case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:        return
> "SURFACE_TYPE_MISMATCH";
> +       case CAIRO_STATUS_PATTERN_TYPE_MISMATCH:        return
> "PATTERN_TYPE_MISMATCH";
> +       case CAIRO_STATUS_INVALID_CONTENT:              return
> "INVALID_CONTENT";
> +       case CAIRO_STATUS_INVALID_FORMAT:               return
> "INVALID_FORMAT";
> +       case CAIRO_STATUS_INVALID_VISUAL:               return
> "INVALID_VISUAL";
> +       case CAIRO_STATUS_FILE_NOT_FOUND:               return
> "FILE_NOT_FOUND";
> +       case CAIRO_STATUS_INVALID_DASH:                 return
> "INVALID_DASH";
> +       case CAIRO_STATUS_INVALID_DSC_COMMENT:          return
> "INVALID_DSC_COMMENT";
> +       case CAIRO_STATUS_INVALID_INDEX:                return
> "INVALID_INDEX";
> +       case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE:       return
> "CLIP_NOT_REPRESENTABLE";
> +       case CAIRO_STATUS_TEMP_FILE_ERROR:              return
> "TEMP_FILE_ERROR";
> +       case CAIRO_STATUS_INVALID_STRIDE:               return
> "INVALID_STRIDE";
> +       case CAIRO_STATUS_FONT_TYPE_MISMATCH:           return
> "FONT_TYPE_MISMATCH";
> +       case CAIRO_STATUS_USER_FONT_IMMUTABLE:          return
> "USER_FONT_IMMUTABLE";
> +       case CAIRO_STATUS_USER_FONT_ERROR:              return
> "USER_FONT_ERROR";
> +       case CAIRO_STATUS_NEGATIVE_COUNT:               return
> "NEGATIVE_COUNT";
> +       case CAIRO_STATUS_INVALID_CLUSTERS:             return
> "INVALID_CLUSTERS";
> +       case CAIRO_STATUS_INVALID_SLANT:                return
> "INVALID_SLANT";
> +       case CAIRO_STATUS_INVALID_WEIGHT:               return
> "INVALID_WEIGHT";
> +       case CAIRO_STATUS_INVALID_SIZE:                 return
> "INVALID_SIZE";
> +       case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:    return
> "USER_FONT_NOT_IMPLEMENTED";
> +       case CAIRO_STATUS_DEVICE_TYPE_MISMATCH:         return
> "DEVICE_TYPE_MISMATCH";
> +       case CAIRO_STATUS_DEVICE_ERROR:                 return
> "DEVICE_ERROR";
> +       case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION:    return
> "INVALID_MESH_CONSTRUCTION";
> +       case CAIRO_STATUS_DEVICE_FINISHED:              return
> "DEVICE_FINISHED";
> +       case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:         return
> "JBIG2_GLOBAL_MISSING";
> +       case CAIRO_STATUS_LAST_STATUS:                  return
> "LAST_STATUS";
> +    }
> +
> +    static __thread char _buf[32];
> +    snprintf(_buf, sizeof(_buf), "%d", status);
> +    return _buf;
> +}
> diff --git a/src/cairo.h b/src/cairo.h
> index 3104d47..a993d38 100644
> --- a/src/cairo.h
> +++ b/src/cairo.h
> @@ -352,6 +352,8 @@ typedef enum _cairo_status {
>      CAIRO_STATUS_LAST_STATUS
>  } cairo_status_t;
>
> +const char* cairo_status_text(cairo_status_t status);
> +
>  /**
>   * cairo_content_t:
>   * @CAIRO_CONTENT_COLOR: The surface will hold color content only. (Since
> 1.0)
> --
> 2.6.4.442.g545299f
>
> --
> cairo mailing list
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.