+++ /dev/null
-#include <bash/Config.h>
-
-#define MAX_NUMBER_OF_INPUTS 9
-
-// -------------------------------------------------------------------------
-int main( int argc, char* argv[] )
-{
- // Get inputs
- if( argc < 4 )
- {
- std::cerr
- << "Usage: " << argv[ 0 ]
- << " definitons_file object_name output_file"
- << std::endl;
- return( 1 );
-
- } // fi
- std::string definitions_filename = argv[ 1 ];
- std::string object_name = argv[ 2 ];
- std::string output_filename = argv[ 3 ];
-
- // Read inputs
- std::string definitions_buffer;
- if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) )
- {
- std::cerr
- << argv[ 0 ]
- << ": Error reading definitions file \"" << definitions_filename
- << "\"" << std::endl;
- return( 1 );
-
- } // fi
-
- // Put it in a line-by-line structure
- TStrings definitions_lines;
- cpPlugins_bash::Tokenize( definitions_lines, definitions_buffer, "\n" );
-
- // Parse input file
- TCommands commands;
- cpPlugins_bash::Parse( commands, definitions_lines );
-
- // Load pre-compiled definitions
- cpPlugins_bash::LoadDefinitions( commands );
-
- // Expand definitions
- TCommands definitions;
- cpPlugins_bash::ExpandDefinitions( definitions, commands );
-
- // Expand data
- std::stringstream data;
- data
- << "#ifndef __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl
- << "#define __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl
- << std::endl;
-
- for( auto cIt = commands.begin( ); cIt != commands.end( ); ++cIt )
- {
- if( cIt->first == "define" )
- continue;
-
- TStrings instances;
- cpPlugins_bash::Expand( instances, definitions, commands, cIt->first );
- TStrings toks;
- cpPlugins_bash::Tokenize( toks, cIt->first, "|" );
- for( unsigned int nIns = 1; nIns <= MAX_NUMBER_OF_INPUTS; ++nIns )
- {
- if( toks.size( ) > 1 )
- {
- data
- << "#define cpPlugins_Demangle_" << object_name << "_"
- << toks[ 0 ] << "_" << nIns << "( o, f";
- for( unsigned int i = 1; i < toks.size( ); ++i )
- data << ", " << toks[ i ];
- }
- else
- data
- << "#define cpPlugins_Demangle_" << object_name << "_"
- << toks[ 0 ] << "_" << nIns << "( o, f";
-
- for( unsigned int i = 1; i < nIns; ++i )
- data << ", X" << i;
- data << " ) \\";
-
- data << std::endl;
- std::string prefix = "";
- for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt )
- {
- data
- << " " << prefix
- << "if( dynamic_cast< " << *iIt << "* >( o ) != NULL ) \\"
- << std::endl
- << " this->f( dynamic_cast< " << *iIt << "* >( o )";
-
- for( unsigned int i = 1; i < nIns; ++i )
- data << ", X" << i;
- data
- << " ); \\"
- << std::endl;
- prefix = "else ";
-
- } // rof
- data << " " << prefix << std::endl << std::endl;
-
- } // rof
-
- } // rof
-
- data
- << "#endif // __cpPlugins__Demanglers__" << object_name << "__h__"
- << std::endl;
- if( !( cpPlugins_bash::Write( data.str( ), output_filename ) ) )
- {
- std::cerr << "Error writing file." << std::endl;
- return( 1 );
-
- } // fi
-
- return( 0 );
-}
-
-// eof - $RCSfile$