mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:10:24 +00:00
Use string_view for readonly string properties
This commit is contained in:
parent
4f65b7167a
commit
084fc80efd
2 changed files with 4 additions and 2 deletions
|
@ -122,7 +122,8 @@ namespace MWLua
|
||||||
return "ESM3_FactionRank[" + rec.mFactionId.toDebugString() + ", " + std::to_string(rec.mRankIndex + 1)
|
return "ESM3_FactionRank[" + rec.mFactionId.toDebugString() + ", " + std::to_string(rec.mRankIndex + 1)
|
||||||
+ "]";
|
+ "]";
|
||||||
};
|
};
|
||||||
rankT["name"] = sol::readonly_property([](const FactionRank& rec) { return rec.mRankName; });
|
rankT["name"]
|
||||||
|
= sol::readonly_property([](const FactionRank& rec) -> std::string_view { return rec.mRankName; });
|
||||||
rankT["primarySkillValue"] = sol::readonly_property([](const FactionRank& rec) { return rec.mPrimarySkill; });
|
rankT["primarySkillValue"] = sol::readonly_property([](const FactionRank& rec) { return rec.mPrimarySkill; });
|
||||||
rankT["favouredSkillValue"] = sol::readonly_property([](const FactionRank& rec) { return rec.mFavouredSkill; });
|
rankT["favouredSkillValue"] = sol::readonly_property([](const FactionRank& rec) { return rec.mFavouredSkill; });
|
||||||
rankT["factionReaction"] = sol::readonly_property([](const FactionRank& rec) { return rec.mFactReaction; });
|
rankT["factionReaction"] = sol::readonly_property([](const FactionRank& rec) { return rec.mFactReaction; });
|
||||||
|
|
|
@ -161,7 +161,8 @@ namespace MWLua
|
||||||
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
sol::usertype<FileHandle> handle = context.mLua->sol().new_usertype<FileHandle>("FileHandle");
|
sol::usertype<FileHandle> handle = context.mLua->sol().new_usertype<FileHandle>("FileHandle");
|
||||||
handle["fileName"] = sol::readonly_property([](const FileHandle& self) { return self.mFileName; });
|
handle["fileName"]
|
||||||
|
= sol::readonly_property([](const FileHandle& self) -> std::string_view { return self.mFileName; });
|
||||||
handle[sol::meta_function::to_string] = [](const FileHandle& self) {
|
handle[sol::meta_function::to_string] = [](const FileHandle& self) {
|
||||||
return "FileHandle{'" + self.mFileName + "'" + (!self.mFilePtr ? ", closed" : "") + "}";
|
return "FileHandle{'" + self.mFileName + "'" + (!self.mFilePtr ? ", closed" : "") + "}";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue