Skip to content

Commit 5718748

Browse files
committed
refactor(codegen): Add custom arg rule to JS gen
JS wrapper method generators now has access to custom operation rules in general setup.
1 parent 6510018 commit 5718748

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

internal/code-gen/customrules/customrules.go

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ type OperationRule struct {
4343
ReturnType *TypeRule
4444
}
4545

46+
func (r OperationRule) Argument(name string) ArgumentRule {
47+
if r.Arguments == nil {
48+
return ArgumentRule{}
49+
}
50+
return r.Arguments[name]
51+
}
52+
4653
type ArgumentRules map[string]ArgumentRule
4754

4855
type ArgumentRule struct {

internal/code-gen/script-wrappers/es_wrapper_generator.go

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func createOperation(
137137
IdlType: arg.IdlType,
138138
ArgumentSpec: esArgumentSpec,
139139
Ignore: esArgumentSpec.Ignored,
140+
CustomRule: opRules.Argument(arg.Name),
140141
}
141142
if len(arg.IdlType.Types) > 0 {
142143
slog.Warn(

internal/code-gen/script-wrappers/model/es_operation_argument.go

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package model
33
import (
44
"fmt"
55

6+
"github.com/gost-dom/code-gen/customrules"
67
"github.com/gost-dom/code-gen/script-wrappers/configuration"
78
"github.com/gost-dom/webref/idl/legacy"
89
)
@@ -14,6 +15,7 @@ type ESOperationArgument struct {
1415
Variadic bool
1516
IdlType legacy.IdlTypes
1617
ArgumentSpec configuration.ESMethodArgument
18+
CustomRule customrules.ArgumentRule
1719
Ignore bool
1820
}
1921

0 commit comments

Comments
 (0)