Skip to content

Commit 4aade26

Browse files
committed
CR feedback
1 parent 153bca0 commit 4aade26

File tree

2 files changed

+99
-133
lines changed

2 files changed

+99
-133
lines changed

Shared.fs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ open Microsoft.FSharp.Reflection
1313
module GlobalVars =
1414
if not (Directory.Exists(__SOURCE_DIRECTORY__ + @"\generated")) then
1515
Directory.CreateDirectory(__SOURCE_DIRECTORY__ + @"\generated") |> ignore
16-
16+
1717
let inputFolder = __SOURCE_DIRECTORY__ + @"\inputfiles"
1818
let makeTextWriter fileName = File.CreateText(__SOURCE_DIRECTORY__ + @"\generated\" + fileName) :> TextWriter
1919
let jsWebOutput = makeTextWriter "domWeb.js"
@@ -102,7 +102,7 @@ type Printer(target : TextWriter) =
102102
member this.endBrace() =
103103
this.decreaseIndent()
104104
this.printl "}"
105-
105+
106106
member this.resetIndent() = curTabCount <- 0
107107
member this.printWithAddedIndent content =
108108
Printf.kprintf (fun s -> output.Append("\r\n" + this.getCurIndent() + " " + s) |> ignore) content
@@ -169,6 +169,15 @@ type DumpScope =
169169
| InstanceOnly
170170
| All
171171

172+
// Used to decide if a member should be emitted given its static property and
173+
// the intended scope level.
174+
let inline matchScope scope (x: ^a when ^a: (member Static: Option<int>)) =
175+
if scope = DumpScope.All then true
176+
else
177+
let isStatic = (^a: (member Static: Option<int>)x)
178+
if isStatic.IsSome then scope = DumpScope.StaticOnly
179+
else scope = DumpScope.InstanceOnly
180+
172181
/// ===========================================
173182
/// Shared data and helper functions
174183
/// ===========================================
@@ -190,8 +199,7 @@ let AdjustParamName name =
190199
| _ -> name
191200

192201
/// Quick checker for option type values
193-
let OptionCheckValue value =
194-
function
202+
let OptionCheckValue value = function
195203
| Some v when v = value -> true
196204
| _ -> false
197205

@@ -228,9 +236,7 @@ let inline ShouldKeep flavor (i : ^a when ^a : (member Tags : string option) and
228236
let allWebNonCallbackInterfaces = Array.concat [| browser.Interfaces; browser.MixinInterfaces.Interfaces |]
229237

230238
let allWebInterfaces =
231-
Array.concat [| browser.Interfaces
232-
[| browser.CallbackInterfaces.Interface |]
233-
browser.MixinInterfaces.Interfaces |]
239+
Array.concat [| browser.Interfaces; [| browser.CallbackInterfaces.Interface |]; browser.MixinInterfaces.Interfaces |]
234240

235241
let allWorkerAdditionalInterfaces = Array.concat [| worker.Interfaces; worker.MixinInterfaces.Interfaces |]
236242
let allInterfaces = Array.concat [| allWebInterfaces; allWorkerAdditionalInterfaces |]
@@ -555,3 +561,14 @@ let workerEventsMap =
555561
("loadend", "ProgressEvent")
556562
("progress", "ProgressEvent") ]
557563
|> Map.ofList
564+
565+
module Option =
566+
let runIfSome f x =
567+
match x with
568+
| Some x' -> f x'
569+
| _ -> ()
570+
571+
let toBool f x =
572+
match x with
573+
| Some x' -> f x'
574+
| _ -> false

0 commit comments

Comments
 (0)