Skip to content

Commit

Permalink
Fix HL array things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Apprentice-Alchemist committed Nov 29, 2022
1 parent 66758a0 commit f3abec2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Backends/Kinc-HL/kinc-bridge/arrays.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,28 @@ double hl_kinc_bytearray_getfloat64_le(vbyte *bytearray, int byteoffset) {
// Set (little endian on big endian system)

void hl_kinc_bytearray_setint16_le(vbyte *bytearray, int byteoffset, int value) {
int8_t *data = (int8_t *)&((int16_t)value);
int16_t val = value;
int8_t *data = (int8_t *)&(val);
int16_t le_value = data[0] << 8 | data[1] << 0;
*((int16_t *)&bytearray[byteoffset]) = le_value;
}

void hl_kinc_bytearray_setuint16_le(vbyte *bytearray, int byteoffset, int value) {
int8_t *data = (int8_t *)&((uint16_t)value);
uint16_t val = value;
int8_t *data = (int8_t *)&(val);
uint16_t le_value = data[0] << 8 | data[1] << 0;
*((uint16_t *)&bytearray[byteoffset]) = le_value;
}

void hl_kinc_bytearray_setint32_le(vbyte *bytearray, int byteoffset, int value) {
int8_t *data = (int8_t *)&((int32_t)value);
int8_t *data = (int8_t *)&(value);
int32_t le_value = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3] << 0;
*((int32_t *)&bytearray[byteoffset]) = le_value;
}

void hl_kinc_bytearray_setuint32_le(vbyte *bytearray, int byteoffset, int64_t value) {
int8_t *data = (int8_t *)&((uint32_t)value);
uint32_t val = (uint32_t)value;
int8_t *data = (int8_t *)&(val);
uint32_t le_value = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3] << 0;
*((uint32_t *)&bytearray[byteoffset]) = le_value;
}
Expand Down

0 comments on commit f3abec2

Please sign in to comment.