Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ld
go-ld-prime
Commits
2f7f3437
Commit
2f7f3437
authored
Jan 03, 2021
by
Eric Myhre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drop old generation mechanisms that were already deprecated.
parent
e89a5536
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
65 deletions
+0
-65
schema/gen/go/generate.go
schema/gen/go/generate.go
+0
-65
No files found.
schema/gen/go/generate.go
View file @
2f7f3437
...
...
@@ -135,71 +135,6 @@ func Generate(pth string, pkgName string, ts schema.TypeSystem, adjCfg *AdjunctC
})
}
// GenerateSplayed is like Generate, but emits a differnet pattern of files.
// GenerateSplayed emits many more individual files than Generate.
//
// This function should be considered deprecated and may be removed in the future.
func
GenerateSplayed
(
pth
string
,
pkgName
string
,
ts
schema
.
TypeSystem
,
adjCfg
*
AdjunctCfg
)
{
// Emit fixed bits.
withFile
(
filepath
.
Join
(
pth
,
"minima.go"
),
func
(
f
io
.
Writer
)
{
EmitInternalEnums
(
pkgName
,
f
)
})
// Emit a file for each type.
for
_
,
typ
:=
range
ts
.
GetTypes
()
{
withFile
(
filepath
.
Join
(
pth
,
"t"
+
typ
.
Name
()
.
String
()
+
".go"
),
func
(
f
io
.
Writer
)
{
EmitFileHeader
(
pkgName
,
f
)
switch
t2
:=
typ
.
(
type
)
{
case
*
schema
.
TypeBool
:
EmitEntireType
(
NewBoolReprBoolGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeInt
:
EmitEntireType
(
NewIntReprIntGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeFloat
:
EmitEntireType
(
NewFloatReprFloatGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeString
:
EmitEntireType
(
NewStringReprStringGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeBytes
:
EmitEntireType
(
NewBytesReprBytesGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeLink
:
EmitEntireType
(
NewLinkReprLinkGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeStruct
:
switch
t2
.
RepresentationStrategy
()
.
(
type
)
{
case
schema
.
StructRepresentation_Map
:
EmitEntireType
(
NewStructReprMapGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
schema
.
StructRepresentation_Tuple
:
EmitEntireType
(
NewStructReprTupleGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
schema
.
StructRepresentation_Stringjoin
:
EmitEntireType
(
NewStructReprStringjoinGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
default
:
panic
(
"unrecognized struct representation strategy"
)
}
case
*
schema
.
TypeMap
:
EmitEntireType
(
NewMapReprMapGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeList
:
EmitEntireType
(
NewListReprListGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
*
schema
.
TypeUnion
:
switch
t2
.
RepresentationStrategy
()
.
(
type
)
{
case
schema
.
UnionRepresentation_Keyed
:
EmitEntireType
(
NewUnionReprKeyedGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
case
schema
.
UnionRepresentation_Kinded
:
EmitEntireType
(
NewUnionKindedGenerator
(
pkgName
,
t2
,
adjCfg
),
f
)
default
:
panic
(
"unrecognized union representation strategy"
)
}
default
:
panic
(
"add more type switches here :)"
)
}
})
}
// Emit the unified type table.
withFile
(
filepath
.
Join
(
pth
,
"typeTable.go"
),
func
(
f
io
.
Writer
)
{
fmt
.
Fprintf
(
f
,
"package %s
\n\n
"
,
pkgName
)
fmt
.
Fprintf
(
f
,
doNotEditComment
+
"
\n\n
"
)
EmitTypeTable
(
pkgName
,
ts
,
adjCfg
,
f
)
})
}
func
withFile
(
filename
string
,
fn
func
(
io
.
Writer
))
{
f
,
err
:=
os
.
OpenFile
(
filename
,
os
.
O_CREATE
|
os
.
O_TRUNC
|
os
.
O_WRONLY
,
0644
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment