Merge pull request #649 from hellerve/veit/reformat-core

Reformat carp_string and carp_byte
This commit is contained in:
Erik Svedäng 2020-01-28 15:24:00 +01:00 committed by GitHub
commit 148add054f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 19 deletions

View File

@ -1,23 +1,55 @@
typedef uint8_t byte;
uint8_t Byte__PLUS_(uint8_t x, uint8_t y) { return x + y; }
uint8_t Byte__MINUS_(uint8_t x, uint8_t y) { return x - y; }
uint8_t Byte__MUL_(uint8_t x, uint8_t y) { return x * y; }
uint8_t Byte__DIV_(uint8_t x, uint8_t y) { return x / y; }
bool Byte__EQ_(uint8_t x, uint8_t y) { return x == y; }
bool Byte__LT_(uint8_t x, uint8_t y) { return x < y; }
bool Byte__GT_(uint8_t x, uint8_t y) { return x > y; }
uint8_t Byte__PLUS_(uint8_t x, uint8_t y) {
return x + y;
}
uint8_t Byte__MINUS_(uint8_t x, uint8_t y) {
return x - y;
}
uint8_t Byte__MUL_(uint8_t x, uint8_t y) {
return x * y;
}
uint8_t Byte__DIV_(uint8_t x, uint8_t y) {
return x / y;
}
bool Byte__EQ_(uint8_t x, uint8_t y) {
return x == y;
}
bool Byte__LT_(uint8_t x, uint8_t y) {
return x < y;
}
bool Byte__GT_(uint8_t x, uint8_t y) {
return x > y;
}
uint8_t Byte_inc(uint8_t x) { return x + 1; }
uint8_t Byte_dec(uint8_t x) { return x - 1; }
uint8_t Byte_bit_MINUS_shift_MINUS_left(uint8_t x, uint8_t y) { return x << y; }
uint8_t Byte_bit_MINUS_shift_MINUS_right(uint8_t x, uint8_t y) { return x >> y; }
uint8_t Byte_bit_MINUS_and(uint8_t x, uint8_t y) { return x & y; }
uint8_t Byte_bit_MINUS_or(uint8_t x, uint8_t y) { return x | y; }
uint8_t Byte_bit_MINUS_xor(uint8_t x, uint8_t y) { return x ^ y; }
uint8_t Byte_bit_MINUS_not(uint8_t x) { return ~x; }
uint8_t Byte_inc(uint8_t x) {
return x + 1;
}
uint8_t Byte_dec(uint8_t x) {
return x - 1;
}
uint8_t Byte_bit_MINUS_shift_MINUS_left(uint8_t x, uint8_t y) {
return x << y;
}
uint8_t Byte_bit_MINUS_shift_MINUS_right(uint8_t x, uint8_t y) {
return x >> y;
}
uint8_t Byte_bit_MINUS_and(uint8_t x, uint8_t y) {
return x & y;
}
uint8_t Byte_bit_MINUS_or(uint8_t x, uint8_t y) {
return x | y;
}
uint8_t Byte_bit_MINUS_xor(uint8_t x, uint8_t y) {
return x ^ y;
}
uint8_t Byte_bit_MINUS_not(uint8_t x) {
return ~x;
}
uint8_t Byte_copy(const uint8_t *x) { return *x; }
uint8_t Byte_copy(const uint8_t *x) {
return *x;
}
uint8_t Byte_mod(uint8_t x, uint8_t divider) {
return x % divider;

View File

@ -248,14 +248,14 @@ long Long_from_MINUS_string(const String *s) {
}
String Byte_str(uint8_t x) {
int size = snprintf(NULL, 0, "%ub", x)+1;
int size = snprintf(NULL, 0, "%ub", x) + 1;
String buffer = CARP_MALLOC(size);
snprintf(buffer, size, "%ub", x);
return buffer;
}
String Byte_format(const String* str, uint8_t x) {
int size = snprintf(NULL, 0, *str, x)+1;
String Byte_format(const String *str, uint8_t x) {
int size = snprintf(NULL, 0, *str, x) + 1;
String buffer = CARP_MALLOC(size);
snprintf(buffer, size, *str, x);
return buffer;