PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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