Update for PkmnLib.

This commit is contained in:
Deukhoofd 2021-11-27 11:48:49 +01:00
parent 20edf39d48
commit 94de1d4dca
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 57 additions and 9 deletions

View File

@ -40,6 +40,8 @@ function(include_pkmnlib)
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include)
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/src
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/PkmnLib)
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/extern)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include

View File

@ -8,7 +8,7 @@ static PkmnLib::Library::PokemonLibrary* BuildStaticLibrary() {
new PkmnLib::Library::LibrarySettings(100, 4, 4096), new PkmnLib::Library::SpeciesLibrary(),
new PkmnLib::Library::MoveLibrary(), new PkmnLib::Library::ItemLibrary(),
new CreatureLib::Library::GrowthRateLibrary(), new CreatureLib::Library::TypeLibrary(),
new PkmnLib::Library::NatureLibrary());
new CreatureLib::Library::TalentLibrary(), new PkmnLib::Library::NatureLibrary());
}
static PkmnLib::Library::TimeOfDay GetTime() { return PkmnLib::Library::TimeOfDay::Morning; }

View File

@ -67,11 +67,35 @@ static void PrintObjectTypeDef(asITypeInfo* type, const std::filesystem::path& d
auto name = std::string(method->GetName());
auto decl = std::string(method->GetDeclaration(false, true, false));
auto realName = name.substr(4);
if (method->GetParamCount() > 0 && !name.starts_with("set_")) {
fs << " " << decl << " property;" << std::endl;
} else if (name.starts_with("get_")) {
replace(decl, name, realName);
replace(decl, "() const", " { get const; }");
replace(decl, "()", " { get; }");
replace(decl, "() const", " { get const; ");
replace(decl, "()", " { get; ");
fs << " " << decl << ";" << std::endl;
fs << " " << decl;
auto setMethod = type->GetMethodByName(("set_" + realName).c_str());
if (setMethod != nullptr) {
auto setDecl = std::string(setMethod->GetDeclaration(false, true, false));
if (setDecl.find("const") != std::string::npos) {
fs << "set const; ";
} else {
fs << "set; ";
}
}
fs << "};" << std::endl;
} else if (name.starts_with("set")) {
auto getMethod = type->GetMethodByName(("get_" + realName).c_str());
if (getMethod != nullptr) {
continue;
}
replace(decl, name, realName);
replace(decl, "() const", " { set const; }");
replace(decl, "()", " { set; }");
fs << "\t" << decl << ";" << std::endl;
}
} else {
auto name = std::string(method->GetName());
auto decl = std::string(method->GetDeclaration(false, true, true));
@ -107,11 +131,33 @@ static void PrintScriptObject(asITypeInfo* type, const std::filesystem::path& di
auto name = std::string(method->GetName());
auto decl = std::string(method->GetDeclaration(false, true, false));
auto realName = name.substr(4);
if (name.starts_with("get_")) {
replace(decl, name, realName);
replace(decl, "() const", " { get const; }");
replace(decl, "()", " { get; }");
replace(decl, "() const", " get const; ");
replace(decl, "()", " get; ");
fs << "\t" << decl << std::endl;
fs << "\t"
<< "{" << decl;
auto setMethod = type->GetMethodByName(("set_" + realName).c_str());
if (setMethod != nullptr) {
auto setDecl = replace(decl, name, realName);
replace(decl, "() const", " set const; ");
replace(decl, "()", " set; ");
fs << setDecl;
}
fs << "}" << std::endl;
} else if (name.starts_with("set")) {
auto getMethod = type->GetMethodByName(("get_" + realName).c_str());
if (getMethod != nullptr) {
continue;
}
replace(decl, name, realName);
replace(decl, "() const", " set const; ");
replace(decl, "()", " set; ");
fs << "\t"
<< "{" << decl << "}" << std::endl;
}
} else {
auto name = std::string(method->GetName());
if (name == "opAssign")