Rename gmio_realXX_t to gmio_floatXX_t (XX = 32,64)

This commit is contained in:
Hugues Delorme 2015-03-03 10:44:45 +01:00
parent 97923e2dfe
commit 0b0152dbb3
10 changed files with 37 additions and 37 deletions

View File

@ -87,10 +87,10 @@ enum gmio_bool_value
#endif /* GMIO_HAVE_STDBOOL_H */
/*! Typedef for 32bit real type (float) */
typedef float gmio_real32_t;
typedef float gmio_float32_t;
/*! Typedef for 64bit real type (double) */
typedef double gmio_real64_t;
typedef double gmio_float64_t;
/*! Tells the compiler that a parameter is not used in the body of a function */
#define GMIO_UNUSED(x) (void)x;

View File

@ -17,16 +17,16 @@
#include "convert.h"
gmio_real32_t gmio_convert_real32(uint32_t val)
gmio_float32_t gmio_convert_float32(uint32_t val)
{
gmio_uint32_float_t conv;
gmio_uint_float_32_t conv;
conv.as_uint32 = val;
return conv.as_float;
return conv.as_float32;
}
uint32_t gmio_convert_uint32(gmio_real32_t val)
uint32_t gmio_convert_uint32(gmio_float32_t val)
{
gmio_uint32_float_t conv;
conv.as_float = val;
gmio_uint_float_32_t conv;
conv.as_float32 = val;
return conv.as_uint32;
}

View File

@ -20,14 +20,14 @@
#include "../global.h"
union gmio_uint32_float
union gmio_uint_float_32
{
uint32_t as_uint32;
float as_float;
uint32_t as_uint32;
gmio_float32_t as_float32;
};
typedef union gmio_uint32_float gmio_uint32_float_t;
typedef union gmio_uint_float_32 gmio_uint_float_32_t;
gmio_real32_t gmio_convert_real32(uint32_t val);
uint32_t gmio_convert_uint32(gmio_real32_t val);
gmio_float32_t gmio_convert_float32(uint32_t val);
uint32_t gmio_convert_uint32(gmio_float32_t val);
#endif /* GMIO_INTERNAL_CONVERT_H */

View File

@ -103,14 +103,14 @@ int gmio_eat_word(gmio_string_stream_fwd_iterator_t *it, gmio_string_buffer_t *b
return -3;
}
int gmio_get_real32(const char *str, gmio_real32_t *value_ptr)
int gmio_get_float32(const char *str, gmio_float32_t *value_ptr)
{
char* end_ptr; /* for strtod() */
#ifdef GMIO_HAVE_STRTOF_FUNC
*value_ptr = strtof(str, &end_ptr); /* Requires C99 */
#else
*value_ptr = (gmio_real32_t)strtod(str, &end_ptr);
*value_ptr = (gmio_float32_t)strtod(str, &end_ptr);
#endif
if (end_ptr == str || errno == ERANGE)

View File

@ -47,12 +47,12 @@ char* gmio_current_char(const gmio_string_stream_fwd_iterator_t* it);
void gmio_skip_spaces(gmio_string_stream_fwd_iterator_t* it);
int gmio_eat_word(gmio_string_stream_fwd_iterator_t* it, gmio_string_buffer_t* buffer);
/*! \brief Converts the string pointed to by \p str to gmio_real32_t representation
/*! \brief Converts the string pointed to by \p str to gmio_float32_t representation
*
* \retval 0 On success
* \retval -1 On error(check \c errno to see what happened)
*/
int gmio_get_real32(const char* str, gmio_real32_t* value_ptr);
int gmio_get_float32(const char* str, gmio_float32_t* value_ptr);
char* gmio_next_char(gmio_string_stream_fwd_iterator_t* it);
gmio_bool_t gmio_checked_next_chars(gmio_string_stream_fwd_iterator_t* it, const char* str);

View File

@ -60,7 +60,7 @@ struct gmio_stla_write_options
const char* solid_name;
/*! The maximum number of significant digits(set to 9 if options == NULL) */
uint8_t real32_prec;
uint8_t float32_prec;
};
typedef struct gmio_stla_write_options gmio_stla_write_options_t;

View File

@ -25,9 +25,9 @@
*/
struct gmio_stl_coords
{
gmio_real32_t x;
gmio_real32_t y;
gmio_real32_t z;
gmio_float32_t x;
gmio_float32_t y;
gmio_float32_t z;
};
typedef struct gmio_stl_coords gmio_stl_coords_t;
@ -47,7 +47,7 @@ struct gmio_stl_triangle
typedef struct gmio_stl_triangle gmio_stl_triangle_t;
/*! Compact size of a gmio_stl_coords_t object */
enum { GMIO_STL_COORDS_RAWSIZE = (3 * sizeof(gmio_real32_t)) };
enum { GMIO_STL_COORDS_RAWSIZE = (3 * sizeof(gmio_float32_t)) };
/*! Compact size of a gmio_stl_triangle_t object for STL ascii format */
enum { GMIO_STLA_TRIANGLE_RAWSIZE = (4 * GMIO_STL_COORDS_RAWSIZE) };

View File

@ -135,11 +135,11 @@ GMIO_INLINE static const char* current_token_as_identifier(const gmio_stla_parse
return data->token == ID_token ? data->string_buffer.ptr : "";
}
GMIO_INLINE static int get_current_token_as_real32(const gmio_stla_parse_data_t* data,
gmio_real32_t* value_ptr)
GMIO_INLINE static int get_current_token_as_float32(const gmio_stla_parse_data_t* data,
gmio_float32_t* value_ptr)
{
if (data->token == FLOAT_token)
return gmio_get_real32(data->string_buffer.ptr, value_ptr);
return gmio_get_float32(data->string_buffer.ptr, value_ptr);
return -3;
}
@ -336,13 +336,13 @@ static void parse_xyz_coords(gmio_stla_parse_data_t* data, gmio_stl_coords_t* co
switch (data->token) {
case FLOAT_token: {
if (get_current_token_as_real32(data, &coords->x) != 0)
if (get_current_token_as_float32(data, &coords->x) != 0)
parsing_error(data);
parsing_eat_token(FLOAT_token, data);
if (get_current_token_as_real32(data, &coords->y) != 0)
if (get_current_token_as_float32(data, &coords->y) != 0)
parsing_error(data);
parsing_eat_token(FLOAT_token, data);
if (get_current_token_as_real32(data, &coords->z) != 0)
if (get_current_token_as_float32(data, &coords->z) != 0)
parsing_error(data);
parsing_eat_token(FLOAT_token, data);
break;

View File

@ -96,7 +96,7 @@ static char* gmio_write_stdio_format(char* buffer, uint8_t prec)
return buffer + 3 + prec_len;
}
/*static char* gmio_write_real32_string(char* buffer, const char* format, gmio_real32_t val)
/*static char* gmio_write_float32_string(char* buffer, const char* format, gmio_float32_t val)
{
return buffer + sprintf(buffer, format, val);
}*/
@ -118,7 +118,7 @@ int gmio_stla_write(const gmio_stl_mesh_t* mesh,
const gmio_stla_write_options_t* options)
{
const char* solid_name = options != NULL ? options->solid_name : NULL;
const uint8_t real32_prec = options != NULL ? options->real32_prec : 9;
const uint8_t float32_prec = options != NULL ? options->float32_prec : 9;
const uint32_t total_facet_count = mesh != NULL ? mesh->triangle_count : 0;
const uint32_t buffer_facet_count =
trsf != NULL ?
@ -131,7 +131,7 @@ int gmio_stla_write(const gmio_stl_mesh_t* mesh,
/* Check validity of input parameters */
gmio_check_transfer(&error, trsf);
gmio_stl_check_mesh(&error, mesh);
if (real32_prec == 0 || real32_prec > 9)
if (float32_prec == 0 || float32_prec > 9)
error = GMIO_STLA_WRITE_INVALID_REAL32_PREC_ERROR;
if (trsf->buffer_size < GMIO_STLA_FACET_SIZE_P2)
error = GMIO_INVALID_BUFFER_SIZE_ERROR;
@ -140,11 +140,11 @@ int gmio_stla_write(const gmio_stl_mesh_t* mesh,
{ /* Create XYZ coords format string (for normal and vertex coords) */
char* coords_format_iterator = coords_format;
coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, real32_prec);
coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, float32_prec);
coords_format_iterator = gmio_write_nspaces(coords_format_iterator, 2);
coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, real32_prec);
coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, float32_prec);
coords_format_iterator = gmio_write_nspaces(coords_format_iterator, 2);
coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, real32_prec);
coords_format_iterator = gmio_write_stdio_format(coords_format_iterator, float32_prec);
*coords_format_iterator = 0; /* Write terminating null byte */
/* TODO: check the "format" string can contain the given precision */
}

View File

@ -50,8 +50,8 @@ const char* test_platform__global_h()
UTEST_ASSERT(sizeof(int32_t) == 4);
UTEST_ASSERT(sizeof(uint32_t) == 4);
UTEST_ASSERT(sizeof(gmio_real32_t) == 4);
UTEST_ASSERT(sizeof(gmio_real64_t) == 8);
UTEST_ASSERT(sizeof(gmio_float32_t) == 4);
UTEST_ASSERT(sizeof(gmio_float64_t) == 8);
return NULL;
}