aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/size.go
diff options
context:
space:
mode:
authoraarzilli <alessandro.arzilli@gmail.com>2014-05-02 15:09:23 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:22 +0200
commita548d9d0f7b889627c43b18811357fad88760b2d (patch)
tree0d4a0ad302d753638dfdb16159e03d1fb87b0872 /nexgb/xgbgen/size.go
parent1f8bd79abee5d96a41a934d1eb8c74e90ccbcc8f (diff)
downloadhaven-a548d9d0f7b889627c43b18811357fad88760b2d.tar.gz
haven-a548d9d0f7b889627c43b18811357fad88760b2d.tar.xz
haven-a548d9d0f7b889627c43b18811357fad88760b2d.zip
Fix Issue #21: automatic calculation of alignment padding after lists
Diffstat (limited to 'nexgb/xgbgen/size.go')
-rw-r--r--nexgb/xgbgen/size.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/nexgb/xgbgen/size.go b/nexgb/xgbgen/size.go
index 8836892..6e49371 100644
--- a/nexgb/xgbgen/size.go
+++ b/nexgb/xgbgen/size.go
@@ -7,24 +7,25 @@ package main
// for adding and multiplying sizes.
type Size struct {
Expression
+ exact bool
}
// newFixedSize creates a new Size with some fixed and known value.
-func newFixedSize(fixed uint) Size {
- return Size{&Value{v: int(fixed)}}
+func newFixedSize(fixed uint, exact bool) Size {
+ return Size{&Value{v: int(fixed)}, exact}
}
// newExpressionSize creates a new Size with some expression.
-func newExpressionSize(variable Expression) Size {
- return Size{variable}
+func newExpressionSize(variable Expression, exact bool) Size {
+ return Size{variable, exact}
}
// Add adds s1 and s2 and returns a new Size.
func (s1 Size) Add(s2 Size) Size {
- return Size{newBinaryOp("+", s1, s2)}
+ return Size{newBinaryOp("+", s1, s2), s1.exact && s2.exact}
}
// Multiply mupltiplies s1 and s2 and returns a new Size.
func (s1 Size) Multiply(s2 Size) Size {
- return Size{newBinaryOp("*", s1, s2)}
+ return Size{newBinaryOp("*", s1, s2), s1.exact && s2.exact}
}