More debug data and moved the template detailed debugs to the TemplateDebug as they shove the other data off the console.

Tweaked a few things in the forum permissions functions.
This commit is contained in:
Azareal 2017-09-23 22:28:50 +01:00
parent 96b157e5aa
commit 2ef7726080
5 changed files with 101 additions and 97 deletions

View File

@ -50,5 +50,6 @@ func init() {
// Developer flag // Developer flag
dev.DebugMode = true dev.DebugMode = true
//dev.SuperDebug = true //dev.SuperDebug = true
//dev.TemplateDebug = true
//dev.Profiling = true //dev.Profiling = true
} }

View File

@ -194,6 +194,7 @@ config.ItemsPerPage = 25
// Developer flag // Developer flag
dev.DebugMode = true dev.DebugMode = true
//dev.SuperDebug = true //dev.SuperDebug = true
//dev.TemplateDebug = true
//dev.Profiling = true //dev.Profiling = true
} }
`) `)

View File

@ -347,29 +347,26 @@ func rebuildForumPermissions(fid int) error {
if dev.DebugMode { if dev.DebugMode {
log.Print("Updating the forum permissions for Group #" + strconv.Itoa(group.ID)) log.Print("Updating the forum permissions for Group #" + strconv.Itoa(group.ID))
} }
var blankIntList []int
group.Forums = []ForumPerms{BlankForumPerms} group.Forums = []ForumPerms{BlankForumPerms}
group.CanSee = blankIntList group.CanSee = []int{}
for ffid := range forums { for ffid := range forums {
forumPerm, ok := forumPerms[group.ID][ffid] forumPerm, ok := forumPerms[group.ID][ffid]
if ok { if ok {
//log.Print("Overriding permissions for forum #" + strconv.Itoa(fid)) //log.Print("Overriding permissions for forum #" + strconv.Itoa(fid))
group.Forums = append(group.Forums, forumPerm) group.Forums = append(group.Forums, forumPerm)
if forumPerm.Overrides {
if forumPerm.ViewTopic {
group.CanSee = append(group.CanSee, ffid)
}
} else if group.Perms.ViewTopic {
group.CanSee = append(group.CanSee, ffid)
}
} else { } else {
//log.Print("Inheriting from default for forum #" + strconv.Itoa(fid)) //log.Print("Inheriting from default for forum #" + strconv.Itoa(fid))
forumPerm = BlankForumPerms forumPerm = BlankForumPerms
group.Forums = append(group.Forums, forumPerm) group.Forums = append(group.Forums, forumPerm)
} }
if forumPerm.Overrides {
if forumPerm.ViewTopic {
group.CanSee = append(group.CanSee, ffid)
}
} else if group.Perms.ViewTopic {
group.CanSee = append(group.CanSee, ffid)
}
} }
if dev.SuperDebug { if dev.SuperDebug {
log.Printf("group.CanSee %+v\n", group.CanSee) log.Printf("group.CanSee %+v\n", group.CanSee)
@ -418,6 +415,9 @@ func buildForumPermissions() error {
} }
forumPerms[gid][fid] = pperms forumPerms[gid][fid] = pperms
} }
if dev.SuperDebug {
log.Print("forumPerms ", forumPerms)
}
groups, err := gstore.GetAll() groups, err := gstore.GetAll()
if err != nil { if err != nil {
@ -429,32 +429,33 @@ func buildForumPermissions() error {
log.Print("Adding the forum permissions for Group #" + strconv.Itoa(group.ID) + " - " + group.Name) log.Print("Adding the forum permissions for Group #" + strconv.Itoa(group.ID) + " - " + group.Name)
} }
group.Forums = []ForumPerms{BlankForumPerms} group.Forums = []ForumPerms{BlankForumPerms}
group.CanSee = []int{}
for fid := range forums { for fid := range forums {
forumPerm, ok := forumPerms[group.ID][fid] forumPerm, ok := forumPerms[group.ID][fid]
if ok { if ok {
// Override group perms // Override group perms
//log.Print("Overriding permissions for forum #" + strconv.Itoa(fid)) //log.Print("Overriding permissions for forum #" + strconv.Itoa(fid))
group.Forums = append(group.Forums, forumPerm) group.Forums = append(group.Forums, forumPerm)
if forumPerm.Overrides {
if forumPerm.ViewTopic {
group.CanSee = append(group.CanSee, fid)
}
} else if group.Perms.ViewTopic {
group.CanSee = append(group.CanSee, fid)
}
} else { } else {
// Inherit from Group // Inherit from Group
// ? - Is this really inheriting from the Group? At-least for CanSee?
//log.Print("Inheriting from default for forum #" + strconv.Itoa(fid)) //log.Print("Inheriting from default for forum #" + strconv.Itoa(fid))
forumPerm = BlankForumPerms forumPerm = BlankForumPerms
group.Forums = append(group.Forums, forumPerm) group.Forums = append(group.Forums, forumPerm)
} }
if forumPerm.Overrides {
if forumPerm.ViewTopic {
group.CanSee = append(group.CanSee, fid)
}
} else if group.Perms.ViewTopic {
group.CanSee = append(group.CanSee, fid)
}
} }
if dev.SuperDebug { if dev.SuperDebug {
//log.Printf("group.CanSee %+v\n", group.CanSee) log.Printf("group.CanSee %+v\n", group.CanSee)
//log.Printf("group.Forums %+v\n", group.Forums) log.Printf("group.Forums %+v\n", group.Forums)
//log.Print("len(group.CanSee)",len(group.CanSee)) log.Print("len(group.CanSee)", len(group.CanSee))
//log.Print("len(group.Forums)",len(group.Forums)) log.Print("len(group.Forums)", len(group.Forums))
} }
} }
return nil return nil

View File

@ -57,9 +57,10 @@ type Config struct {
} }
type DevConfig struct { type DevConfig struct {
DebugMode bool DebugMode bool
SuperDebug bool SuperDebug bool
Profiling bool TemplateDebug bool
Profiling bool
} }
func processConfig() { func processConfig() {

View File

@ -99,7 +99,7 @@ func (c *CTemplateSet) compileTemplate(name string, dir string, expects string,
if err != nil { if err != nil {
return "", err return "", err
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println(name) fmt.Println(name)
} }
@ -109,7 +109,7 @@ func (c *CTemplateSet) compileTemplate(name string, dir string, expects string,
c.tlist[fname] = tree c.tlist[fname] = tree
varholder := "tmpl_" + fname + "_vars" varholder := "tmpl_" + fname + "_vars"
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println(c.tlist) fmt.Println(c.tlist)
} }
c.localVars = make(map[string]map[string]VarItemReflect) c.localVars = make(map[string]map[string]VarItemReflect)
@ -122,13 +122,13 @@ func (c *CTemplateSet) compileTemplate(name string, dir string, expects string,
c.FragmentCursor[fname] = 0 c.FragmentCursor[fname] = 0
subtree := c.tlist[fname] subtree := c.tlist[fname]
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println(subtree.Root) fmt.Println(subtree.Root)
} }
treeLength := len(subtree.Root.Nodes) treeLength := len(subtree.Root.Nodes)
for index, node := range subtree.Root.Nodes { for index, node := range subtree.Root.Nodes {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Node: " + node.String()) fmt.Println("Node: " + node.String())
} }
@ -171,7 +171,7 @@ w.Write([]byte(`, " + ", -1)
fmt.Println(" ") fmt.Println(" ")
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Output!") fmt.Println("Output!")
fmt.Println(fout) fmt.Println(fout)
} }
@ -179,12 +179,12 @@ w.Write([]byte(`, " + ", -1)
} }
func (c *CTemplateSet) compileSwitch(varholder string, holdreflect reflect.Value, templateName string, node interface{}) (out string) { func (c *CTemplateSet) compileSwitch(varholder string, holdreflect reflect.Value, templateName string, node interface{}) (out string) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileSwitch") fmt.Println("in compileSwitch")
} }
switch node := node.(type) { switch node := node.(type) {
case *parse.ActionNode: case *parse.ActionNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Action Node") fmt.Println("Action Node")
} }
if node.Pipe == nil { if node.Pipe == nil {
@ -195,24 +195,24 @@ func (c *CTemplateSet) compileSwitch(varholder string, holdreflect reflect.Value
} }
return out return out
case *parse.IfNode: case *parse.IfNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("If Node:") fmt.Println("If Node:")
fmt.Println("node.Pipe", node.Pipe) fmt.Println("node.Pipe", node.Pipe)
} }
var expr string var expr string
for _, cmd := range node.Pipe.Cmds { for _, cmd := range node.Pipe.Cmds {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("If Node Bit:", cmd) fmt.Println("If Node Bit:", cmd)
fmt.Println("If Node Bit Type:", reflect.ValueOf(cmd).Type().Name()) fmt.Println("If Node Bit Type:", reflect.ValueOf(cmd).Type().Name())
} }
expr += c.compileVarswitch(varholder, holdreflect, templateName, cmd) expr += c.compileVarswitch(varholder, holdreflect, templateName, cmd)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("If Node Expression Step:", c.compileVarswitch(varholder, holdreflect, templateName, cmd)) fmt.Println("If Node Expression Step:", c.compileVarswitch(varholder, holdreflect, templateName, cmd))
} }
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("If Node Expression:", expr) fmt.Println("If Node Expression:", expr)
} }
@ -220,18 +220,18 @@ func (c *CTemplateSet) compileSwitch(varholder string, holdreflect reflect.Value
c.currentNode = parse.NodeList c.currentNode = parse.NodeList
c.nextNode = -1 c.nextNode = -1
if node.ElseList == nil { if node.ElseList == nil {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Selected Branch 1") fmt.Println("Selected Branch 1")
} }
return "if " + expr + " {\n" + c.compileSwitch(varholder, holdreflect, templateName, node.List) + "}\n" return "if " + expr + " {\n" + c.compileSwitch(varholder, holdreflect, templateName, node.List) + "}\n"
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Selected Branch 2") fmt.Println("Selected Branch 2")
} }
return "if " + expr + " {\n" + c.compileSwitch(varholder, holdreflect, templateName, node.List) + "} else {\n" + c.compileSwitch(varholder, holdreflect, templateName, node.ElseList) + "}\n" return "if " + expr + " {\n" + c.compileSwitch(varholder, holdreflect, templateName, node.List) + "} else {\n" + c.compileSwitch(varholder, holdreflect, templateName, node.ElseList) + "}\n"
case *parse.ListNode: case *parse.ListNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("List Node") fmt.Println("List Node")
} }
for _, subnode := range node.Nodes { for _, subnode := range node.Nodes {
@ -239,20 +239,20 @@ func (c *CTemplateSet) compileSwitch(varholder string, holdreflect reflect.Value
} }
return out return out
case *parse.RangeNode: case *parse.RangeNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Range Node!") fmt.Println("Range Node!")
fmt.Println(node.Pipe) fmt.Println(node.Pipe)
} }
var outVal reflect.Value var outVal reflect.Value
for _, cmd := range node.Pipe.Cmds { for _, cmd := range node.Pipe.Cmds {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Range Bit:", cmd) fmt.Println("Range Bit:", cmd)
} }
out, outVal = c.compileReflectswitch(varholder, holdreflect, templateName, cmd) out, outVal = c.compileReflectswitch(varholder, holdreflect, templateName, cmd)
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Returned:", out) fmt.Println("Returned:", out)
fmt.Println("Range Kind Switch!") fmt.Println("Range Kind Switch!")
} }
@ -317,13 +317,13 @@ func (c *CTemplateSet) compileSwitch(varholder string, holdreflect reflect.Value
} }
func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) { func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileSubswitch") fmt.Println("in compileSubswitch")
} }
firstWord := node.Args[0] firstWord := node.Args[0]
switch n := firstWord.(type) { switch n := firstWord.(type) {
case *parse.FieldNode: case *parse.FieldNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Field Node:", n.Ident) fmt.Println("Field Node:", n.Ident)
} }
@ -337,20 +337,20 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
} }
for _, id := range n.Ident { for _, id := range n.Ident {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Data Kind:", cur.Kind().String()) fmt.Println("Data Kind:", cur.Kind().String())
fmt.Println("Field Bit:", id) fmt.Println("Field Bit:", id)
} }
if cur.Kind() == reflect.Ptr { if cur.Kind() == reflect.Ptr {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Looping over pointer") fmt.Println("Looping over pointer")
} }
for cur.Kind() == reflect.Ptr { for cur.Kind() == reflect.Ptr {
cur = cur.Elem() cur = cur.Elem()
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Data Kind:", cur.Kind().String()) fmt.Println("Data Kind:", cur.Kind().String())
fmt.Println("Field Bit:", id) fmt.Println("Field Bit:", id)
} }
@ -361,7 +361,7 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
fmt.Println("Debug Data:") fmt.Println("Debug Data:")
fmt.Println("Holdreflect:", holdreflect) fmt.Println("Holdreflect:", holdreflect)
fmt.Println("Holdreflect.Kind()", holdreflect.Kind()) fmt.Println("Holdreflect.Kind()", holdreflect.Kind())
if !dev.SuperDebug { if !dev.TemplateDebug {
fmt.Println("cur.Kind():", cur.Kind().String()) fmt.Println("cur.Kind():", cur.Kind().String())
} }
fmt.Println("") fmt.Println("")
@ -386,7 +386,7 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
} else { } else {
varbit += "." + id varbit += "." + id
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("End Cycle") fmt.Println("End Cycle")
} }
} }
@ -399,14 +399,14 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
} }
return out return out
case *parse.DotNode: case *parse.DotNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Dot Node:", node.String()) fmt.Println("Dot Node:", node.String())
} }
return c.compileVarsub(varholder, holdreflect) return c.compileVarsub(varholder, holdreflect)
case *parse.NilNode: case *parse.NilNode:
panic("Nil is not a command x.x") panic("Nil is not a command x.x")
case *parse.VariableNode: case *parse.VariableNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Variable Node:", n.String()) fmt.Println("Variable Node:", n.String())
fmt.Println(n.Ident) fmt.Println(n.Ident)
} }
@ -415,7 +415,7 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
case *parse.StringNode: case *parse.StringNode:
return n.Quoted return n.Quoted
case *parse.IdentifierNode: case *parse.IdentifierNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Identifier Node:", node) fmt.Println("Identifier Node:", node)
fmt.Println("Identifier Node Args:", node.Args) fmt.Println("Identifier Node Args:", node.Args)
} }
@ -428,13 +428,13 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
} }
func (c *CTemplateSet) compileVarswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) { func (c *CTemplateSet) compileVarswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compile_varswitch") fmt.Println("in compile_varswitch")
} }
firstWord := node.Args[0] firstWord := node.Args[0]
switch n := firstWord.(type) { switch n := firstWord.(type) {
case *parse.FieldNode: case *parse.FieldNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Field Node:", n.Ident) fmt.Println("Field Node:", n.Ident)
for _, id := range n.Ident { for _, id := range n.Ident {
fmt.Println("Field Bit:", id) fmt.Println("Field Bit:", id)
@ -444,13 +444,13 @@ func (c *CTemplateSet) compileVarswitch(varholder string, holdreflect reflect.Va
/* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */ /* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */
return c.compileBoolsub(n.String(), varholder, templateName, holdreflect) return c.compileBoolsub(n.String(), varholder, templateName, holdreflect)
case *parse.ChainNode: case *parse.ChainNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Chain Node:", n.Node) fmt.Println("Chain Node:", n.Node)
fmt.Println("Chain Node Args:", node.Args) fmt.Println("Chain Node Args:", node.Args)
} }
break break
case *parse.IdentifierNode: case *parse.IdentifierNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Identifier Node:", node) fmt.Println("Identifier Node:", node)
fmt.Println("Identifier Node Args:", node.Args) fmt.Println("Identifier Node Args:", node.Args)
} }
@ -458,7 +458,7 @@ func (c *CTemplateSet) compileVarswitch(varholder string, holdreflect reflect.Va
case *parse.DotNode: case *parse.DotNode:
return varholder return varholder
case *parse.VariableNode: case *parse.VariableNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Variable Node:", n.String()) fmt.Println("Variable Node:", n.String())
fmt.Println("Variable Node Identifier:", n.Ident) fmt.Println("Variable Node Identifier:", n.Ident)
} }
@ -467,14 +467,14 @@ func (c *CTemplateSet) compileVarswitch(varholder string, holdreflect reflect.Va
case *parse.NilNode: case *parse.NilNode:
panic("Nil is not a command x.x") panic("Nil is not a command x.x")
case *parse.PipeNode: case *parse.PipeNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Pipe Node!") fmt.Println("Pipe Node!")
fmt.Println(n) fmt.Println(n)
fmt.Println("Args:", node.Args) fmt.Println("Args:", node.Args)
} }
out += c.compileIdentswitchN(varholder, holdreflect, templateName, node) out += c.compileIdentswitchN(varholder, holdreflect, templateName, node)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Out:", out) fmt.Println("Out:", out)
} }
return out return out
@ -487,7 +487,7 @@ func (c *CTemplateSet) compileVarswitch(varholder string, holdreflect reflect.Va
} }
func (c *CTemplateSet) compileIdentswitchN(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) { func (c *CTemplateSet) compileIdentswitchN(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compile_identswitch_n") fmt.Println("in compile_identswitch_n")
} }
out, _ = c.compileIdentswitch(varholder, holdreflect, templateName, node) out, _ = c.compileIdentswitch(varholder, holdreflect, templateName, node)
@ -495,7 +495,7 @@ func (c *CTemplateSet) compileIdentswitchN(varholder string, holdreflect reflect
} }
func (c *CTemplateSet) compileIdentswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, val reflect.Value) { func (c *CTemplateSet) compileIdentswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, val reflect.Value) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileIdentswitch") fmt.Println("in compileIdentswitch")
} }
@ -503,7 +503,7 @@ func (c *CTemplateSet) compileIdentswitch(varholder string, holdreflect reflect.
ArgLoop: ArgLoop:
for pos := 0; pos < len(node.Args); pos++ { for pos := 0; pos < len(node.Args); pos++ {
id := node.Args[pos] id := node.Args[pos]
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("pos:", pos) fmt.Println("pos:", pos)
fmt.Println("ID:", id) fmt.Println("ID:", id)
} }
@ -511,7 +511,7 @@ ArgLoop:
case "not": case "not":
out += "!" out += "!"
case "or": case "or":
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Building or function") fmt.Println("Building or function")
} }
if pos == 0 { if pos == 0 {
@ -534,7 +534,7 @@ ArgLoop:
out += left + " || " + right out += left + " || " + right
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Left operand:", node.Args[pos-1]) fmt.Println("Left operand:", node.Args[pos-1])
fmt.Println("Right operand:", node.Args[pos+1]) fmt.Println("Right operand:", node.Args[pos+1])
} }
@ -543,12 +543,12 @@ ArgLoop:
pos++ pos++
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("pos:", pos) fmt.Println("pos:", pos)
fmt.Println("len(node.Args):", len(node.Args)) fmt.Println("len(node.Args):", len(node.Args))
} }
case "and": case "and":
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Building and function") fmt.Println("Building and function")
} }
if pos == 0 { if pos == 0 {
@ -571,7 +571,7 @@ ArgLoop:
out += left + " && " + right out += left + " && " + right
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Left operand:", node.Args[pos-1]) fmt.Println("Left operand:", node.Args[pos-1])
fmt.Println("Right operand:", node.Args[pos+1]) fmt.Println("Right operand:", node.Args[pos+1])
} }
@ -580,48 +580,48 @@ ArgLoop:
pos++ pos++
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("pos:", pos) fmt.Println("pos:", pos)
fmt.Println("len(node.Args):", len(node.Args)) fmt.Println("len(node.Args):", len(node.Args))
} }
case "le": case "le":
out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " <= " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect) out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " <= " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
break ArgLoop break ArgLoop
case "lt": case "lt":
out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " < " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect) out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " < " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
break ArgLoop break ArgLoop
case "gt": case "gt":
out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " > " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect) out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " > " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
break ArgLoop break ArgLoop
case "ge": case "ge":
out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " >= " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect) out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " >= " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
break ArgLoop break ArgLoop
case "eq": case "eq":
out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " == " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect) out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " == " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
break ArgLoop break ArgLoop
case "ne": case "ne":
out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " != " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect) out += c.compileIfVarsubN(node.Args[pos+1].String(), varholder, templateName, holdreflect) + " != " + c.compileIfVarsubN(node.Args[pos+2].String(), varholder, templateName, holdreflect)
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
@ -640,7 +640,7 @@ ArgLoop:
} }
out += param1 + " + " + param2 out += param1 + " + " + param2
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("add") fmt.Println("add")
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
@ -660,7 +660,7 @@ ArgLoop:
} }
out += param1 + " - " + param2 out += param1 + " - " + param2
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("subtract") fmt.Println("subtract")
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
@ -680,7 +680,7 @@ ArgLoop:
} }
out += param1 + " / " + param2 out += param1 + " / " + param2
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("divide") fmt.Println("divide")
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
@ -700,14 +700,14 @@ ArgLoop:
} }
out += param1 + " * " + param2 out += param1 + " * " + param2
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("multiply") fmt.Println("multiply")
fmt.Println("node.Args[pos + 1]", node.Args[pos+1]) fmt.Println("node.Args[pos + 1]", node.Args[pos+1])
fmt.Println("node.Args[pos + 2]", node.Args[pos+2]) fmt.Println("node.Args[pos + 2]", node.Args[pos+2])
} }
break ArgLoop break ArgLoop
default: default:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Variable!") fmt.Println("Variable!")
} }
if len(node.Args) > (pos + 1) { if len(node.Args) > (pos + 1) {
@ -727,13 +727,13 @@ ArgLoop:
} }
func (c *CTemplateSet) compileReflectswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, outVal reflect.Value) { func (c *CTemplateSet) compileReflectswitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, outVal reflect.Value) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileReflectswitch") fmt.Println("in compileReflectswitch")
} }
firstWord := node.Args[0] firstWord := node.Args[0]
switch n := firstWord.(type) { switch n := firstWord.(type) {
case *parse.FieldNode: case *parse.FieldNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Field Node:", n.Ident) fmt.Println("Field Node:", n.Ident)
for _, id := range n.Ident { for _, id := range n.Ident {
fmt.Println("Field Bit:", id) fmt.Println("Field Bit:", id)
@ -742,7 +742,7 @@ func (c *CTemplateSet) compileReflectswitch(varholder string, holdreflect reflec
/* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */ /* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */
return c.compileIfVarsub(n.String(), varholder, templateName, holdreflect) return c.compileIfVarsub(n.String(), varholder, templateName, holdreflect)
case *parse.ChainNode: case *parse.ChainNode:
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Chain Node:", n.Node) fmt.Println("Chain Node:", n.Node)
fmt.Println("node.Args", node.Args) fmt.Println("node.Args", node.Args)
} }
@ -758,7 +758,7 @@ func (c *CTemplateSet) compileReflectswitch(varholder string, holdreflect reflec
} }
func (c *CTemplateSet) compileIfVarsubN(varname string, varholder string, templateName string, cur reflect.Value) (out string) { func (c *CTemplateSet) compileIfVarsubN(varname string, varholder string, templateName string, cur reflect.Value) (out string) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileIfVarsubN") fmt.Println("in compileIfVarsubN")
} }
out, _ = c.compileIfVarsub(varname, varholder, templateName, cur) out, _ = c.compileIfVarsub(varname, varholder, templateName, cur)
@ -766,7 +766,7 @@ func (c *CTemplateSet) compileIfVarsubN(varname string, varholder string, templa
} }
func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templateName string, cur reflect.Value) (out string, val reflect.Value) { func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templateName string, cur reflect.Value) (out string, val reflect.Value) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileIfVarsub") fmt.Println("in compileIfVarsub")
} }
if varname[0] != '.' && varname[0] != '$' { if varname[0] != '.' && varname[0] != '$' {
@ -797,13 +797,13 @@ func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templat
} }
bits[0] = strings.TrimPrefix(bits[0], "$") bits[0] = strings.TrimPrefix(bits[0], "$")
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Cur Kind:", cur.Kind()) fmt.Println("Cur Kind:", cur.Kind())
fmt.Println("Cur Type:", cur.Type().Name()) fmt.Println("Cur Type:", cur.Type().Name())
} }
for _, bit := range bits { for _, bit := range bits {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Variable Field:", bit) fmt.Println("Variable Field:", bit)
} }
if bit == "" { if bit == "" {
@ -812,14 +812,14 @@ func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templat
// TODO: Fix this up so that it works for regular pointers and not just struct pointers. Ditto for the other cur.Kind() == reflect.Ptr we have in this file // TODO: Fix this up so that it works for regular pointers and not just struct pointers. Ditto for the other cur.Kind() == reflect.Ptr we have in this file
if cur.Kind() == reflect.Ptr { if cur.Kind() == reflect.Ptr {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Looping over pointer") fmt.Println("Looping over pointer")
} }
for cur.Kind() == reflect.Ptr { for cur.Kind() == reflect.Ptr {
cur = cur.Elem() cur = cur.Elem()
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Data Kind:", cur.Kind().String()) fmt.Println("Data Kind:", cur.Kind().String())
fmt.Println("Field Bit:", bit) fmt.Println("Field Bit:", bit)
} }
@ -837,13 +837,13 @@ func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templat
panic(out + "^\n" + "Invalid value. Maybe, it doesn't exist?") panic(out + "^\n" + "Invalid value. Maybe, it doesn't exist?")
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Data Kind:", cur.Kind()) fmt.Println("Data Kind:", cur.Kind())
fmt.Println("Data Type:", cur.Type().Name()) fmt.Println("Data Type:", cur.Type().Name())
} }
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Out Value:", out) fmt.Println("Out Value:", out)
fmt.Println("Out Kind:", cur.Kind()) fmt.Println("Out Kind:", cur.Kind())
fmt.Println("Out Type:", cur.Type().Name()) fmt.Println("Out Type:", cur.Type().Name())
@ -855,7 +855,7 @@ func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templat
} }
} }
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Out Value:", out) fmt.Println("Out Value:", out)
fmt.Println("Out Kind:", cur.Kind()) fmt.Println("Out Kind:", cur.Kind())
fmt.Println("Out Type:", cur.Type().Name()) fmt.Println("Out Type:", cur.Type().Name())
@ -872,7 +872,7 @@ func (c *CTemplateSet) compileIfVarsub(varname string, varholder string, templat
} }
func (c *CTemplateSet) compileBoolsub(varname string, varholder string, templateName string, val reflect.Value) string { func (c *CTemplateSet) compileBoolsub(varname string, varholder string, templateName string, val reflect.Value) string {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileBoolsub") fmt.Println("in compileBoolsub")
} }
out, val := c.compileIfVarsub(varname, varholder, templateName, val) out, val := c.compileIfVarsub(varname, varholder, templateName, val)
@ -894,7 +894,7 @@ func (c *CTemplateSet) compileBoolsub(varname string, varholder string, template
} }
func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value) string { func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value) string {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileVarsub") fmt.Println("in compileVarsub")
} }
for _, varItem := range c.varList { for _, varItem := range c.varList {
@ -940,7 +940,7 @@ func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value) string {
} }
func (c *CTemplateSet) compileSubtemplate(pvarholder string, pholdreflect reflect.Value, node *parse.TemplateNode) (out string) { func (c *CTemplateSet) compileSubtemplate(pvarholder string, pholdreflect reflect.Value, node *parse.TemplateNode) (out string) {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("in compileSubtemplate") fmt.Println("in compileSubtemplate")
fmt.Println("Template Node:", node.Name) fmt.Println("Template Node:", node.Name)
} }
@ -985,7 +985,7 @@ func (c *CTemplateSet) compileSubtemplate(pvarholder string, pholdreflect reflec
c.tlist[fname] = tree c.tlist[fname] = tree
subtree := c.tlist[fname] subtree := c.tlist[fname]
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("subtree.Root", subtree.Root) fmt.Println("subtree.Root", subtree.Root)
} }
@ -995,7 +995,7 @@ func (c *CTemplateSet) compileSubtemplate(pvarholder string, pholdreflect reflec
treeLength := len(subtree.Root.Nodes) treeLength := len(subtree.Root.Nodes)
for index, node := range subtree.Root.Nodes { for index, node := range subtree.Root.Nodes {
if dev.SuperDebug { if dev.TemplateDebug {
fmt.Println("Node:", node.String()) fmt.Println("Node:", node.String())
} }