Engine → Scripting → null_script_host.h
null_script_host¶
| Type | Class |
| Namespace | conjure::scripting |
| Include File Path | engine/include/conjure/scripting/null_script_host.h |
| Source File Path | engine/src/scripting/null_script_host.cpp |
| API ↗ | Hosting, the native API and hot reload, Scripting |
Syntax¶
Inheritance Hierarchy¶
script_host → null_script_host
Constructors¶
| Access | Signature | Description |
|---|---|---|
| public | null_script_host(); |
Destructors¶
| Access | Signature | Description |
|---|---|---|
| public | ~null_script_host() override; |
Variables¶
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | m | activity_hook | {} | |
| private | m | bool | false | |
| private | m | collision_hook | {} | |
| private | mCreateHook | create_hook | {} | |
| private | mDestroyHook | destroy_hook | {} | |
| private | mFakeClasses | std:: | {} | |
| private | mFreeList | std::vector<i32> | {} | |
| private | m | std::string | {} | |
| private | mLoadResult | i32 | 0 | |
| private | mManagedApi | conjure_managed_api | {} | |
| private | m | conjure_managed_memory | {} | |
| private | mNativeApi | conjure_native_api * | nullptr | |
| private | mPhaseHook | phase_hook | {} | |
| private | mRecorder | null_host_recorder | {} | |
| private | mReloadHook | create_hook | {} | |
| private | m | i32 | 0 | |
| private | mSlots | std::vector<slot_state> | {} | |
| private | mStatus | script_host_status | script_ | |
| private | m | i32 | 0 |
Functions¶
Public¶
active¶
active¶[[nodiscard]] static null_script_host *active() noexcept;The null host whose functions the managed table currently calls, or nullptr.
add_fake_class¶
add_fake_class¶void add_fake_class(
script_class_info info);A class load_game_assembly reports to native through script_register_class/field (fields may be in any order; the registry sorts them).
backend¶
backend¶[[nodiscard]] script_backend backend() const noexcept override;free_list¶
free_list¶[[nodiscard]] const std::vector<i32> &free_list() const noexcept;Slots on the free list, most recently freed first.
initialise¶
initialise¶[[nodiscard]] core::result<void> initialise(
const script_host_config &config,
conjure_native_api &nativeApi) override;Fills the managed table with the recording functions and becomes the active null host. Never fails; a second active null host in the process asserts and replaces the first.
is_assembly_loaded¶
is_assembly_loaded¶[[nodiscard]] bool is_assembly_loaded() const noexcept;is_slot_active¶
is_slot_active¶[[nodiscard]] bool is_slot_active(
i32 slot) const noexcept;True when the slot is live and active: a slot starts active unless its create request carried CREATE_FLAG_INACTIVE, and set_active changes it. This is what the managed side keeps per instance.
is_slot_started¶
is_slot_started¶[[nodiscard]] bool is_slot_started(
i32 slot) const noexcept;True when the slot is live and either took part in a FIXED_UPDATE or UPDATE run_phase (the phases that run OnStart; LATE_UPDATE does not start a slot) or was created with CREATE_FLAG_ALREADY_STARTED. This mirrors what the managed side marks after OnStart, so a test can inspect it.
loaded_assembly¶
loaded_assembly¶[[nodiscard]] const std::string &loaded_assembly() const noexcept;managed_api¶
managed_api¶[[nodiscard]] const conjure_managed_api &managed_api() const noexcept override;parse_classes_fixture¶
parse_classes_fixture¶[[nodiscard]] static core::result<std::vector<script_class_info>> parse_classes_fixture(
std::string_view jsonText);Parses a <assembly>.classes.json fixture: {"classes":[{"name","callbacks":["UPDATE",...], "fields":[{"name","kind","elementKind","default","meta"}]}]}.
recorder¶
recorder¶[[nodiscard]] const null_host_recorder &recorder() const noexcept;remove_fake_class¶
remove_fake_class¶bool remove_fake_class(
u64 classHash);Removes a fake class so the next load models an assembly that dropped it.
reset_recorder¶
reset_recorder¶void reset_recorder();set_activity_hook¶
set_activity_hook¶void set_activity_hook(
activity_hook hook);set_collect_override¶
set_collect_override¶Bytes collect_fields returns for a slot instead of echoing the last apply_fields blob.
set_collision_hook¶
set_collision_hook¶void set_collision_hook(
collision_hook hook);set_create_hook¶
set_create_hook¶void set_create_hook(
create_hook hook);Callbacks standing in for managed script code (empty = none). They run on the main thread inside the managed_api call and may call back into the runtime like a script would: add scripts, destroy entities, open query scopes through the native table.
set_destroy_hook¶
set_destroy_hook¶void set_destroy_hook(
destroy_hook hook);set_load_result¶
set_load_result¶void set_load_result(
i32 result) noexcept;The value load_game_assembly returns (0 = success; a scripting_error code models a failed load).
set_managed_memory¶
set_managed_memory¶void set_managed_memory(
const conjure_managed_memory &memory) noexcept;The counters sample_memory reports from now on (all 0 until set), standing in for the CLR's. Like the CLR's, every field but heap_bytes should only grow while the host lives; a test models a host restart by setting smaller values.
set_phase_hook¶
set_phase_hook¶void set_phase_hook(
phase_hook hook);set_recording¶
set_recording¶void set_recording(
bool enabled) noexcept;False makes the recorder record nothing (null_host_recorder::set_enabled) and the host build no record, so recording adds no allocation to a managed call: for long runs and allocation gates. Only the slot state the host keeps (a new slot, a slot's fields) may still grow. Survives reset_recorder(). On by default.
set_reload_hook¶
set_reload_hook¶void set_reload_hook(
create_hook hook);set_sample_memory_result¶
set_sample_memory_result¶void set_sample_memory_result(
i32 result) noexcept;The value sample_memory returns (0 = success and out filled; a negative scripting status models a failed sample and leaves out untouched).
set_unload_result¶
set_unload_result¶void set_unload_result(
i32 result) noexcept;The value unload_game_assembly returns: 0 collected, 1 leaked.
shutdown¶
shutdown¶void shutdown() override;Frees every slot, forgets the loaded assembly, deactivates. Recorded as "shutdown".
slot_entity¶
slot_entity¶Entity recorded for a live slot (0 otherwise).
slot_fields¶
slot_fields¶Blob last applied to a live slot (empty otherwise).
slot_phase_count¶
slot_phase_count¶[[nodiscard]] u32 slot_phase_count(
i32 slot,
script_phase phase) const noexcept;How often a live slot took part in run_phase(phase).
status¶
status¶[[nodiscard]] script_host_status status() const noexcept override;Private¶
create_instances¶
create_instances¶[[nodiscard]] i32 create_instances(
conjure_create_request *requests,
i32 count);destroy_instances¶
destroy_instances¶dispatch_collisions¶
dispatch_collisions¶[[nodiscard]] i32 dispatch_collisions(
const conjure_collision_record *records,
i32 count);register_classes_with_native¶
register_classes_with_native¶void register_classes_with_native(
const std::vector<script_class_info> &classes);sample_memory¶
sample_memory¶[[nodiscard]] i32 sample_memory(
conjure_managed_memory *out);trampoline_collect_fields¶
trampoline_collect_fields¶trampoline_create_instances¶
trampoline_create_instances¶static i32 trampoline_create_instances(
conjure_create_request *requests,
i32 count);trampoline_destroy_instances¶
trampoline_destroy_instances¶trampoline_dispatch_collisions¶
trampoline_dispatch_collisions¶static i32 trampoline_dispatch_collisions(
const conjure_collision_record *records,
i32 count);trampoline_load_game_assembly¶
trampoline_load_game_assembly¶trampoline_sample_memory¶
trampoline_sample_memory¶static i32 trampoline_sample_memory(
conjure_managed_memory *out);