Skip to content

Commit

Permalink
Use bool for predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
bettio committed Nov 13, 2022
1 parent 3d74479 commit 19daa97
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/libAtomVM/term.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static inline const term *term_to_const_term_ptr(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_atom(term t)
static inline bool term_is_atom(term t)
{
/* atom: | atom index | 00 10 11 */
return ((t & 0x3F) == 0xB);
Expand All @@ -182,7 +182,7 @@ static inline int term_is_atom(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_invalid_term(term t)
static inline bool term_is_invalid_term(term t)
{
return (t == 0);
}
Expand All @@ -194,7 +194,7 @@ static inline int term_is_invalid_term(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_nil(term t)
static inline bool term_is_nil(term t)
{
/* nil: 11 10 11 */
return ((t & 0x3F) == 0x3B);
Expand All @@ -207,7 +207,7 @@ static inline int term_is_nil(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_nonempty_list(term t)
static inline bool term_is_nonempty_list(term t)
{
/* list: 01 */
return ((t & 0x3) == 0x1);
Expand All @@ -220,7 +220,7 @@ static inline int term_is_nonempty_list(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_list(term t)
static inline bool term_is_list(term t)
{
/* list: 01 */
return term_is_nonempty_list(t) || term_is_nil(t);
Expand All @@ -233,7 +233,7 @@ static inline int term_is_list(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_boxed(term t)
static inline bool term_is_boxed(term t)
{
/* boxed: 10 */
return ((t & 0x3) == 0x2);
Expand All @@ -246,7 +246,7 @@ static inline int term_is_boxed(term t)
* @param t the term that will checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_movable_boxed(term t)
static inline bool term_is_movable_boxed(term t)
{
/* boxed: 10 */
if ((t & 0x3) == 0x2) {
Expand Down Expand Up @@ -299,7 +299,7 @@ static inline int term_boxed_size(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_binary(term t)
static inline bool term_is_binary(term t)
{
/* boxed: 10 */
if ((t & 0x3) == 0x2) {
Expand Down Expand Up @@ -368,7 +368,7 @@ static inline bool term_is_sub_binary(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_integer(term t)
static inline bool term_is_integer(term t)
{
/* integer: 11 11 */
return ((t & 0xF) == 0xF);
Expand All @@ -381,12 +381,12 @@ static inline int term_is_integer(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline uint8_t term_is_uint8(term t)
static inline bool term_is_uint8(term t)
{
return ((t & ~((term) 0xFF0)) == 0xF);
}

static inline int term_is_boxed_integer(term t)
static inline bool term_is_boxed_integer(term t)
{
if (term_is_boxed(t)) {
const term *boxed_value = term_to_const_term_ptr(t);
Expand All @@ -398,12 +398,12 @@ static inline int term_is_boxed_integer(term t)
return 0;
}

static inline int term_is_any_integer(term t)
static inline bool term_is_any_integer(term t)
{
return term_is_integer(t) || term_is_boxed_integer(t);
}

static inline int term_is_catch_label(term t)
static inline bool term_is_catch_label(term t)
{
return (t & 0x3F) == TERM_CATCH_TAG;
}
Expand All @@ -415,7 +415,7 @@ static inline int term_is_catch_label(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_pid(term t)
static inline bool term_is_pid(term t)
{
/* integer: 00 11 */
return ((t & 0xF) == 0x3);
Expand All @@ -428,7 +428,7 @@ static inline int term_is_pid(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_tuple(term t)
static inline bool term_is_tuple(term t)
{
if (term_is_boxed(t)) {
const term *boxed_value = term_to_const_term_ptr(t);
Expand All @@ -447,7 +447,7 @@ static inline int term_is_tuple(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_reference(term t)
static inline bool term_is_reference(term t)
{
if (term_is_boxed(t)) {
const term *boxed_value = term_to_const_term_ptr(t);
Expand All @@ -466,7 +466,7 @@ static inline int term_is_reference(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_function(term t)
static inline bool term_is_function(term t)
{
if (term_is_boxed(t)) {
const term *boxed_value = term_to_const_term_ptr(t);
Expand All @@ -485,7 +485,7 @@ static inline int term_is_function(term t)
* @param t the term that will be checked.
* @return 1 if check succeeds, 0 otherwise.
*/
static inline int term_is_cp(term t)
static inline bool term_is_cp(term t)
{
return ((t & 0x3) == 0);
}
Expand Down

0 comments on commit 19daa97

Please sign in to comment.