mirror of
https://github.com/hyprwm/hyprwayland-scanner.git
synced 2024-12-22 16:19:49 +01:00
core: add support for nullable objects
This commit is contained in:
parent
1cfe2d26a8
commit
4eb457b3f7
1 changed files with 6 additions and 3 deletions
|
@ -13,6 +13,7 @@ struct SRequestArgument {
|
|||
std::string interface;
|
||||
std::string enumName;
|
||||
std::string name;
|
||||
bool allowNull = false;
|
||||
};
|
||||
|
||||
struct SRequest {
|
||||
|
@ -59,7 +60,7 @@ std::string argsToShort(std::vector<SRequestArgument>& args) {
|
|||
else if (a.wlType == "string")
|
||||
shortt += "s";
|
||||
else if (a.wlType == "object")
|
||||
shortt += "o";
|
||||
shortt += std::string(a.allowNull ? "?" : "") + "o";
|
||||
else if (a.wlType == "array")
|
||||
shortt += "a";
|
||||
else if (a.wlType == "fd")
|
||||
|
@ -99,8 +100,8 @@ std::string WPTypeToCType(const SRequestArgument& arg, bool event /* events pass
|
|||
|
||||
// iface
|
||||
if (!arg.interface.empty() && event)
|
||||
return camelize("C_" + arg.interface + "*");
|
||||
|
||||
return camelize("C_" + arg.interface + "*");
|
||||
|
||||
return "uint32_t";
|
||||
}
|
||||
if (arg.wlType == "object")
|
||||
|
@ -167,6 +168,7 @@ void parseXML(pugi::xml_document& doc) {
|
|||
sargm.wlType = arg.attribute("type").as_string();
|
||||
sargm.interface = arg.attribute("interface").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);
|
||||
|
||||
srq.args.push_back(sargm);
|
||||
|
@ -185,6 +187,7 @@ void parseXML(pugi::xml_document& doc) {
|
|||
sargm.interface = arg.attribute("interface").as_string();
|
||||
sargm.wlType = arg.attribute("type").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);
|
||||
|
||||
sev.args.push_back(sargm);
|
||||
|
|
Loading…
Reference in a new issue