Changelog
Source:NEWS.md
RSimpleFFI 1.0.1.9002 (Development)
New Features
-
Added
generate_htslib_package.Rtool: Script to generate FFI bindings for htslib (SAM/BAM/VCF/BCF library) demonstrating package generation capabilities.
Breaking Changes
-
ffi_struct()andffi_union()parameter renamed:pack→.pack- The dot prefix prevents collision with C struct field names like
pack - Old code using
pack = 1should change to.pack = 1
- The dot prefix prevents collision with C struct field names like
Internal Changes
- Removed
strip_type_qualifiers()- tree-sitter AST parsing handles type qualifier stripping directly via node type filtering, making the regex-based approach unnecessary.
Bug Fixes
Fixed anonymous bitfields (e.g.,
: 30for padding) causing empty field names in generated code by checking fornode_is_missing()in tree-sitter parsing.Fixed inline/nested struct definitions generating invalid R code by extracting just the struct name from
struct_specifiernodes instead of the full body text.Fixed typedef’d anonymous structs/unions/enums being duplicated in typedefs (they are already extracted as structs/unions/enums).
-
Fixed missing
treesitterpackage import declaration (#2)- Added
treesitterto DESCRIPTION Imports field - Added proper
@importFromroxygen2 directives for tree-sitter functions - Resolves R CMD check warnings on macOS and Ubuntu
- Added
RSimpleFFI 1.0.1.9001 (Development)
Major Milestones
-
Completed migration to treesitter.c: Full transition from regex-based parsing to AST-based parsing
- All legacy parsing code removed
- Tree-sitter now handles 100% of C header parsing
- More robust, accurate, and maintainable codebase
- Better support for complex C syntax patterns
Breaking Changes
-
Removed regex-based header parser: The package now exclusively uses tree-sitter for C header parsing
- Removed functions:
tcc_extract_structs(),tcc_extract_unions(),tcc_extract_enums(),tcc_extract_functions(),tcc_extract_typedefs(),tcc_parse_header() -
ffi_parse_header()now always uses tree-sitter (nouse_treesitterparameter) - Packages
treesitterandtreesitter.care now required dependencies (not optional) - Migration: Simply remove
use_treesitter = FALSEfrom any code - tree-sitter handles all valid C syntax
- Removed functions:
New Features
-
Tree-sitter parser is now the only parser:
- Robust AST-based parsing handles all valid C syntax
- Correctly parses pointer return types (e.g.,
FILE* open_file(...)) - Correctly parses complex array declarations and nested structs
- Detects
__attribute__((packed))and setspackedattribute on structs/unions - Generates code with
pack=1for packed structs automatically - TCC preprocessor still used first to expand macros before tree-sitter parsing
- Struct allocation helpers are now auto-generated in R bindings:
-
new_StructName()- allocate and optionally initialize struct instances -
StructName_to_list()- convert struct pointer to R list
-
- Typedef resolution in function wrappers:
- Function parameters now correctly use typedef’d FFI types (e.g.,
SEXPTYPE→ffi_uint()) - FFI types shown in
@paramdocumentation for better IDE support
- Function parameters now correctly use typedef’d FFI types (e.g.,
- Improved variadic function handling:
- Functions with
...now generate usage examples usingffi_cif_var()instead of broken wrappers
- Functions with
RSimpleFFI 1.0.1.9000 (Development)
New Features
-
Added
packparameter toffi_struct()for controlling struct alignment:-
pack = 1for byte-packed structs (no padding) -
pack = 2,4,8, or16for specific alignment boundaries -
pack = NULL(default) uses natural alignment - Matches GCC/Clang
#pragma pack(n)and MSVC packing behavior
-
-
Added
packparameter toffi_union()for controlling union alignment:- Reduces union’s alignment requirement (size stays the same)
- Affects placement when union is a struct member
- Example: packed union in normal struct eliminates trailing padding
Added
ffi_packed_offset()andffi_packed_size()for computing packed struct layouts-
Added bit-field helper functions for manual bit manipulation:
-
ffi_pack_bits()/ffi_unpack_bits()- pack/unpack multiple bit-fields -
ffi_extract_bit_field()/ffi_set_bit_field()- single field operations -
ffi_create_bitfield_accessors()- generate accessor functions for bit-field structs - 64-bit bit-field support with
ffi_longlong()/ffi_ulonglong()storage types - Signed bit-field extraction with sign extension
-
-
Automatic bit-field detection and code generation:
- Parser detects bit-field syntax (
: N) in struct definitions -
generate_r_bindings()auto-generates accessor code when bit-fields are present - Generated code includes usage examples showing
pack(),get(),set()operations
- Parser detects bit-field syntax (
-
Added typedef extraction from C headers:
-
tcc_extract_typedefs()parses typedef definitions -
generate_typedef_definition()generates R code for typedefs - Dependency-aware ordering via
sort_typedefs_by_dependency() - Automatic detection and filtering of unresolvable typedefs
-
Autogeneration of bindings using tinycc for preprocessing of header files
Improvements
-
Centralized C-to-FFI type mappings in
get_ffi_type_map():- 300+ type mappings including cross-platform aliases
- Support for glibc, musl, macOS/Darwin, BSD, MSYS2/MinGW types
- Clang-specific typedefs and compiler builtins
Added
strip_type_qualifiers()for handling const/volatile in type resolutionAdded
get_resolvable_types()helper function
RSimpleFFI 1.0.1
New Features
Added
ffi_deref_pointer()to dereference pointer addresses, enabling access to global pointer variables in shared libraries (e.g.,R_GlobalEnv,R_NilValue)Added
ffi_read_global()to read typed values from global symbol addressesAdded test global variables (
test_global_int,test_global_double,test_global_string,test_global_array) for testing and examples
RSimpleFFI 1.0.0
Initial release
Core FFI functionality using libffi
Support for basic C types (int, double, float, pointer, string, etc.)
Support for fixed-width integer types (int8, int16, int32, int64, uint8, etc.)
Support for platform-specific types (size_t, ssize_t, long, etc.)
Struct types with
ffi_struct(), field access, and nested structsArray types with
ffi_array_type()Variadic function support with
ffi_cif_var()Closure API for R callbacks (
ffi_closure())Dynamic library loading with
dll_load(),dll_compile_and_load()Memory allocation with
ffi_alloc(),ffi_copy_array(),ffi_fill_typed_buffer()