Use std::shared_ptr for MacroArgs

This commit is contained in:
Rangi42
2024-03-22 10:02:22 -04:00
committed by Sylvie
parent e255af9e10
commit b85c5cde8f
6 changed files with 25 additions and 23 deletions

View File

@@ -12,7 +12,7 @@
#define MAXMACROARGS 99999
static MacroArgs *macroArgs = nullptr;
static std::shared_ptr<MacroArgs> macroArgs = nullptr;
void MacroArgs::append(std::shared_ptr<std::string> arg) {
if (arg->empty())
@@ -22,14 +22,22 @@ void MacroArgs::append(std::shared_ptr<std::string> arg) {
args.push_back(arg);
}
MacroArgs *macro_GetCurrentArgs() {
bool macro_HasCurrentArgs() {
return macroArgs != nullptr;
}
std::shared_ptr<MacroArgs> macro_GetCurrentArgs() {
return macroArgs;
}
void macro_UseNewArgs(MacroArgs *args) {
void macro_UseNewArgs(std::shared_ptr<MacroArgs> args) {
macroArgs = args;
}
uint32_t macro_NbArgs() {
return macroArgs->args.size() - macroArgs->shift;
}
std::shared_ptr<std::string> macro_GetArg(uint32_t i) {
if (!macroArgs)
return nullptr;
@@ -83,7 +91,3 @@ void macro_ShiftCurrentArgs(int32_t count) {
macroArgs->shift += count;
}
}
uint32_t macro_NbArgs() {
return macroArgs->args.size() - macroArgs->shift;
}