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

http://github.com/tybor/Liberty · Specman e · 113 lines · 69 code · 20 blank · 24 comment · 6 complexity · f97cd0cc57523f9da91f84af5bd0a3a9 MD5 · raw file

  1. class C_PLUS_PLUS_CLASS
  2. -- A "Class" node of an XML file made by gccxml representing a C++ class.
  3. -- Beware class names includes templates, so they may be like
  4. -- "QFlags<Qt::MouseButton>" escaped as "QFlags%lt;Qt::MouseButton&gt;".
  5. -- C++ and therefore also GccXml does not have the concept of template
  6. -- classes at parsed code level, only within source code.
  7. inherit
  8. COMPOSED_NODE -- hence also a STORABLE_NODE and a NAMED_NODE
  9. undefine compute_eiffel_name end
  10. CONTEXTED_NODE -- therefore also a NAMED_NODE
  11. FILED_NODE
  12. IDENTIFIED_NODE
  13. TYPED_NODE
  14. WRAPPER_CLASS
  15. -- This node also has those fields: demangled, size, align, bases
  16. insert NAME_CONVERTER
  17. creation make
  18. feature
  19. store is
  20. do
  21. create {LINKED_LIST[C_FIELD]} fields.make
  22. types.put(Current,id)
  23. if is_named then
  24. symbols.put(Current,c_string_name)
  25. end
  26. composed_types.put(Current,id)
  27. end
  28. is_fundamental: BOOLEAN is False
  29. is_void: BOOLEAN is False
  30. has_wrapper: BOOLEAN is False
  31. c_type: STRING is
  32. do
  33. if is_artificial then
  34. Result := once "class"
  35. else
  36. Result := once ""
  37. end
  38. end
  39. wrapper_type: STRING is
  40. do
  41. debug
  42. print(once
  43. "C_PLUS_PLUS_CLASS.wrapper_type requires creation%
  44. % of external/expanded types.")
  45. end
  46. not_yet_implemented -- Result := class_name
  47. end
  48. is_to_be_emitted: BOOLEAN is
  49. do
  50. Result:= is_named and then (is_public or has_assigned_name) and then
  51. (global or else headers.has(c_file.c_string_name))
  52. end
  53. emit_wrapper is
  54. local path: POSIX_PATH_NAME
  55. do
  56. if is_to_be_emitted then
  57. create path.make_from_string(directory)
  58. path.add_last(eiffel_name.as_lower+once ".e")
  59. log(once "Class @(1) to @(2) in @(3)%N", <<c_string_name, eiffel_name, path.to_string>>)
  60. create {TEXT_FILE_WRITE} output.connect_to(path.to_string)
  61. -- emit_header
  62. -- emit_members
  63. -- emit_size
  64. -- emit_footer
  65. output.flush
  66. output.disconnect
  67. else
  68. if is_anonymous then log_string(once "Skipping anonymous structure at line "+line.out+".%N")
  69. else log(once "Struct @(1) skipped%N", <<c_string_name>>)
  70. end
  71. end
  72. end
  73. is_artificial: BOOLEAN is
  74. do
  75. Result := attributes.has(once U"artificial") and then attributes.at(once U"artificial").is_equal(once U"1")
  76. end
  77. suffix: STRING is "_CLASS"
  78. class_inherits: STRING is "%N%Ninsert STANDARD_C_LIBRARY_TYPES%N%N"
  79. -- TODO: the above reference to STANDARD_C_LIBRARY_TYPES creates requires
  80. -- to wrap standard C library using a file called
  81. -- "standard-c-library.gcc-xml"; allow the user to specify its name,
  82. end -- class C_PLUS_PLUS_CLASS
  83. -- Copyright 2010 Paolo Redaelli
  84. -- wrappers-generator is free software: you can redistribute it and/or modify it
  85. -- under the terms of the GNU General Public License as published by the Free
  86. -- Software Foundation, either version 2 of the License, or (at your option)
  87. -- any later version.
  88. -- wrappers-generator is distributed in the hope that it will be useful, but
  89. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  90. -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  91. -- more details.
  92. -- You should have received a copy of the GNU General Public License along with
  93. -- this program. If not, see <http://www.gnu.org/licenses/>.