PIPS
xv_compile.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "misc.h"
#include "phases.h"
#include "database.h"
#include "pipsdbm.h"
#include "pipsmake.h"
#include "top-level.h"
#include "wpips.h"
+ Include dependency graph for xv_compile.c:

Go to the source code of this file.

Macros

#define HPFC_COMPILE   "Compile an HPF program"
 
#define HPFC_MAKE   "Make an HPF program"
 
#define HPFC_RUN   "Run an HPF program"
 

Functions

void apply_on_each_compile_item (void(*function_to_apply_on_each_menu_item)(Menu_item))
 
void disable_compile_selection ()
 
void enable_compile_selection ()
 
void notify_hpfc_file_view (Menu menu, Menu_item menu_item)
 
Menu generate_a_menu_with_HPF_output_files (Menu_item menu_item, Menu_generate action)
 
void initialize_wpips_hpfc_hack_for_fabien_and_from_fabien ()
 
void hpfc_notify (Menu menu, Menu_item menu_item)
 
void create_compile_menu ()
 

Variables

static Menu compile_menu
 
static bool wpips_hpfc_install_was_performed_hack = FALSE
 quick fix around pipsmake, FC, 23/10/95 More...
 

Macro Definition Documentation

◆ HPFC_COMPILE

#define HPFC_COMPILE   "Compile an HPF program"

Definition at line 205 of file xv_compile.c.

◆ HPFC_MAKE

#define HPFC_MAKE   "Make an HPF program"

Definition at line 206 of file xv_compile.c.

◆ HPFC_RUN

#define HPFC_RUN   "Run an HPF program"

Definition at line 207 of file xv_compile.c.

Function Documentation

◆ apply_on_each_compile_item()

void apply_on_each_compile_item ( void(*)(Menu_item)  function_to_apply_on_each_menu_item)

Skip the title item and the separator items:

Definition at line 47 of file xv_compile.c.

49 {
50  int i;
51 
52  for(i = (int) xv_get(compile_menu, MENU_NITEMS); i >= 1; i--) {
53  Menu_item menu_item = (Menu_item) xv_get(compile_menu, MENU_NTH_ITEM, i);
54  /* Skip the title item and the separator items: */
55  if (!(bool) xv_get(menu_item, MENU_TITLE))
56  function_to_apply_on_each_menu_item(menu_item);
57  }
58 }
static Menu compile_menu
Definition: xv_compile.c:44

References compile_menu.

Referenced by disable_compile_selection(), and enable_compile_selection().

+ Here is the caller graph for this function:

◆ create_compile_menu()

void create_compile_menu ( )

Just a separator:

Definition at line 257 of file xv_compile.c.

258 {
259  compile_menu =
260  xv_create(XV_NULL, MENU_COMMAND_MENU,
261  MENU_GEN_PIN_WINDOW, main_frame, "Compile Menu",
262  MENU_TITLE_ITEM, "Compilation ",
263  MENU_ACTION_ITEM, HPFC_COMPILE, hpfc_notify,
264  MENU_ACTION_ITEM, HPFC_MAKE, hpfc_notify,
265  MENU_ACTION_ITEM, HPFC_RUN, hpfc_notify,
266  /* Just a separator: */
268  MENU_GEN_PULLRIGHT_ITEM,
269  "View the HPF Compiler Output",
271  NULL);
272 
273  (void) xv_create(main_panel, PANEL_BUTTON,
274  PANEL_LABEL_STRING, "Compile",
275  PANEL_ITEM_MENU, compile_menu,
276  NULL);
277 }
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
Panel main_panel
Definition: wpips.c:63
#define WPIPS_MENU_SEPARATOR
Define the menu separator:
Definition: wpips-local.h:94
Menu generate_a_menu_with_HPF_output_files(Menu_item menu_item, Menu_generate action)
Definition: xv_compile.c:93
#define HPFC_COMPILE
Definition: xv_compile.c:205
#define HPFC_RUN
Definition: xv_compile.c:207
void hpfc_notify(Menu menu, Menu_item menu_item)
Definition: xv_compile.c:220
#define HPFC_MAKE
Definition: xv_compile.c:206

References compile_menu, generate_a_menu_with_HPF_output_files(), HPFC_COMPILE, HPFC_MAKE, hpfc_notify(), HPFC_RUN, main_frame, main_panel, and WPIPS_MENU_SEPARATOR.

+ Here is the call graph for this function:

◆ disable_compile_selection()

void disable_compile_selection ( )

Definition at line 62 of file xv_compile.c.

63 {
65 }
void apply_on_each_compile_item(void(*function_to_apply_on_each_menu_item)(Menu_item))
Definition: xv_compile.c:47
void disable_menu_item(Menu_item item)
Definition: xv_edit2.c:558

References apply_on_each_compile_item(), and disable_menu_item().

+ Here is the call graph for this function:

◆ enable_compile_selection()

void enable_compile_selection ( )

Definition at line 69 of file xv_compile.c.

70 {
72 }
void enable_menu_item(Menu_item item)
Definition: xv_edit2.c:565

References apply_on_each_compile_item(), and enable_menu_item().

+ Here is the call graph for this function:

◆ generate_a_menu_with_HPF_output_files()

Menu generate_a_menu_with_HPF_output_files ( Menu_item  menu_item,
Menu_generate  action 
)

Create a new menu with the content of the hpfc directory:

First, free the old menu if it exist:

We can remove all the menu it now:

The strdup'ed string will also be freed when the menu is discarded:

We cannot remove the menu here since the notify procedure is called afterward.

Rely on the notify procedure.

Definition at line 93 of file xv_compile.c.

96 {
97  int i;
98  Menu menu;
99  gen_array_t file_names = gen_array_make(0);
100  int file_number = 0;
101 
102  pips_debug(2, "Enter\n");
103 
104  menu = (Menu) xv_get(menu_item, MENU_PULLRIGHT);
105 
106  switch(action) {
107  case MENU_DISPLAY:
108  {
109  int return_code;
110  char *hpfc_directory;
111 
112  pips_debug(2, "MENU_DISPLAY\n");
113 
114  /* Create a new menu with the content of the hpfc directory: */
115 
116  if (menu != NULL) {
117  /* First, free the old menu if it exist: */
118  /* We can remove all the menu it now: */
119  for(i = (int) xv_get(menu, MENU_NITEMS); i > 0; i--) {
120  xv_set(menu, MENU_REMOVE, i, NULL);
121  xv_destroy(xv_get(menu, MENU_NTH_ITEM, i));
122  }
123  xv_destroy(menu);
124  }
125 
126 
127  return_code = hpfc_get_file_list(file_names,
128  &hpfc_directory);
129 
130  if (return_code == -1) {
131  user_warning("generate_a_menu_with_HPF_output_files",
132  "Directory \"%s\" not found... \n"
133  " Have you run the HPFC compiler from the Compile menu?\n",
134  hpfc_directory);
135 
136  menu = (Menu) xv_create(NULL, MENU,
137  MENU_TITLE_ITEM,
138  "Are you sure you used the HPF compiler ?",
139  MENU_ITEM, MENU_STRING,
140  "*** No HPFC directory found ! ***", NULL,
141  NULL);
142  }
143  else if (file_number == 0) {
144  user_warning("generate_a_menu_with_HPF_output_files",
145  "No file found in the directory \"%s\"... \n"
146  " Have you run the HPFC compiler from the Compile menu?\n",
147  hpfc_directory);
148 
149  menu = (Menu) xv_create(NULL, MENU,
150  MENU_TITLE_ITEM,
151  "Are you sure you used the HPF compiler ?",
152  MENU_ITEM, MENU_STRING,
153  "*** No HPFC file found ! ***", NULL,
154  NULL);
155  }
156  else {
157  menu = (Menu) xv_create(NULL, MENU,
158  MENU_TITLE_ITEM,
159  " Select an HPFC file to view ",
160  MENU_NOTIFY_PROC, notify_hpfc_file_view,
161  NULL);
162 
163  for(i = 0; i < file_number; i++)
164  xv_set(menu, MENU_APPEND_ITEM,
165  xv_create(XV_NULL, MENUITEM,
166  MENU_STRING,
167  strdup(gen_array_item(file_names, i)),
168  MENU_RELEASE,
169  /* The strdup'ed string will also be
170  freed when the menu is discarded: */
171  MENU_RELEASE_IMAGE,
172  NULL),
173  NULL);
174 
175  gen_array_full_free(file_names);
176  }
177  break;
178  }
179 
180  case MENU_DISPLAY_DONE:
181  /* We cannot remove the menu here since the notify
182  procedure is called afterward. */
183  menu = (Menu) xv_get(menu_item, MENU_PULLRIGHT);
184  pips_debug(2, "MENU_DISPLAY_DONE\n");
185  break;
186 
187  case MENU_NOTIFY:
188  /* Rely on the notify procedure. */
189  menu = (Menu) xv_get(menu_item, MENU_PULLRIGHT);
190  pips_debug(2, "MENU_NOTIFY\n");
191  break;
192 
193  case MENU_NOTIFY_DONE:
194  menu = (Menu) xv_get(menu_item, MENU_PULLRIGHT);
195  pips_debug(2, "MENU_NOTIFY_DONE\n");
196  break;
197 
198  default:
199  pips_internal_error("Unknown Menu_generate action: %d\n", action);
200  }
201  pips_debug(2, "Exit\n");
202  return menu;
203 }
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_internal_error
Definition: misc-local.h:149
#define user_warning(fn,...)
Definition: misc-local.h:262
int hpfc_get_file_list(gen_array_t, char **)
Definition: source_file.c:106
char * strdup()
void notify_hpfc_file_view(Menu menu, Menu_item menu_item)
Definition: xv_compile.c:76

References gen_array_full_free(), gen_array_item(), gen_array_make(), hpfc_get_file_list(), notify_hpfc_file_view(), pips_debug, pips_internal_error, strdup(), and user_warning.

Referenced by create_compile_menu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hpfc_notify()

void hpfc_notify ( Menu  menu,
Menu_item  menu_item 
)

I apply the installation only once, whatever... Quick fix because the right dependences expressed for pipsmake do not seem to work. It seems that the verification of up to date resources is too clever... FC.

Definition at line 220 of file xv_compile.c.

222 {
223  char *label, *modulename;
224 
225  modulename = db_get_current_module_name();
226  if (!modulename)
227  {
228  prompt_user("No module selected");
229  return;
230  }
231 
232  label = (char *) xv_get(menu_item, MENU_STRING);
233 
234  /* I apply the installation only once, whatever...
235  * Quick fix because the right dependences expressed for pipsmake
236  * do not seem to work. It seems that the verification of up to date
237  * resources is too clever... FC.
238  */
240  {
241  safe_apply(BUILDER_HPFC_INSTALL, modulename);
243  }
244 
245  if (same_string_p(label, HPFC_COMPILE))
246  ;
247  else if (same_string_p(label, HPFC_MAKE))
248  safe_apply_outside_the_notifyer(BUILDER_HPFC_MAKE, modulename);
249  else if (same_string_p(label, HPFC_RUN))
250  safe_apply_outside_the_notifyer(BUILDER_HPFC_RUN, modulename);
251  else
252  pips_internal_error("Bad choice: %s", label);
253 }
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
void safe_apply_outside_the_notifyer(string transformation_name_to_apply, string module_name)
#define same_string_p(s1, s2)
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723
static bool wpips_hpfc_install_was_performed_hack
quick fix around pipsmake, FC, 23/10/95
Definition: xv_compile.c:211

References db_get_current_module_name(), HPFC_COMPILE, HPFC_MAKE, HPFC_RUN, pips_internal_error, prompt_user(), safe_apply(), safe_apply_outside_the_notifyer(), same_string_p, and wpips_hpfc_install_was_performed_hack.

Referenced by create_compile_menu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_wpips_hpfc_hack_for_fabien_and_from_fabien()

void initialize_wpips_hpfc_hack_for_fabien_and_from_fabien ( )

Definition at line 214 of file xv_compile.c.

215 {
217 }

References wpips_hpfc_install_was_performed_hack.

Referenced by close_workspace_notify().

+ Here is the caller graph for this function:

◆ notify_hpfc_file_view()

void notify_hpfc_file_view ( Menu  menu,
Menu_item  menu_item 
)

Try to allocate an available edit_textsw in non-emacs mode:

Definition at line 76 of file xv_compile.c.

78 {
79  char * file_name = (char *) xv_get(menu_item, MENU_STRING);
81 
82  if (! wpips_emacs_mode) {
83  /* Try to allocate an available edit_textsw in non-emacs mode: */
84  (void) alloc_first_initialized_window(FALSE);
85  }
86 
87  wpips_file_view(path_name, file_name, "HPFC File", "HPFC", "HPFC");
88  user_log("HPFC View of \"%s\" done.\n", file_name);
89 }
void user_log(const char *format,...)
Definition: message.c:234
bool wpips_emacs_mode
Here are all the stuff to interface Pips with Emacs.
Definition: emacs.c:65
int alloc_first_initialized_window(bool the_same_as_previous)
Find the first free window if any.
Definition: gtk_edit2.c:215
string hpfc_generate_path_name_of_file_name(const char *)
Return the path of an HPFC file name relative to the current PIPS directory.
Definition: source_file.c:97
static string file_name
void wpips_file_view(char *file_name, char *title_module_name, char *title_label, char *icon_name, char *icon_title)
Display a file in a wpips or epips window:
Definition: xv_edit2.c:277

References alloc_first_initialized_window(), file_name, hpfc_generate_path_name_of_file_name(), user_log(), wpips_emacs_mode, and wpips_file_view().

Referenced by generate_a_menu_with_HPF_output_files().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ compile_menu

Menu compile_menu
static

Definition at line 44 of file xv_compile.c.

Referenced by apply_on_each_compile_item(), and create_compile_menu().

◆ wpips_hpfc_install_was_performed_hack

bool wpips_hpfc_install_was_performed_hack = FALSE
static

quick fix around pipsmake, FC, 23/10/95

Definition at line 211 of file xv_compile.c.

Referenced by hpfc_notify(), and initialize_wpips_hpfc_hack_for_fabien_and_from_fabien().