The preprocessor cpp has a long history in software development for the implementation of variable source code. By means of preprocessor directives (e.g., #if, #ifdef, and #ifndef) a programmer annotates variable parts of the source code. The implementation of variable source code is also a major aim of feature-oriented programming. In feature-oriented programming variable source code is represented by feature-modules. a feature-module is a folder that contains all source code (e.g., new classes or class refinements) that a feature adds to the existing code base. Although, #ifdef-annotated source code and feature modules share the same goal of implementing variable source code, the transformation of one in another is complicated. This project deals with the transformation of #ifdef-annotated source code in feature-modules.
cnife is an extensible Java library for the (semi)automatic transformation of #ifdef annotated source code in C++ programs into FeatureC++ feature-modules (see FeatureC++ project website for more information). cnife recognizes a set of patterns automatically (#ifdef usage in software systems) and tries to transform the annotated code into feature-modules.
/* Config.cpp */
#define NOSORT 0
#define INSERTIONSORT 1
#define BUBBLESORT 2
#define DLINKED 1
#define SORTALGO INSERTIONSORT
#if SORTALGO != NOSORT
#define UPWARD 0
#define DOWNWARD 1
#define SORTORDER DOWNWARD
#endif
/* Node.cpp */
class Node {
public:
int data;
Node *next;
#if DLINKED
Node *prev;
#endif
};
/* List.cpp */
LinkedList::LinkedList() {
first = NULL;
#if DLINKED
last = NULL;
#endif
return;
}
void LinkedList::insert( int newData ) {
Node *n = new Node();
n->data = newData;
#if SORTALGO == BUBBLESORT || SORTALGO == INSERTIONSORT
Node *a = NULL;
Node *b = NULL;
#endif
#if SORTALGO == BUBBLESORT
Node *c = NULL;
Node *e = NULL;
Node *tmp = NULL;
#endif
if (NULL == first) {
first = n;
} else {
...
java -jar cnife.jar --inputfolder ./test/list
cnife has been developed at the University of Passau, Germany. For more information please contact the developers: