Skip to content

Fix for static interfaces with non-static methods #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions Shared.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open Microsoft.FSharp.Reflection
module GlobalVars =
if not (Directory.Exists(__SOURCE_DIRECTORY__ + @"\generated")) then
Directory.CreateDirectory(__SOURCE_DIRECTORY__ + @"\generated") |> ignore

let inputFolder = __SOURCE_DIRECTORY__ + @"\inputfiles"
let makeTextWriter fileName = File.CreateText(__SOURCE_DIRECTORY__ + @"\generated\" + fileName) :> TextWriter
let jsWebOutput = makeTextWriter "domWeb.js"
Expand Down Expand Up @@ -102,7 +102,7 @@ type Printer(target : TextWriter) =
member this.endBrace() =
this.decreaseIndent()
this.printl "}"

member this.resetIndent() = curTabCount <- 0
member this.printWithAddedIndent content =
Printf.kprintf (fun s -> output.Append("\r\n" + this.getCurIndent() + " " + s) |> ignore) content
Expand Down Expand Up @@ -169,6 +169,15 @@ type DumpScope =
| InstanceOnly
| All

// Used to decide if a member should be emitted given its static property and
// the intended scope level.
let inline matchScope scope (x: ^a when ^a: (member Static: Option<int>)) =
if scope = DumpScope.All then true
else
let isStatic = (^a: (member Static: Option<int>)x)
if isStatic.IsSome then scope = DumpScope.StaticOnly
else scope = DumpScope.InstanceOnly

/// ===========================================
/// Shared data and helper functions
/// ===========================================
Expand All @@ -190,8 +199,7 @@ let AdjustParamName name =
| _ -> name

/// Quick checker for option type values
let OptionCheckValue value =
function
let OptionCheckValue value = function
| Some v when v = value -> true
| _ -> false

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

let allWebInterfaces =
Array.concat [| browser.Interfaces
[| browser.CallbackInterfaces.Interface |]
browser.MixinInterfaces.Interfaces |]
Array.concat [| browser.Interfaces; [| browser.CallbackInterfaces.Interface |]; browser.MixinInterfaces.Interfaces |]

let allWorkerAdditionalInterfaces = Array.concat [| worker.Interfaces; worker.MixinInterfaces.Interfaces |]
let allInterfaces = Array.concat [| allWebInterfaces; allWorkerAdditionalInterfaces |]
Expand Down Expand Up @@ -555,3 +561,14 @@ let workerEventsMap =
("loadend", "ProgressEvent")
("progress", "ProgressEvent") ]
|> Map.ofList

module Option =
let runIfSome f x =
match x with
| Some x' -> f x'
| _ -> ()

let toBool f x =
match x with
| Some x' -> f x'
| _ -> false
Loading