fullstack-lang / gong

Gong (go+ng) is a go sub-language that compiles to go and angular. All valid go is valid gong and vice versa. Gong enables fast development of web applications. Gong is model centric and by default, a UML diagram editor of the model is embedded in each application.
MIT License
11 stars 1 forks source link

Make probe a stack #450

Closed thomaspeugeot closed 8 months ago

thomaspeugeot commented 10 months ago

problem

The probe code is generated for each stack. In theory, it should be generic:

Opportunities

less generated code

means less complexity

reusable functions

Analysis

Form

func FillUpForm[T models.Gongstruct](
    instance *T,
    formGroup *form.FormGroup,
    probe *Probe,
) {

    switch instanceWithInferedType := any(instance).(type) {
    // insertion point
    case *models.Astruct:
        // insertion point
        BasicFieldtoForm("Name", instanceWithInferedType.Name, instanceWithInferedType, probe.formStage, formGroup, false)
        AssociationFieldToForm("Associationtob", instanceWithInferedType.Associationtob, formGroup, probe)
        AssociationSliceToForm("Anarrayofb", instanceWithInferedType, &instanceWithInferedType.Anarrayofb, formGroup, probe)

In this case, one need a function that returns all the fields of an instance.

type Field interface {

}

The is already generic functions like

func GetFields[Type Gongstruct]() (res []string) {
...
func GetFieldStringValueFromPointer[Type PointerToGongstruct](instance Type, fieldName string) (res string) {

They are based on Gongstruct. That is something that is stack specific.