Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 2.69 KB

overview.md

File metadata and controls

52 lines (39 loc) · 2.69 KB
id embedding-overview
title Embedding Overview
slug /embedding/overview

FScript is designed for host applications that embed a scripting language safely.

Embedding workflow

  1. Reference Language/Runtime for embedding and the independent Extensibility SDK for provider authoring.
  2. Build a host context.
  3. Register typed extern handlers and, when needed, host-provided types your scripts can use.
  4. Load scripts (with include resolution if needed).
  5. Resolve exported function signatures.
  6. Execute exported functions and handle results/errors.

NuGet packages

Recommended reading order

  1. Real-World Embedding (Load, Resolve Type, Execute)
  2. Fable and JavaScript Hosts
  3. Register Extern Functions
  4. Host-Provided Types
  5. Environment Configuration
  6. Resolver and Includes
  7. Sandbox and Safety

Executable graphics sample

The FFI graphics walkthrough puts geometry, camera, lighting, and animation in FScript. A typed .NET provider uploads the generated Utah teapot and renders it with OpenGL. It demonstrates script-constructible scene records, opaque window/mesh resources, typed function adapters, and editor discovery through fscript.toml. Run it with fscript samples/ffi/main.fss; use -- --headless to exercise the scripts without a display.

Optional task-sharing checks

To report potential FFI sharing before interpreting, call ScriptHost.loadSourceWithTaskSharingAnalysis registration purity options report source. Use PurityContracts.empty and TaskSharingAnalysis.defaults for conservative defaults. The report callback receives diagnostics before script evaluation; hosts decide whether to log warnings or reject execution.

loadFileWithTaskSharingAnalysis and loadProgramWithTaskSharingAnalysis support file and parsed-program loading. They reuse the resolved inference result for interpretation. Existing loading and invocation APIs skip analysis entirely, and there is no runtime tracking or synchronization overhead.

See Checking FFI Task Sharing for examples, provider contracts, and how to interpret the warnings.