PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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