@@ -31,97 +31,97 @@ open Bolero.TemplatingInternals
31
31
open Bolero.Templating .ConvertExpr
32
32
33
33
let getThis ( args : list < Expr >) : Expr < TemplateNode > =
34
- TExpr.Coerce< TemplateNode>( args. [0 ])
34
+ TExpr.Coerce< TemplateNode>( args[ 0 ])
35
35
36
36
let MakeCtor ( holes : Parsing.Vars ) =
37
37
ProvidedConstructor([], fun args ->
38
38
let holes = TExpr.Array< obj> [
39
39
for KeyValue(_, type') in holes ->
40
40
match type' with
41
- | Parsing. HoleType.String -> <@ box " " @>
42
- | Parsing. HoleType.Html -> <@ box ( Node.Empty()) @>
43
- | Parsing. HoleType.Event _ -> <@ box ( Events.NoOp< EventArgs>()) @>
44
- | Parsing. HoleType.DataBinding _ -> <@ box ( null , Events.NoOp< ChangeEventArgs>()) @>
45
- | Parsing. HoleType.Attribute -> <@ box ( Attr.Empty()) @>
46
- | Parsing. HoleType.AttributeValue -> <@ null @>
47
- | Parsing. HoleType.Ref -> <@ null @>
41
+ | HoleType.String -> <@ box " " @>
42
+ | HoleType.Html -> <@ box ( Node.Empty()) @>
43
+ | HoleType.Event _ -> <@ box ( Events.NoOp< EventArgs>()) @>
44
+ | HoleType.DataBinding _ -> <@ box ( null , Events.NoOp< ChangeEventArgs>()) @>
45
+ | HoleType.Attribute -> <@ box ( Attr.Empty()) @>
46
+ | HoleType.AttributeValue -> <@ null @>
47
+ | HoleType.Ref -> <@ null @>
48
48
]
49
49
<@@ (% getThis args) .Holes <- % holes @@>)
50
50
51
51
/// Get the argument lists and bodies for methods that fill a hole of the given type.
52
- let HoleMethodBodies ( holeType : Parsing. HoleType) : ( ProvidedParameter list * ( Expr list -> Expr )) list =
52
+ let HoleMethodBodies ( holeType : HoleType ) : ( ProvidedParameter list * ( Expr list -> Expr )) list =
53
53
let (= >) name ty = ProvidedParameter( name, ty)
54
54
match holeType with
55
- | Parsing. HoleType.String ->
55
+ | HoleType.String ->
56
56
[
57
57
[ " value" => typeof< string>], fun args ->
58
- <@@ box (%% args. [1 ]: string) @@>
58
+ <@@ box (%% args[ 1 ]: string) @@>
59
59
]
60
- | Parsing. HoleType.Html ->
60
+ | HoleType.Html ->
61
61
[
62
62
[ " value" => typeof< string>], fun args ->
63
- <@@ box ( Node.Text (%% args. [1 ]: string)) @@>
63
+ <@@ box ( Node.Text (%% args[ 1 ]: string)) @@>
64
64
[ " value" => typeof< Node>], fun args ->
65
- <@@ box (%% args. [1 ]: Node) @@>
65
+ <@@ box (%% args[ 1 ]: Node) @@>
66
66
]
67
- | Parsing. HoleType.Event argTy ->
67
+ | HoleType.Event argTy ->
68
68
[
69
69
[ " value" => EventHandlerOf argTy], fun args ->
70
- Expr.Coerce( args. [1 ], typeof< obj>)
70
+ Expr.Coerce( args[ 1 ], typeof< obj>)
71
71
]
72
- | Parsing. HoleType.DataBinding Parsing. BindingType.BindString ->
72
+ | HoleType.DataBinding BindingType.BindString ->
73
73
[
74
74
[ " value" => typeof< string>; " set" => typeof< Action< string>>], fun args ->
75
- <@@ box ( box (%% args. [1 ]: string), Events.OnChange(%% args. [2 ])) @@>
75
+ <@@ box ( box (%% args[ 1 ]: string), Events.OnChange(%% args[ 2 ])) @@>
76
76
]
77
- | Parsing. HoleType.DataBinding Parsing. BindingType.BindNumber ->
77
+ | HoleType.DataBinding BindingType.BindNumber ->
78
78
[
79
79
[ " value" => typeof< int>; " set" => typeof< Action< int>>], fun args ->
80
- <@@ box ( box (%% args. [1 ]: int), Events.OnChangeInt(%% args. [2 ])) @@>
80
+ <@@ box ( box (%% args[ 1 ]: int), Events.OnChangeInt(%% args[ 2 ])) @@>
81
81
[ " value" => typeof< float>; " set" => typeof< Action< float>>], fun args ->
82
- <@@ box ( box (%% args. [1 ]: float), Events.OnChangeFloat(%% args. [2 ])) @@>
82
+ <@@ box ( box (%% args[ 1 ]: float), Events.OnChangeFloat(%% args[ 2 ])) @@>
83
83
]
84
- | Parsing. HoleType.DataBinding Parsing. BindingType.BindBool ->
84
+ | HoleType.DataBinding BindingType.BindBool ->
85
85
[
86
86
[ " value" => typeof< bool>; " set" => typeof< Action< bool>>], fun args ->
87
- <@@ box ( box (%% args. [1 ]: bool), Events.OnChangeBool(%% args. [2 ])) @@>
87
+ <@@ box ( box (%% args[ 1 ]: bool), Events.OnChangeBool(%% args[ 2 ])) @@>
88
88
]
89
- | Parsing. HoleType.Attribute ->
89
+ | HoleType.Attribute ->
90
90
[
91
91
[ " value" => typeof< Attr>], fun args ->
92
- <@@ box (%% args. [1 ]: Attr) @@>
92
+ <@@ box (%% args[ 1 ]: Attr) @@>
93
93
[ " value" => typeof< list< Attr>>], fun args ->
94
- <@@ box ( Attr.Attrs(%% args. [1 ]: list< Attr>)) @@>
94
+ <@@ box ( Attr.Attrs(%% args[ 1 ]: list< Attr>)) @@>
95
95
]
96
- | Parsing. HoleType.AttributeValue ->
96
+ | HoleType.AttributeValue ->
97
97
[
98
98
[ " value" => typeof< obj>], fun args ->
99
- <@@ %% args. [1 ] @@>
99
+ <@@ %% args[ 1 ] @@>
100
100
]
101
- | Parsing. HoleType.Ref ->
101
+ | HoleType.Ref ->
102
102
[
103
103
[ " value" => typeof< HtmlRef>], fun args ->
104
- <@@ box (%% args. [1 ]: HtmlRef) @@>
104
+ <@@ box (%% args[ 1 ]: HtmlRef) @@>
105
105
]
106
106
107
- let MakeHoleMethods ( holeName : string ) ( holeType : Parsing. HoleType) ( index : int ) ( containerTy : ProvidedTypeDefinition ) =
107
+ let MakeHoleMethods ( holeName : string ) ( holeType : HoleType ) ( index : int ) ( containerTy : ProvidedTypeDefinition ) =
108
108
[
109
109
for args, value in HoleMethodBodies holeType do
110
110
yield ProvidedMethod( holeName, args, containerTy, fun args ->
111
111
let this = getThis args
112
- <@@ (% this) .Holes. [ index] <- %%( value args)
112
+ <@@ (% this) .Holes[ index] <- %%( value args)
113
113
% this @@>) :> MemberInfo
114
114
]
115
115
116
- let MakeFinalMethod ( filename : option < string >) ( subTemplateName : option < string >) ( content : Parsing. Parsed) =
116
+ let MakeFinalMethod ( filename : option < string >) ( subTemplateName : option < string >) ( content : Parsed ) =
117
117
ProvidedMethod( " Elt" , [], typeof< Node>, fun args ->
118
118
let this = getThis args
119
119
let directExpr =
120
120
let vars = content.Vars |> Map.map ( fun k v -> Var( k, TypeOf v))
121
121
let varExprs = vars |> Map.map ( fun _ v -> Expr.Var v)
122
- (( 0 , ConvertNode varExprs ( Parsing. Concat content.Expr) :> Expr), vars)
122
+ (( 0 , ConvertNode varExprs ( Concat content.Expr) :> Expr), vars)
123
123
||> Seq.fold ( fun ( i , e ) ( KeyValue ( _ , var )) ->
124
- let value = <@@ (% this) .Holes. [ i] @@>
124
+ let value = <@@ (% this) .Holes[ i] @@>
125
125
let value = Expr.Coerce( value, var.Type)
126
126
i + 1 , Expr.Let( var, value, e)
127
127
)
0 commit comments