core: add support for nullable objects

This commit is contained in:
Vaxry 2024-04-26 23:45:55 +01:00
parent 1cfe2d26a8
commit 4eb457b3f7

View file

@ -13,6 +13,7 @@ struct SRequestArgument {
std::string interface; std::string interface;
std::string enumName; std::string enumName;
std::string name; std::string name;
bool allowNull = false;
}; };
struct SRequest { struct SRequest {
@ -59,7 +60,7 @@ std::string argsToShort(std::vector<SRequestArgument>& args) {
else if (a.wlType == "string") else if (a.wlType == "string")
shortt += "s"; shortt += "s";
else if (a.wlType == "object") else if (a.wlType == "object")
shortt += "o"; shortt += std::string(a.allowNull ? "?" : "") + "o";
else if (a.wlType == "array") else if (a.wlType == "array")
shortt += "a"; shortt += "a";
else if (a.wlType == "fd") else if (a.wlType == "fd")
@ -167,6 +168,7 @@ void parseXML(pugi::xml_document& doc) {
sargm.wlType = arg.attribute("type").as_string(); sargm.wlType = arg.attribute("type").as_string();
sargm.interface = arg.attribute("interface").as_string(); sargm.interface = arg.attribute("interface").as_string();
sargm.enumName = arg.attribute("enum").as_string(); sargm.enumName = arg.attribute("enum").as_string();
sargm.allowNull = arg.attribute("allow-null").as_string() == std::string{"true"};
sargm.CType = WPTypeToCType(sargm, false); sargm.CType = WPTypeToCType(sargm, false);
srq.args.push_back(sargm); srq.args.push_back(sargm);
@ -185,6 +187,7 @@ void parseXML(pugi::xml_document& doc) {
sargm.interface = arg.attribute("interface").as_string(); sargm.interface = arg.attribute("interface").as_string();
sargm.wlType = arg.attribute("type").as_string(); sargm.wlType = arg.attribute("type").as_string();
sargm.enumName = arg.attribute("enum").as_string(); sargm.enumName = arg.attribute("enum").as_string();
sargm.allowNull = arg.attribute("allow-null").as_string() == std::string{"true"};
sargm.CType = WPTypeToCType(sargm, true); sargm.CType = WPTypeToCType(sargm, true);
sev.args.push_back(sargm); sev.args.push_back(sargm);