@@ -524,13 +524,16 @@ APP_ERROR_CODES processInputFile(const Context & c, bin2cpp::IGenerator * genera
524524 if (!ra::filesystem::FileExists (c.inputFilePath .c_str ()))
525525 return APP_ERROR_INPUTFILENOTFOUND;
526526
527- Context cCopy = c;
528-
529527 // prepare output files path
530- std::string cppFilename = cCopy .headerFilename ;
528+ std::string cppFilename = c .headerFilename ;
531529 ra::strings::Replace (cppFilename, " .hpp" , " .cpp" );
532530 ra::strings::Replace (cppFilename, " .h" , " .cpp" );
533531
532+ // create a copy of the context.
533+ // we may have already generated files from a previous call to processInputFile().
534+ // make sure the file paths are unique.
535+ Context cCopy = c;
536+
534537 // build unique output relative file paths
535538 cCopy.headerFilename = bin2cpp::getUniqueFilePath (cCopy.headerFilename , output_files_dictionary);
536539 cppFilename = bin2cpp::getUniqueFilePath (cppFilename, output_files_dictionary);
@@ -540,7 +543,7 @@ APP_ERROR_CODES processInputFile(const Context & c, bin2cpp::IGenerator * genera
540543 std::string outputCppPath = cCopy.outputDirPath + ra::filesystem::GetPathSeparatorStr () + cppFilename;
541544
542545 // configure the generator
543- generator->setContext (c );
546+ generator->setContext (cCopy );
544547
545548 // build the output directory structure if required
546549 if (cCopy.keepDirectoryStructure )
@@ -732,8 +735,9 @@ APP_ERROR_CODES processManagerFiles(const Context & c)
732735 std::string outputHeaderPath = c.outputDirPath + ra::filesystem::GetPathSeparatorStr () + c.managerHeaderFilename ;
733736 std::string outputCppPath = c.outputDirPath + ra::filesystem::GetPathSeparatorStr () + cppFilename;
734737
735- // init generator
736738 ManagerGenerator generator;
739+
740+ // configure the generator
737741 generator.setContext (c);
738742
739743 // process files
@@ -755,10 +759,8 @@ APP_ERROR_CODES processPlainOutput(const Context & c, bin2cpp::IGenerator * gene
755759 if (!ra::filesystem::FileExists (c.inputFilePath .c_str ()))
756760 return APP_ERROR_INPUTFILENOTFOUND;
757761
758- Context cCopy = c;
759-
760762 // configure the generator
761- generator->setContext (cCopy );
763+ generator->setContext (c );
762764
763765 // process file
764766 bool result = generator->printFileContent ();
0 commit comments