The Endstone C++ interop surface for the Hosihikari projection: a CI-generated native-style Interop and the native binding shim.
Hosihikari.Binding.Endstone.Interopis generated byHosihikariProjection/BindingGeneratorfrom the versioned IR. It mirrors Endstone declarations: single-level pointer and reference returns become typed borrowed wrappers,optional_ref<T>results reuse those wrappers, and other opaque handles staynint. ABI value types and the shim loader come fromHosihikariProjection/BindingAbi.native/BindingShim/is the C ABI projection. Endstone plugins resolve the server throughendstone::detail::getServer(); the shim uses the same bootstrap and calls virtual interfaces directly, so it needs no Endstone import library.- The shim builds on Windows x64 with clang-cl. On Linux x64, CI builds the libTooling frontend, generates
linux-x64-serverIR from the Endstone headers, emits the same Interop surface from that IR, and compiles the shim withnative/BindingShim/build.sh. - The hand-written Idiomatic layer is deferred; the generated Interop is the current public interop surface.
- Interop: 245 generated C# files under
src/Hosihikari.Binding.Endstone.Interop/Generated/. - Binding Shim: 2,422 functions in
native/BindingShim/generated/win-x64-server/endstone/. - Coverage: 307 declarations and 1,968 members bound.
The shim is emitted in --virtual-dispatch mode. Inline members, virtual methods (including pure virtual interfaces), eligible template instances, inline/constexpr static fields, std::optional<T> parameters/results, std::vector<T> parameters/results, std::unique_ptr<T> results, std::shared_ptr<T> results, nonstd::expected_lite::expected<T, std::string> results, std::variant<T...> parameters/results, NotNull/Nullable shared handles, borrowed pointer sets, owned/shared element arrays, chrono time values, returned std::function callables, unordered_map parameters and results as dictionaries, shared_ptr parameters as shared handles, unique_ptr parameters as ownership transfers, and borrowed-string identifiers through holder-backed factories, namespace-level inline functions as Functions static classes, namespace-level comparison operators as static operator_equal-style methods, enum declarations as C# enums carrying their evaluated enumerators, and ModalForm controls through the typed form-control variant are projected; non-virtual out-of-line members remain Interop stubs with a reasoned NotSupportedException message and an [Obsolete] marker that raises CS0618 when called; a type with no usable member keeps its type identity and carries the same marker. Host-owned interface objects are not disposed; only objects created by the shim receive a disposer.
NativeMethods.Load(path) loads the shim. NativeMethods.GetServer() returns the host endstone::Server handle, which can be wrapped with the generated Server class.
The frontend parses include/endstone/endstone.hpp with the Endstone dependency headers:
powershell -File ../Binding.Generator/frontend/run-endstone.ps1
powershell -File scripts/regenerate.ps1 -IrDirectory ..\Binding.Generator\artifacts\endstone-ir -AbiRoot ..\Binding.Abidotnet build Hosihikari.Binding.Endstone.slnx -c Release
powershell -File native/BindingShim/build.ps1The generated shim directory contains hosihikari_abi.h from BindingAbi, so the native build stays self-contained. The native build uses clang-cl, C++20, the MSVC STL, and the expected-lite/nlohmann_json headers already provisioned by the local toolchain. It does not link endstone_core; calls dispatch through the host-provided virtual interfaces.
scripts/run-benchmarks.ps1 loads the shim in a real Endstone server through a native plugin that hosts the CLR with nethost/hostfxr, then runs the managed benchmark assembly in-process. It reports nanoseconds and managed allocation per call for scalar and string methods, string/int vector parameters, map parameters and results, variant-valued maps, and shared handles. Results are written to data/hosihikari/shim-benchmarks/benchmarks.txt; the numbers are environment-dependent and are not a CI gate. See tests/benchmarks/README.md.
scripts/verify_generated.py checks provenance, the coverage baseline, the native table function count, the table version, and the managed table. CI builds the solution, runs the verifier, and validates the committed coverage contract with the generator.
HosihikariProjection/BindingIr: schema, models, reader/writer, validator.HosihikariProjection/BindingAbi: shared ABI value types, loader, and native header.HosihikariProjection/BindingGenerator: libTooling frontend and emitters.HosihikariProjection/LeviLaminaBinding: the LeviLamina interop surface.
LGPL-3.0-or-later, see LICENSE.md.