Skip to content

Commit

Permalink
move some explicit template instantiations to .cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
florianessl committed May 24, 2024
1 parent 4e779fc commit 073a42a
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 94 deletions.
96 changes: 96 additions & 0 deletions src/game_variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,99 @@ int Game_Variables::GetMaxDigits() const {
auto val = std::max(std::llabs(GetMaxValue()), std::llabs(GetMinValue()));
return static_cast<int>(std::log10(val) + 1);
}



#define EXPLICIT_INSTANCES_OP(N) \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_Global>(int variable_id, Var_t value); \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_Frame>(int variable_id, Var_t value, lcf::rpg::SaveEventExecFrame*); \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_Map>(int variable_id, Var_t value, int map_id); \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int variable_id, Var_t value, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGE_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, Var_t value); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, Var_t value, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, Var_t value, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, Var_t value, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGEVAR_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, int var_id); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, int var_id, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, int var_id, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, int var_id, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, int var_id); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, int var_id, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, int var_id, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, int var_id, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGE_RANDOM_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, Var_t minval, Var_t maxval); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, Var_t minval, Var_t maxval, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, Var_t minval, Var_t maxval, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, Var_t minval, Var_t maxval, int map_id, int event_id);

EXPLICIT_INSTANCES_OP(Add)
EXPLICIT_INSTANCES_OP(Sub)
EXPLICIT_INSTANCES_OP(Mult)
EXPLICIT_INSTANCES_OP(Div)
EXPLICIT_INSTANCES_OP(Mod)
EXPLICIT_INSTANCES_OP(BitOr)
EXPLICIT_INSTANCES_OP(BitAnd)
EXPLICIT_INSTANCES_OP(BitXor)
EXPLICIT_INSTANCES_OP(BitShiftLeft)
EXPLICIT_INSTANCES_OP(BitShiftRight)

EXPLICIT_INSTANCES_RANGE_OP(AddRange)
EXPLICIT_INSTANCES_RANGE_OP(SubRange)
EXPLICIT_INSTANCES_RANGE_OP(MultRange)
EXPLICIT_INSTANCES_RANGE_OP(DivRange)
EXPLICIT_INSTANCES_RANGE_OP(ModRange)
EXPLICIT_INSTANCES_RANGE_OP(BitOrRange)
EXPLICIT_INSTANCES_RANGE_OP(BitAndRange)
EXPLICIT_INSTANCES_RANGE_OP(BitXorRange)
EXPLICIT_INSTANCES_RANGE_OP(BitShiftLeftRange)
EXPLICIT_INSTANCES_RANGE_OP(BitShiftRightRange)

EXPLICIT_INSTANCES_RANGEVAR_OP(SetRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(AddRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(SubRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(MultRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(DivRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(ModRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitOrRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitAndRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitXorRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitShiftLeftRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitShiftRightRangeVariable)

EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(SetRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(AddRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(SubRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(MultRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(DivRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(ModRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitOrRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitAndRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitXorRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitShiftLeftRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitShiftRightRangeVariableIndirect)

EXPLICIT_INSTANCES_RANGE_RANDOM_OP(SetRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(AddRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(SubRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(MultRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(DivRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(ModRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitOrRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitAndRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitXorRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitShiftLeftRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitShiftRightRangeRandom)

#undef EXPLICIT_INSTANCES_OP
#undef EXPLICIT_INSTANCES_RANGE_OP
#undef EXPLICIT_INSTANCES_RANGEVAR_OP
#undef EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP
#undef EXPLICIT_INSTANCES_RANGE_RANDOM_OP
94 changes: 0 additions & 94 deletions src/game_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,98 +273,4 @@ SCOPED_IMPL inline void Game_Variables::ValidateRangeRandomOp(int first_id, int
}
}

#define EXPLICIT_INSTANCES_OP(N) \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_Global>(int variable_id, Var_t value); \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_Frame>(int variable_id, Var_t value, lcf::rpg::SaveEventExecFrame*); \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_Map>(int variable_id, Var_t value, int map_id); \
template Game_Variables::Var_t Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int variable_id, Var_t value, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGE_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, Var_t value); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, Var_t value, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, Var_t value, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, Var_t value, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGEVAR_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, int var_id); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, int var_id, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, int var_id, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, int var_id, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, int var_id); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, int var_id, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, int var_id, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, int var_id, int map_id, int event_id);

#define EXPLICIT_INSTANCES_RANGE_RANDOM_OP(N) \
template void Game_Variables::N<DataScopeType::eDataScope_Global>(int first_id, int last_id, Var_t minval, Var_t maxval); \
template void Game_Variables::N<DataScopeType::eDataScope_Frame>(int first_id, int last_id, Var_t minval, Var_t maxval, lcf::rpg::SaveEventExecFrame*); \
template void Game_Variables::N<DataScopeType::eDataScope_Map>(int first_id, int last_id, Var_t minval, Var_t maxval, int map_id); \
template void Game_Variables::N<DataScopeType::eDataScope_MapEvent>(int first_id, int last_id, Var_t minval, Var_t maxval, int map_id, int event_id);

EXPLICIT_INSTANCES_OP(Add)
EXPLICIT_INSTANCES_OP(Sub)
EXPLICIT_INSTANCES_OP(Mult)
EXPLICIT_INSTANCES_OP(Div)
EXPLICIT_INSTANCES_OP(Mod)
EXPLICIT_INSTANCES_OP(BitOr)
EXPLICIT_INSTANCES_OP(BitAnd)
EXPLICIT_INSTANCES_OP(BitXor)
EXPLICIT_INSTANCES_OP(BitShiftLeft)
EXPLICIT_INSTANCES_OP(BitShiftRight)

EXPLICIT_INSTANCES_RANGE_OP(AddRange)
EXPLICIT_INSTANCES_RANGE_OP(SubRange)
EXPLICIT_INSTANCES_RANGE_OP(MultRange)
EXPLICIT_INSTANCES_RANGE_OP(DivRange)
EXPLICIT_INSTANCES_RANGE_OP(ModRange)
EXPLICIT_INSTANCES_RANGE_OP(BitOrRange)
EXPLICIT_INSTANCES_RANGE_OP(BitAndRange)
EXPLICIT_INSTANCES_RANGE_OP(BitXorRange)
EXPLICIT_INSTANCES_RANGE_OP(BitShiftLeftRange)
EXPLICIT_INSTANCES_RANGE_OP(BitShiftRightRange)

EXPLICIT_INSTANCES_RANGEVAR_OP(SetRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(AddRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(SubRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(MultRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(DivRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(ModRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitOrRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitAndRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitXorRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitShiftLeftRangeVariable)
EXPLICIT_INSTANCES_RANGEVAR_OP(BitShiftRightRangeVariable)

EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(SetRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(AddRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(SubRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(MultRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(DivRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(ModRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitOrRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitAndRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitXorRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitShiftLeftRangeVariableIndirect)
EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP(BitShiftRightRangeVariableIndirect)

EXPLICIT_INSTANCES_RANGE_RANDOM_OP(SetRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(AddRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(SubRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(MultRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(DivRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(ModRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitOrRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitAndRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitXorRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitShiftLeftRangeRandom)
EXPLICIT_INSTANCES_RANGE_RANDOM_OP(BitShiftRightRangeRandom)

#undef EXPLICIT_INSTANCES_OP
#undef EXPLICIT_INSTANCES_RANGE_OP
#undef EXPLICIT_INSTANCES_RANGEVAR_OP
#undef EXPLICIT_INSTANCES_RANGEVARINDIRECT_OP
#undef EXPLICIT_INSTANCES_RANGE_RANDOM_OP

#endif

0 comments on commit 073a42a

Please sign in to comment.