1
0

shell_dump.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * shell_dump.c
  3. */
  4. #include "private.h"
  5. #ifdef DEBUG
  6. #include "lub/dump.h"
  7. /*--------------------------------------------------------- */
  8. void clish_shell_dump(clish_shell_t * this)
  9. {
  10. clish_view_t *v;
  11. clish_ptype_t *t;
  12. clish_var_t *var;
  13. lub_bintree_iterator_t iter;
  14. lub_dump_printf("shell(%p)\n", this);
  15. lub_dump_printf("OVERVIEW:\n%s\n", LUB_DUMP_STR(this->overview));
  16. lub_dump_indent();
  17. v = lub_bintree_findfirst(&this->view_tree);
  18. /* iterate the tree of views */
  19. for (lub_bintree_iterator_init(&iter, &this->view_tree, v);
  20. v; v = lub_bintree_iterator_next(&iter)) {
  21. clish_view_dump(v);
  22. }
  23. /* iterate the tree of types */
  24. t = lub_bintree_findfirst(&this->ptype_tree);
  25. for (lub_bintree_iterator_init(&iter, &this->ptype_tree, t);
  26. t; t = lub_bintree_iterator_next(&iter)) {
  27. clish_ptype_dump(t);
  28. }
  29. /* iterate the tree of vars */
  30. var = lub_bintree_findfirst(&this->var_tree);
  31. for (lub_bintree_iterator_init(&iter, &this->var_tree, var);
  32. var; var = lub_bintree_iterator_next(&iter)) {
  33. clish_var_dump(var);
  34. }
  35. lub_dump_undent();
  36. }
  37. /*--------------------------------------------------------- */
  38. #endif /* DEBUG */
  39. /*--------------------------------------------------------- */
  40. void clish_shell_xml2c(clish_shell_t *this)
  41. {
  42. // clish_view_t *v;
  43. clish_ptype_t *t;
  44. // clish_var_t *var;
  45. lub_bintree_iterator_t iter;
  46. printf("#include \"private.h\"\n"
  47. "#include \"lub/string.h\"\n"
  48. "#include <stdlib.h>\n"
  49. "#include <string.h>\n"
  50. "#include <assert.h>\n"
  51. "#include <errno.h>\n"
  52. "#include <sys/types.h>\n"
  53. "\n"
  54. );
  55. printf("int clish_shell_load_scheme(clish_shell_t *shell, const char *xml_path)\n"
  56. "{\n\n");
  57. /* Iterate the tree of types */
  58. printf("/*########## PTYPE ##########*/\n\n");
  59. t = lub_bintree_findfirst(&this->ptype_tree);
  60. for (lub_bintree_iterator_init(&iter, &this->ptype_tree, t);
  61. t; t = lub_bintree_iterator_next(&iter)) {
  62. clish_ptype_xml2c(t);
  63. }
  64. #if 0
  65. v = lub_bintree_findfirst(&this->view_tree);
  66. /* iterate the tree of views */
  67. for (lub_bintree_iterator_init(&iter, &this->view_tree, v);
  68. v; v = lub_bintree_iterator_next(&iter)) {
  69. clish_view_dump(v);
  70. }
  71. /* iterate the tree of vars */
  72. var = lub_bintree_findfirst(&this->var_tree);
  73. for (lub_bintree_iterator_init(&iter, &this->var_tree, var);
  74. var; var = lub_bintree_iterator_next(&iter)) {
  75. clish_var_dump(var);
  76. }
  77. #endif
  78. printf("\n"
  79. "return 0;\n"
  80. "}\n"
  81. );
  82. }