shell_dump.c 2.5 KB

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