PIPS
xv_transform.c File Reference
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/text.h>
#include "genC.h"
#include "constants.h"
#include "misc.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "top-level.h"
#include "database.h"
#include "pipsmake.h"
#include "pipsdbm.h"
#include "wpips.h"
#include "wpips-labels.h"
#include "resources.h"
#include "phases.h"
#include "wpips_transform_menu_layout.h"
+ Include dependency graph for xv_transform.c:

Go to the source code of this file.

Functions

void apply_on_each_transform_item (void(*function_to_apply_on_each_menu_item)(Menu_item))
 
void disable_transform_selection ()
 
void enable_transform_selection ()
 
void execute_safe_apply_outside_the_notifyer ()
 
void safe_apply_outside_the_notifyer (string transformation_name_to_apply, string module_name)
 
static void transform_notify (Menu menu, Menu_item menu_item)
 
void create_transform_menu ()
 

Variables

wpips_transform_menu_layout_line wpips_transform_menu_layout []
 Include the label names: More...
 
static string execute_safe_apply_outside_the_notifyer_transformation_name_to_apply = NULL
 To pass arguments to execute_safe_apply_outside_the_notifyer(): More...
 
static string execute_safe_apply_outside_the_notifyer_module_name = NULL
 
Menu transform_menu
 The transform menu: More...
 

Function Documentation

◆ apply_on_each_transform_item()

void apply_on_each_transform_item ( void(*)(Menu_item)  function_to_apply_on_each_menu_item)

Walk through items of

Skip the title item:

Definition at line 81 of file xv_transform.c.

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 }
Menu transform_menu
The transform menu:
Definition: xv_transform.c:78

References transform_menu.

Referenced by disable_transform_selection(), and enable_transform_selection().

+ Here is the caller graph for this function:

◆ create_transform_menu()

void create_transform_menu ( )

Now add all the transformation entries:

Just a separator:

Add the Edit entry as the last one:

Just a separator:

Definition at line 172 of file xv_transform.c.

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 }
#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 edit_notify(GtkWidget *widget, gpointer data)
Definition: gtk_edit2.c:101
GtkWidget * edit_menu_item
Definition: gtk_edit2.c:90
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
Panel main_panel
Definition: wpips.c:63
#define WPIPS_MENU_SEPARATOR
Define the menu separator:
Definition: wpips-local.h:94
static void transform_notify(Menu menu, Menu_item menu_item)
Definition: xv_transform.c:138
wpips_transform_menu_layout_line wpips_transform_menu_layout[]
Include the label names:
Definition: xv_transform.c:63

References edit_menu_item, edit_notify(), EDIT_VIEW, main_frame, main_panel, wpips_transform_menu_layout_line::menu_entry_string, transform_menu, transform_notify(), WPIPS_MENU_SEPARATOR, WPIPS_MENU_SEPARATOR_ID, and wpips_transform_menu_layout.

+ Here is the call graph for this function:

◆ disable_transform_selection()

void disable_transform_selection ( )

Definition at line 97 of file xv_transform.c.

98 {
100 }
void disable_menu_item(Menu_item item)
Definition: xv_edit2.c:558
void apply_on_each_transform_item(void(*function_to_apply_on_each_menu_item)(Menu_item))
Definition: xv_transform.c:81

References apply_on_each_transform_item(), and disable_menu_item().

+ Here is the call graph for this function:

◆ enable_transform_selection()

void enable_transform_selection ( )

Definition at line 104 of file xv_transform.c.

105 {
107 }
void enable_menu_item(Menu_item item)
Definition: xv_edit2.c:565

References apply_on_each_transform_item(), and enable_menu_item().

+ Here is the call graph for this function:

◆ execute_safe_apply_outside_the_notifyer()

void execute_safe_apply_outside_the_notifyer ( )

The module list may have changed:

Definition at line 111 of file xv_transform.c.

112 {
116 
117  /* The module list may have changed: */
120 }
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
void free(void *)
void display_memory_usage()
Definition: gtk_status.c:84
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723
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

References display_memory_usage(), execute_safe_apply_outside_the_notifyer_module_name, execute_safe_apply_outside_the_notifyer_transformation_name_to_apply, free(), safe_apply(), and send_the_names_of_the_available_modules_to_emacs().

Referenced by wpips_main_loop().

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

◆ safe_apply_outside_the_notifyer()

void safe_apply_outside_the_notifyer ( string  transformation_name_to_apply,
string  module_name 
)

Ask to execute the execute_safe_apply_outside_the_notifyer():

I guess the function above does not return...

Definition at line 124 of file xv_transform.c.

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 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void execute_main_loop_command(gpips_main_loop_command_type command)
To ask pipsmake to stop as soon as possible:
Definition: gpips.c:267
char * strdup()
@ WPIPS_SAFE_APPLY
Definition: wpips-local.h:68

References execute_main_loop_command(), execute_safe_apply_outside_the_notifyer_module_name, execute_safe_apply_outside_the_notifyer_transformation_name_to_apply, module_name(), strdup(), and WPIPS_SAFE_APPLY.

Referenced by transform_notify().

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

◆ transform_notify()

static void transform_notify ( Menu  menu,
Menu_item  menu_item 
)
static

FI: borrowed from edit_notify()

Find the transformation to apply:

Apply the transformation:

I guess the function above does not return...

Definition at line 138 of file xv_transform.c.

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 }
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
#define pips_internal_error
Definition: misc-local.h:149
void safe_apply_outside_the_notifyer(string transformation_name_to_apply, string module_name)
Definition: xv_transform.c:124

References db_get_current_module_name(), display_memory_usage(), wpips_transform_menu_layout_line::menu_entry_string, pips_internal_error, prompt_user(), safe_apply_outside_the_notifyer(), wpips_transform_menu_layout_line::transformation_name_to_apply, and wpips_transform_menu_layout.

Referenced by create_transform_menu().

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

Variable Documentation

◆ execute_safe_apply_outside_the_notifyer_module_name

string execute_safe_apply_outside_the_notifyer_module_name = NULL
static

◆ execute_safe_apply_outside_the_notifyer_transformation_name_to_apply

string execute_safe_apply_outside_the_notifyer_transformation_name_to_apply = NULL
static

◆ transform_menu

Menu transform_menu

The transform menu:

Definition at line 78 of file xv_transform.c.

Referenced by apply_on_each_transform_item(), and create_transform_menu().

◆ wpips_transform_menu_layout

wpips_transform_menu_layout_line wpips_transform_menu_layout[]
Initial value:
= {
{
NULL, NULL
}
}

Include the label names:

Definition at line 63 of file xv_transform.c.

Referenced by create_transform_menu(), and transform_notify().