1 #include <bash/Config.h>
3 #define MAX_NUMBER_OF_INPUTS 9
5 // -------------------------------------------------------------------------
6 int main( int argc, char* argv[] )
12 << "Usage: " << argv[ 0 ]
13 << " definitons_file object_name output_file"
18 std::string definitions_filename = argv[ 1 ];
19 std::string object_name = argv[ 2 ];
20 std::string output_filename = argv[ 3 ];
23 std::string definitions_buffer;
24 if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) )
28 << ": Error reading definitions file \"" << definitions_filename
34 // Put it in a line-by-line structure
35 TStrings definitions_lines;
36 cpPlugins_bash::Tokenize( definitions_lines, definitions_buffer, "\n" );
40 cpPlugins_bash::Parse( commands, definitions_lines );
42 // Load pre-compiled definitions
43 cpPlugins_bash::LoadDefinitions( commands );
46 TCommands definitions;
47 cpPlugins_bash::ExpandDefinitions( definitions, commands );
50 std::stringstream data;
52 << "#ifndef __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl
53 << "#define __cpPlugins__Demanglers__" << object_name << "__h__" << std::endl
56 for( auto cIt = commands.begin( ); cIt != commands.end( ); ++cIt )
58 if( cIt->first == "define" )
62 cpPlugins_bash::Expand( instances, definitions, commands, cIt->first );
64 cpPlugins_bash::Tokenize( toks, cIt->first, "|" );
65 for( unsigned int nIns = 1; nIns <= MAX_NUMBER_OF_INPUTS; ++nIns )
67 if( toks.size( ) > 1 )
70 << "#define cpPlugins_Demangle_" << object_name << "_"
71 << toks[ 0 ] << "_" << nIns << "( o, f";
72 for( unsigned int i = 1; i < toks.size( ); ++i )
73 data << ", " << toks[ i ];
77 << "#define cpPlugins_Demangle_" << object_name << "_"
78 << toks[ 0 ] << "_" << nIns << "( o, f";
80 for( unsigned int i = 1; i < nIns; ++i )
85 std::string prefix = "";
86 for( auto iIt = instances.begin( ); iIt != instances.end( ); ++iIt )
90 << "if( dynamic_cast< " << *iIt << "* >( o ) != NULL ) \\"
92 << " this->f( dynamic_cast< " << *iIt << "* >( o )";
94 for( unsigned int i = 1; i < nIns; ++i )
102 data << " " << prefix << std::endl << std::endl;
109 << "#endif // __cpPlugins__Demanglers__" << object_name << "__h__"
111 if( !( cpPlugins_bash::Write( data.str( ), output_filename ) ) )
113 std::cerr << "Error writing file." << std::endl;