File: class_writer.e

package info (click to toggle)
eglade 0.3.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 560 kB
  • ctags: 823
  • sloc: yacc: 429; makefile: 174; sh: 24; ansic: 9
file content (132 lines) | stat: -rw-r--r-- 2,357 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
-- Copyright (C) 1999 Daniel Elphick and others
-- Licensed under Eiffel Forum Freeware License, version 1;
-- (see forum.txt)
--
indexing

	description: "Template for all class writers"
	author: "Daniel Elphick <de397@ecs.soton.ac.uk>"

deferred class CLASS_WRITER

inherit

	CONTAINER

	GLOBALS

	VERSION

feature

	file: STD_FILE_WRITE
				
	inherit_from: STRING is
		deferred
		end

	inherit_klass: KLASS is
		do
			!!Result.make_with_name(inherit_from)
		end

	write_inherit is
		local
			children: ARRAY[STRING]
			list: INHERIT_LIST
		do
			if not inherit_list.empty then
				write_line("inherit")
				indent
				write_lines(inherit_list.get_array)
				outdent
				blank_line
			end
		ensure
			indentation_restored: indentation = old indentation
		end

	inherit_list: INHERIT_LIST

	write_make_body is
		deferred
		ensure
			indentation_restored: indentation = old indentation
		end
		
	write_features is
		deferred
		ensure
			indentation_restored: indentation = old indentation
		end
		
	write_creation is
		do
			write_line("creation")
			blank_line
			indent
			write_line("make")
			outdent
			blank_line
		ensure
			indentation_restored: indentation = old indentation
		end

	classname: STRING

	filename: STRING

	write_class is
		local
			i: INTEGER
		do
			print("Writing ")
			print(filename)
			print("%N")
			!!file.connect_to(filename)
			write_line("indexing")
			blank_line
			indent
			write_line("description: %""+ classname +"%"")
			write_line("generated_by: %"eglade " + version + "%"")
			write_line("project_file: %"" + project_file + "%"")
			write_line("date: %"" + gendate +"%"")
			write_line(regeneration_status)
			write_line("CVS: %"$I" + "d$%"")
			outdent
			blank_line
			write_line("class "+classname)
			blank_line
			write_inherit
			write_creation
			write_line("feature")
			blank_line
			indent
			write_features
			blank_line
			write_make_body
			outdent
			blank_line
			write_line("end -- " + classname)
			file.disconnect
		end

	regeneration_status: STRING is
		do
			Result := "on_regeneration: %"This class text will be overwritten%""
		ensure
			Result /= Void and then not Result.empty
		end

	gendate: STRING is
			-- date and time of generating the program
		local
			date: DATE
		once
			!!date
			Result := clone(date.now)
		ensure
			date_set: Result /= Void and then not Result.empty
		end

end