From 306916327d0d4b683fc9990c7749dcbc7f9e7eac Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Thu, 2 Apr 2015 10:04:24 +0200 Subject: [PATCH] gmio_core,stl: change prefix of enum values for gmio_error and gmio_stl_error --- benchs/bench_assimp/main.cpp | 2 +- benchs/bench_gmio/main.c | 4 ++-- benchs/bench_occ/main.cpp | 2 +- src/gmio_core/buffer.c | 2 +- src/gmio_core/error.h | 20 ++++++++++---------- src/gmio_stl/internal/stl_rw_common.c | 12 ++++++------ src/gmio_stl/stl_error.h | 14 +++++++------- src/gmio_stl/stl_io.c | 10 +++++----- src/gmio_stl/stl_io.h | 4 ++-- src/gmio_stl/stla_read.c | 8 ++++---- src/gmio_stl/stla_write.c | 14 +++++++------- src/gmio_stl/stlb_read.c | 14 +++++++------- src/gmio_stl/stlb_write.c | 10 +++++----- 13 files changed, 58 insertions(+), 58 deletions(-) diff --git a/benchs/bench_assimp/main.cpp b/benchs/bench_assimp/main.cpp index ea318c7..50e6fff 100644 --- a/benchs/bench_assimp/main.cpp +++ b/benchs/bench_assimp/main.cpp @@ -156,7 +156,7 @@ static void bench_gmio_stl_read(const char* filepath) mesh_creator.end_solid_func = gmio_assimp_end_solid; int error = gmio_stl_read_file(filepath, &buffer, &mesh_creator); - if (error != GMIO_NO_ERROR) + if (error != GMIO_ERROR_OK) printf("GeomIO error: 0x%X\n", error); gmio_buffer_deallocate(&buffer); diff --git a/benchs/bench_gmio/main.c b/benchs/bench_gmio/main.c index 8c745e7..7f1f72f 100644 --- a/benchs/bench_gmio/main.c +++ b/benchs/bench_gmio/main.c @@ -22,13 +22,13 @@ static void bench_gmio_stl_read(const char* filepath) gmio_buffer_t buffer = gmio_buffer_malloc(512 * 1024); my_igeom_t cookie = { 0 }; gmio_stl_mesh_creator_t mesh_creator = { 0 }; - int error = GMIO_NO_ERROR; + int error = GMIO_ERROR_OK; mesh_creator.cookie = &cookie; mesh_creator.add_triangle_func = dummy_process_triangle; error = gmio_stl_read_file(filepath, &buffer, &mesh_creator); - if (error != GMIO_NO_ERROR) + if (error != GMIO_ERROR_OK) printf("GeomIO error: 0x%X\n", error); gmio_buffer_deallocate(&buffer); diff --git a/benchs/bench_occ/main.cpp b/benchs/bench_occ/main.cpp index df9a7af..3ec1b1d 100644 --- a/benchs/bench_occ/main.cpp +++ b/benchs/bench_occ/main.cpp @@ -19,7 +19,7 @@ static void bench_gmio_stl_read(const char* filepath) Handle_StlMesh_Mesh mesh = new StlMesh_Mesh; gmio_stl_mesh_creator_t mesh_creator = gmio_stl_occmesh_creator(mesh); int error = gmio_stl_read_file(filepath, &buffer, &mesh_creator); - if (error != GMIO_NO_ERROR) + if (error != GMIO_ERROR_OK) printf("GeomIO error: 0x%X\n", error); gmio_buffer_deallocate(&buffer); } diff --git a/src/gmio_core/buffer.c b/src/gmio_core/buffer.c index eebb064..ff34629 100644 --- a/src/gmio_core/buffer.c +++ b/src/gmio_core/buffer.c @@ -68,7 +68,7 @@ gmio_buffer_t gmio_buffer_alloca(size_t size) __except(GetExceptionCode() == STATUS_STACK_OVERFLOW) { /* The stack overflowed */ if (_resetstkoflw() == 0) - exit(GMIO_UNKNOWN_ERROR); + exit(GMIO_ERROR_UNKNOWN); return gmio_buffer_null(); } # else diff --git a/src/gmio_core/error.h b/src/gmio_core/error.h index 59a70ea..57ea9af 100644 --- a/src/gmio_core/error.h +++ b/src/gmio_core/error.h @@ -26,36 +26,36 @@ enum gmio_error { /*! No error occurred, success */ - GMIO_NO_ERROR = 0, + GMIO_ERROR_OK = 0, /*! Pointer on argument gmio_transfer_t is NULL */ - GMIO_NULL_TRANSFER_ERROR = -1, + GMIO_ERROR_NULL_TRANSFER = -1, /*! Pointer on argument buffer is NULL */ - GMIO_NULL_BUFFER_ERROR = -2, + GMIO_ERROR_NULL_BUFFER = -2, /*! Argument buffer's size is too small */ - GMIO_INVALID_BUFFER_SIZE_ERROR = -3, + GMIO_ERROR_INVALID_BUFFER_SIZE = -3, - /*! An error occurred with the gmio_stream */ - GMIO_STREAM_ERROR = -4, + /*! An error occurred with gmio_stream */ + GMIO_ERROR_STREAM = -4, /*! Transfer was stopped by user, that is to say * gmio_transfer::is_stop_requested_func() returned GMIO_TRUE */ - GMIO_TRANSFER_STOPPED_ERROR = -5, + GMIO_ERROR_TRANSFER_STOPPED = -5, /*! Unknown error */ - GMIO_UNKNOWN_ERROR = -6 + GMIO_ERROR_UNKNOWN = -6 }; typedef enum gmio_error gmio_error_t; /*! Returns true if code == GMIO_NO_ERROR */ GMIO_INLINE gmio_bool_t gmio_no_error(int code) -{ return code == GMIO_NO_ERROR; } +{ return code == GMIO_ERROR_OK ? GMIO_TRUE : GMIO_FALSE; } /*! Returns true if code != GMIO_NO_ERROR */ GMIO_INLINE gmio_bool_t gmio_error(int code) -{ return code != GMIO_NO_ERROR; } +{ return code != GMIO_ERROR_OK ? GMIO_TRUE : GMIO_FALSE; } #endif /* GMIO_ERROR_H */ diff --git a/src/gmio_stl/internal/stl_rw_common.c b/src/gmio_stl/internal/stl_rw_common.c index 1da1b68..7c316bb 100644 --- a/src/gmio_stl/internal/stl_rw_common.c +++ b/src/gmio_stl/internal/stl_rw_common.c @@ -21,13 +21,13 @@ gmio_bool_t gmio_check_transfer(int *error, const gmio_transfer_t* trsf) { if (trsf == NULL) { - *error = GMIO_NULL_TRANSFER_ERROR; + *error = GMIO_ERROR_NULL_TRANSFER; } else { if (trsf->buffer.ptr == NULL) - *error = GMIO_NULL_BUFFER_ERROR; + *error = GMIO_ERROR_NULL_BUFFER; else if (trsf->buffer.size == 0) - *error = GMIO_INVALID_BUFFER_SIZE_ERROR; + *error = GMIO_ERROR_INVALID_BUFFER_SIZE; } return gmio_no_error(*error); @@ -38,7 +38,7 @@ gmio_bool_t gmio_stl_check_mesh(int *error, const gmio_stl_mesh_t* mesh) if (mesh == NULL || (mesh->triangle_count > 0 && mesh->get_triangle_func == NULL)) { - *error = GMIO_STL_WRITE_NULL_GET_TRIANGLE_FUNC_ERROR; + *error = GMIO_STL_ERROR_NULL_GET_TRIANGLE_FUNC; } return gmio_no_error(*error); @@ -52,11 +52,11 @@ gmio_bool_t gmio_stlb_check_params(int *error, return GMIO_FALSE; if (trsf->buffer.size < GMIO_STLB_MIN_CONTENTS_SIZE) - *error = GMIO_INVALID_BUFFER_SIZE_ERROR; + *error = GMIO_ERROR_INVALID_BUFFER_SIZE; if (byte_order != GMIO_ENDIANNESS_LITTLE && byte_order != GMIO_ENDIANNESS_BIG) { - *error = GMIO_STLB_UNSUPPORTED_BYTE_ORDER_ERROR; + *error = GMIO_STL_ERROR_UNSUPPORTED_BYTE_ORDER; } return gmio_no_error(*error); diff --git a/src/gmio_stl/stl_error.h b/src/gmio_stl/stl_error.h index 24c6506..0d94885 100644 --- a/src/gmio_stl/stl_error.h +++ b/src/gmio_stl/stl_error.h @@ -28,34 +28,34 @@ enum { GMIO_STL_ERROR_TAG = 0x11000000 }; enum gmio_stl_error { /*! STL format could not be guessed in read function */ - GMIO_STL_UNKNOWN_FORMAT_ERROR = GMIO_STL_ERROR_TAG + 1, + GMIO_STL_ERROR_UNKNOWN_FORMAT = GMIO_STL_ERROR_TAG + 1, /*! Common STL write error indicating gmio_stl_mesh::get_triangle_func() * pointer is NULL */ - GMIO_STL_WRITE_NULL_GET_TRIANGLE_FUNC_ERROR = GMIO_STL_ERROR_TAG + 2, + GMIO_STL_ERROR_NULL_GET_TRIANGLE_FUNC = GMIO_STL_ERROR_TAG + 2, /* Specific error codes returned by STL_ascii read function */ /*! Parsing error occured in gmio_stla_read() due to malformed STL ascii * input */ - GMIO_STLA_READ_PARSE_ERROR = GMIO_STL_ERROR_TAG + 100, + GMIO_STL_ERROR_PARSING = GMIO_STL_ERROR_TAG + 100, /*! Invalid max number of decimal significants digits for * gmio_stla_write(), must be in [1..9] */ - GMIO_STLA_WRITE_INVALID_REAL32_PREC_ERROR = GMIO_STL_ERROR_TAG + 101, + GMIO_STL_ERROR_INVALID_REAL32_PREC = GMIO_STL_ERROR_TAG + 101, /* Specific error codes returned by STL_binary read/write functions */ /*! The byte order argument supplied is not supported, must be little or * big endian */ - GMIO_STLB_UNSUPPORTED_BYTE_ORDER_ERROR = GMIO_STL_ERROR_TAG + 300, + GMIO_STL_ERROR_UNSUPPORTED_BYTE_ORDER = GMIO_STL_ERROR_TAG + 300, /*! Error occured when reading header data in gmio_stlb_read() */ - GMIO_STLB_READ_HEADER_WRONG_SIZE_ERROR = GMIO_STL_ERROR_TAG + 301, + GMIO_STL_ERROR_HEADER_WRONG_SIZE = GMIO_STL_ERROR_TAG + 301, /*! Error occured when reading facet count in gmio_stlb_read() */ - GMIO_STLB_READ_FACET_COUNT_ERROR = GMIO_STL_ERROR_TAG + 302 + GMIO_STL_ERROR_FACET_COUNT = GMIO_STL_ERROR_TAG + 302 }; typedef enum gmio_stl_error gmio_stl_error_t; diff --git a/src/gmio_stl/stl_io.c b/src/gmio_stl/stl_io.c index 4886118..cf78a76 100644 --- a/src/gmio_stl/stl_io.c +++ b/src/gmio_stl/stl_io.c @@ -27,7 +27,7 @@ int gmio_stl_read_file( gmio_buffer_t* buffer, gmio_stl_mesh_creator_t* creator) { - int error = GMIO_NO_ERROR; + int error = GMIO_ERROR_OK; FILE* file = NULL; file = fopen(filepath, "rb"); @@ -42,7 +42,7 @@ int gmio_stl_read_file( fclose(file); } else { - error = GMIO_UNKNOWN_ERROR; + error = GMIO_ERROR_UNKNOWN; } return error; @@ -50,7 +50,7 @@ int gmio_stl_read_file( int gmio_stl_read(gmio_transfer_t *trsf, gmio_stl_mesh_creator_t *creator) { - int error = GMIO_NO_ERROR; + int error = GMIO_ERROR_OK; if (trsf != NULL) { const gmio_stl_format_t stl_format = gmio_stl_get_format(&trsf->stream); @@ -69,12 +69,12 @@ int gmio_stl_read(gmio_transfer_t *trsf, gmio_stl_mesh_creator_t *creator) break; } case GMIO_STL_UNKNOWN_FORMAT: { - error = GMIO_STL_UNKNOWN_FORMAT_ERROR; + error = GMIO_STL_ERROR_UNKNOWN_FORMAT; } } /* end switch() */ } else { - error = GMIO_NULL_TRANSFER_ERROR; + error = GMIO_ERROR_NULL_TRANSFER; } return error; diff --git a/src/gmio_stl/stl_io.h b/src/gmio_stl/stl_io.h index 781c764..421334e 100644 --- a/src/gmio_stl/stl_io.h +++ b/src/gmio_stl/stl_io.h @@ -109,7 +109,7 @@ typedef struct gmio_stla_write_options gmio_stla_write_options_t; * values * * \return Error code (see error.h and stl_error.h) - * \retval GMIO_INVALID_BUFFER_SIZE_ERROR + * \retval GMIO_ERROR_INVALID_BUFFER_SIZE * if trsf->buffer.size < 512 */ GMIO_LIBSTL_EXPORT @@ -129,7 +129,7 @@ int gmio_stla_write( * \param options Byte order of the input STL binary data * * \return Error code (see error.h and stl_error.h) - * \retval GMIO_INVALID_BUFFER_SIZE_ERROR + * \retval GMIO_ERROR_INVALID_BUFFER_SIZE * if trsf->buffer.size < GMIO_STLB_MIN_CONTENTS_SIZE */ GMIO_LIBSTL_EXPORT diff --git a/src/gmio_stl/stla_read.c b/src/gmio_stl/stla_read.c index 3eeda2f..3becf04 100644 --- a/src/gmio_stl/stla_read.c +++ b/src/gmio_stl/stla_read.c @@ -462,7 +462,7 @@ int gmio_stla_read(gmio_transfer_t* trsf, gmio_stl_mesh_creator_t* creator) gmio_stla_parse_data_t parse_data; { /* Check validity of input parameters */ - int error = GMIO_NO_ERROR; + int error = GMIO_ERROR_OK; if (!gmio_check_transfer(&error, trsf)) return error; } @@ -494,8 +494,8 @@ int gmio_stla_read(gmio_transfer_t* trsf, gmio_stl_mesh_creator_t* creator) parse_solid(&parse_data); if (parse_data.error) - return GMIO_STLA_READ_PARSE_ERROR; + return GMIO_STL_ERROR_PARSING; if (parse_data.stream_iterator_cookie.is_stop_requested) - return GMIO_TRANSFER_STOPPED_ERROR; - return GMIO_NO_ERROR; + return GMIO_ERROR_TRANSFER_STOPPED; + return GMIO_ERROR_OK; } diff --git a/src/gmio_stl/stla_write.c b/src/gmio_stl/stla_write.c index 6775bb4..337f8d4 100644 --- a/src/gmio_stl/stla_write.c +++ b/src/gmio_stl/stla_write.c @@ -132,7 +132,7 @@ int gmio_stla_write( void* buffer_ptr = trsf != NULL ? trsf->buffer.ptr : NULL; char* buffc = buffer_ptr; char coords_format[64]; - int error = GMIO_NO_ERROR; + int error = GMIO_ERROR_OK; /* Check validity of input parameters */ if (!gmio_check_transfer(&error, trsf)) @@ -140,9 +140,9 @@ int gmio_stla_write( if (!gmio_stl_check_mesh(&error, mesh)) return error; if (float32_prec == 0 || float32_prec > 9) - return GMIO_STLA_WRITE_INVALID_REAL32_PREC_ERROR; + return GMIO_STL_ERROR_INVALID_REAL32_PREC; if (trsf->buffer.size < GMIO_STLA_FACET_SIZE_P2) - return GMIO_INVALID_BUFFER_SIZE_ERROR; + return GMIO_ERROR_INVALID_BUFFER_SIZE; { /* Create XYZ coords format string (for normal and vertex coords) */ char* it = coords_format; @@ -160,7 +160,7 @@ int gmio_stla_write( buffc = gmio_write_string(buffc, "solid "); buffc = gmio_write_string_eol(buffc, solid_name); if (!gmio_transfer_flush_buffer(trsf, buffc - (char*)buffer_ptr)) - return GMIO_STREAM_ERROR; + return GMIO_ERROR_STREAM; } /* Write solid's facets */ @@ -202,11 +202,11 @@ int gmio_stla_write( } /* end for (ibuffer_facet) */ if (!gmio_transfer_flush_buffer(trsf, buffc - (char*)buffer_ptr)) - error = GMIO_STREAM_ERROR; + error = GMIO_ERROR_STREAM; /* Task control */ if (gmio_no_error(error) && gmio_transfer_is_stop_requested(trsf)) - error = GMIO_TRANSFER_STOPPED_ERROR; + error = GMIO_ERROR_TRANSFER_STOPPED; } /* end for (ifacet) */ /* Write end of solid */ @@ -214,7 +214,7 @@ int gmio_stla_write( buffc = gmio_write_string(trsf->buffer.ptr, "endsolid "); buffc = gmio_write_string_eol(buffc, solid_name); if (!gmio_transfer_flush_buffer(trsf, buffc - (char*)buffer_ptr)) - error = GMIO_STREAM_ERROR; + error = GMIO_ERROR_STREAM; } return error; diff --git a/src/gmio_stl/stlb_read.c b/src/gmio_stl/stlb_read.c index 8ea59ae..0818e5b 100644 --- a/src/gmio_stl/stlb_read.c +++ b/src/gmio_stl/stlb_read.c @@ -83,7 +83,7 @@ int gmio_stlb_read( gmio_stlb_readwrite_helper_t rparams = {0}; uint8_t header_data[GMIO_STLB_HEADER_SIZE]; uint32_t total_facet_count = 0; /* Facet count, as declared in the stream */ - int error = GMIO_NO_ERROR; /* Helper to store function result error code */ + int error = GMIO_ERROR_OK; /* Helper to store function result error code */ /* Check validity of input parameters */ if (!gmio_stlb_check_params(&error, trsf, byte_order)) @@ -97,14 +97,14 @@ int gmio_stlb_read( if (gmio_stream_read(&trsf->stream, header_data, 1, GMIO_STLB_HEADER_SIZE) != GMIO_STLB_HEADER_SIZE) { - return GMIO_STLB_READ_HEADER_WRONG_SIZE_ERROR; + return GMIO_STL_ERROR_HEADER_WRONG_SIZE; } /* Read facet count */ if (gmio_stream_read(&trsf->stream, buffer_ptr, sizeof(uint32_t), 1) != 1) { - return GMIO_STLB_READ_FACET_COUNT_ERROR; + return GMIO_STL_ERROR_FACET_COUNT; } memcpy(&total_facet_count, buffer_ptr, sizeof(uint32_t)); @@ -130,9 +130,9 @@ int gmio_stlb_read( GMIO_STLB_TRIANGLE_RAWSIZE, max_facet_count_per_read)); if (gmio_stream_error(&trsf->stream) != 0) - error = GMIO_STREAM_ERROR; + error = GMIO_ERROR_STREAM; else if (rparams.facet_count > 0) - error = GMIO_NO_ERROR; + error = GMIO_ERROR_OK; else break; /* Exit if no facet to read */ @@ -140,7 +140,7 @@ int gmio_stlb_read( gmio_stlb_read_facets(creator, buffer_ptr, &rparams); rparams.i_facet_offset += rparams.facet_count; if (gmio_transfer_is_stop_requested(trsf)) - error = GMIO_TRANSFER_STOPPED_ERROR; + error = GMIO_ERROR_TRANSFER_STOPPED; } } /* end while */ @@ -148,6 +148,6 @@ int gmio_stlb_read( gmio_stl_mesh_creator_end_solid(creator); if (gmio_no_error(error) && rparams.i_facet_offset != total_facet_count) - error = GMIO_STLB_READ_FACET_COUNT_ERROR; + error = GMIO_STL_ERROR_FACET_COUNT; return error; } diff --git a/src/gmio_stl/stlb_write.c b/src/gmio_stl/stlb_write.c index 4976642..d098f54 100644 --- a/src/gmio_stl/stlb_write.c +++ b/src/gmio_stl/stlb_write.c @@ -83,7 +83,7 @@ int gmio_stlb_write( void* buffer_ptr = trsf != NULL ? trsf->buffer.ptr : NULL; gmio_stlb_readwrite_helper_t wparams = {0}; uint32_t i_facet = 0; - int error = GMIO_NO_ERROR; + int error = GMIO_ERROR_OK; /* Check validity of input parameters */ gmio_stl_check_mesh(&error, mesh); @@ -106,7 +106,7 @@ int gmio_stlb_write( if (gmio_stream_write(&trsf->stream, header_data, GMIO_STLB_HEADER_SIZE, 1) != 1) { - return GMIO_STREAM_ERROR; + return GMIO_ERROR_STREAM; } /* Write facet count */ @@ -115,7 +115,7 @@ int gmio_stlb_write( else gmio_encode_uint32_be(facet_count, buffer_ptr); if (gmio_stream_write(&trsf->stream, buffer_ptr, sizeof(uint32_t), 1) != 1) - return GMIO_STREAM_ERROR; + return GMIO_ERROR_STREAM; /* Write triangles */ for (i_facet = 0; @@ -139,12 +139,12 @@ int gmio_stlb_write( wparams.facet_count) != wparams.facet_count) { - error = GMIO_STREAM_ERROR; + error = GMIO_ERROR_STREAM; } /* Handle stop request */ if (gmio_no_error(error) && gmio_transfer_is_stop_requested(trsf)) - error = GMIO_TRANSFER_STOPPED_ERROR; + error = GMIO_ERROR_TRANSFER_STOPPED; } /* end for */ return error;