Changes between Initial Version and Version 1 of RefactoringSteps/MoveMacro


Ignore:
Timestamp:
Feb 17, 2012, 9:50:25 PM (13 years ago)
Author:
manualwiki
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RefactoringSteps/MoveMacro

    v1 v1  
     1= Move macro = 
     2 
     3This transformation moves macro definitions between two files. Source and target files can be either modules or header files, the conditions are slightly different in every case. The goal of the transformation is to make the moved macro definitions available in every place where they are used. 
     4 
     5Move macro example: 
     6 
     7{{{ 
     8%%header.hrl 
     9 
     10-define(Ok, ok). 
     11}}} 
     12 
     13{{{ 
     14%%mm.erl 
     15 
     16-module(mm). 
     17-define(Person(Name,Age), 
     18        {Name,Age}). 
     19 
     20f() -> ?Person("John",33). 
     21}}} 
     22 
     23Result: 
     24 
     25{{{ 
     26%%header.hrl 
     27 
     28-define(Ok, ok). 
     29-define(Person(Name,Age), 
     30        {Name,Age}). 
     31}}} 
     32 
     33{{{ 
     34%%mm.erl 
     35 
     36-module(mm). 
     37-include("client.hrl"). 
     38 
     39f() -> ?Person("John",33). 
     40}}} 
     41 
     42== Side conditions == 
     43 
     44 * The names of the macros to be moved must not clash with existing macro names in none of: 
     45  * the target file, 
     46  * the target’s included files, 
     47  * files where the target is included. 
     48 
     49 * If the user does not specify the macros to be moved, the transformation starts an interaction to ask the user to specify macros. The user has to select the macros to be moved from a checkbox list. 
     50 
     51 * Moving macros from a header to a module is only allowed if there exist no other module that both includes the header and uses some of the macros to be moved. 
     52 
     53 * An include form can only by introduced when it does not cause inconsistency at the place of inclusion. 
     54 
     55 
     56== Transformation steps and compensations == 
     57 
     58 1. The macro definitions are removed from the source file. 
     59  
     60 2. If the target is a header file that does not exist, the file is created. 
     61 
     62 3. The macro definitions are placed at the end of the target header file, or before the first function of the target module file. 
     63 
     64 4. If a macro is moved into a header file, then every module that uses the record is changed to include the target header file. This is not an issue when the target is a module file.