Import with #import "std/bundle_host".

HostValueKind :: enum { HostVoid = 0; HostInteger = 1; HostUnsigned = 2; HostReal = 3; HostString = 4; HostRecord = 5; HostSlice = 6; HostPointer = 7; HostArray = 8; }
HostValue :: struct { kind: s32; type_name: *u8; integer: s64; bits: u64; real: float64; data: *u8; length: usize; fields: *HostField; field_count: usize; elements: *HostValue; pointer: *void; }
HostField :: struct { name: *u8; value: HostValue; }
HostCall :: #type (context: *void, module: *u8, function: *u8, arguments: *HostValue, count: s32, result: *HostValue) -> s32
HostBinding :: struct { module: *u8; function: *u8; call: HostCall; context: *void; }
BundleStateValue :: struct { module: *u8; name: *u8; type: *u8; value: HostValue; }
BundleStateMigrate :: #type (context: *void, old_state: *void, new_state: *void) -> s32
BundleComponentVerify :: #type (context: *void, instance: *void) -> s32
BundleCapabilityAbi :: struct { module: *u8; function: *u8; signature: *u8; arguments: *u8; return_type: *u8; variable_arguments: s32; reads_arguments: s32; }
UsePortableBundleVm :: (enabled: bool)

Select the portable VM for subsequent opens and instances in this process.

OpenBundle :: (path: *u8) -> *void
OpenBundleWithLibraries :: (path: *u8, libraries: **void, count: u64) -> *void
OpenBundleBytesWithLibraries :: (data: *u8, size: u64, libraries: **void, count: u64) -> *void
OpenBundleBytes :: (data: *u8, size: u64) -> *void
CloseBundle :: (bundle: *void)
BundleCapabilities :: (bundle: *void) -> u64

Borrowed names remain valid until CloseBundle. A host can bind the exact package-qualified names in a downloaded program without knowing its lock.

BundleCapabilityModuleName :: (bundle: *void, index: u64) -> *u8
BundleCapabilityFunctionName :: (bundle: *void, index: u64) -> *u8
ReadBundleCapabilityAbi :: (bundle: *void, index: u64, abi: *BundleCapabilityAbi) -> s32
BundlesAbiCompatible :: (left: *void, right: *void) -> bool
BundleEntryModule :: (bundle: *void) -> *u8
BundleEntryFunction :: (bundle: *void) -> *u8
BundleCodeDigest :: (bundle: *void, identity: *u8)
BundleAssets :: (bundle: *void) -> u64
BundleOwnAssets :: (bundle: *void) -> u64

Own assets precede inherited library assets in the resource table.

BundleAssetPath :: (bundle: *void, index: u64) -> *u8
BundleAssetBytes :: (bundle: *void, index: u64) -> *u8
BundleAssetLength :: (bundle: *void, index: u64) -> u64
InstantiateBundle :: (bundle: *void, bindings: *HostBinding, count: u64) -> *void
InstantiateBundleLimited :: (bundle: *void, bindings: *HostBinding, count: u64, max_steps: s32) -> *void

Portable VM with one positive budget covering global initialization and runs.

InstantiateBundlePortable :: (bundle: *void, bindings: *HostBinding, count: u64) -> *void
RunBundleInstance :: (instance: *void, result: *s64, has_result: *s32) -> s32
CloseBundleInstance :: (instance: *void)
LimitBundleSteps :: (instance: *void, max_steps: s32)
MatchBundleFieldsByName :: (instance: *void, enabled: bool)

Records returned to the instance match fields by name, so a bundle built against an older or newer record layout still runs.

ExportBundleState :: (instance: *void, state: **void) -> bool
ImportBundleState :: (instance: *void, state: *void) -> bool
BundleStateValueCount :: (state: *void) -> u64
BundleStateBytes :: (state: *void) -> u64
ReadBundleStateValue :: (state: *void, index: u64, value: *BundleStateValue) -> bool
BundleStateValueReference :: (state: *void, index: u64) -> *BundleStateValue
FindBundleStateValue :: (state: *void, module: *u8, name: *u8, index: *u64) -> bool
SetBundleStateInteger :: (state: *void, index: u64, value: s64) -> bool
SetBundleStateUnsigned :: (state: *void, index: u64, value: u64) -> bool
SetBundleStateReal :: (state: *void, index: u64, value: float64) -> bool
SetBundleStateString :: (state: *void, index: u64, data: *u8, length: u64) -> bool
CloseBundleState :: (state: *void)
OpenBundleComponent :: (bundle: *void, bindings: *HostBinding, count: u64, max_steps: s32) -> *void
AcquireBundleComponent :: (component: *void) -> *void
BundleComponentHandleIsValid :: (handle: *void) -> bool
RunBundleComponent :: (handle: *void, result: *s64, has_result: *s32) -> s32
ReplaceBundleComponent :: (component: *void, replacement: *void, migrate: BundleStateMigrate, verify: BundleComponentVerify, context: *void, new_handle: **void) -> bool
BundleComponentLiveBytes :: (component: *void) -> u64
CloseBundleComponent :: (component: *void)
CloseBundleComponentHandle :: (handle: *void)

Source ↗ · All modules