Skip to content

Commit 89e7aa0

Browse files
committed
Clang format
1 parent 7834583 commit 89e7aa0

File tree

8 files changed

+56
-52
lines changed

8 files changed

+56
-52
lines changed

src/Interpreter/proxied.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") {
1515
bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr,
1616
StackValue &sval) {
1717
Interpreter::store(m, type, addr, sval);
18-
// m->warduino->debugger->channel->write("%02" PRIx8, interruptStore);
19-
// send_leb(m->warduino->debugger->channel, addr);
20-
// send_leb(m->warduino->debugger->channel, 0);
21-
// send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n");
18+
// m->warduino->debugger->channel->write("%02" PRIx8, interruptStore);
19+
// send_leb(m->warduino->debugger->channel, addr);
20+
// send_leb(m->warduino->debugger->channel, 0);
21+
// send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n");
2222
return true;
2323
}

src/Oop/RFC.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ SerializeData *merge(SerializeData a, SerializeData b, bool divide) {
1010
auto *data = new SerializeData;
1111
auto padding = divide ? 2 : 1;
1212
data->size = a.size + b.size + padding;
13-
// size_t lengte = a.size + b.size + padding;
14-
data->raw = new char[data->size]; //(unsigned char *)calloc(data->size, sizeof(char));
13+
// size_t lengte = a.size + b.size + padding;
14+
data->raw = new char[data->size]; //(unsigned char *)calloc(data->size,
15+
//sizeof(char));
1516
if (divide) {
1617
*(data->raw + a.size) = '\n';
1718
*(data->raw + a.size + b.size + 1) = '\n';
@@ -24,20 +25,22 @@ SerializeData *merge(SerializeData a, SerializeData b, bool divide) {
2425
return data;
2526
}
2627

27-
struct SerializeData* mergeSerializeData(struct SerializeData data1, struct SerializeData data2, bool divide) {
28+
struct SerializeData *mergeSerializeData(struct SerializeData data1,
29+
struct SerializeData data2,
30+
bool divide) {
2831
// Allocate memory for the result struct
2932
struct SerializeData *result =
3033
static_cast<SerializeData *>(malloc(sizeof(struct SerializeData)));
3134
if (result == NULL) {
32-
return NULL; // Memory allocation failure
35+
return NULL; // Memory allocation failure
3336
}
3437

3538
uint32_t extra = divide ? 1 : 0;
3639
result->size = data1.size + data2.size + extra;
3740
result->raw = static_cast<char *>(malloc(result->size));
3841
if (result->raw == NULL) {
3942
free(result);
40-
return NULL; // Memory allocation failure
43+
return NULL; // Memory allocation failure
4144
}
4245

4346
// Copy the first data block

src/Oop/RFC.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ struct SerializeData {
1111
uint32_t size;
1212
};
1313

14-
SerializeData *merge(SerializeData a, SerializeData b, bool divide=true);
14+
SerializeData *merge(SerializeData a, SerializeData b, bool divide = true);
1515

16-
struct SerializeData *mergeSerializeData(struct SerializeData data1, struct SerializeData data2, bool divide=true);
16+
struct SerializeData *mergeSerializeData(struct SerializeData data1,
17+
struct SerializeData data2,
18+
bool divide = true);
1719

18-
class RFC {
20+
class RFC {
1921
public:
2022
Module *m;
2123
const uint32_t fidx;

src/Oop/proxy_supervisor.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) {
188188

189189
// array as hexa
190190
const uint32_t hexa_size = serializationSize * 2;
191-
auto *hexa =
192-
new char[hexa_size + 2]; //+2 for '\n' and '0' termination
191+
auto *hexa = new char[hexa_size + 2]; //+2 for '\n' and '0' termination
193192
chars_as_hexa(hexa, buffer, serializationSize);
194193
hexa[hexa_size] = '\n';
195194
hexa[hexa_size + 1] = '\0'; // TODO remove zero termination and +2 above
@@ -251,7 +250,6 @@ bool ProxySupervisor::call(RFC *callee) {
251250
printf("serializing RFC\n");
252251
struct SerializeData *rfc_request = this->serializeRFC(callee);
253252

254-
printf("sending to proxy: %s ...", static_cast<const char *>((void *)rfc_request->raw));
255253
bool sent = this->send((void *)rfc_request->raw, rfc_request->size);
256254
if (!sent) {
257255
callee->success = false;
@@ -263,10 +261,10 @@ bool ProxySupervisor::call(RFC *callee) {
263261
}
264262
// Fetch new callback mapping
265263
// convert message to hex TODO: move to proxyserver
266-
// char cmdBuffer[10] = "";
267-
// int cmdBufferLen = 0;
268-
// sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, &cmdBufferLen);
269-
// this->send(cmdBuffer, cmdBufferLen);
264+
// char cmdBuffer[10] = "";
265+
// int cmdBufferLen = 0;
266+
// sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping,
267+
// &cmdBufferLen); this->send(cmdBuffer, cmdBufferLen);
270268
this->deserializeRFCResult(callee);
271269
printf("end of supervisor::call(rfc)\n");
272270
return true;

src/Oop/stateful.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ char *sync_memory(Module *m, uint32_t start, uint32_t end) {
66
uint8_t len = end - start;
77
auto *buffer = (char *)calloc(sizeof(char), (2 * len) + 8);
88

9-
sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start, end);
9+
sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start,
10+
end);
1011
auto target = m->memory.bytes + start;
1112
slebf(buffer + 6, target, len, "\n");
1213

src/Primitives/emulated.cpp

+26-25
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ double sensor_emu = 0;
4040
/*
4141
Private macros to install a primitive
4242
*/
43-
#define install_primitive(prim_name) \
44-
{ \
43+
#define install_primitive(prim_name) \
44+
{ \
4545
dbg_info("installing primitive number: %d of %d with name: %s\n", \
46-
prim_index + 1, ALL_PRIMITIVES, #prim_name); \
47-
if (prim_index < ALL_PRIMITIVES) { \
48-
PrimitiveEntry *p = &primitives[prim_index++]; \
49-
p->name = #prim_name; \
50-
p->t = &(prim_name##_type); \
51-
p->index = prim_index - 1; \
52-
p->f = &(prim_name); \
53-
p->f_reverse = nullptr; \
54-
p->f_serialize_state = nullptr; \
55-
p->f_backward = nullptr; \
56-
p->f_forward = nullptr; \
57-
} else { \
58-
FATAL("prim_index out of bounds"); \
59-
} \
46+
prim_index + 1, ALL_PRIMITIVES, #prim_name); \
47+
if (prim_index < ALL_PRIMITIVES) { \
48+
PrimitiveEntry *p = &primitives[prim_index++]; \
49+
p->name = #prim_name; \
50+
p->t = &(prim_name##_type); \
51+
p->index = prim_index - 1; \
52+
p->f = &(prim_name); \
53+
p->f_reverse = nullptr; \
54+
p->f_serialize_state = nullptr; \
55+
p->f_backward = nullptr; \
56+
p->f_forward = nullptr; \
57+
} else { \
58+
FATAL("prim_index out of bounds"); \
59+
} \
6060
}
6161

6262
#define install_primitive_reverse(prim_name) \
@@ -66,16 +66,16 @@ double sensor_emu = 0;
6666
p->f_serialize_state = &(prim_name##_serialize); \
6767
}
6868

69-
#define install_primitive_backward(prim_name) \
70-
{ \
71-
PrimitiveEntry *p = &primitives[prim_index - 1]; \
72-
p->f_backward = &(prim_name##_backward); \
69+
#define install_primitive_backward(prim_name) \
70+
{ \
71+
PrimitiveEntry *p = &primitives[prim_index - 1]; \
72+
p->f_backward = &(prim_name##_backward); \
7373
}
7474

75-
#define install_primitive_forward(prim_name) \
76-
{ \
77-
PrimitiveEntry *p = &primitives[prim_index - 1]; \
78-
p->f_forward = &(prim_name##_forward); \
75+
#define install_primitive_forward(prim_name) \
76+
{ \
77+
PrimitiveEntry *p = &primitives[prim_index - 1]; \
78+
p->f_forward = &(prim_name##_forward); \
7979
}
8080

8181
#define def_prim(function_name, type) \
@@ -720,7 +720,8 @@ bool do_forward(Module *m, uint32_t index) {
720720
if (primitive.f_forward) {
721721
auto data = primitive.f_forward(m);
722722
printf("transfer built\n");
723-
WARDuino::instance()->debugger->channel->write("%02" PRIx8 "00%02" PRIx8 "%s", interruptTransfer, 1, data);
723+
WARDuino::instance()->debugger->channel->write(
724+
"%02" PRIx8 "00%02" PRIx8 "%s", interruptTransfer, 1, data);
724725
free(data);
725726
}
726727
} else {

src/Utils/util.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ uint32_t write_LEB_signed(uint8_t *dest, uint64_t val, uint64_t bits) {
9696
return count;
9797
}
9898

99-
uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits,
100-
bool sign) {
99+
uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size,
100+
uint32_t bits, bool sign) {
101101
if (size_leb(value) > size) {
102102
return 0;
103103
}
@@ -369,7 +369,7 @@ uint32_t read_L32(uint8_t **bytes) {
369369
return n;
370370
} // TODO replace with read_LEB_32? If keep Big endian use memcpy?
371371

372-
int slebf(char *dest, uint8_t *source, const int size, const char *end) {
372+
int slebf(char *dest, uint8_t *source, const int size, const char *end) {
373373
char *cursor = dest;
374374
for (int i = 0; i < size; i++) {
375375
sprintf(cursor, "%02" PRIx8, source[i]);
@@ -379,8 +379,7 @@ int slebf(char *dest, uint8_t *source, const int size, const char *end) {
379379
return size;
380380
}
381381

382-
void chars_as_hexa(char *dest, unsigned char *source,
383-
uint32_t len_source) {
382+
void chars_as_hexa(char *dest, unsigned char *source, uint32_t len_source) {
384383
for (uint32_t i = 0; i < len_source; i++) {
385384
unsigned c = source[i] >> 4;
386385
unsigned c2 = source[i] & 0xF;

src/Utils/util.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ uint32_t write_LEB_(uint8_t *dest, uint64_t val);
3636
* @param sign Whether the value should be sign-extended.
3737
* @return The number of bytes written.
3838
*/
39-
uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits,
40-
bool sign);
39+
uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size,
40+
uint32_t bits, bool sign);
4141

4242
uint64_t write_LEB_32(uint32_t value, uint8_t *buff, uint32_t size);
4343

0 commit comments

Comments
 (0)