Commit 34aa6fa4 authored by Eric Myhre's avatar Eric Myhre

Hack settability of more adjconfig.

This thing need to be replaced with non-placeholder code soon; it's
getting pretty nasty.
parent 08391195
......@@ -20,10 +20,13 @@ type FieldTuple struct {
type AdjunctCfg struct {
typeSymbolOverrides map[schema.TypeName]string
fieldSymbolLowerOverrides map[FieldTuple]string
FieldSymbolLowerOverrides map[FieldTuple]string
fieldSymbolUpperOverrides map[FieldTuple]string
maybeUsesPtr map[schema.TypeName]bool // treat absent as true
unionMemlayout map[schema.TypeName]string // "embedAll"|"interface"; maybe more options later, unclear for now.
CfgUnionMemlayout map[schema.TypeName]string // "embedAll"|"interface"; maybe more options later, unclear for now.
// ... some of these fields have sprouted messy name prefixes so they don't collide with their matching method names.
// this structure has reached the critical threshhold where it due to be cleaned up and taken seriously.
// note: PkgName doesn't appear in here, because it's...
// not adjunct data. it's a generation invocation parameter.
......@@ -49,7 +52,7 @@ func (cfg *AdjunctCfg) TypeSymbol(t schema.Type) string {
}
func (cfg *AdjunctCfg) FieldSymbolLower(f schema.StructField) string {
if x, ok := cfg.fieldSymbolLowerOverrides[FieldTuple{f.Type().Name(), f.Name()}]; ok {
if x, ok := cfg.FieldSymbolLowerOverrides[FieldTuple{f.Type().Name(), f.Name()}]; ok {
return x
}
return f.Name() // presumed already lower
......@@ -84,7 +87,7 @@ func (cfg *AdjunctCfg) UnionMemlayout(t schema.Type) string {
if t.Kind() != schema.Kind_Union {
panic(fmt.Errorf("%s is not a union!", t.Name()))
}
v, ok := cfg.unionMemlayout[t.Name()]
v, ok := cfg.CfgUnionMemlayout[t.Name()]
if !ok {
return "embedAll"
}
......
......@@ -57,7 +57,7 @@ func TestUnionKeyed(t *testing.T) {
}
t.Run("union-using-embed", func(t *testing.T) {
adjCfg.unionMemlayout = map[schema.TypeName]string{"StrStr": "embedAll"}
adjCfg.CfgUnionMemlayout = map[schema.TypeName]string{"StrStr": "embedAll"}
prefix := "union-keyed-using-embed"
pkgName := "main"
......@@ -66,7 +66,7 @@ func TestUnionKeyed(t *testing.T) {
})
})
t.Run("union-using-interface", func(t *testing.T) {
adjCfg.unionMemlayout = map[schema.TypeName]string{"StrStr": "interface"}
adjCfg.CfgUnionMemlayout = map[schema.TypeName]string{"StrStr": "interface"}
prefix := "union-keyed-using-interface"
pkgName := "main"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment