aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/representation.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 02:55:38 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-05 02:55:38 -0400
commitc222d406b09de529388fcd248476e9ae258895b8 (patch)
tree9cfcc6ee29e4e88757a91f572283c714115cb6e3 /nexgb/xgbgen/representation.go
parenta5d4ad6c9d763b3d3f797075038023756c38bb28 (diff)
downloadhaven-c222d406b09de529388fcd248476e9ae258895b8.tar.gz
haven-c222d406b09de529388fcd248476e9ae258895b8.tar.xz
haven-c222d406b09de529388fcd248476e9ae258895b8.zip
converting to new reply/cookie scheme
Diffstat (limited to 'nexgb/xgbgen/representation.go')
-rw-r--r--nexgb/xgbgen/representation.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/nexgb/xgbgen/representation.go b/nexgb/xgbgen/representation.go
index ef62157..be7accd 100644
--- a/nexgb/xgbgen/representation.go
+++ b/nexgb/xgbgen/representation.go
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
+ "unicode"
)
type Protocol struct {
@@ -62,11 +63,27 @@ func (r *Request) ReplyName() string {
log.Panicf("Cannot call 'ReplyName' on request %s, which has no reply.",
r.SrcName())
}
+ name := r.SrcName()
+ lower := string(unicode.ToLower(rune(name[0]))) + name[1:]
+ return fmt.Sprintf("%sReply", lower)
+}
+
+func (r *Request) ReplyTypeName() string {
+ if r.Reply == nil {
+ log.Panicf("Cannot call 'ReplyName' on request %s, which has no reply.",
+ r.SrcName())
+ }
return fmt.Sprintf("%sReply", r.SrcName())
}
func (r *Request) ReqName() string {
- return fmt.Sprintf("%sRequest", r.SrcName())
+ name := r.SrcName()
+ lower := string(unicode.ToLower(rune(name[0]))) + name[1:]
+ return fmt.Sprintf("%sRequest", lower)
+}
+
+func (r *Request) CookieName() string {
+ return fmt.Sprintf("%sCookie", r.SrcName())
}
// Size for Request needs a context.
@@ -99,7 +116,9 @@ func (r *Request) Size(c *Context) Size {
size = size.Add(field.Size())
}
}
- return size
+ return newExpressionSize(&Padding{
+ Expr: size.Expression,
+ })
}
type Reply struct {