-
Notifications
You must be signed in to change notification settings - Fork 10
Macro Code Generation
Julien SOYSOUVANH edited this page Jul 8, 2021
·
1 revision
The macro specialization of the framework allows generating code to inject back into the source code. The code can be inserted in 4 different locations:
- at the top of a parsed header file (HeaderFileHeader);
- in a parsed struct or class (ClassFooter);
- at the end of a parsed header file (HeaderFileFooter);
- at the top of a source file (SourceFileHeader);
To do so, the generator will generate 2 files, which must be included in the header and source files.
The source code would look like something like this:
//ExampleClass.h
#pragma once
//All includes here
#include "Generated/ExampleClass.h.h" //Generated header file, must be the last include
//Code generated for the "HeaderFileHeader" location is injected as soon as the generated file is included
class Class() ExampleClass
{
//Write some stuff in here
ExampleClass_GENERATED //Code generated for the "ClassFooter" location is injected here
};
File_ExampleClass_GENERATED //Code generated for the "HeaderFileFooter" location is injected here
//ExampleClass.cpp
//All includes here, note that it is not necessary to include ExampleClass.h here since it
//is already included in the generated source file.
#include "Generated/ExampleClass.src.h"
//Code generated for the "SourceFileHeader" location is injected as soon as the generated file is included
//Write your code here as usual