/src/wrappers/llvm/library/values/llvm_const_string.e

http://github.com/tybor/Liberty · Specman e · 60 lines · 23 code · 12 blank · 25 comment · 0 complexity · e6a996117ac4ec78edab207aa13ea8b8 MD5 · raw file

  1. class LLVM_CONST_STRING
  2. -- An LLVM constant string value.
  3. -- LLVM allows strings to be null-terminated and not-null-terminated.
  4. -- Currently only null-terminated strings are supported.
  5. -- TODO: Provide access to non-null-terminated strings.
  6. inherit LLVM_VALUE
  7. create {ANY} from_string, from_string_non_null_terminated, in_context
  8. feature {} -- Creation
  9. from_string (a_text: ABSTRACT_STRING)
  10. -- A new NULL-terminated constant string containing `a_text'.
  11. require text_non_void: a_text /= Void
  12. do
  13. from_external_pointer(llvmconst_string(a_text.to_external, (a_text.count+1).to_natural_32, 1))
  14. -- Note: the meaning of the underlying argument dontnullterminate - here set to 1 - seems to be the opposite of what I understood.
  15. end
  16. from_string_non_null_terminated (a_text: ABSTRACT_STRING)
  17. -- A new non NULL-terminated constant string containing `a_text'.
  18. require text_non_void: a_text /= Void
  19. do
  20. from_external_pointer(llvmconst_string(a_text.to_external, (a_text.count+1).to_natural_32, 0))
  21. -- Note: the meaning of the underlying argument dontnullterminate - here set to 0 - seems to be the opposite of what I understood.
  22. end
  23. in_context (a_context: LLVM_CONTEXT; a_text: ABSTRACT_STRING; do_not_null_terminate: BOOLEAN)
  24. -- Create a new constant string containing `a_text'.
  25. -- TODO: Clarify the meaning of `do_not_null_terminate'
  26. require
  27. context_non_void: a_context/=Void
  28. text_non_void: a_text/=Void
  29. do
  30. from_external_pointer(llvmconst_string_in_context
  31. (a_context.handle, a_text.to_external, (a_text.count+1).to_natural_32, do_not_null_terminate.to_integer))
  32. end
  33. end -- class LLVM_CONST_STRING
  34. -- Copyright (C) 2009-2017: ,2010,2013 Paolo Redaelli - 2013 Cyril Adrian
  35. -- This file is part of LLVM wrappers for Liberty Eiffel.
  36. --
  37. -- This library is free software: you can redistribute it and/or modify
  38. -- it under the terms of the GNU Lesser General Public License as published by
  39. -- the Free Software Foundation, version 3 of the License.
  40. --
  41. -- Liberty Eiffel is distributed in the hope that it will be useful,
  42. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  43. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44. -- GNU General Public License for more details.
  45. --
  46. -- You should have received a copy of the GNU General Public License
  47. -- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>.
  48. --