|
PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
|
One-line C ABI export for a hand-written NativeStrategyHost.
More...
#include <pineforge/native_host.hpp>#include <pineforge/pineforge.h>#include <cstddef>#include <cstring>#include <exception>#include <type_traits>#include <vector>Go to the source code of this file.
Data Structures | |
| class | pineforge::native_module::Module< Host > |
| The one class the macro instantiates: the host plus the module boundary. More... | |
Namespaces | |
| namespace | pineforge |
| namespace | pineforge::native_module |
Macros | |
| #define | PINEFORGE_EXPORT_NATIVE_STRATEGY(Class) |
Define the loadable-module C ABI for one NativeStrategyHost subclass. | |
Functions | |
| BacktestEngine * | pineforge::native_module::as_engine (pf_strategy_t strategy) |
| template<typename Host> | |
| Module< Host > * | pineforge::native_module::as_module (pf_strategy_t strategy) |
| template<typename Host> | |
| void | pineforge::native_module::note_error (pf_strategy_t strategy, const char *text) |
| template<typename Host, typename Fn> | |
| void | pineforge::native_module::guarded (pf_strategy_t strategy, Fn &&fn) |
Runs fn and converts any escaping exception into presentation text. | |
| Bar | pineforge::native_module::copy_bar (const pf_bar_t &in) |
| bool | pineforge::native_module::magnifier_unsupported (int bar_magnifier, int magnifier_samples, pf_magnifier_distribution_t distribution) |
A native host owns its own intrabar path through NativeRunSpec::intrabar, so the C magnifier arguments have no meaning here. | |
| void | pineforge::native_module::publish_report (BacktestEngine *engine, pf_report_t *out) |
| Fills a local report first: the caller's struct is written only once the engine has produced a complete, owned value. | |
| template<typename Host> | |
| pf_strategy_t | pineforge::native_module::create () |
| void | pineforge::native_module::destroy (pf_strategy_t strategy) |
| template<typename Host> | |
| void | pineforge::native_module::set_input (pf_strategy_t strategy, const char *key, const char *value) |
| template<typename Host> | |
| void | pineforge::native_module::set_override (pf_strategy_t strategy, const char *key, const char *value) |
| template<typename Host> | |
| void | pineforge::native_module::set_magnifier_volume_weighted (pf_strategy_t strategy, int on) |
| template<typename Host> | |
| void | pineforge::native_module::run_batch (pf_strategy_t strategy, pf_bar_t *bars, int count, const char *input_tf, const char *script_tf, bool with_timeframes, pf_report_t *out) |
| template<typename Host> | |
| void | pineforge::native_module::run_backtest (pf_strategy_t strategy, pf_bar_t *bars, int count, pf_report_t *out) |
| template<typename Host> | |
| void | pineforge::native_module::run_backtest_full (pf_strategy_t strategy, pf_bar_t *bars, int count, const char *input_tf, const char *script_tf, int bar_magnifier, int magnifier_samples, pf_magnifier_distribution_t magnifier_distribution, pf_report_t *out) |
| void | pineforge::native_module::report_free (pf_report_t *report) |
One-line C ABI export for a hand-written NativeStrategyHost.
A loadable PineForge strategy is a shared object that exports a small, fixed set of extern "C" entry points (strategy_create, run_backtest, …) declared in <pineforge/pineforge.h>. Codegen emits them for a PineScript strategy; a native C++ host had to hand-write them. This header generates exactly that surface from one macro:
The macro adds no new C symbol: every name it defines is already declared in <pineforge/pineforge.h>. The remaining runtime exports (strategy_configure_native_v1, the strategy_stream_* family, strategy_get_last_error, …) come from the engine's own c_abi.cpp; the generated strategy_create references pf_abi_version() so the linker keeps that object when the module links libpineforge.a statically.
The host class must be a NativeStrategyHost subclass and must not be final: the module wraps it in one derived class, which is what makes the engine's protected presentation-error string (read back through strategy_get_last_error) writable from the C boundary.
Definition in file native_module.hpp.
| #define PINEFORGE_EXPORT_NATIVE_STRATEGY | ( | Class | ) |
Define the loadable-module C ABI for one NativeStrategyHost subclass.
Use it once, at namespace scope, in the module's translation unit.
Definition at line 271 of file native_module.hpp.