Add the R binding over the C ABI hub (#230)

Adds an R binding (`bindings/r`) over the C ABI hub — the third language stecker after C# and Go, reaching the hub through R's native `.Call` interface (not extendr).

## What's here
- **`bindings/r`** — an R package exposing all 514 indicators as constructors that return a `wickra_indicator` object with generic `update`/`batch`/`reset` methods. The C glue (`src/wickra.c`) and R wrappers (`R/indicators.R`) are generated from `bindings/c/include/wickra.h` (same archetype taxonomy as the C#/Go generators: scalar/batch, multi-output, bars, profile, profile-values, array-input). The opaque handle is an R external pointer freed by a registered finalizer; multi-output returns a named vector (`NA` at warmup), bars a matrix, profiles a list.
- **`examples/r`** — the full example suite mirroring C/C#/Go: streaming, backtest, multi_timeframe, parallel_assets (`mclapply`), three strategies, and `fetch_btcusdt`/`live_binance`.
- **CI** — an `r` job builds the C ABI library, installs the package, runs the `testthat` suite and the offline examples on Linux, macOS and Windows (`R CMD check` is clean: 0 warnings, 0 notes).
- **Docs** — R added to the README languages table, project layout, building/testing, CONTRIBUTING binding table + regenerate note, ARCHITECTURE, examples index, issue/PR templates, the About-description template, and the other binding READMEs.

## Linking / distribution
The package compiles a thin `.Call` glue layer against the prebuilt C ABI library (header via `WICKRA_INCLUDE_DIR`, library via `WICKRA_LIB_DIR`). On Windows the package's own `wickra.dll` would collide with the C ABI's `wickra.dll`, so `configure.win` stages a renamed copy (`wickra_abi.dll`) and builds an import library referencing it; `install.libs.R` bundles the DLL and `.onLoad` puts it on the load path. On Linux/macOS the rpath locates the shared library. No `release.yml` change — R is distributed via r-universe / source install (gated).

No Rust crate or `Cargo.toml` change — the R package is standalone and additive.
This commit is contained in:
kingchenc
2026-06-09 19:18:40 +02:00
committed by GitHub
parent 8225e1ab91
commit b7ef63400d
569 changed files with 30036 additions and 25 deletions
+7
View File
@@ -0,0 +1,7 @@
# Build artifacts and the configure.win-generated C ABI import shims.
*.o
*.so
*.dll
*.dll.a
wickra_abi.def
symbols.rds
+5
View File
@@ -0,0 +1,5 @@
# The Wickra C ABI header and library are not vendored; point the build at them
# via WICKRA_INCLUDE_DIR (containing wickra.h) and WICKRA_LIB_DIR (containing
# libwickra). Build the library first with: cargo build -p wickra-c --release.
PKG_CPPFLAGS = -I$(WICKRA_INCLUDE_DIR)
PKG_LIBS = -L$(WICKRA_LIB_DIR) -lwickra -Wl,-rpath,$(WICKRA_LIB_DIR)
+5
View File
@@ -0,0 +1,5 @@
# Link the import library built by configure.win (references wickra_abi.dll, not
# the package's own wickra.dll). The C ABI header dir is passed via
# WICKRA_INCLUDE_DIR at build time.
PKG_CPPFLAGS = -I$(WICKRA_INCLUDE_DIR)
PKG_LIBS = libwickra_abi.dll.a
+10
View File
@@ -0,0 +1,10 @@
# Install the compiled package shared object plus, on Windows, the bundled
# wickra_abi.dll (matched by the *.dll glob) so the loader can resolve the import
# from the package's own libs directory (see .onLoad, which puts it on PATH).
files <- Sys.glob(paste0("*", SHLIB_EXT))
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH))
dir.create(dest, recursive = TRUE, showWarnings = FALSE)
file.copy(files, dest, overwrite = TRUE)
if (file.exists("symbols.rds")) {
file.copy("symbols.rds", dest, overwrite = TRUE)
}
File diff suppressed because it is too large Load Diff