IDL compiler front-end library
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
IDL_FrontEnd Class Referenceabstract

IDL front-end. More...

#include <IDL_FrontEnd.h>

Classes

class  CmdLine
 Command line argument iterator. More...
 

Public Member Functions

int main (int argc, const char *const argv[]) noexcept
 Call this method from the main() function. More...
 
int run (const char *command, int argc, const char *const argv[]) noexcept
 The same as main (), but aruments must not include the first main() argument (executable file name). More...
 
unsigned flags () const noexcept
 
std::ostream & err_out () const noexcept
 

Static Public Member Functions

static const char * filename (const char *path) noexcept
 Get file name from path. More...
 

Static Public Attributes

static const unsigned FLAG_DEPRECATE_ANONYMOUS_TYPES = 1
 Disallows anonymous IDL types as required by the C++11 Language Mapping Specification.
 
static const unsigned FLAG_DEPRECATE_PSEUDO_INTERFACES = 2
 Disallows pseudo interfaces.
 
static const unsigned FLAG_ENABLE_CONST_OBJREF = 4
 Allow Nirvana const interface references.
 

Protected Member Functions

 IDL_FrontEnd (unsigned flags=0, std::ostream &err_out=std::cerr)
 Constructor. More...
 
virtual void parse_arguments (CmdLine &args)
 Parse command line parameters. More...
 
virtual bool parse_command_line (CmdLine &args)
 Parse command line parameter. More...
 
virtual void print_usage_info (const char *exe_name)
 Prints usage information to std::cout. More...
 
std::vector< std::string > & defines () noexcept
 
std::vector< std::string > & undefines () noexcept
 
std::vector< std::string > & include_paths () noexcept
 
std::vector< std::string > & includes () noexcept
 
std::vector< std::string > & files () noexcept
 
virtual void generate_code (const AST::Root &tree)=0
 Generate user code from AST. More...
 
virtual void file_begin (const std::filesystem::path &file, AST::Builder &builder)
 Begin of the file parsing. More...
 
virtual void interface_end (const AST::Interface &itf, AST::Builder &builder)
 End of the interface parsing. More...
 

Friends

class AST::Builder
 

Detailed Description

IDL front-end.

Performs:

The compiler class should derive from this class and implement virtual void generate_code ();

Examples
IDL_Print.cpp.

Definition at line 62 of file IDL_FrontEnd.h.

Constructor & Destructor Documentation

◆ IDL_FrontEnd()

IDL_FrontEnd::IDL_FrontEnd ( unsigned  flags = 0,
std::ostream &  err_out = std::cerr 
)
inlineprotected

Constructor.

Parameters
flagsThe flags. Currently only IDL_FrontEnd::FLAG_DEPRECATE_ANONYMOUS_TYPES is supported.
err_outCompiler messages output stream. Default is std::cerr.
Examples
IDL_Print.cpp.

Definition at line 166 of file IDL_FrontEnd.h.

Member Function Documentation

◆ main()

int IDL_FrontEnd::main ( int  argc,
const char *const  argv[] 
)
inlinenoexcept

Call this method from the main() function.

Parameters
argcCount of command line arguments.
argvCommand line arguments.
Returns
The 0 if no errors, otherwise -1.

Definition at line 70 of file IDL_FrontEnd.h.

◆ run()

int IDL_FrontEnd::run ( const char *  command,
int  argc,
const char *const  argv[] 
)
noexcept

The same as main (), but aruments must not include the first main() argument (executable file name).

Parameters
commandThe command name for usage info. You can use filename (argv [0]).
argcCount of command line arguments.
argvCommand line arguments.
Returns
The 0 if no errors, otherwise -1.

◆ filename()

static const char* IDL_FrontEnd::filename ( const char *  path)
staticnoexcept

Get file name from path.

Parameters
pathThe file path.
Returns
The file name.

◆ flags()

unsigned IDL_FrontEnd::flags ( ) const
inlinenoexcept
Returns
Flags parameter specified in constructor.

Definition at line 91 of file IDL_FrontEnd.h.

◆ err_out()

std::ostream& IDL_FrontEnd::err_out ( ) const
inlinenoexcept
Returns
Compiler messages output stream.

Definition at line 106 of file IDL_FrontEnd.h.

◆ parse_arguments()

virtual void IDL_FrontEnd::parse_arguments ( CmdLine args)
protectedvirtual

Parse command line parameters.

User can override this method to do some parameter fix/check. For example, user can add include paths from the environment.

Parameters
argsCmdLine object.

◆ parse_command_line()

virtual bool IDL_FrontEnd::parse_command_line ( CmdLine args)
protectedvirtual

Parse command line parameter.

User can override this method to parse additional parameters. The user method must call IDL_FrontEnd::parse_command_line () first to let the IDL_FrontEnd parse it's arguments. If the IDL_FrontEnd::parse_command_line () returns false, user method may parse it's own arguments. If the argument is recognized, args.next () must be called for advance to the next argument.

Switches recognized by IDL_FrontEnd:

  • -D definition Define a symbol.
  • -U definition Undefine a sy
  • -I include_path Add directory to the include directories.
  • -FI include_file Include a file.
  • -h Display usage information.
Parameters
argsCmdLine object.
Returns
true if command line parameter was recognized.
Exceptions
std::invalid_argumentIf the argument was recognized but the syntax is invalid.
Examples
IDL_Print.cpp.

◆ print_usage_info()

virtual void IDL_FrontEnd::print_usage_info ( const char *  exe_name)
protectedvirtual

Prints usage information to std::cout.

User can override this method to print additional information.

Parameters
exe_nameThe name of program executable file obtained from argv[0].
Examples
IDL_Print.cpp.

◆ defines()

std::vector<std::string>& IDL_FrontEnd::defines ( )
inlineprotectednoexcept
Returns
Macros to define.

Definition at line 209 of file IDL_FrontEnd.h.

◆ undefines()

std::vector<std::string>& IDL_FrontEnd::undefines ( )
inlineprotectednoexcept
Returns
Macros to undefine.

Definition at line 215 of file IDL_FrontEnd.h.

◆ include_paths()

std::vector<std::string>& IDL_FrontEnd::include_paths ( )
inlineprotectednoexcept
Returns
Paths to find included files.

Definition at line 221 of file IDL_FrontEnd.h.

◆ includes()

std::vector<std::string>& IDL_FrontEnd::includes ( )
inlineprotectednoexcept
Returns
Files to include.

Definition at line 227 of file IDL_FrontEnd.h.

◆ files()

std::vector<std::string>& IDL_FrontEnd::files ( )
inlineprotectednoexcept
Returns
Files to compile.

Definition at line 233 of file IDL_FrontEnd.h.

◆ generate_code()

virtual void IDL_FrontEnd::generate_code ( const AST::Root tree)
protectedpure virtual

Generate user code from AST.

User must override this method.

Parameters
treeAST::Root object.
Exceptions
std::runtime_errorFor displaying the error message and compile next file. Other exceptions will cause the compilation interruption.
Examples
IDL_Print.cpp.

◆ file_begin()

virtual void IDL_FrontEnd::file_begin ( const std::filesystem::path &  file,
AST::Builder builder 
)
inlineprotectedvirtual

Begin of the file parsing.

Parameters
fileThe IDL file path.
builderThe AST builder. User can use this object to inject some initial items to the empty AST.

Definition at line 252 of file IDL_FrontEnd.h.

◆ interface_end()

virtual void IDL_FrontEnd::interface_end ( const AST::Interface itf,
AST::Builder builder 
)
inlineprotectedvirtual

End of the interface parsing.

User can override this method for interface post-processing, e. g. AMI IDL generation. This method is called on the end of interface from the IDL file. It is not called on Builder::interface_end () call.

Parameters
itfThe parsed interface.
builderThe AST builder.

Definition at line 263 of file IDL_FrontEnd.h.


The documentation for this class was generated from the following file: