DSPAssembler: Make AssembleFile take a std::string
File paths passed to it would have been implicitly converted to std::strings prior to this function being reached, so it gets rid of some string churn. It also makes it safer since nullptr can't be passed in.
This commit is contained in:
parent
507715f316
commit
cbe1ec51df
|
@ -63,11 +63,11 @@ bool DSPAssembler::Assemble(const std::string& text, std::vector<u16>& code,
|
|||
{
|
||||
if (line_numbers)
|
||||
line_numbers->clear();
|
||||
const char* fname = "tmp.asm";
|
||||
if (!File::WriteStringToFile(text, fname))
|
||||
const std::string file_name = "tmp.asm";
|
||||
if (!File::WriteStringToFile(text, file_name))
|
||||
return false;
|
||||
InitPass(1);
|
||||
if (!AssembleFile(fname, 1))
|
||||
if (!AssembleFile(file_name, 1))
|
||||
return false;
|
||||
|
||||
// We now have the size of the output buffer
|
||||
|
@ -83,7 +83,7 @@ bool DSPAssembler::Assemble(const std::string& text, std::vector<u16>& code,
|
|||
return false;
|
||||
|
||||
InitPass(2);
|
||||
if (!AssembleFile(fname, 2))
|
||||
if (!AssembleFile(file_name, 2))
|
||||
return false;
|
||||
|
||||
code.resize(m_totalSize);
|
||||
|
@ -764,16 +764,16 @@ void DSPAssembler::InitPass(int pass)
|
|||
segment_addr[SEGMENT_OVERLAY] = 0;
|
||||
}
|
||||
|
||||
bool DSPAssembler::AssembleFile(const char* fname, int pass)
|
||||
bool DSPAssembler::AssembleFile(const std::string& file_path, int pass)
|
||||
{
|
||||
int disable_text = 0; // modified by Hermes
|
||||
|
||||
std::ifstream fsrc;
|
||||
OpenFStream(fsrc, fname, std::ios_base::in);
|
||||
OpenFStream(fsrc, file_path, std::ios_base::in);
|
||||
|
||||
if (fsrc.fail())
|
||||
{
|
||||
std::cerr << "Cannot open file " << fname << std::endl;
|
||||
std::cerr << "Cannot open file " << file_path << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
u32 GetParams(char* parstr, param_t* par);
|
||||
|
||||
void InitPass(int pass);
|
||||
bool AssembleFile(const char* fname, int pass);
|
||||
bool AssembleFile(const std::string& file_path, int pass);
|
||||
|
||||
void ShowError(err_t err_code, const char* extra_info = nullptr);
|
||||
// void ShowWarning(err_t err_code, const char *extra_info = nullptr);
|
||||
|
|
Loading…
Reference in New Issue