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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
-- Copyright (C) 1999 Daniel Elphick and others
-- Licensed under Eiffel Forum Freeware License, version 1;
-- (see forum.txt)
--
indexing
description: "This class is responsible for generating the eiffel code"
author: "Daniel Elphick <de397@ecs.soton.ac.uk>"
cvs: "$Id: code_generator.e,v 1.16 2002/02/26 07:31:44 elphick Exp $"
class CODE_GENERATOR
inherit
GLOBALS
BASIC_DIRECTORY
CLASS_INDEX
creation
make
feature
program_name: STRING
directory: STRING
src_directory: STRING
interface: TAG_TREE
root_class: ROOT_CLASS_WRITER
top_level_class: TOP_LEVEL_CLASS_WRITER
custom_class: CUSTOM_CLASS_WRITER
make(tree: TAG_TREE; dirname: STRING) is
-- Writes all the source files into the specified
-- directory (if empty, current directory)
require
valid_tree: tree /= Void
local
temp_tree: TAG_TREE
project: TAG_TREE
do
interface := tree.find_child("GTK-Interface")
if interface = Void then
print("GTK-Interface tag must be at root%N")
die_with_code(exit_failure_code)
end
project := interface.find_child("project")
if project = Void then
print("GTK-Interface must have a project tag%N")
die_with_code(exit_failure_code)
end
set_project_name(project.get_string_from_field("name"))
program_name := project.get_string_from_field("program_name")
-- Code to find the directory
-- however I think this is useless as I've never seen glade fill
-- this field in!
if program_name.count = 0 then
program_name.make_from_string(project_name)
end
temp_tree := project.find_child("directory")
if temp_tree = Void then
print("Project must have a directory field%N")
die_with_code(exit_failure_code)
end
directory ?= temp_tree @ 0
if directory.is_empty then
directory := clone(dirname)
end
if directory.is_empty then
directory := "."
end
temp_tree := project.find_child("source_directory")
if temp_tree = Void then
print("Project must have a source directory field%N")
die_with_code(exit_failure_code)
end
src_directory ?= temp_tree @ 0
if src_directory.is_empty then
src_directory := directory
else
src_directory.precede('/')
src_directory.prepend(directory)
end
generate_root_name(program_name, src_directory)
print("Project name : " + project_name + "%N")
print("Program name : " + program_name + "%N")
print("Directory : " + directory +"%N")
print("Source directory : " + src_directory + "%N")
-- file_tools.mkdir(directory)
-- file_tools.mkdir(src_directory)
if basic_directory_open(directory.to_external).is_null then
print("Could not open directory " + directory + "%N")
die_with_code(exit_failure_code)
end
if basic_directory_open(src_directory.to_external).is_null then
if not basic_directory_mkdir(src_directory.to_external) then
print("Could not create directory " + src_directory + "%N")
die_with_code(exit_failure_code)
end
end
src_directory.extend('/')
!!root_class.make(interface, project, src_directory)
!!top_level_class.make(interface, root_class.root_features,
src_directory)
!!custom_class.make(src_directory)
root_class.write_gtk_classes
root_class.write_class
top_level_class.write_class
custom_class.write_class
write_loadpath
end
write_loadpath is
-- Write loadpath.se which includes paths to eGTK
local
loadpath_file: TEXT_FILE_WRITE
loadpath_file_name: STRING
do
loadpath_file_name := clone(src_directory)
loadpath_file_name.append("loadpath.se")
if file_exists(loadpath_file_name) then
print("loadpath.se exists%N")
else
!!loadpath_file.connect_to(loadpath_file_name)
if is_vegtk then
loadpath_file.put_string("${VEGTK}/VEGTK/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/enums/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/externals/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/externals/se/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/se/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/support/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/support/se/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/support/vese/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gtk/vese/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gdk/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gdk/enums/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gdk/enums/se/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gdk/externals/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/gdk/vese/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/support/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/support/se/%N")
loadpath_file.put_string("${VEGTK}/VEGTK/support/vese/%N")
else
loadpath_file.put_string("${EGNOME}/loadpath.se%N")
loadpath_file.put_string("${EGTK}/loadpath.se%N")
end
loadpath_file.disconnect
print("Wrote loadpath.se%N")
end
end
end
|