Skip to content

Engine → Bindings

call_counters.h

Call counters of the native table. Every entry of native_api.inl, core and bindings alike, has an index (native_function_id, its .inl line order, the same value as the C# NativeFunction enum and the manifest's "index") and a descriptor. When !CONJURE_DISTRIBUTION the subsystem replaces every filled slot with counting_thunk<Id, Fn>::invoke, a forwarding function that increments sCounters[Id] and calls the original; in Distribution the raw pointers stay and call_counters() is empty. Counters are plain u32 because every entry is main-thread.

Structs

File Description
counting_thunk<Id, Ret(Args...)>
native_entry_descriptor One row of the table: its id, group and name, the normalised "<return> <arguments>" signature of the generator and whether the bindings module owns the entry.

Enumerations

native_function_id

enum class native_function_id : u16 {
#define CONJURE_BINDINGS_FUNCTION_ID(group, name, signature) group##_##name,
    CONJURE_NATIVE_API_FOR_EACH_ENTRY(CONJURE_BINDINGS_FUNCTION_ID)
#undef CONJURE_BINDINGS_FUNCTION_ID
    COUNT
};

Index of every entry of the table (one enumerator per CONJURE_NATIVE_FN line, in table order).

Type Aliases

counting_thunk<Id, Ret(Args...)>::function_pointer

using function_pointer = Ret (*)(Args...);

Forward Declarations

counting_thunk

template <native_function_id Id, typename Fn> struct counting_thunk;

The forwarding function installed over an entry's slot: one unique instantiation per entry, increments the entry's counter and calls the original pointer kept in sTarget. Specialised on the function type Ret(Args...) that the .inl's return and argument lists form.

Constants

Name Type Value Description
NATIVE_FUNCTION_COUNT inline constexpr u32 static_cast<u32>(native_function_id::COUNT) Entries in the table (core and bindings together).

Functions

Public

call_count

[[nodiscard]] CONJURE_API u32 call_count(
    native_function_id id) noexcept;

Calls recorded for one entry since the last reset; 0 in Distribution and for out-of-range ids.

call_counters

[[nodiscard]] CONJURE_API std::span<const u32> call_counters() noexcept;

The counters, NATIVE_FUNCTION_COUNT entries indexed by native_function_id; empty in Distribution.

detail::counter_storage

[[nodiscard]] CONJURE_API std::array<u32, NATIVE_FUNCTION_COUNT + 1> &counter_storage() noexcept;

The counter storage the thunks increment (one slot per entry plus one spare for COUNT so the index never needs a check).

find_function

[[nodiscard]] CONJURE_API native_function_id find_function(
    std::string_view fullName) noexcept;

The id of the entry named "<group>_<name>", or COUNT.

function_name

[[nodiscard]] CONJURE_API std::string_view function_name(
    native_function_id id) noexcept;

"transform_set_local": the C name of an entry; "" for an out-of-range id.

is_bindings_owned

[[nodiscard]] constexpr bool is_bindings_owned(
    native_function_id id) noexcept;

True when the entry belongs to one of the thirteen bindings groups (everything after the marker).

native_entry_descriptor_of

[[nodiscard]] CONJURE_API const native_entry_descriptor &native_entry_descriptor_of(
    native_function_id id) noexcept;

The descriptor of an id; the COUNT descriptor (empty names) for an out-of-range id.

native_entry_descriptors

[[nodiscard]] CONJURE_API std::span<const native_entry_descriptor> native_entry_descriptors() noexcept;

Every entry in table order.

reset_call_counters

CONJURE_API void reset_call_counters() noexcept;

Zeroes every counter (headless fixtures call it between cases).