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

http://github.com/tybor/Liberty · Specman e · 104 lines · 82 code · 12 blank · 10 comment · 4 complexity · ebc4185935c002f4b7e2b76aa65b7071 MD5 · raw file

  1. class C_ARGUMENT
  2. -- An "Argument" node of an XML file made by gccxml.
  3. inherit
  4. C_FUNCTION_ARGUMENT
  5. NAMED_NODE
  6. TYPED_NODE
  7. insert
  8. NAME_CONVERTER
  9. create {GCCXML_TREE}
  10. make
  11. feature {ANY}
  12. is_ellipsis: BOOLEAN False
  13. is_fundamental: BOOLEAN
  14. do
  15. Result := types.at(dequalify(type)).is_fundamental
  16. end
  17. is_void: BOOLEAN
  18. do
  19. Result := types.at(dequalify(type)).is_void
  20. end
  21. has_wrapper: BOOLEAN
  22. local dequalified: UNICODE_STRING; actual_type: C_TYPE
  23. do
  24. -- Previously it was "Result := types.at(dequalify(type)).has_wrapper" but that's too brittle
  25. check type/=Void end -- unnecessary when we will have attached types
  26. dequalified := dequalify(type)
  27. if dequalified /= Void then
  28. actual_type := types.reference_at(dequalified)
  29. if actual_type/=Void then
  30. Result := actual_type.has_wrapper
  31. else
  32. check
  33. Result=False
  34. end
  35. end
  36. else
  37. check
  38. Result=False
  39. end
  40. end
  41. rescue
  42. log("has_wrapper failed. Known types:%N")
  43. types.for_each_item(agent (a_type: C_TYPE)
  44. do
  45. io.put_string(a_type.out)
  46. end(?))
  47. print_run_time_stack
  48. die_with_code(5)
  49. end
  50. wrapper_type: STRING
  51. do
  52. Result := types.at(dequalify(type)).wrapper_type
  53. end
  54. placeholder: STRING
  55. -- The placeholder name of Current, suitable for Liberty as a newly created string.
  56. do
  57. if c_name = Void then
  58. -- Nameless prototype:
  59. if pos /= 0 then
  60. -- the position of Current argment has been set by its
  61. -- function. We trust it to be unique in the function and use
  62. -- it to give a name to this nameless argument
  63. Result := "argument_"
  64. pos.append_in(Result)
  65. else
  66. -- no position set. Using providing sound default, using
  67. -- line and column, which are locally unique.
  68. Result := "an_argument_l"
  69. line.append_in(Result)
  70. Result.append(once "_c")
  71. column.append_in(Result)
  72. end
  73. else
  74. Result := eiffel_argument(c_name.to_utf8)
  75. end
  76. ensure
  77. Result /= Void
  78. not Result.is_empty
  79. end
  80. put_on (a_buffer: FORMATTER)
  81. require else
  82. has_wrapper
  83. local
  84. a_placeholder, a_wrapper_type: STRING
  85. do
  86. -- Cache results of `placeholder' and `wrapper_type' queries
  87. a_placeholder := placeholder
  88. a_wrapper_type := wrapper_type
  89. log(once "#(1): #(2) " # a_placeholder # a_wrapper_type)
  90. a_buffer.append(once "#(1): #(2)" # a_placeholder # a_wrapper_type)
  91. end
  92. end -- class C_ARGUMENT