Skip to content

Commit

Permalink
feat!: use frontendRef instead of just frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Vehmloewff committed Dec 15, 2024
1 parent e660a32 commit d0d3205
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type object struct {
Children []object
}

type FrontendRef struct {
Current *Frontend
}

type Frontend struct {
CurrentChildrenFunc func()
stack []object
Expand Down
14 changes: 7 additions & 7 deletions schema/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ func (self *generator) writeSchema(schema *Schema) {
})

self.writeStruct(self.frontendName, func() {
self.text.WriteString("frontend *objection.Frontend")
self.text.WriteString("frontendRef *objection.FrontendRef")
})

self.writeFunc(
fmt.Sprintf("New%s", self.frontendName),
"",
func() {
self.text.WriteString("frontend *objection.Frontend")
self.text.WriteString("frontendRef *objection.FrontendRef")
},
self.frontendName,
func() {
self.writeReturnStatement(func() {
self.writeStructConstruction(self.frontendName, func() {
self.text.WriteString("frontend,")
self.text.WriteString("frontendRef,")
})
})
},
Expand Down Expand Up @@ -68,14 +68,14 @@ func (self *generator) writeObjectMethod(object *ObjectDef) {
},
"",
func() {
self.text.WriteString("self.frontend.StartNewObject(")
self.text.WriteString("self.frontendRef.Current.StartNewObject(")
self.writeStringLiteral(object.Name)
self.text.WriteString(")\n")

self.text.WriteString("self.frontend.SetAttributes(attributes)\n")
self.text.WriteString("self.frontend.CurrentChildrenFunc = children\n")
self.text.WriteString("self.frontendRef.Current.SetAttributes(attributes)\n")
self.text.WriteString("self.frontendRef.Current.CurrentChildrenFunc = children\n")
self.text.WriteString("children()\n")
self.text.WriteString("self.frontend.FinishObject()")
self.text.WriteString("self.frontendRef.Current.FinishObject()")
},
)

Expand Down

0 comments on commit d0d3205

Please sign in to comment.