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

http://github.com/tybor/Liberty · Specman e · 92 lines · 47 code · 12 blank · 33 comment · 3 complexity · 450d51633c394b584bc0eafc4323012b MD5 · raw file

  1. class C_NAMESPACE
  2. -- A node of an XML file made by gccxml representing a C++ namespace.
  3. -- A C++ name-space is modelled in Liberty as a cluster, a directory
  4. -- containing classes, subclusters and how they shall be compiled and
  5. -- linked.
  6. inherit
  7. GCCXML_NODE
  8. CONTEXTED_NODE
  9. NAMED_NODE
  10. redefine compute_eiffel_name
  11. end
  12. IDENTIFIED_NODE
  13. STORABLE_NODE
  14. create {GCCXML_TREE}
  15. make
  16. feature {ANY}
  17. store
  18. do
  19. namespaces.put(Current, id)
  20. if not is_main then
  21. symbols.put(Current, c_string_name)
  22. end
  23. end
  24. is_main: BOOLEAN
  25. -- Is Current name space the "main" default namespace? The default namespace is named "::"
  26. do
  27. Result := c_string_name.is_equal(once "::")
  28. end
  29. path: PATH_NAME
  30. -- Path of the directory representing Current namespace
  31. do
  32. if cached_path = Void then
  33. if is_main then
  34. create {POSIX_PATH_NAME} cached_path.make_current
  35. else
  36. -- Recursively build the path
  37. cached_path := namespace.path / c_string_name
  38. end
  39. end
  40. Result := cached_path
  41. end
  42. are_members_wrapped: BOOLEAN
  43. -- Shall the members of th namespace be wrapped?
  44. compute_eiffel_name
  45. -- Compute cluster name as basename of path (its last part).
  46. do
  47. cached_eiffel_name := path.last
  48. end
  49. emit_wrapper
  50. -- The wrapper of a namespace actually is not any Liberty code but only
  51. -- a directory that will be the cluster representing that namespace.
  52. do
  53. -- local cwd: STRING; bd: BASIC_DIRECTORY;
  54. -- Create a directory named like Current namespace that will contain everything defined in that namespace.
  55. -- Try to create the directory and forget about the result
  56. log("Faking creation of «" + path.to_string + "»directory%N")
  57. -- outcome := bd.create_new_directory(path.to_string);
  58. -- if path.is_directory then
  59. -- are_members_wrapped:=True
  60. -- -- Each gccxml node will query its containing namespace to see if it shall be wrapped.
  61. -- else -- directory still doesn't exists, we cannot wrap its content.
  62. -- log("Namespace `#(1)' would be wrapped into `#(2)', but it is not a directory or could not be created: its contents shall not be wrapped.%N"
  63. -- # c_string_name # path.to_string)
  64. -- end
  65. end
  66. feature {STORABLE_NODE} -- Contained nodes
  67. feature {} -- Implementation
  68. cached_path: PATH_NAME
  69. end -- class C_NAMESPACE
  70. -- Copyright (C) 2008-2017: Paolo Redaelli
  71. -- wrappers-generator is free software: you can redistribute it and/or modify it
  72. -- under the terms of the GNU General Public License as publhed by the Free
  73. -- Software Foundation, either version 2 of the License, or (at your option)
  74. -- any later version.
  75. -- wrappers-generator is distributed in the hope that it will be useful, but
  76. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  77. -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  78. -- more details.
  79. -- You should have received a copy of the GNU General Public License along with
  80. -- th program. If not, see <http://www.gnu.org/licenses/>.