PIPS
xv_transform.c
Go to the documentation of this file.
1 /*
2 
3  $Id: xv_transform.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 
28 #include <stdio.h>
29 
30 #include <sys/time.h>
31 #include <sys/resource.h>
32 #include <xview/xview.h>
33 #include <xview/panel.h>
34 #include <xview/text.h>
35 
36 #if (defined(TEXT))
37 #undef TEXT
38 #endif
39 
40 #if (defined(TEXT_TYPE))
41 #undef TEXT_TYPE
42 #endif
43 
44 #include "genC.h"
45 
46 #include "constants.h"
47 #include "misc.h"
48 #include "linear.h"
49 #include "ri.h"
50 #include "ri-util.h"
51 #include "top-level.h"
52 #include "database.h"
53 #include "pipsmake.h"
54 #include "pipsdbm.h"
55 #include "wpips.h"
56 
57 /* Include the label names: */
58 #include "wpips-labels.h"
59 
60 #include "resources.h"
61 #include "phases.h"
62 
64 #include "wpips_transform_menu_layout.h"
65  /* No more transformations */
66  {
67  NULL, NULL
68  }
69 };
70 
71 
72 /* To pass arguments to execute_safe_apply_outside_the_notifyer(): */
75 
76 
77 /* The transform menu: */
79 
80 void
81 apply_on_each_transform_item(void (* function_to_apply_on_each_menu_item)(Menu_item))
82 {
83  int i;
84  /* Walk through items of */
85  for (i = (int) xv_get(transform_menu, MENU_NITEMS); i > 0; i--) {
86  Menu_item menu_item = (Menu_item) xv_get(transform_menu,
87  MENU_NTH_ITEM, i);
88  /* Skip the title item: */
89  if (!(bool) xv_get(menu_item, MENU_TITLE)
90  && xv_get(menu_item, MENU_NOTIFY_PROC) != NULL)
91  function_to_apply_on_each_menu_item(menu_item);
92  }
93 }
94 
95 
96 void
98 {
100 }
101 
102 
103 void
105 {
107 }
108 
109 
110 void
112 {
116 
117  /* The module list may have changed: */
120 }
121 
122 
123 void
124 safe_apply_outside_the_notifyer(string transformation_name_to_apply,
125  string module_name)
126 {
128  strdup(transformation_name_to_apply);
131  /* Ask to execute the execute_safe_apply_outside_the_notifyer(): */
133  /* I guess the function above does not return... */
134 }
135 
136 
137 void static
139  Menu_item menu_item)
140 {
141  char * label = (char *) xv_get(menu_item, MENU_STRING);
142 
143  char * modulename = db_get_current_module_name();
144 
145  /* FI: borrowed from edit_notify() */
146  if (modulename == NULL) {
147  prompt_user("No module selected");
148  }
149  else {
150  wpips_transform_menu_layout_line * current_transformation;
151 
152  /* Find the transformation to apply: */
153  for (current_transformation = &wpips_transform_menu_layout[0];
154  current_transformation->menu_entry_string != NULL;
155  current_transformation++)
156  if (strcmp(label, current_transformation->menu_entry_string) == 0)
157  break;
158 
159  if (current_transformation->menu_entry_string != NULL)
160  /* Apply the transformation: */
161  safe_apply_outside_the_notifyer(current_transformation->transformation_name_to_apply, modulename);
162  /* I guess the function above does not return... */
163  else
164  pips_internal_error("What is this \"%s\" entry you ask for?", label);
165  }
166 
168 }
169 
170 
171 void
173 {
174  wpips_transform_menu_layout_line * current_transformation;
175 
176  edit_menu_item =
177  xv_create(NULL, MENUITEM,
178  MENU_STRING, EDIT_VIEW,
179  MENU_NOTIFY_PROC, edit_notify,
180  MENU_RELEASE,
181  NULL);
182 
184  xv_create(XV_NULL, MENU_COMMAND_MENU,
185  MENU_GEN_PIN_WINDOW, main_frame, "Transform Menu",
186  MENU_TITLE_ITEM, "Apply a program transformation to a module ",
187  NULL);
188 
189  /* Now add all the transformation entries: */
190  for (current_transformation = &wpips_transform_menu_layout[0];
191  current_transformation->menu_entry_string != NULL;
192  current_transformation++) {
193  if (strcmp(current_transformation->menu_entry_string,
195  xv_set(transform_menu,
196  /* Just a separator: */
198  NULL);
199  else
200  xv_set(transform_menu,
201  MENU_ACTION_ITEM, current_transformation->menu_entry_string,
203  NULL);
204  }
205 
206  /* Add the Edit entry as the last one: */
207  xv_set(transform_menu,
208  /* Just a separator: */
210  MENU_APPEND_ITEM, edit_menu_item,
211  NULL);
212 
213  (void) xv_create(main_panel, PANEL_BUTTON,
214  PANEL_LABEL_STRING, "Transform/Edit",
215  PANEL_ITEM_MENU, transform_menu,
216  0);
217 }
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
void send_the_names_of_the_available_modules_to_emacs(void)
Tell Emacs about what are the modules available in the current workspace, if any:
Definition: emacs.c:137
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void free(void *)
#define EDIT_VIEW
A special view that gives the .f source mainly for edition:
Definition: gpips-labels.h:46
GtkWidget * main_frame
If we are in the Emacs mode, the log_frame is no longer really used:
Definition: gpips.c:60
void execute_main_loop_command(gpips_main_loop_command_type command)
To ask pipsmake to stop as soon as possible:
Definition: gpips.c:267
void edit_notify(GtkWidget *widget, gpointer data)
Definition: gtk_edit2.c:101
GtkWidget * edit_menu_item
Definition: gtk_edit2.c:90
void prompt_user(string a_printf_format,...)
Definition: gtk_log.c:66
void display_memory_usage()
Definition: gtk_status.c:84
#define pips_internal_error
Definition: misc-local.h:149
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723
char * strdup()
The type describing a Transform menu entry:
Definition: wpips-local.h:75
#define WPIPS_MENU_SEPARATOR_ID
How it is specified in the layout .h:
Definition: wpips-local.h:96
@ WPIPS_SAFE_APPLY
Definition: wpips-local.h:68
Panel main_panel
Definition: wpips.c:63
#define WPIPS_MENU_SEPARATOR
Define the menu separator:
Definition: wpips-local.h:94
void enable_menu_item(Menu_item item)
Definition: xv_edit2.c:565
void disable_menu_item(Menu_item item)
Definition: xv_edit2.c:558
void create_transform_menu()
Definition: xv_transform.c:172
static void transform_notify(Menu menu, Menu_item menu_item)
Definition: xv_transform.c:138
void disable_transform_selection()
Definition: xv_transform.c:97
wpips_transform_menu_layout_line wpips_transform_menu_layout[]
Include the label names:
Definition: xv_transform.c:63
void apply_on_each_transform_item(void(*function_to_apply_on_each_menu_item)(Menu_item))
Definition: xv_transform.c:81
void safe_apply_outside_the_notifyer(string transformation_name_to_apply, string module_name)
Definition: xv_transform.c:124
static string execute_safe_apply_outside_the_notifyer_module_name
Definition: xv_transform.c:74
static string execute_safe_apply_outside_the_notifyer_transformation_name_to_apply
To pass arguments to execute_safe_apply_outside_the_notifyer():
Definition: xv_transform.c:73
Menu transform_menu
The transform menu:
Definition: xv_transform.c:78
void execute_safe_apply_outside_the_notifyer()
Definition: xv_transform.c:111
void enable_transform_selection()
Definition: xv_transform.c:104