Bug Vanquisher

14 April 2007

Runtime Code Generation in C++ 2

Filed under: C++ — Tanveer Badar @ 12:56 AM

Enough with the background, move along and dig into the dirty details. First, CodeObject: Base class for everyone else, contains no data members and all functions are abstract, provides base services contracts copying, assignment and output operations.

Next the six classes in the top row, they do not have much in themselves and do what their name says. A CodeSnippet is a literal code snippet which you will have trouble getting correct through CPlusPlusCodeProvider; a Comment is, well, just a comment; variable declarations are declarations nothing more than that, though, their implementation is full of quirks; a Namespace represents a namespace; a Typedefinition is a typedefinition. VariableDeclaration has two distinct parts, a declarator and a declarator specifier. This distinction is necessary because you can write something like extern static const int** const k; where everything before the pointers is declarator specifier and applies to all the variables which can be specified in this declaration and from pointers onwards is the declarator which applies to k only and can be different for every variable in the list.

Next, consider the two classes PreprocessorDirective and MacroTestDirective. A preprocessor directive represents anything other than #if, meaning things like #define, #undef, #include, #pragma etc. A MacroTestDirective is for everything like #if, #ifdef, #ifndef etc.

Next time, I’ll be discussing Function and its descendants.

Advertisements

1 Comment »

  1. […] the hell CPPCodeProvider is, here are some links which explain it in much more details: part 1, part 2, part 3, part 4, part 5 and part […]

    Pingback by Major Changes in CPPCodeProvider « Bug Vanquisher — 4 November 2007 @ 6:51 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: