mirror of https://github.com/arendst/Tasmota.git
Fix compilation
This commit is contained in:
parent
3e2cd4f67d
commit
4e57083f52
|
@ -12,7 +12,7 @@
|
||||||
// the first 4 bytes are a pointer to a string
|
// the first 4 bytes are a pointer to a string
|
||||||
// returns 0..total_elements-1 or -1 if not found
|
// returns 0..total_elements-1 or -1 if not found
|
||||||
|
|
||||||
int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements) {
|
int32_t bin_search_ctypes(const char * needle, const void * table, size_t elt_size, size_t total_elements) {
|
||||||
int32_t low = 0;
|
int32_t low = 0;
|
||||||
int32_t high = total_elements - 1;
|
int32_t high = total_elements - 1;
|
||||||
int32_t mid = (low + high) / 2;
|
int32_t mid = (low + high) / 2;
|
||||||
|
@ -109,7 +109,7 @@ int be_ctypes_init(bvm *vm) {
|
||||||
// berry_log_C("be_ctypes_init> init called");
|
// berry_log_C("be_ctypes_init> init called");
|
||||||
|
|
||||||
// look for class definition
|
// look for class definition
|
||||||
int32_t class_idx = bin_search(class_name, &be_ctypes_classes->classes[0], sizeof(be_ctypes_class_t), be_ctypes_classes->size);
|
int32_t class_idx = bin_search_ctypes(class_name, &be_ctypes_classes->classes[0], sizeof(be_ctypes_class_t), be_ctypes_classes->size);
|
||||||
if (class_idx >= 0) {
|
if (class_idx >= 0) {
|
||||||
// found
|
// found
|
||||||
const be_ctypes_structure_t * definitions = be_ctypes_classes->classes[class_idx].definitions;
|
const be_ctypes_structure_t * definitions = be_ctypes_classes->classes[class_idx].definitions;
|
||||||
|
@ -139,7 +139,7 @@ int be_ctypes_member(bvm *vm) {
|
||||||
const char *name = be_tostring(vm, 2);
|
const char *name = be_tostring(vm, 2);
|
||||||
|
|
||||||
// look for member
|
// look for member
|
||||||
int32_t member_idx = bin_search(name, &definitions->items[0], sizeof(be_ctypes_structure_item_t), definitions->size_elt);
|
int32_t member_idx = bin_search_ctypes(name, &definitions->items[0], sizeof(be_ctypes_structure_item_t), definitions->size_elt);
|
||||||
if (member_idx >= 0) {
|
if (member_idx >= 0) {
|
||||||
const be_ctypes_structure_item_t *member = &definitions->items[member_idx];
|
const be_ctypes_structure_item_t *member = &definitions->items[member_idx];
|
||||||
// berry_log_C("member found bytes=%i, bits=%i, len_bits=%i, type=%i", member->offset_bytes, member->offset_bits, member->len_bits, member->type);
|
// berry_log_C("member found bytes=%i, bits=%i, len_bits=%i, type=%i", member->offset_bytes, member->offset_bits, member->len_bits, member->type);
|
||||||
|
@ -193,7 +193,7 @@ int be_ctypes_setmember(bvm *vm) {
|
||||||
const char *name = be_tostring(vm, 2);
|
const char *name = be_tostring(vm, 2);
|
||||||
|
|
||||||
// look for member
|
// look for member
|
||||||
int32_t member_idx = bin_search(name, &definitions->items[0], sizeof(be_ctypes_structure_item_t), definitions->size_elt);
|
int32_t member_idx = bin_search_ctypes(name, &definitions->items[0], sizeof(be_ctypes_structure_item_t), definitions->size_elt);
|
||||||
if (member_idx >= 0) {
|
if (member_idx >= 0) {
|
||||||
const be_ctypes_structure_item_t *member = &definitions->items[member_idx];
|
const be_ctypes_structure_item_t *member = &definitions->items[member_idx];
|
||||||
// berry_log_C("member found bytes=%i, bits=%i, len_bits=%i, type=%i", member->offset_bytes, member->offset_bits, member->len_bits, member->type);
|
// berry_log_C("member found bytes=%i, bits=%i, len_bits=%i, type=%i", member->offset_bytes, member->offset_bits, member->len_bits, member->type);
|
||||||
|
|
|
@ -176,30 +176,30 @@ extern "C" {
|
||||||
// the first 4 bytes are a pointer to a string
|
// the first 4 bytes are a pointer to a string
|
||||||
// returns 0..total_elements-1 or -1 if not found
|
// returns 0..total_elements-1 or -1 if not found
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements);
|
int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements);
|
||||||
// int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements) {
|
int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements) {
|
||||||
// int32_t low = 0;
|
int32_t low = 0;
|
||||||
// int32_t high = total_elements - 1;
|
int32_t high = total_elements - 1;
|
||||||
// int32_t mid = (low + high) / 2;
|
int32_t mid = (low + high) / 2;
|
||||||
// // start a dissect
|
// start a dissect
|
||||||
// while (low <= high) {
|
while (low <= high) {
|
||||||
// const char * elt = *(const char **) ( ((uint8_t*)table) + mid * elt_size );
|
const char * elt = *(const char **) ( ((uint8_t*)table) + mid * elt_size );
|
||||||
// int32_t comp = strcmp(needle, elt);
|
int32_t comp = strcmp(needle, elt);
|
||||||
// if (comp < 0) {
|
if (comp < 0) {
|
||||||
// high = mid - 1;
|
high = mid - 1;
|
||||||
// } else if (comp > 0) {
|
} else if (comp > 0) {
|
||||||
// low = mid + 1;
|
low = mid + 1;
|
||||||
// } else {
|
} else {
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// mid = (low + high) / 2;
|
mid = (low + high) / 2;
|
||||||
// }
|
}
|
||||||
// if (low <= high) {
|
if (low <= high) {
|
||||||
// return mid;
|
return mid;
|
||||||
// } else {
|
} else {
|
||||||
// return -1;
|
return -1;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
|
Loading…
Reference in New Issue