unit_add_declaration.xsl

Weaving Rule that adds a declaration to a unit.
  • srcML element: src:unit
  • advice type: add
  • codeModifier type: declaration

The declaration is added to the first possible location of the following choices:

  1. Before first function definition
  2. At the end of the unit

Example

#include <stdio.h>
void Foo:foo() {
  printf("foo");
}

Code Modifier

<codeModifier type="declaration">
  <text>const int MAX_WIDTH = 10;</text>
</codeModifier>

Modified Code

#include <stdio.h>
const int MAX_WIDTH = 10;
void Foo:foo() {
  printf("foo");
}

Examples in AspectX Sample Library

CVS Id:
Author:
ibirrer
Copyright:
2004, P&P Software GmbH

Match Templates Summary

* (param: node-set advicemode: weaving_unit_add_declaration_function) - source
Default copy template for adding declarations before a function definiton
src:comment[following-sibling::*[position() = 1 and self::src:function]][1] (param: node-set advicemode: weaving_unit_add_declaration_function) - source
If a function has a comment attached, the declaration is added before the comment
src:function[1] (param: node-set advicemode: weaving_unit_add_declaration_function) - source
This template adds the declaration before the first function that occurs in the source file
Adds a declaration to the first possible location of the following choices:

Match Templates Detail

* (param: node-set advicemode: weaving_unit_add_declaration_function) - source
Default copy template for adding declarations before a function definiton
 
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
src:comment[following-sibling::*[position() = 1 and self::src:function]][1] (param: node-set advicemode: weaving_unit_add_declaration_function) - source
If a function has a comment attached, the declaration is added before the comment
 
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
src:function[1] (param: node-set advicemode: weaving_unit_add_declaration_function) - source
This template adds the declaration before the first function that occurs in the source file
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
Adds a declaration to the first possible location of the following choices: