summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2018-07-12 19:38:37 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2018-11-26 13:26:44 +0200
commita3b3135d3398f71368b075219b7021bb726e2bc3 (patch)
tree5133a1aaf7a4a80278773af9c5b344fcfee1bcd5
parentb23b7f9ab66291ff89e247b458c2e1403ff23008 (diff)
Remove useless union
-rw-r--r--src/lib/Clouseau_Debug.h5
-rw-r--r--src/lib/clouseau_debug.c50
-rw-r--r--src/lib/extensions/objects_introspection/main.c28
3 files changed, 40 insertions, 43 deletions
diff --git a/src/lib/Clouseau_Debug.h b/src/lib/Clouseau_Debug.h
index 6b106e8..8a71e24 100644
--- a/src/lib/Clouseau_Debug.h
+++ b/src/lib/Clouseau_Debug.h
@@ -58,10 +58,7 @@ typedef enum
58typedef struct 58typedef struct
59{ 59{
60 Eolian_Debug_Basic_Type type; 60 Eolian_Debug_Basic_Type type;
61 union 61 uint64_t value;
62 {
63 uint64_t value;
64 } value;
65 Eina_List *complex_type_values; 62 Eina_List *complex_type_values;
66} Eolian_Debug_Value; 63} Eolian_Debug_Value;
67 64
diff --git a/src/lib/clouseau_debug.c b/src/lib/clouseau_debug.c
index 1785e83..0307451 100644
--- a/src/lib/clouseau_debug.c
+++ b/src/lib/clouseau_debug.c
@@ -264,7 +264,7 @@ _function_invoke(Eo *ptr, const Eolian_Function *foo, Eolian_Function_Type foo_t
264 if (!ed_type) goto error; 264 if (!ed_type) goto error;
265 265
266 types[ffi_argc] = debug_types[ed_type].ffi_type_p; 266 types[ffi_argc] = debug_types[ed_type].ffi_type_p;
267 values[ffi_argc] = &(params[argc].value.value.value); 267 values[ffi_argc] = &(params[argc].value.value);
268 params[argc].eparam = eo_param; 268 params[argc].eparam = eo_param;
269 ffi_argc++; 269 ffi_argc++;
270 argc++; 270 argc++;
@@ -285,13 +285,13 @@ _function_invoke(Eo *ptr, const Eolian_Function *foo, Eolian_Function_Type foo_t
285 /* Out parameter */ 285 /* Out parameter */
286 if (ed_type == EOLIAN_DEBUG_STRUCT) 286 if (ed_type == EOLIAN_DEBUG_STRUCT)
287 { 287 {
288 params[argc].value.value.value = (uint64_t) calloc(_struct_mem_len_get(eo_type), 1); 288 params[argc].value.value = (uint64_t) calloc(_struct_mem_len_get(eo_type), 1);
289 pointers[ffi_argc] = (char *)params[argc].value.value.value; 289 pointers[ffi_argc] = (char *)params[argc].value.value;
290 } 290 }
291 else 291 else
292 { 292 {
293 params[argc].value.value.value = 0; 293 params[argc].value.value = 0;
294 pointers[ffi_argc] = &(params[argc].value.value.value); 294 pointers[ffi_argc] = &(params[argc].value.value);
295 } 295 }
296 params[argc].value.type = ed_type; 296 params[argc].value.type = ed_type;
297 types[ffi_argc] = &ffi_type_pointer; 297 types[ffi_argc] = &ffi_type_pointer;
@@ -301,7 +301,7 @@ _function_invoke(Eo *ptr, const Eolian_Function *foo, Eolian_Function_Type foo_t
301 { 301 {
302 /* In parameter */ 302 /* In parameter */
303 types[ffi_argc] = debug_types[ed_type].ffi_type_p; 303 types[ffi_argc] = debug_types[ed_type].ffi_type_p;
304 values[ffi_argc] = &(params[argc].value.value.value); 304 values[ffi_argc] = &(params[argc].value.value);
305 } 305 }
306 ffi_argc++; 306 ffi_argc++;
307 argc++; 307 argc++;
@@ -330,7 +330,7 @@ _function_invoke(Eo *ptr, const Eolian_Function *foo, Eolian_Function_Type foo_t
330 { 330 {
331 ffi_ret_type = debug_types[params[0].value.type].ffi_type_p; 331 ffi_ret_type = debug_types[params[0].value.type].ffi_type_p;
332 } 332 }
333 result = (char *)params[0].value.value.value; 333 result = (char *)params[0].value.value;
334 /* If there is no return type but only one value is present, the value will 334 /* If there is no return type but only one value is present, the value will
335 * be returned by the function. 335 * be returned by the function.
336 * So we need FFI to not take it into account when invoking the function. 336 * So we need FFI to not take it into account when invoking the function.
@@ -351,12 +351,12 @@ _function_invoke(Eo *ptr, const Eolian_Function *foo, Eolian_Function_Type foo_t
351 { 351 {
352 if (!param_as_ret) 352 if (!param_as_ret)
353 { 353 {
354 ret->value.value.value = (uint64_t) result; 354 ret->value.value = (uint64_t) result;
355 ret->value.type = ed_type; 355 ret->value.type = ed_type;
356 ret->etype = eo_type; 356 ret->etype = eo_type;
357 } 357 }
358 else 358 else
359 params[0].value.value.value = (uint64_t) result; 359 params[0].value.value = (uint64_t) result;
360 } 360 }
361 goto success; 361 goto success;
362 } 362 }
@@ -580,26 +580,26 @@ _class_buffer_fill(Eo *obj, const Eolian_Class *ekl, char *buf)
580 // if its a string we wont copy the pointer but the value 580 // if its a string we wont copy the pointer but the value
581 if (params[i].value.type == EOLIAN_DEBUG_STRING) 581 if (params[i].value.type == EOLIAN_DEBUG_STRING)
582 { 582 {
583 if((char *)params[i].value.value.value == NULL) 583 if((char *)params[i].value.value == NULL)
584 params[i].value.value.value = (uint64_t)""; 584 params[i].value.value = (uint64_t)"";
585 len = strlen((char *)params[i].value.value.value) + 1; 585 len = strlen((char *)params[i].value.value) + 1;
586 memcpy(buf + size, (char *)params[i].value.value.value, len); 586 memcpy(buf + size, (char *)params[i].value.value, len);
587 size += len; 587 size += len;
588 } 588 }
589 else if (params[i].value.type == EOLIAN_DEBUG_STRUCT) 589 else if (params[i].value.type == EOLIAN_DEBUG_STRUCT)
590 { 590 {
591 const Eolian_Type *eo_type = eolian_parameter_type_get(params[i].eparam); 591 const Eolian_Type *eo_type = eolian_parameter_type_get(params[i].eparam);
592 size += _struct_buffer_fill(buf+size, eo_type, (char *)params[i].value.value.value); 592 size += _struct_buffer_fill(buf+size, eo_type, (char *)params[i].value.value);
593 } 593 }
594 else 594 else
595 { 595 {
596 const Eolian_Type *eo_type = eolian_parameter_type_get(params[i].eparam); 596 const Eolian_Type *eo_type = eolian_parameter_type_get(params[i].eparam);
597 size += _param_buffer_fill(buf+size, params[i].value.value.value, 597 size += _param_buffer_fill(buf+size, params[i].value.value,
598 debug_types[params[i].value.type].size); 598 debug_types[params[i].value.type].size);
599 if (params[i].value.type == EOLIAN_DEBUG_LIST) 599 if (params[i].value.type == EOLIAN_DEBUG_LIST)
600 { 600 {
601 size += _complex_buffer_fill(buf+size, eo_type, 601 size += _complex_buffer_fill(buf+size, eo_type,
602 params[i].value.value.value); 602 params[i].value.value);
603 } 603 }
604 } 604 }
605 } 605 }
@@ -615,20 +615,20 @@ _class_buffer_fill(Eo *obj, const Eolian_Class *ekl, char *buf)
615 //if its a string we wont copy the pointer but the values 615 //if its a string we wont copy the pointer but the values
616 if (ret.value.type == EOLIAN_DEBUG_STRING) 616 if (ret.value.type == EOLIAN_DEBUG_STRING)
617 { 617 {
618 if((char *)ret.value.value.value == NULL) 618 if((char *)ret.value.value == NULL)
619 ret.value.value.value = (uint64_t)""; 619 ret.value.value = (uint64_t)"";
620 len = strlen((char *)ret.value.value.value) + 1; 620 len = strlen((char *)ret.value.value) + 1;
621 memcpy(buf + size, (char *)ret.value.value.value, len); 621 memcpy(buf + size, (char *)ret.value.value, len);
622 size += len; 622 size += len;
623 } 623 }
624 else 624 else
625 { 625 {
626 size += _param_buffer_fill(buf+size, ret.value.value.value, 626 size += _param_buffer_fill(buf+size, ret.value.value,
627 debug_types[ret.value.type].size); 627 debug_types[ret.value.type].size);
628 if (ret.value.type == EOLIAN_DEBUG_LIST) 628 if (ret.value.type == EOLIAN_DEBUG_LIST)
629 { 629 {
630 size += _complex_buffer_fill(buf+size, 630 size += _complex_buffer_fill(buf+size,
631 ret.etype, ret.value.value.value); 631 ret.etype, ret.value.value);
632 } 632 }
633 } 633 }
634 } 634 }
@@ -1358,7 +1358,7 @@ eolian_debug_object_information_free(Eolian_Debug_Object_Information *main)
1358 EINA_LIST_FREE(func->params, param) 1358 EINA_LIST_FREE(func->params, param)
1359 { 1359 {
1360 if (param->value.type == EOLIAN_DEBUG_STRING) 1360 if (param->value.type == EOLIAN_DEBUG_STRING)
1361 eina_stringshare_del((char *)param->value.value.value); 1361 eina_stringshare_del((char *)param->value.value);
1362 free(param); 1362 free(param);
1363 } 1363 }
1364 free(func); 1364 free(func);
@@ -1411,7 +1411,7 @@ _value_decode(char **buffer, unsigned int *size, const Eolian_Type *eo_type, Eol
1411 if (type == EOLIAN_DEBUG_STRING) 1411 if (type == EOLIAN_DEBUG_STRING)
1412 { 1412 {
1413 len = strlen(*buffer) + 1; 1413 len = strlen(*buffer) + 1;
1414 v->value.value = (uint64_t) eina_stringshare_add(*buffer); 1414 v->value = (uint64_t) eina_stringshare_add(*buffer);
1415 *buffer += len; 1415 *buffer += len;
1416 *size -= len; 1416 *size -= len;
1417 } 1417 }
@@ -1435,7 +1435,7 @@ _value_decode(char **buffer, unsigned int *size, const Eolian_Type *eo_type, Eol
1435 { 1435 {
1436 uint64_t value = 0;; 1436 uint64_t value = 0;;
1437 EXTRACT(*buffer, &value, debug_types[type].size); 1437 EXTRACT(*buffer, &value, debug_types[type].size);
1438 v->value.value = SWAP_64(value); 1438 v->value = SWAP_64(value);
1439 *size -= debug_types[type].size; 1439 *size -= debug_types[type].size;
1440 if (type == EOLIAN_DEBUG_LIST) 1440 if (type == EOLIAN_DEBUG_LIST)
1441 { 1441 {
diff --git a/src/lib/extensions/objects_introspection/main.c b/src/lib/extensions/objects_introspection/main.c
index fac54e4..4d14811 100644
--- a/src/lib/extensions/objects_introspection/main.c
+++ b/src/lib/extensions/objects_introspection/main.c
@@ -368,7 +368,7 @@ _ptr_highlight(Clouseau_Extension *ext, Eolian_Debug_Value *v)
368 { 368 {
369 case EOLIAN_DEBUG_POINTER: 369 case EOLIAN_DEBUG_POINTER:
370 { 370 {
371 _obj_highlight(ext, v->value.value); 371 _obj_highlight(ext, v->value);
372 break; 372 break;
373 } 373 }
374 case EOLIAN_DEBUG_LIST: 374 case EOLIAN_DEBUG_LIST:
@@ -376,7 +376,7 @@ _ptr_highlight(Clouseau_Extension *ext, Eolian_Debug_Value *v)
376 Eina_List *itr; 376 Eina_List *itr;
377 EINA_LIST_FOREACH(v->complex_type_values, itr, v) 377 EINA_LIST_FOREACH(v->complex_type_values, itr, v)
378 { 378 {
379 _obj_highlight(ext, v->value.value); 379 _obj_highlight(ext, v->value);
380 } 380 }
381 break; 381 break;
382 } 382 }
@@ -464,66 +464,66 @@ _eolian_value_to_string(Eolian_Debug_Value *value, Eina_Strbuf *buf)
464 case EOLIAN_DEBUG_STRING: 464 case EOLIAN_DEBUG_STRING:
465 { 465 {
466 eina_strbuf_append_printf(buf, "\"%s\" ", 466 eina_strbuf_append_printf(buf, "\"%s\" ",
467 (char *)value->value.value); 467 (char *)value->value);
468 break; 468 break;
469 } 469 }
470 case EOLIAN_DEBUG_POINTER: 470 case EOLIAN_DEBUG_POINTER:
471 { 471 {
472 eina_strbuf_append_printf(buf, "%p ", 472 eina_strbuf_append_printf(buf, "%p ",
473 (void *)value->value.value); 473 (void *)value->value);
474 break; 474 break;
475 } 475 }
476 case EOLIAN_DEBUG_CHAR: 476 case EOLIAN_DEBUG_CHAR:
477 { 477 {
478 eina_strbuf_append_printf(buf, "%c ", 478 eina_strbuf_append_printf(buf, "%c ",
479 (char)value->value.value); 479 (char)value->value);
480 break; 480 break;
481 } 481 }
482 case EOLIAN_DEBUG_INT: 482 case EOLIAN_DEBUG_INT:
483 { 483 {
484 eina_strbuf_append_printf(buf, "%d ", 484 eina_strbuf_append_printf(buf, "%d ",
485 (int)value->value.value); 485 (int)value->value);
486 break; 486 break;
487 } 487 }
488 case EOLIAN_DEBUG_SHORT: 488 case EOLIAN_DEBUG_SHORT:
489 { 489 {
490 eina_strbuf_append_printf(buf, "%u ", 490 eina_strbuf_append_printf(buf, "%u ",
491 (unsigned int)value->value.value); 491 (unsigned int)value->value);
492 break; 492 break;
493 } 493 }
494 case EOLIAN_DEBUG_DOUBLE: 494 case EOLIAN_DEBUG_DOUBLE:
495 { 495 {
496 eina_strbuf_append_printf(buf, "%f ", 496 eina_strbuf_append_printf(buf, "%f ",
497 (double)value->value.value); 497 (double)value->value);
498 break; 498 break;
499 } 499 }
500 case EOLIAN_DEBUG_BOOLEAN: 500 case EOLIAN_DEBUG_BOOLEAN:
501 { 501 {
502 eina_strbuf_append_printf(buf, "%s ", 502 eina_strbuf_append_printf(buf, "%s ",
503 (value->value.value ? "true" : "false")); 503 (value->value ? "true" : "false"));
504 break; 504 break;
505 } 505 }
506 case EOLIAN_DEBUG_LONG: 506 case EOLIAN_DEBUG_LONG:
507 { 507 {
508 eina_strbuf_append_printf(buf, "%ld ", 508 eina_strbuf_append_printf(buf, "%ld ",
509 (long)value->value.value); 509 (long)value->value);
510 break; 510 break;
511 } 511 }
512 case EOLIAN_DEBUG_UINT: 512 case EOLIAN_DEBUG_UINT:
513 { 513 {
514 eina_strbuf_append_printf(buf, "%u ", 514 eina_strbuf_append_printf(buf, "%u ",
515 (unsigned int)value->value.value); 515 (unsigned int)value->value);
516 break; 516 break;
517 } 517 }
518 case EOLIAN_DEBUG_LIST: 518 case EOLIAN_DEBUG_LIST:
519 { 519 {
520 Eina_List *l = value->complex_type_values, *itr; 520 Eina_List *l = value->complex_type_values, *itr;
521 eina_strbuf_append_printf(buf, "%lX [", value->value.value); 521 eina_strbuf_append_printf(buf, "%lX [", value->value);
522 EINA_LIST_FOREACH(l, itr, value) 522 EINA_LIST_FOREACH(l, itr, value)
523 { 523 {
524 eina_strbuf_append_printf(buf, "%s%lX", 524 eina_strbuf_append_printf(buf, "%s%lX",
525 l != itr ? ", " : "", 525 l != itr ? ", " : "",
526 value->value.value); 526 value->value);
527 } 527 }
528 eina_strbuf_append(buf, "]"); 528 eina_strbuf_append(buf, "]");
529 break; 529 break;
@@ -538,7 +538,7 @@ _eolian_value_to_string(Eolian_Debug_Value *value, Eina_Strbuf *buf)
538 } 538 }
539 break; 539 break;
540 } 540 }
541 default: eina_strbuf_append_printf(buf, "%lX ", value->value.value); 541 default: eina_strbuf_append_printf(buf, "%lX ", value->value);
542 } 542 }
543} 543}
544 544