1
0

shell_dump.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. /* Declare vars */
  58. printf("clish_var_t *var;\n");
  59. printf("clish_action_t *action;\n");
  60. printf("\n");
  61. /* Iterate the tree of types */
  62. printf("/*########## PTYPE ##########*/\n\n");
  63. t = lub_bintree_findfirst(&this->ptype_tree);
  64. for (lub_bintree_iterator_init(&iter, &this->ptype_tree, t);
  65. t; t = lub_bintree_iterator_next(&iter)) {
  66. clish_ptype_xml2c(t);
  67. }
  68. /* Iterate the tree of vars */
  69. printf("/*########## VAR ##########*/\n\n");
  70. var = lub_bintree_findfirst(&this->var_tree);
  71. for (lub_bintree_iterator_init(&iter, &this->var_tree, var);
  72. var; var = lub_bintree_iterator_next(&iter)) {
  73. clish_var_xml2c(var);
  74. }
  75. #if 0
  76. v = lub_bintree_findfirst(&this->view_tree);
  77. /* iterate the tree of views */
  78. for (lub_bintree_iterator_init(&iter, &this->view_tree, v);
  79. v; v = lub_bintree_iterator_next(&iter)) {
  80. clish_view_dump(v);
  81. }
  82. #endif
  83. printf("\n"
  84. "return 0;\n"
  85. "}\n"
  86. );
  87. }