Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix switch/separator in rules_xml #617

Merged
merged 2 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/actions/vstudio/vs2010_rules_xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@
function m.boolProperty(def)
p.push('<BoolProperty')
m.baseProperty(def)
p.w('Switch="%s" />', def.switch or "[value]")
if def.switch then
p.w('Switch="%s"', def.switch)
end
p.w('/>')
p.pop()
end

Expand All @@ -166,10 +169,13 @@
p.w('Name="%d"', key)
if switches[key] then
p.w('DisplayName="%s"', values[key])
p.w('Switch="%s" />', switches[key])
if switches[key] then
p.w('Switch="%s"', switches[key])
end
else
p.w('DisplayName="%s" />', values[key])
p.w('DisplayName="%s"', values[key])
end
p.w('/>')
p.pop()
end

Expand All @@ -180,16 +186,24 @@
function m.stringProperty(def)
p.push('<StringProperty')
m.baseProperty(def)
p.w('Switch="%s" />', def.switch or "[value]")
if def.switch then
p.w('Switch="%s"', def.switch)
end
p.w('/>')
p.pop()
end


function m.stringListProperty(def)
p.push('<StringListProperty')
m.baseProperty(def)
p.w('Separator="%s"', def.separator or " ")
p.w('Switch="%s" />', def.switch or "[value]")
if def.separator then
p.w('Separator="%s"', def.separator)
end
if def.switch then
p.w('Switch="%s"', def.switch)
end
p.w('/>')
p.pop()
end

Expand Down
126 changes: 123 additions & 3 deletions tests/actions/vstudio/vc2010/test_rule_xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
-- Property definitions
---

function suite.properties_onString()
function suite.properties_onStringNoSwitch()
createVar { name="MyVar", kind="string" }
local r = test.getRule("MyRule")
m.properties(r)
Expand All @@ -43,7 +43,21 @@
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]" />
/>
]]
end

function suite.properties_onString()
createVar { name="MyVar", kind="string", switch="[value]" }
local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<StringProperty
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]"
/>
]]
end

Expand All @@ -56,6 +70,112 @@
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]" />
/>
]]
end


function suite.properties_onBooleanNoSwitch()
createVar { name="MyVar", kind="boolean" }
local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<BoolProperty
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
/>
]]
end

function suite.properties_onBoolean()
createVar { name="MyVar", kind="boolean", switch="[value]" }
local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<BoolProperty
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]"
/>
]]
end

function suite.properties_onEnum()
createVar {
name = "OptimizationLevel",
display = "Optimization Level",
values = {
[0] = "None",
[1] = "Size",
[2] = "Speed",
},
switch = {
[0] = "-O0",
[1] = "-O1",
[2] = "-O3",
},
value = 2,
}

local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<EnumProperty
Name="OptimizationLevel"
HelpContext="0"
DisplayName="Optimization Level">
<EnumValue
Name="0"
DisplayName="None"
Switch="-O0"
/>
<EnumValue
Name="1"
DisplayName="Size"
Switch="-O1"
/>
<EnumValue
Name="2"
DisplayName="Speed"
Switch="-O3"
/>
</EnumProperty>
]]
end

function suite.properties_onEnumNoSwitches()
createVar {
name = "OptimizationLevel",
display = "Optimization Level",
values = {
[0] = "None",
[1] = "Size",
[2] = "Speed",
},
value = 2,
}

local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<EnumProperty
Name="OptimizationLevel"
HelpContext="0"
DisplayName="Optimization Level">
<EnumValue
Name="0"
DisplayName="None"
/>
<EnumValue
Name="1"
DisplayName="Size"
/>
<EnumValue
Name="2"
DisplayName="Speed"
/>
</EnumProperty>
]]
end