Replace gmio_bool_t with bool

This commit is contained in:
Hugues Delorme 2016-01-26 17:03:58 +01:00
parent 0c15f9f325
commit 9ae18d1b9e
34 changed files with 146 additions and 166 deletions

View File

@ -134,7 +134,7 @@ static void stl_readwrite_flush_triangles(struct stl_readwrite_conv* rw_conv)
write.mesh.cookie = &rw_conv->triangle_array[0];
write.mesh.triangle_count = rw_conv->triangle_pos;
write.mesh.func_get_triangle = &readwrite_get_triangle;
write.options.stl_write_triangles_only = GMIO_TRUE;
write.options.stl_write_triangles_only = true;
write.options.stla_float32_format = GMIO_FLOAT_TEXT_FORMAT_SCIENTIFIC_LOWERCASE;
write.options.stla_float32_prec = 6;
gmio_stl_write(&write, rw_conv->out_format);
@ -215,7 +215,7 @@ static void bmk_gmio_stl_readwrite_conv(const void* filepath)
void bmk_gmio_stl_infos_get(const void* filepath)
{
static gmio_bool_t already_exec = GMIO_FALSE;
static bool already_exec = false;
FILE* file = fopen(filepath, "rb");
if (file != NULL) {
@ -244,7 +244,7 @@ void bmk_gmio_stl_infos_get(const void* filepath)
args.infos.stlb_header.data);
}
}
already_exec = GMIO_TRUE;
already_exec = true;
}
fclose(file);

View File

@ -152,7 +152,7 @@ static void gprintf_func_exec_time(
func_gprintf_t func_gprintf,
size_t width_column,
gmio_time_ms_t time,
gmio_bool_t has_time)
bool has_time)
{
if (has_time) {
char str_time[128] = {0};
@ -186,7 +186,7 @@ static void gprintf_func_exec_ratio(
static void printf_func_exec_time(
size_t width_column,
gmio_time_ms_t time_ms,
gmio_bool_t has_time)
bool has_time)
{
gprintf_func_exec_time(
NULL, &printf_wrap, width_column, time_ms, has_time);
@ -208,7 +208,7 @@ static size_t find_maxlen_cmp_result_tag(struct benchmark_cmp_result_array res_a
static void select_cmp_result_func1_exec_infos(
const struct benchmark_cmp_result* cmp,
gmio_time_ms_t* time,
gmio_bool_t* has_time)
bool* has_time)
{
*time = cmp->func1_exec_time_ms;
*has_time = cmp->has_func1_exec_time;
@ -218,7 +218,7 @@ static void select_cmp_result_func1_exec_infos(
static void select_cmp_result_func2_exec_infos(
const struct benchmark_cmp_result* cmp,
gmio_time_ms_t* time,
gmio_bool_t* has_time)
bool* has_time)
{
*time = cmp->func2_exec_time_ms;
*has_time = cmp->has_func2_exec_time;
@ -226,7 +226,7 @@ static void select_cmp_result_func2_exec_infos(
/*! Typedef on pointer to functions like select_cmp_result_funcX_exec_infos() */
typedef void (*func_select_cmp_result_func_exec_infos_t)(
const struct benchmark_cmp_result*, gmio_time_ms_t*, gmio_bool_t*);
const struct benchmark_cmp_result*, gmio_time_ms_t*, bool*);
/*! Returns the strlen of the longest execution time string */
static size_t find_maxlen_cmp_result_func_exec_time(
@ -238,7 +238,7 @@ static size_t find_maxlen_cmp_result_func_exec_time(
size_t i;
for (i = 0; i < res_array.count; ++i) {
gmio_time_ms_t time = 0;
gmio_bool_t has_time = GMIO_FALSE;
bool has_time = false;
func_select_exec_infos(&res_array.ptr[i], &time, &has_time);
gprintf_func_exec_time(strbuff, &sprintf_wrap, 0, time, has_time);
max_len = size_t_max(safe_strlen(strbuff), max_len);
@ -291,14 +291,14 @@ struct benchmark_cmp_result benchmark_cmp(struct benchmark_cmp_arg arg)
benchmark_timer_start(&timer);
(*arg.func1)(arg.func1_arg);
result.func1_exec_time_ms = benchmark_timer_elapsed_ms(&timer);
result.has_func1_exec_time = GMIO_TRUE;
result.has_func1_exec_time = true;
}
if (arg.func2 != NULL) {
struct benchmark_timer timer = {0};
benchmark_timer_start(&timer);
(*arg.func2)(arg.func2_arg);
result.func2_exec_time_ms = benchmark_timer_elapsed_ms(&timer);
result.has_func2_exec_time = GMIO_TRUE;
result.has_func2_exec_time = true;
}
update_benchmark_cmp_result_ratio(&result);

View File

@ -55,11 +55,11 @@ struct benchmark_cmp_result
/*! Execution time(in ms) of the 1st function */
gmio_time_ms_t func1_exec_time_ms;
/*! Is exec time of the 1st function valid ? */
gmio_bool_t has_func1_exec_time;
bool has_func1_exec_time;
/*! Execution time(in ms) of the 2nd function */
gmio_time_ms_t func2_exec_time_ms;
/*! Is exec time of the 2nd function valid ? */
gmio_bool_t has_func2_exec_time;
bool has_func2_exec_time;
float func2_func1_ratio;
};

View File

@ -44,7 +44,7 @@ enum gmio_error
GMIO_ERROR_STREAM,
/*! Transfer was stopped by user, that is to say
* gmio_transfer::func_is_stop_requested() returned GMIO_TRUE */
* gmio_transfer::func_is_stop_requested() returned true */
GMIO_ERROR_TRANSFER_STOPPED,
/*! An error occured after a call to a <stdio.h> function
@ -58,12 +58,12 @@ enum gmio_error
};
/*! Returns true if <tt>code == GMIO_NO_ERROR</tt> */
GMIO_INLINE gmio_bool_t gmio_no_error(int code)
{ return code == GMIO_ERROR_OK ? GMIO_TRUE : GMIO_FALSE; }
GMIO_INLINE bool gmio_no_error(int code)
{ return code == GMIO_ERROR_OK ? true : false; }
/*! Returns true if <tt>code != GMIO_NO_ERROR</tt> */
GMIO_INLINE gmio_bool_t gmio_error(int code)
{ return code != GMIO_ERROR_OK ? GMIO_TRUE : GMIO_FALSE; }
GMIO_INLINE bool gmio_error(int code)
{ return code != GMIO_ERROR_OK ? true : false; }
#endif /* GMIO_ERROR_H */
/*! @} */

View File

@ -120,37 +120,17 @@ typedef unsigned long long uint64_t;
# define GMIO_HAVE_INT64_TYPE
#endif
/* gmio_bool_t */
/* GMIO_TRUE and GMIO_FALSE */
/* GMIO_HAVE_STDBOOL_H */
#ifdef GMIO_HAVE_STDBOOL_H
# include <stdbool.h>
typedef bool gmio_bool_t;
# define GMIO_FALSE false
# define GMIO_TRUE true
#elif !defined(DOXYGEN)
typedef int gmio_bool_t;
#elif !defined(DOXYGEN) && !defined(__cplusplus)
typedef int bool;
enum gmio_bool_value
{
GMIO_FALSE = 0,
GMIO_TRUE = 1
false = 0,
true = 1
};
#else
/* For documentation only */
/*! Boolean type alias
*
* If strict ISO-C90 or if \c <stdbool.h> does not exists then:
* \li \c gmio_bool_t is an alias of \c int
* \li <tt>GMIO_FALSE == 0</tt> and <tt>GMIO_TRUE == 1</tt>
*
* Otherwise:
* \li \c gmio_bool_t is an alias of \c bool
* \li \c GMIO_FALSE expands to \c false and \c GMIO_TRUE to \c true
*/
typedef int_or_bool gmio_bool_t;
#endif /* GMIO_HAVE_STDBOOL_H */
#endif
/* GMIO_UNUSED */
/*! Tells the compiler that a parameter is not used in the body of a function */

View File

@ -16,7 +16,7 @@
#include <limits.h>
#include <math.h>
GMIO_INLINE gmio_bool_t is_local_decimal_point(char in)
GMIO_INLINE bool is_local_decimal_point(char in)
{
/*! Selection of characters which count as decimal point in fast_atof
* TODO: This should probably also be used in irr::core::string, but
@ -57,7 +57,7 @@ GMIO_INLINE uint64_t strtoul10_64( const char* in, const char** out, unsigned in
{
unsigned int cur = 0;
uint64_t value = 0;
const gmio_bool_t running = GMIO_TRUE;
const bool running = true;
if ( !gmio_ascii_isdigit(*in) )
return value;
@ -104,7 +104,7 @@ GMIO_INLINE uint64_t strtoul10_64( const char* in, const char** out, unsigned in
* ------------------------------------------------------------------------------------*/
GMIO_INLINE int64_t strtol10_64(const char* in, const char** out, unsigned int* max_inout)
{
const gmio_bool_t inv = (*in == '-');
const bool inv = (*in == '-');
int64_t value;
if (inv || *in == '+')
++in;
@ -125,10 +125,10 @@ GMIO_INLINE int64_t strtol10_64(const char* in, const char** out, unsigned int*
* about 6 times faster than atof in win32.
* If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
* ------------------------------------------------------------------------------------*/
GMIO_INLINE const char* fast_atoreal_move(const char* c, double* out, gmio_bool_t check_comma)
GMIO_INLINE const char* fast_atoreal_move(const char* c, double* out, bool check_comma)
{
double f = 0;
const gmio_bool_t inv = (*c == '-');
const bool inv = (*c == '-');
if (inv || *c == '+') {
++c;
@ -198,7 +198,7 @@ GMIO_INLINE const char* fast_atoreal_move(const char* c, double* out, gmio_bool_
/* A major 'E' must be allowed. Necessary for proper reading of some DXF files.
* Thanks to Zhao Lei to point out that this if() must be outside the if (*c == '.' ..) */
if (*c == 'e' || *c == 'E') {
const gmio_bool_t einv = (*(c+1)=='-');
const bool einv = (*(c+1)=='-');
double exp;
++c;
@ -226,14 +226,14 @@ GMIO_INLINE const char* fast_atoreal_move(const char* c, double* out, gmio_bool_
GMIO_INLINE float fast_atof(const char* c)
{
double ret;
fast_atoreal_move(c, &ret, GMIO_TRUE);
fast_atoreal_move(c, &ret, true);
return (float)ret;
}
GMIO_INLINE double fast_atod(const char* c)
{
double ret;
fast_atoreal_move(c, &ret, GMIO_TRUE);
fast_atoreal_move(c, &ret, true);
return ret;
}
@ -241,9 +241,9 @@ GMIO_INLINE float fast_strtof(const char* str, const char** out)
{
double ret;
if (out)
*out = fast_atoreal_move(str, &ret, GMIO_TRUE);
*out = fast_atoreal_move(str, &ret, true);
else
fast_atoreal_move(str, &ret, GMIO_TRUE);
fast_atoreal_move(str, &ret, true);
return (float)ret;
}
@ -303,7 +303,7 @@ GMIO_INLINE uint32_t strtoul10(const char* in, const char** out)
*/
GMIO_INLINE int32_t strtol10(const char* in, const char** out)
{
const gmio_bool_t inv = (*in == '-');
const bool inv = (*in == '-');
int value = 0;
if (inv || *in == '+')
++in;
@ -355,7 +355,7 @@ GMIO_INLINE float strtof10(const char* in, const char** out)
*/
GMIO_INLINE const char* fast_atof_move(const char* in, float* result)
{
const gmio_bool_t negative = ('-' == *in);
const bool negative = ('-' == *in);
float value = 0.f;
/* Please run the regression test when making any modifications to this

View File

@ -23,7 +23,7 @@
struct gmio_memblock_helper
{
struct gmio_memblock* memblock;
gmio_bool_t was_allocated;
bool was_allocated;
};
GMIO_INLINE
@ -44,7 +44,7 @@ struct gmio_memblock_helper gmio_memblock_helper(struct gmio_memblock* mblock)
helper.memblock = mblock;
if (mblock != NULL && (mblock->ptr == NULL || mblock->size == 0)) {
*(helper.memblock) = gmio_memblock_default();
helper.was_allocated = GMIO_TRUE;
helper.was_allocated = true;
}
return helper;
}
@ -54,7 +54,7 @@ void gmio_memblock_helper_release(struct gmio_memblock_helper* helper)
if (helper != NULL && helper->was_allocated) {
gmio_memblock_deallocate(helper->memblock);
helper->memblock = NULL;
helper->was_allocated = GMIO_FALSE;
helper->was_allocated = false;
}
}

View File

@ -22,12 +22,12 @@
/*! Safe and convenient function for gmio_task_iface::func_is_stop_requested()
* through gmio_transfer::task_iface
*/
GMIO_INLINE gmio_bool_t gmio_rwargs_is_stop_requested(
GMIO_INLINE bool gmio_rwargs_is_stop_requested(
const struct gmio_rwargs* args)
{
if (args != NULL)
return gmio_task_iface_is_stop_requested(&args->task_iface);
return GMIO_FALSE;
return false;
}
/*! Safe and convenient function for gmio_task_iface::func_handle_progress()

View File

@ -19,7 +19,7 @@
#include "../stream.h"
/*! Safe and convenient function for gmio_stream::func_at_end() */
GMIO_INLINE gmio_bool_t gmio_stream_at_end(struct gmio_stream* stream);
GMIO_INLINE bool gmio_stream_at_end(struct gmio_stream* stream);
/*! Safe and convenient function for gmio_stream::func_error() */
GMIO_INLINE int gmio_stream_error(struct gmio_stream* stream);
@ -53,11 +53,11 @@ GMIO_INLINE int gmio_stream_set_pos(
* Implementation
*/
gmio_bool_t gmio_stream_at_end(struct gmio_stream* stream)
bool gmio_stream_at_end(struct gmio_stream* stream)
{
if (stream != NULL && stream->func_at_end != NULL)
return stream->func_at_end(stream->cookie);
return GMIO_FALSE;
return false;
}
int gmio_stream_error(struct gmio_stream* stream)

View File

@ -21,12 +21,12 @@
#include <stddef.h>
/*! Safe and convenient function for gmio_task_iface::func_is_stop_requested() */
GMIO_INLINE gmio_bool_t gmio_task_iface_is_stop_requested(
GMIO_INLINE bool gmio_task_iface_is_stop_requested(
const struct gmio_task_iface* itask)
{
if (itask != NULL && itask->func_is_stop_requested != NULL)
return itask->func_is_stop_requested(itask->cookie);
return GMIO_FALSE;
return false;
}
/*! Safe and convenient function for gmio_task_iface::func_handle_progress() */

View File

@ -15,7 +15,7 @@
#include "numeric_utils.h"
gmio_bool_t gmio_float32_ulp_equals(float a, float b, uint32_t max_ulp_diff)
bool gmio_float32_ulp_equals(float a, float b, uint32_t max_ulp_diff)
{
const int32_t ia = gmio_convert_int32(a);
const int32_t ib = gmio_convert_int32(b);

View File

@ -28,7 +28,7 @@
* See:
* http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
*/
gmio_bool_t gmio_float32_ulp_equals(float a, float b, uint32_t max_ulp_diff);
bool gmio_float32_ulp_equals(float a, float b, uint32_t max_ulp_diff);
/*! Count of ULP between \p a and \p b */
GMIO_INLINE uint32_t gmio_float32_ulp_diff(float a, float b);

View File

@ -42,7 +42,7 @@ GMIO_INLINE char gmio_ascii_tolower(char c);
*
* Comparison is case-insensitive
*/
GMIO_INLINE gmio_bool_t gmio_ascii_char_iequals(char c1, char c2);
GMIO_INLINE bool gmio_ascii_char_iequals(char c1, char c2);
/*! Returns 0 if \p str1 and \p str2 compare equal, non-zero otherwise
*
@ -62,7 +62,7 @@ GMIO_INLINE int gmio_ascii_strincmp(
*
* Comparison is case-insensitive
*/
GMIO_INLINE gmio_bool_t gmio_ascii_istarts_with(
GMIO_INLINE bool gmio_ascii_istarts_with(
const char* str, const char* begin);
/*! Locate substring (insensitive case string matching)
@ -168,7 +168,7 @@ char gmio_ascii_tolower(char c)
#endif
}
gmio_bool_t gmio_ascii_char_iequals(char c1, char c2)
bool gmio_ascii_char_iequals(char c1, char c2)
{
/* TODO: eliminate branch */
return c1 == c2 || (gmio_ascii_toupper(c1) == gmio_ascii_toupper(c2));
@ -193,15 +193,15 @@ int gmio_ascii_strincmp(const char* str1, const char* str2, size_t n)
return gmio_ascii_tolower(*str1) - gmio_ascii_tolower(*str2);
}
gmio_bool_t gmio_ascii_istarts_with(const char* str, const char* begin)
bool gmio_ascii_istarts_with(const char* str, const char* begin)
{
while (*begin != 0) {
if (*str == 0 || !gmio_ascii_char_iequals(*str, *begin))
return GMIO_FALSE;
return false;
++str;
++begin;
}
return GMIO_TRUE;
return true;
}
#endif /* GMIO_INTERNAL_STRING_ASCII_UTILS_H */

View File

@ -71,12 +71,12 @@ enum gmio_eat_word_error gmio_stringstream_eat_word(
}
#if 0
gmio_bool_t gmio_stringstream_checked_next_chars(
bool gmio_stringstream_checked_next_chars(
struct gmio_stringstream *sstream, const char *str)
{
size_t pos = 0;
const char* curr_char = gmio_stringstream_current_char(sstream);
gmio_bool_t same = curr_char != NULL && *curr_char == *str;
bool same = curr_char != NULL && *curr_char == *str;
while (same) {
curr_char = gmio_stringstream_next_char(sstream);

View File

@ -93,9 +93,9 @@ enum gmio_eat_word_error gmio_stringstream_eat_word(
#if 0
/*! Iterate over stream while it matches input string \p str
*
* Returns GMIO_TRUE if \p str was fully matched
* Returns true if \p str was fully matched
*/
gmio_bool_t gmio_stringstream_checked_next_chars(
bool gmio_stringstream_checked_next_chars(
struct gmio_stringstream* sstream, const char* str);
#endif

View File

@ -30,7 +30,7 @@ GMIO_INLINE int32_t gmio_stringstream_strtol10(
struct gmio_stringstream* sstream)
{
const char* in = gmio_stringstream_current_char(sstream);
const gmio_bool_t inv = (*in == '-');
const bool inv = (*in == '-');
int value = 0;
if (inv || *in == '+')
@ -84,7 +84,7 @@ GMIO_INLINE struct gmio_stringstream_strtof10_result
GMIO_INLINE float gmio_stringstream_fast_atof(struct gmio_stringstream* sstream)
{
const char* in = gmio_stringstream_current_char(sstream);
const gmio_bool_t negative = ('-' == *in);
const bool negative = ('-' == *in);
float value = 0.f;
/* Please run the regression test when making any modifications to this

View File

@ -51,7 +51,7 @@ struct gmio_stream gmio_stream_null()
return null_stream;
}
static gmio_bool_t gmio_stream_stdio_at_end(void* cookie)
static bool gmio_stream_stdio_at_end(void* cookie)
{
return feof((FILE*)cookie);
}

View File

@ -58,12 +58,12 @@ struct gmio_stream
/*! Pointer on a function that checks end-of-stream indicator
*
* Checks whether the end-of-stream indicator associated with stream
* pointed by \p cookie is set, returning GMIO_TRUE if is.
* pointed by \p cookie is set, returning true if is.
*
* The function should behaves like C standard [feof()]
* (http://pubs.opengroup.org/onlinepubs/007904975/functions/feof.html)
*/
gmio_bool_t (*func_at_end)(void* cookie);
bool (*func_at_end)(void* cookie);
/*! Pointer on a function that checks error indicator
*

View File

@ -35,10 +35,10 @@ struct gmio_task_iface
/*! Optional pointer on a function that says if the currently running
* task must stop
*
* If \c GMIO_TRUE is returned then the current task should abort as
* If \c true is returned then the current task should abort as
* soon as possible, otherwise it can continue execution.
*/
gmio_bool_t (*func_is_stop_requested)(void* cookie);
bool (*func_is_stop_requested)(void* cookie);
/*! Optional pointer on a function that is called anytime some new progress
* was done

View File

@ -20,7 +20,7 @@
#include "../stl_error.h"
#include "../stl_io.h"
gmio_bool_t gmio_check_rwargs(int *error, const struct gmio_rwargs* args)
bool gmio_check_rwargs(int *error, const struct gmio_rwargs* args)
{
if (args == NULL) {
*error = GMIO_ERROR_NULL_RWARGS;
@ -35,7 +35,7 @@ gmio_bool_t gmio_check_rwargs(int *error, const struct gmio_rwargs* args)
return gmio_no_error(*error);
}
gmio_bool_t gmio_check_memblock(int *error, const struct gmio_memblock* mblock)
bool gmio_check_memblock(int *error, const struct gmio_memblock* mblock)
{
if (mblock->ptr == NULL)
*error = GMIO_ERROR_NULL_MEMBLOCK;
@ -44,7 +44,7 @@ gmio_bool_t gmio_check_memblock(int *error, const struct gmio_memblock* mblock)
return gmio_no_error(*error);
}
gmio_bool_t gmio_stl_check_mesh(int *error, const struct gmio_stl_mesh* mesh)
bool gmio_stl_check_mesh(int *error, const struct gmio_stl_mesh* mesh)
{
if (mesh == NULL
|| (mesh->triangle_count > 0 && mesh->func_get_triangle == NULL))
@ -55,13 +55,13 @@ gmio_bool_t gmio_stl_check_mesh(int *error, const struct gmio_stl_mesh* mesh)
return gmio_no_error(*error);
}
gmio_bool_t gmio_stlb_check_params(
bool gmio_stlb_check_params(
int *error,
const struct gmio_rwargs* args,
enum gmio_endianness byte_order)
{
if (!gmio_check_rwargs(error, args))
return GMIO_FALSE;
return false;
if (args->stream_memblock.size < GMIO_STLB_MIN_CONTENTS_SIZE)
*error = GMIO_ERROR_INVALID_MEMBLOCK_SIZE;

View File

@ -27,12 +27,12 @@ struct gmio_memblock;
struct gmio_rwargs;
struct gmio_stl_mesh;
gmio_bool_t gmio_check_rwargs(int* error, const struct gmio_rwargs* args);
gmio_bool_t gmio_check_memblock(int* error, const struct gmio_memblock* mblock);
bool gmio_check_rwargs(int* error, const struct gmio_rwargs* args);
bool gmio_check_memblock(int* error, const struct gmio_memblock* mblock);
gmio_bool_t gmio_stl_check_mesh(int* error, const struct gmio_stl_mesh* mesh);
bool gmio_stl_check_mesh(int* error, const struct gmio_stl_mesh* mesh);
gmio_bool_t gmio_stlb_check_params(
bool gmio_stlb_check_params(
int* error,
const struct gmio_rwargs* args,
enum gmio_endianness byte_order);

View File

@ -111,11 +111,11 @@ static void gmio_stringstream_stla_read_hook(
int gmio_stla_infos_get(
struct gmio_stl_infos_get_args* args, unsigned flags)
{
const gmio_bool_t flag_facet_count =
const bool flag_facet_count =
(flags & GMIO_STL_INFO_FLAG_FACET_COUNT) != 0;
const gmio_bool_t flag_size =
const bool flag_size =
(flags & GMIO_STL_INFO_FLAG_SIZE) != 0;
const gmio_bool_t flag_stla_solidname =
const bool flag_stla_solidname =
(flags & GMIO_STLA_INFO_FLAG_SOLIDNAME) != 0;
struct gmio_stl_infos* infos = &args->infos;
@ -237,11 +237,11 @@ int gmio_stla_infos_get(
const size_t mblock_size = args->stream_memblock.size - 1;
struct gmio_string strbuff = gmio_string(mblock_ptr, 0, mblock_size);
const gmio_bool_t flag_facet_count =
const bool flag_facet_count =
(flags & GMIO_STL_INFO_FLAG_FACET_COUNT) != 0;
const gmio_bool_t flag_size =
const bool flag_size =
(flags & GMIO_STL_INFO_FLAG_SIZE) != 0;
const gmio_bool_t flag_stla_solidname =
const bool flag_stla_solidname =
(flags & GMIO_STLA_INFO_FLAG_SOLIDNAME) != 0;
int err = GMIO_ERROR_OK;
@ -253,15 +253,15 @@ int gmio_stla_infos_get(
/* 'overlap' stores the ending/starting bytes of the previous/current
* stream buffers(memblock) */
char overlap[14] = {0}; /* 14 == 2*(strlen("endfacet") - 1) */
gmio_bool_t endsolid_found = GMIO_FALSE;
bool endsolid_found = false;
while (!endsolid_found && gmio_no_error(err)) {
const char* substr_at = NULL;
const size_t read_size =
gmio_stream_read(stream, mblock_ptr, 1, mblock_size);
const int stream_err = gmio_stream_error(&args->stream);
const gmio_bool_t overlap_has_contents = overlap[0] != 0;
gmio_bool_t endsolid_in_overlap = GMIO_FALSE;
const bool overlap_has_contents = overlap[0] != 0;
bool endsolid_in_overlap = false;
err = stream_err;
strbuff.len = read_size;
@ -305,7 +305,7 @@ int gmio_stla_infos_get(
const char* endsolid_ptr =
endsolid_found ? substr_at : gmio_string_end(&strbuff);
/* Check in overlap */
const gmio_bool_t endfacet_in_overlap =
const bool endfacet_in_overlap =
overlap_has_contents
&& strstr(overlap, "endfacet") != NULL;
infos->facet_count += endfacet_in_overlap ? 1 : 0;

View File

@ -49,14 +49,14 @@ struct gmio_stringstream_stla_cookie
/* Offset (in bytes) from beginning of stream : current position */
gmio_streamoffset_t stream_offset;
/* Cache for gmio_transfer::func_is_stop_requested() */
gmio_bool_t is_stop_requested;
bool is_stop_requested;
};
/* gmio_stla_parse_data */
struct gmio_stla_parse_data
{
enum gmio_stla_token token;
gmio_bool_t error;
bool error;
struct gmio_stringstream strstream;
struct gmio_stringstream_stla_cookie strstream_cookie;
struct gmio_string strbuff;

View File

@ -121,7 +121,7 @@ GMIO_INLINE char* gmio_write_coords(
coords_format, coords->x, coords->y, coords->z);
}
GMIO_INLINE gmio_bool_t gmio_rwargs_flush_buffer(
GMIO_INLINE bool gmio_rwargs_flush_buffer(
struct gmio_rwargs* args, size_t n)
{
const size_t write_count =
@ -146,7 +146,7 @@ int gmio_stla_write(struct gmio_stl_write_args* args)
const enum gmio_float_text_format f32_format = options->stla_float32_format;
const uint8_t opt_f32_prec = options->stla_float32_prec;
const uint8_t f32_prec = opt_f32_prec != 0 ? opt_f32_prec : 9;
const gmio_bool_t write_triangles_only = options->stl_write_triangles_only;
const bool write_triangles_only = options->stl_write_triangles_only;
/* Variables */
struct gmio_rwargs* core_args = &args->core;

View File

@ -45,7 +45,7 @@ GMIO_INLINE gmio_streamsize_t gmio_stlb_streamsize(uint32_t facet_count)
}
/* Does \p str contains <SPC>token ? */
static gmio_bool_t gmio_str_has_token(const char* str, const char* token)
static bool gmio_str_has_token(const char* str, const char* token)
{
const char* substr = gmio_ascii_istrstr(str, token);
return substr != NULL
@ -99,7 +99,7 @@ static enum gmio_stl_format gmio_stlb_format(
return GMIO_STL_FORMAT_UNKNOWN;
}
static gmio_bool_t gmio_is_stl_ascii(const char* buff, size_t buff_len)
static bool gmio_is_stl_ascii(const char* buff, size_t buff_len)
{
/* Skip spaces at beginning */
size_t pos = 0;
@ -116,10 +116,10 @@ static gmio_bool_t gmio_is_stl_ascii(const char* buff, size_t buff_len)
if (gmio_str_has_token(buff + pos, "facet")
|| gmio_str_has_token(buff + pos, "endsolid"))
{
return GMIO_TRUE;
return true;
}
}
return GMIO_FALSE;
return false;
}
enum gmio_stl_format gmio_stl_get_format(struct gmio_stream *stream)

View File

@ -34,13 +34,13 @@ struct gmio_stl_write_options
/*! Flag allowing to skip writting of any header/footer data, but just
* triangles
*
* If set to \c GMIO_TRUE then :
* If set to \c true then :
* \li for STL ASCII format, <tt>"solid [name]"</tt> and
* <tt>"endsolid"</tt> will no be written to output stream
* \li for STL binary format, the 80 bytes header followed by the mesh
* facet count (4bytes) will no be written to output stream
*/
gmio_bool_t stl_write_triangles_only;
bool stl_write_triangles_only;
/*! Name of the solid to appear in <tt>solid [name] facet normal ...</tt>
*

View File

@ -111,7 +111,7 @@ int gmio_stla_read(struct gmio_stl_read_args* args)
struct gmio_stla_parse_data parse_data;
parse_data.token = unknown_token;
parse_data.error = GMIO_FALSE;
parse_data.error = false;
parse_data.strstream_cookie.rwargs = core_args;
parse_data.strstream_cookie.stream_offset = 0;
@ -122,7 +122,7 @@ int gmio_stla_read(struct gmio_stl_read_args* args)
&core_args->stream, &core_args->stream_memblock) :
gmio_stream_size(&core_args->stream);
parse_data.strstream_cookie.is_stop_requested = GMIO_FALSE;
parse_data.strstream_cookie.is_stop_requested = false;
parse_data.strstream.stream = core_args->stream;
parse_data.strstream.strbuff.ptr = core_args->stream_memblock.ptr;
@ -193,7 +193,7 @@ GMIO_INLINE enum gmio_stla_token stla_find_token_from_string(const struct gmio_s
*
* Array \p candidates must end with a "null_token" item
*/
GMIO_INLINE gmio_bool_t stla_token_match_candidate(
GMIO_INLINE bool stla_token_match_candidate(
enum gmio_stla_token token, const enum gmio_stla_token* candidates);
/* --------------------------------------------------------------------------
@ -213,7 +213,7 @@ static void stla_error_token_expected(
* -------------------------------------------------------------------------- */
/* Returns true if parsing can continue */
GMIO_INLINE gmio_bool_t stla_parsing_can_continue(
GMIO_INLINE bool stla_parsing_can_continue(
const struct gmio_stla_parse_data* data);
/* --------------------------------------------------------------------------
@ -231,7 +231,7 @@ static int parse_solidname_end(struct gmio_stla_parse_data* data);
static int parse_beginsolid(struct gmio_stla_parse_data* data);
/* Parses "endsolid <name>" */
static gmio_bool_t parse_endsolid(struct gmio_stla_parse_data* data);
static bool parse_endsolid(struct gmio_stla_parse_data* data);
/* Parses STL (x,y,z) coords, each coord being separated by whitespaces */
GMIO_INLINE int parse_xyz_coords(
@ -333,10 +333,10 @@ enum gmio_stla_token stla_find_token_from_string(const struct gmio_string* str)
return gmio_stla_find_token(str->ptr, str->len);
}
gmio_bool_t stla_token_match_candidate(
bool stla_token_match_candidate(
enum gmio_stla_token token, const enum gmio_stla_token* candidates)
{
gmio_bool_t found = GMIO_FALSE;
bool found = false;
size_t i;
for (i = 0; !found && candidates[i] != null_token; ++i)
found = token == candidates[i];
@ -357,7 +357,7 @@ void stla_error_msg(struct gmio_stla_parse_data* data, const char* msg)
msg,
stla_token_to_string(data->token),
data->strbuff.ptr);
data->error = GMIO_TRUE;
data->error = true;
data->token = unknown_token;
}
@ -410,7 +410,7 @@ int gmio_stla_eat_next_token_inplace(
struct gmio_stringstream* sstream = &data->strstream;
const char* stream_char = NULL;
const char* expected_token_str = stla_token_to_string(expected_token);
gmio_bool_t error = GMIO_FALSE;
bool error = false;
data->token = unknown_token;
stream_char = gmio_stringstream_skip_ascii_spaces(sstream);
@ -420,12 +420,12 @@ int gmio_stla_eat_next_token_inplace(
data->token = expected_token;
return 0;
}
error = GMIO_TRUE;
error = true;
}
else if (!gmio_ascii_char_iequals(*stream_char, *expected_token_str)
|| *expected_token_str == 0)
{
error = GMIO_TRUE;
error = true;
}
stream_char = gmio_stringstream_next_char(sstream);
++expected_token_str;
@ -444,7 +444,7 @@ int gmio_stla_eat_until_token(
if (!stla_token_match_candidate(data->token, end_tokens)) {
struct gmio_stringstream* sstream = &data->strstream;
struct gmio_string* strbuff = &data->strbuff;
gmio_bool_t end_token_found = GMIO_FALSE;
bool end_token_found = false;
do {
const size_t previous_buff_len = strbuff->len;
@ -481,7 +481,7 @@ int gmio_stla_eat_until_token(
return 0;
}
gmio_bool_t stla_parsing_can_continue(const struct gmio_stla_parse_data* data)
bool stla_parsing_can_continue(const struct gmio_stla_parse_data* data)
{
return !data->error && !data->strstream_cookie.is_stop_requested;
}
@ -529,7 +529,7 @@ int parse_beginsolid(struct gmio_stla_parse_data* data)
return GMIO_STLA_PARSE_ERROR;
}
gmio_bool_t parse_endsolid(struct gmio_stla_parse_data* data)
bool parse_endsolid(struct gmio_stla_parse_data* data)
{
if (data->token == ENDSOLID_token
|| gmio_stla_eat_next_token(data, ENDSOLID_token) == 0)

View File

@ -53,7 +53,7 @@ namespace gmio {
namespace internal {
template<typename STREAM>
gmio_bool_t stream_cpp_at_end(void* cookie)
bool stream_cpp_at_end(void* cookie)
{
STREAM* s = static_cast<STREAM*>(cookie);
return s->eof();

View File

@ -22,7 +22,7 @@
QT_USE_NAMESPACE
static gmio_bool_t gmio_stream_qiodevice_at_end(void* cookie)
static bool gmio_stream_qiodevice_at_end(void* cookie)
{
return static_cast<QIODevice*>(cookie)->atEnd();
}

View File

@ -115,7 +115,7 @@ struct gmio_stl_mesh gmio_stl_data_mesh(const struct gmio_stl_data *data)
return mesh;
}
gmio_bool_t gmio_stl_coords_equal(
bool gmio_stl_coords_equal(
const struct gmio_stl_coords *lhs,
const struct gmio_stl_coords *rhs,
uint32_t max_ulp_diff)
@ -125,7 +125,7 @@ gmio_bool_t gmio_stl_coords_equal(
&& gmio_float32_ulp_equals(lhs->z, rhs->z, max_ulp_diff);
}
gmio_bool_t gmio_stl_triangle_equal(
bool gmio_stl_triangle_equal(
const struct gmio_stl_triangle *lhs,
const struct gmio_stl_triangle *rhs,
uint32_t max_ulp_diff)

View File

@ -24,18 +24,18 @@
#include <string.h>
gmio_bool_t gmio_stl_coords_equal(
bool gmio_stl_coords_equal(
const struct gmio_stl_coords* lhs,
const struct gmio_stl_coords* rhs,
uint32_t max_ulp_diff);
gmio_bool_t gmio_stl_triangle_equal(
bool gmio_stl_triangle_equal(
const struct gmio_stl_triangle* lhs,
const struct gmio_stl_triangle* rhs,
uint32_t max_ulp_diff);
/*! Does binary STL header \p lhs compare equal to \p rhs ? */
GMIO_INLINE gmio_bool_t gmio_stlb_header_equal(
GMIO_INLINE bool gmio_stlb_header_equal(
const struct gmio_stlb_header* lhs, const struct gmio_stlb_header* rhs)
{
return memcmp(lhs, rhs, GMIO_STLB_HEADER_SIZE) == 0;

View File

@ -17,7 +17,7 @@
#include <string.h>
static gmio_bool_t gmio_stream_buffer_at_end(void* cookie)
static bool gmio_stream_buffer_at_end(void* cookie)
{
const struct gmio_ro_buffer* buff = (const struct gmio_ro_buffer*)cookie;
return buff->pos >= buff->len;

View File

@ -84,7 +84,7 @@ static void gmio_test_atof_fprintf_err(
gmio_float32_ulp_diff(fast_val, std_val));
}
static gmio_bool_t gmio_test_calculation_atof(const char* val_str)
static bool gmio_test_calculation_atof(const char* val_str)
{
const float std_val = (float)strtod(val_str, NULL);
int accurate_count = 0;
@ -120,39 +120,39 @@ static gmio_bool_t gmio_test_calculation_atof(const char* val_str)
const char* test_internal__fast_atof()
{
gmio_bool_t accurate = GMIO_TRUE;
bool ok = true;
accurate &= gmio_test_calculation_atof("340282346638528859811704183484516925440.000000");
accurate &= gmio_test_calculation_atof("3.402823466e+38F");
accurate &= gmio_test_calculation_atof("3402823466e+29F");
accurate &= gmio_test_calculation_atof("-340282346638528859811704183484516925440.000000");
accurate &= gmio_test_calculation_atof("-3.402823466e+38F");
accurate &= gmio_test_calculation_atof("-3402823466e+29F");
accurate &= gmio_test_calculation_atof("34028234663852885981170418348451692544.000000");
accurate &= gmio_test_calculation_atof("3.402823466e+37F");
accurate &= gmio_test_calculation_atof("3402823466e+28F");
accurate &= gmio_test_calculation_atof("-34028234663852885981170418348451692544.000000");
accurate &= gmio_test_calculation_atof("-3.402823466e+37F");
accurate &= gmio_test_calculation_atof("-3402823466e+28F");
accurate &= gmio_test_calculation_atof(".00234567");
accurate &= gmio_test_calculation_atof("-.00234567");
accurate &= gmio_test_calculation_atof("0.00234567");
accurate &= gmio_test_calculation_atof("-0.00234567");
accurate &= gmio_test_calculation_atof("1.175494351e-38F");
ok = ok && gmio_test_calculation_atof("340282346638528859811704183484516925440.000000");
ok = ok && gmio_test_calculation_atof("3.402823466e+38F");
ok = ok && gmio_test_calculation_atof("3402823466e+29F");
ok = ok && gmio_test_calculation_atof("-340282346638528859811704183484516925440.000000");
ok = ok && gmio_test_calculation_atof("-3.402823466e+38F");
ok = ok && gmio_test_calculation_atof("-3402823466e+29F");
ok = ok && gmio_test_calculation_atof("34028234663852885981170418348451692544.000000");
ok = ok && gmio_test_calculation_atof("3.402823466e+37F");
ok = ok && gmio_test_calculation_atof("3402823466e+28F");
ok = ok && gmio_test_calculation_atof("-34028234663852885981170418348451692544.000000");
ok = ok && gmio_test_calculation_atof("-3.402823466e+37F");
ok = ok && gmio_test_calculation_atof("-3402823466e+28F");
ok = ok && gmio_test_calculation_atof(".00234567");
ok = ok && gmio_test_calculation_atof("-.00234567");
ok = ok && gmio_test_calculation_atof("0.00234567");
ok = ok && gmio_test_calculation_atof("-0.00234567");
ok = ok && gmio_test_calculation_atof("1.175494351e-38F");
#if 0
/* This check fails */
accurate &= gmio_test_calculation_atof("1175494351e-47F");
ok = ok && gmio_test_calculation_atof("1175494351e-47F");
#endif
accurate &= gmio_test_calculation_atof("1.175494351e-37F");
accurate &= gmio_test_calculation_atof("1.175494351e-36F");
accurate &= gmio_test_calculation_atof("-1.175494351e-36F");
accurate &= gmio_test_calculation_atof("123456.789");
accurate &= gmio_test_calculation_atof("-123456.789");
accurate &= gmio_test_calculation_atof("0000123456.789");
accurate &= gmio_test_calculation_atof("-0000123456.789");
accurate &= gmio_test_calculation_atof("-0.0690462109446526");
ok = ok && gmio_test_calculation_atof("1.175494351e-37F");
ok = ok && gmio_test_calculation_atof("1.175494351e-36F");
ok = ok && gmio_test_calculation_atof("-1.175494351e-36F");
ok = ok && gmio_test_calculation_atof("123456.789");
ok = ok && gmio_test_calculation_atof("-123456.789");
ok = ok && gmio_test_calculation_atof("0000123456.789");
ok = ok && gmio_test_calculation_atof("-0000123456.789");
ok = ok && gmio_test_calculation_atof("-0.0690462109446526");
UTEST_ASSERT(accurate == GMIO_TRUE);
UTEST_ASSERT(ok);
return NULL;
}

View File

@ -351,7 +351,7 @@ const char* test_stla_write()
for (i = 0; i < data.tri_array.count; ++i) {
const struct gmio_stl_triangle* lhs = &data.tri_array.ptr[i];
const struct gmio_stl_triangle* rhs = &data_stla.tri_array.ptr[i];
const gmio_bool_t tri_equal = gmio_stl_triangle_equal(lhs, rhs, 5);
const bool tri_equal = gmio_stl_triangle_equal(lhs, rhs, 5);
UTEST_ASSERT(tri_equal);
}
}