Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::CboLoader Class Reference

Loads CBO modules and resolves their native function bindings. More...

#include <bond/vm/cboloader.h>

Public Member Functions

 CboLoader (Allocator &allocator)
 Constructs a CboLoader using the same allocator for temporary and persistent data.
 CboLoader (Allocator &tempAllocator, Allocator &permAllocator)
 Constructs a CboLoader with separate allocators for temporary and persistent data.
 CboLoader (const CboLoader &other)=delete
CboLoader & operator= (const CboLoader &other)=delete
void AddNativeBinding (const NativeBindingCollection &nativeBinding)
 Adds a collection of native function bindings used to resolve native declarations.
void AddCboFile (const void *byteCode, size_t length)
 Adds an in-memory CBO file.
void AddCboFile (InputStream &cboStream)
 Adds a CBO file stream.
CodeSegmentHandle Load ()
 Loads all added CBO files and returns the merged code segment.

Detailed Description

Loads CBO modules and resolves their native function bindings.

A CboLoader aggregates one or more CBO inputs, combines their contents into a single CodeSegment, and binds native functions from supplied NativeBindingCollections.

Constructor & Destructor Documentation

◆ CboLoader() [1/3]

Bond::CboLoader::CboLoader ( Allocator & allocator)
inlineexplicit

Constructs a CboLoader using the same allocator for temporary and persistent data.

Parameters
allocatorThe allocator used while loading and for the resulting CodeSegment.

◆ CboLoader() [2/3]

Bond::CboLoader::CboLoader ( Allocator & tempAllocator,
Allocator & permAllocator )
inline

Constructs a CboLoader with separate allocators for temporary and persistent data.

Parameters
tempAllocatorAllocator used for temporary state during loading.
permAllocatorAllocator used for data that survives in the resulting CodeSegment.

◆ CboLoader() [3/3]

Bond::CboLoader::CboLoader ( const CboLoader & other)
delete

Member Function Documentation

◆ AddCboFile() [1/2]

void Bond::CboLoader::AddCboFile ( const void * byteCode,
size_t length )
inline

Adds an in-memory CBO file.

Parameters
byteCodePointer to the CBO byte stream. The bytes are not copied and must remain valid until Load() returns.
lengthNumber of bytes in the CBO stream.

◆ AddCboFile() [2/2]

void Bond::CboLoader::AddCboFile ( InputStream & cboStream)
inline

Adds a CBO file stream.

Parameters
cboStreamInput stream containing CBO data. The stream is not copied and must remain valid until Load() returns.

◆ AddNativeBinding()

void Bond::CboLoader::AddNativeBinding ( const NativeBindingCollection & nativeBinding)
inline

Adds a collection of native function bindings used to resolve native declarations.

Parameters
nativeBindingNative binding collection to search when binding native functions. The collection is not copied and must remain valid until Load() returns.

◆ Load()

CodeSegmentHandle Bond::CboLoader::Load ( )

Loads all added CBO files and returns the merged code segment.

Each CBO is validated with a CboValidator, after which its contents are copied into a single block of memory allocated from the persistent allocator, so the CBO streams are no longer needed once this function returns. Native functions are bound to the functions in the added NativeBindingCollections and references to functions and data are resolved by name.

A Bond::Exception is thrown if a CBO is invalid or was compiled for a different pointer size, if a function or global variable is defined more than once, if a native binding names a function that does not exist or is not native, if a native function has no binding, or if a referenced function or global variable is not defined.

Returns
A CodeSegmentHandle owning the loaded CodeSegment.

◆ operator=()

CboLoader & Bond::CboLoader::operator= ( const CboLoader & other)
delete

The documentation for this class was generated from the following file:
  • include/bond/vm/cboloader.h