Skip to content

Implement new StableApiDefinition struct methods #448

@ianks

Description

@ianks

In order to support Truffleruby on magnus, we need to support struct operations, which currently relies on cruby internals.

/// Defines a struct type with the given name and members.
///
/// # Example
/// 
fn rstruct_define(&self, name: &CStr, members: &[&CStr]);

/// Accesses an indexed member of the struct.
///
/// # Safety
/// This function is unsafe because it dereferences a raw pointer to get
/// access to underlying struct data. The caller must ensure that the
/// `VALUE` is a valid pointer to a struct.
unsafe fn rstruct_get(&self, st: VALUE, idx: c_int) -> VALUE;

/// Sets an indexed member of the struct.
///
/// # Safety
/// This function is unsafe because it dereferences a raw pointer to get
/// access to underlying struct data. The caller must ensure that the
/// `VALUE` is a valid pointer to a struct.
unsafe fn rstruct_set(&self, st: VALUE, idx: c_int, value: VALUE);

/// Returns the number of struct members.
///
/// # Safety
/// This function is unsafe because it dereferences a raw pointer to get
/// access to underlying struct data. The caller must ensure that the
/// `VALUE` is a valid pointer to an RStruct.
unsafe fn rstruct_len(&self, obj: VALUE) -> c_long;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions