diff options
author | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-06 02:21:31 -0400 |
---|---|---|
committer | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-06 02:21:31 -0400 |
commit | 18b2d420b092d71313f0c05210c3038ff32483e7 (patch) | |
tree | e934f6bddd11863e82d591fb2a168d60be382f9d /nexgb/xgbgen/size.go | |
parent | 99bc76de54729df5494faa944d4da96a8885d51e (diff) | |
download | haven-18b2d420b092d71313f0c05210c3038ff32483e7.tar.gz haven-18b2d420b092d71313f0c05210c3038ff32483e7.tar.xz haven-18b2d420b092d71313f0c05210c3038ff32483e7.zip |
added documentation and did some slight restructuring. it's party time.
Diffstat (limited to 'nexgb/xgbgen/size.go')
-rw-r--r-- | nexgb/xgbgen/size.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/nexgb/xgbgen/size.go b/nexgb/xgbgen/size.go index 70edb8f..d8d3ac3 100644 --- a/nexgb/xgbgen/size.go +++ b/nexgb/xgbgen/size.go @@ -1,21 +1,30 @@ package main +// Size corresponds to an expression that represents the number of bytes +// in some *thing*. Generally, sizes are used to allocate buffers and to +// inform X how big requests are. +// Size is basically a thin layer over an Expression that yields easy methods +// for adding and multiplying sizes. type Size struct { Expression } +// newFixedSize creates a new Size with some fixed and known value. func newFixedSize(fixed uint) Size { return Size{&Value{v: fixed}} } +// newExpressionSize creates a new Size with some expression. func newExpressionSize(variable Expression) Size { return Size{variable} } +// Add adds s1 and s2 and returns a new Size. func (s1 Size) Add(s2 Size) Size { return Size{newBinaryOp("+", s1, s2)} } +// Multiply mupltiplies s1 and s2 and returns a new Size. func (s1 Size) Multiply(s2 Size) Size { return Size{newBinaryOp("*", s1, s2)} } |