/src/tools/wrappers-generator/contexted_node.e

http://github.com/tybor/Liberty · Specman e · 77 lines · 48 code · 10 blank · 19 comment · 3 complexity · fae1ee401dff05c8d0a5e6ec65281240 MD5 · raw file

  1. deferred class CONTEXTED_NODE
  2. -- A Gccxml node with "context" attribute
  3. inherit
  4. GCCXML_NODE
  5. insert
  6. SHARED_COLLECTIONS
  7. feature {ANY}
  8. context: UNICODE_STRING
  9. do
  10. Result := attribute_at(once U"context")
  11. ensure
  12. Result /= Void
  13. end
  14. namespace: C_NAMESPACE
  15. local
  16. symbol: NAMED_NODE
  17. do
  18. -- unused contexted: CONTEXTED_NODE
  19. if not namespace_retrieved then
  20. sedb_breakpoint
  21. -- Some elements have a context which is their actual
  22. -- namespace; other like fields referes to their container;
  23. -- also in C++ things like a typedef may be containted into a
  24. -- struct. Therefore the actual namespace is contained in
  25. -- context of Current or in the node referred by context.
  26. cached_namespace := namespaces.reference_at(context)
  27. if cached_namespace = Void then
  28. -- Recursively look for the namespace
  29. from
  30. print("Looking for context " + context.as_utf8 + " namespace: ")
  31. symbol := symbols.reference_at(context.as_utf8)
  32. until
  33. cached_namespace /= Void
  34. loop
  35. print(" symbol " + symbol.out)
  36. check
  37. symbol /= Void
  38. end
  39. print(" symbol: " + symbol.out)
  40. cached_namespace ?= symbol
  41. symbol := symbols.reference_at(symbol.attribute_at(once U"context").as_utf8)
  42. end
  43. end
  44. check
  45. cached_namespace /= Void
  46. end
  47. namespace_retrieved := True
  48. end
  49. Result := cached_namespace
  50. ensure
  51. Result /= Void
  52. end
  53. feature {} -- Implementation
  54. cached_namespace: C_NAMESPACE
  55. namespace_retrieved: BOOLEAN
  56. end -- class CONTEXTED_NODE
  57. -- Copyright (C) 2008-2017: ,2009,2010 Paolo Redaelli
  58. -- wrappers-generator is free software: you can redistribute it and/or modify it
  59. -- under the terms of the GNU General Public License as publhed by the Free
  60. -- Software Foundation, either version 2 of the License, or (at your option)
  61. -- any later version.
  62. -- wrappers-generator is distributed in the hope that it will be useful, but
  63. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  64. -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  65. -- more details.
  66. -- You should have received a copy of the GNU General Public License along with
  67. -- th program. If not, see <http://www.gnu.org/licenses/>.