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 { ...@@ -20,10 +20,13 @@ type FieldTuple struct {
type AdjunctCfg struct { type AdjunctCfg struct {
typeSymbolOverrides map[schema.TypeName]string typeSymbolOverrides map[schema.TypeName]string
fieldSymbolLowerOverrides map[FieldTuple]string FieldSymbolLowerOverrides map[FieldTuple]string
fieldSymbolUpperOverrides map[FieldTuple]string fieldSymbolUpperOverrides map[FieldTuple]string
maybeUsesPtr map[schema.TypeName]bool // treat absent as true 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... // note: PkgName doesn't appear in here, because it's...
// not adjunct data. it's a generation invocation parameter. // not adjunct data. it's a generation invocation parameter.
...@@ -49,7 +52,7 @@ func (cfg *AdjunctCfg) TypeSymbol(t schema.Type) string { ...@@ -49,7 +52,7 @@ func (cfg *AdjunctCfg) TypeSymbol(t schema.Type) string {
} }
func (cfg *AdjunctCfg) FieldSymbolLower(f schema.StructField) 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 x
} }
return f.Name() // presumed already lower return f.Name() // presumed already lower
...@@ -84,7 +87,7 @@ func (cfg *AdjunctCfg) UnionMemlayout(t schema.Type) string { ...@@ -84,7 +87,7 @@ func (cfg *AdjunctCfg) UnionMemlayout(t schema.Type) string {
if t.Kind() != schema.Kind_Union { if t.Kind() != schema.Kind_Union {
panic(fmt.Errorf("%s is not a union!", t.Name())) panic(fmt.Errorf("%s is not a union!", t.Name()))
} }
v, ok := cfg.unionMemlayout[t.Name()] v, ok := cfg.CfgUnionMemlayout[t.Name()]
if !ok { if !ok {
return "embedAll" return "embedAll"
} }
......
...@@ -57,7 +57,7 @@ func TestUnionKeyed(t *testing.T) { ...@@ -57,7 +57,7 @@ func TestUnionKeyed(t *testing.T) {
} }
t.Run("union-using-embed", func(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" prefix := "union-keyed-using-embed"
pkgName := "main" pkgName := "main"
...@@ -66,7 +66,7 @@ func TestUnionKeyed(t *testing.T) { ...@@ -66,7 +66,7 @@ func TestUnionKeyed(t *testing.T) {
}) })
}) })
t.Run("union-using-interface", func(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" prefix := "union-keyed-using-interface"
pkgName := "main" 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