trick/trick_source/codegen/Interface_Code_Gen/ConstructValues.hh
Alex Lin d875f837f2 ICG produces non-compilable io_* code for this weird example #334
When saving the list of namespaces and classes a particular type is contained in
we have to save the class name and any template args it includes separately.  This
allows us to mangle the names easier.  And we now search for type names to see
if they follow this pattern template_name<template_args>::embedded_class.  If
we are using a template embedded class we need to create attributes for the embedded class.
2016-11-02 13:56:40 -05:00

92 lines
3.1 KiB
C++

#ifndef CONSTRUCTVALUES_HH
#define CONSTRUCTVALUES_HH
#include <string>
#include <vector>
#include <utility>
#include "clang/AST/Decl.h"
#include <clang/AST/PrettyPrinter.h>
#include <clang/Basic/LangOptions.h>
/**
ConstructValues is a base class that contains information common to both
classes and enumerations. The information includes the name and location
of the construct, as well as the container namespaces and classes.
@author Alexander S. Lin
@date July 2012
*/
class ConstructValues {
public:
/*
A ContainerClass may be a regular class (zero template_args) or a templated class
The same routines are used to extract the names of the classes from the clang::RecordDecl
data and the to print the class name with or without template arguments.
*/
class ContainerClass {
public:
bool extractType(const clang::RecordDecl * rd) ;
void printTemplateList(std::ostream& ostream, const std::string & delimiter) ;
void printContainerClass(std::ostream& ostream, const std::string & delimiter) ;
private:
bool extractTemplateArgType(const clang::TemplateArgument& ta) ;
std::string name ;
std::vector<ContainerClass> template_args ;
} ;
ConstructValues() ;
void setName(std::string in_name) ;
std::string getName() ;
void setFileName(std::string in_name) ;
std::string getFileName() ;
/** Clears current namespaces and classes */
void clearNamespacesAndClasses() ;
/** Gets all of the container namespaces and classes this construct resides in
returns true if namespaces and classes were succsssfully retrieved.
*/
bool getNamespacesAndClasses( const clang::DeclContext * Ctx ) ;
const std::vector<std::string>& getNamespaces() {
return namespaces;
}
std::string getFullyQualifiedName(const std::string& delimiter = "::") ;
void printOpenNamespaceBlocks(std::ostream& ostream);
void printCloseNamespaceBlocks(std::ostream& ostream);
void printNamespaces(std::ostream& ostream, const std::string& delimiter = "::") ;
void printContainerClasses(std::ostream& ostream, const std::string& delimiter = "::") ;
void printNamespacesAndContainerClasses(std::ostream& ostream, const std::string& delimiter = "::") ;
std::string getNamespacesAndContainerClasses(const std::string& delimiter = "::") ;
std::string getFullyQualifiedTypeName(const std::string& delimiter = "::") ;
protected:
/** Name of the construct */
std::string name ;
/** List of namespaces this class is contained within */
std::vector<std::string> namespaces ;
/** List of container classes this construct is contained within */
std::vector<ContainerClass> container_classes ;
/** File where construct is defined */
std::string file_name ;
const clang::PrintingPolicy printingPolicy = clang::PrintingPolicy(clang::LangOptions());
} ;
#endif