Skip to content

Commit

Permalink
Now only lazily generating matlab functions
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Minerich <[email protected]>
  • Loading branch information
Rickasaurus committed Oct 19, 2013
1 parent ffbde66 commit 17aaae2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions MatlabTypeProvider/MatlabTypeProvider/InterfaceHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module MatlabFunctionHelpers =
else yield path
]

let toolboxesFromPaths (matlabPath: string) (pathTofunctionInfo: string -> MatlabFunctionInfo) (inPaths: string seq) =
let toolboxesFromPaths (matlabPath: string) (pathTofunctionInfo: string -> MatlabFunctionInfo Lazy) (inPaths: string seq) =
let toolboxPath = Path.Combine(matlabPath, "toolbox")

let inpaths = inPaths |> Set.ofSeq
Expand Down Expand Up @@ -134,7 +134,6 @@ module MatlabCallHelpers =
let randomAddendum = System.IO.Path.GetRandomFileName().Replace('.', '_')
yield System.String.Format("mtp_{0}_{1}", procid, randomAddendum)
}
//varNames |> Seq.find (fun v -> not <| Array.exists (fun cv -> cv = v) currentVariables)

let nullToOption =
function
Expand Down
2 changes: 1 addition & 1 deletion MatlabTypeProvider/MatlabTypeProvider/InterfaceTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type MatlabToolboxInfo = {
Name: string
Path: string
HelpName: string option
Funcs: MatlabFunctionInfo seq
Funcs: MatlabFunctionInfo Lazy seq
Toolboxes: MatlabToolboxInfo list
}

Expand Down
14 changes: 7 additions & 7 deletions MatlabTypeProvider/MatlabTypeProvider/MatlabInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ type MatlabCommandExecutor(proxy: MatlabCOMProxy) =
member t.GetPackageMethods (pkgName: string) =
proxy.Execute [|MatlabStrings.getPackageFunctions pkgName|] :?> string |> tsvToMethodInfo

member t.GetFunctionInfoFromFile (path: string) = MatlabFunctionHelpers.fileToFunctionInfo path
member t.GetFunctionInfoFromFile (path: string) : MatlabFunctionInfo option = MatlabFunctionHelpers.fileToFunctionInfo path

member t.GetFunctionInfoFromName (funcname: string) =
member t.GetFunctionInfoFromName (funcname: string) : MatlabFunctionInfo =
try
let numArgsIn, varArgsIn = t.GetFunctionNumInputArgs(funcname)
let numArgsOut, varArgsOut = t.GetFunctionNumOutputArgs(funcname)
Expand All @@ -68,14 +68,14 @@ type MatlabCommandExecutor(proxy: MatlabCOMProxy) =
member t.GetToolboxes () =
let matlabRoot = proxy.Execute [|"matlabroot"|] :?> string |> (fun str -> str.Trim())
let searchPaths = proxy.Execute [|"disp(path)"|] :?> string |> (fun paths -> paths.Split([|';'|], StringSplitOptions.RemoveEmptyEntries)) |> Array.map (fun str -> str.Trim())
let functionBuilder path =
match t.GetFunctionInfoFromFile(path) with
| Some fi -> fi
| None -> t.GetFunctionInfoFromName(System.IO.Path.GetFileNameWithoutExtension(path))
let functionBuilder path =
lazy match t.GetFunctionInfoFromFile(path) with
| Some fi -> fi
| None -> t.GetFunctionInfoFromName(System.IO.Path.GetFileNameWithoutExtension(path))

MatlabFunctionHelpers.toolboxesFromPaths matlabRoot functionBuilder searchPaths

member t.GetFunctionHandle (funcInfo: MatlabFunctionInfo) =
member t.GetFunctionHandle (funcInfo: MatlabFunctionInfo) : MatlabFunctionHandle =
let fexecNamed (inargs: obj []) (outargs: string []) = t.CallFunctionWithHandles(funcInfo.Name, outargs, inargs)
let fexecNum (inargs: obj []) (out: int) = t.CallFunctionWithHandles(funcInfo.Name, out, inargs)
RepresentationBuilders.getFunctionHandleFromFunctionInfo funcInfo fexecNamed fexecNum
Expand Down
2 changes: 1 addition & 1 deletion MatlabTypeProvider/MatlabTypeProvider/Provider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module LazyProviderHelpers =
#endif

// Generate Toolbox Functions
yield! tb.Funcs |> Seq.map (fun func -> generateFunctionHandlesFromDescription executor tb func :> MemberInfo)
yield! tb.Funcs |> Seq.map (fun func -> generateFunctionHandlesFromDescription executor tb (func.Force()) :> MemberInfo)
// Generate Sub-toolboxes
yield! generateToolboxes executor (tb.Toolboxes)
])
Expand Down

0 comments on commit 17aaae2

Please sign in to comment.