Browse Source

💡 some function documentation comments

master
n0m1s 6 years ago
parent
commit
00a766412b
Signed by: nomis GPG Key ID: BC0454CAD76FE803
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      jdr/sheet.go

+ 8
- 0
jdr/sheet.go View File

@ -158,12 +158,18 @@ func (n *xmlNode) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
return d.DecodeElement((*node)(n), &start)
}
// The parseVariable function parses a Variable value from a XML node.
// The variable type is inferred from the "type" attribute of the node.
// If this attribute is omitted, the type of the variable must be given through the
// "defaults" parameter to avoid a parsing error.
// If this attribute is specified, the "defaults" parameter will be unused and may be nil
func parseVariable(root xmlNode, sheet *CharacterSheet, defaults *Variable) (*Variable, error) {
ret := &Variable{}
typeOk := false
nameOk := false
//parsing default values
if defaults != nil {
switch defaults.Type.(type) {
case *VariableType_badType:
@ -174,6 +180,7 @@ func parseVariable(root xmlNode, sheet *CharacterSheet, defaults *Variable) (*Va
}
}
//iterating on the attributes
for i := 0; i < len(root.Attrs); i++ {
attrName := root.Attrs[i].Name.Local
attrVal := root.Attrs[i].Value
@ -192,6 +199,7 @@ func parseVariable(root xmlNode, sheet *CharacterSheet, defaults *Variable) (*Va
}
}
//check if no parse error
if !nameOk {
return nil, errors.New("Unnamed variable")
}


Loading…
Cancel
Save