From c222d406b09de529388fcd248476e9ae258895b8 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sat, 5 May 2012 02:55:38 -0400 Subject: converting to new reply/cookie scheme --- nexgb/xgbgen/representation.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'nexgb/xgbgen/representation.go') 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 { @@ -58,6 +59,16 @@ func (r *Request) XmlName() string { } func (r *Request) ReplyName() string { + if r.Reply == nil { + 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()) @@ -66,7 +77,13 @@ func (r *Request) ReplyName() string { } 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 { -- cgit v1.2.3