PageRenderTime 949ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/library/xslt/src/function/xm_xslt_system_function_library.e

http://github.com/gobo-eiffel/gobo
Specman e | 137 lines | 120 code | 14 blank | 3 comment | 31 complexity | 73f05db6627fd6a3cb72808b37cb2862 MD5 | raw file
  1. note
  2. description:
  3. "Objects that provide access to standard XSLT and core XPATH functions"
  4. library: "Gobo Eiffel XSLT Library"
  5. copyright: "Copyright (c) 2004-2015, Colin Adams and others"
  6. license: "MIT License"
  7. date: "$Date$"
  8. revision: "$Revision$"
  9. class XM_XSLT_SYSTEM_FUNCTION_LIBRARY
  10. inherit
  11. XM_XPATH_CORE_FUNCTION_LIBRARY
  12. redefine
  13. is_function_available, bind_function
  14. end
  15. create
  16. make
  17. feature -- Access
  18. is_function_available (a_fingerprint, an_arity: INTEGER; is_restricted: BOOLEAN): BOOLEAN
  19. -- Does `a_fingerprint' represent an available function with `an_arity'?
  20. do
  21. if a_fingerprint = Current_function_type_code and then not is_restricted then
  22. Result := an_arity = -1 or else an_arity = 0
  23. elseif a_fingerprint = Current_group_function_type_code and then not is_restricted then
  24. Result := an_arity = -1 or else an_arity = 0
  25. elseif a_fingerprint = Current_grouping_key_function_type_code and then not is_restricted then
  26. Result := an_arity = -1 or else an_arity = 0
  27. elseif a_fingerprint = Document_function_type_code and then not is_restricted then
  28. Result := an_arity = -1 or else an_arity = 1 or else an_arity = 2
  29. elseif a_fingerprint = Element_available_function_type_code then
  30. Result := an_arity = -1 or else an_arity = 1
  31. elseif a_fingerprint = Format_date_function_type_code and then not is_restricted then
  32. Result := an_arity = -1 or else an_arity = 2 or else an_arity = 5
  33. elseif a_fingerprint = Format_datetime_function_type_code and then not is_restricted then
  34. Result := an_arity = -1 or else an_arity = 2 or else an_arity = 5
  35. elseif a_fingerprint = Format_number_function_type_code and then not is_restricted then
  36. Result := an_arity = -1 or else an_arity = 2 or else an_arity = 3
  37. elseif a_fingerprint = Format_time_function_type_code and then not is_restricted then
  38. Result := an_arity = -1 or else an_arity = 2 or else an_arity = 5
  39. elseif a_fingerprint = Function_available_function_type_code then
  40. Result := an_arity = -1 or else an_arity = 1 or else an_arity = 2
  41. elseif a_fingerprint = Generate_id_function_type_code and then not is_restricted then
  42. Result := an_arity = -1 or else an_arity = 0 or else an_arity = 1
  43. elseif a_fingerprint = Key_function_type_code and then not is_restricted then
  44. Result := an_arity = -1 or else an_arity = 2 or else an_arity = 3
  45. elseif a_fingerprint = Regex_group_function_type_code then
  46. Result := an_arity = -1 or else an_arity = 1
  47. elseif a_fingerprint = System_property_function_type_code then
  48. Result := an_arity = -1 or else an_arity = 1
  49. elseif a_fingerprint = Type_available_function_type_code then
  50. Result := an_arity = -1 or else an_arity = 1
  51. elseif a_fingerprint = Unparsed_entity_uri_function_type_code and then not is_restricted then
  52. Result := an_arity = -1 or else an_arity = 1
  53. elseif a_fingerprint = Unparsed_entity_public_id_function_type_code and then not is_restricted then
  54. Result := an_arity = -1 or else an_arity = 1
  55. elseif a_fingerprint = Unparsed_text_function_type_code and then not is_restricted then
  56. Result := an_arity = -1 or else an_arity = 1 or else an_arity = 2
  57. elseif a_fingerprint = Unparsed_text_available_function_type_code and then not is_restricted then
  58. Result := an_arity = -1 or else an_arity = 1 or else an_arity = 2
  59. else
  60. Result := Precursor (a_fingerprint, an_arity, is_restricted)
  61. end
  62. end
  63. feature -- Element change
  64. bind_function (a_fingerprint: INTEGER; some_arguments: DS_ARRAYED_LIST [XM_XPATH_EXPRESSION]; is_restricted: BOOLEAN)
  65. -- Bind `a_fingerprint' to it's definition as `last_bound_function'.
  66. local
  67. a_function_call: detachable XM_XPATH_FUNCTION_CALL
  68. precursor_called: BOOLEAN
  69. do
  70. inspect a_fingerprint
  71. when Current_function_type_code then
  72. create {XM_XSLT_CURRENT} a_function_call.make
  73. when Current_group_function_type_code then
  74. create {XM_XSLT_CURRENT_GROUP} a_function_call.make
  75. when Current_grouping_key_function_type_code then
  76. create {XM_XSLT_CURRENT_GROUPING_KEY} a_function_call.make
  77. when Document_function_type_code then
  78. create {XM_XSLT_DOCUMENT_FUNCTION} a_function_call.make
  79. when Element_available_function_type_code then
  80. create {XM_XSLT_ELEMENT_AVAILABLE} a_function_call.make
  81. when Format_date_function_type_code then
  82. create {XM_XSLT_FORMAT_DATE_TIME} a_function_call.make_date
  83. when Format_datetime_function_type_code then
  84. create {XM_XSLT_FORMAT_DATE_TIME} a_function_call.make_date_time
  85. when Format_number_function_type_code then
  86. create {XM_XSLT_FORMAT_NUMBER} a_function_call.make
  87. when Format_time_function_type_code then
  88. create {XM_XSLT_FORMAT_DATE_TIME} a_function_call.make_time
  89. when Function_available_function_type_code then
  90. create {XM_XSLT_FUNCTION_AVAILABLE} a_function_call.make
  91. when Generate_id_function_type_code then
  92. create {XM_XSLT_GENERATE_ID} a_function_call.make
  93. when Key_function_type_code then
  94. create {XM_XSLT_KEY_FUNCTION} a_function_call.make
  95. when Regex_group_function_type_code then
  96. create {XM_XSLT_REGEX_GROUP} a_function_call.make
  97. when System_property_function_type_code then
  98. create {XM_XSLT_SYSTEM_PROPERTY} a_function_call.make
  99. when Type_available_function_type_code then
  100. create {XM_XSLT_TYPE_AVAILABLE} a_function_call.make
  101. when Unparsed_entity_uri_function_type_code then
  102. create {XM_XSLT_UNPARSED_ENTITY_URI} a_function_call.make
  103. when Unparsed_entity_public_id_function_type_code then
  104. create {XM_XSLT_UNPARSED_ENTITY_PUBLIC_ID} a_function_call.make
  105. when Unparsed_text_function_type_code then
  106. create {XM_XSLT_UNPARSED_TEXT} a_function_call.make
  107. when Unparsed_text_available_function_type_code then
  108. create {XM_XSLT_UNPARSED_TEXT_AVAILABLE} a_function_call.make
  109. else
  110. precursor_called := True
  111. Precursor (a_fingerprint, some_arguments, is_restricted)
  112. end
  113. if not precursor_called then
  114. check
  115. function_bound: a_function_call /= Void
  116. -- From pre-condition
  117. then
  118. a_function_call.set_arguments (some_arguments)
  119. last_bound_function := a_function_call
  120. end
  121. end
  122. end
  123. end