Index into a slotted array and assign a sub-object to another slot


  • Look up the array in slot parent_slot
  • Retrieve the sub-object at the index specified in array_id
  • Place sub-object into the slot new_slot or the next available slot if new_slot is 0.
  • Return the new slot number.


int64_t slot_subarray (
    uint32_t parent_slot,
  	uint32_t array_id,
  	uint32_t new_slot


int64_t subslot = 0;
subslot =
    slot_subarray(slot_no, i, (uint32_t)subslot);


parent_slotuint32_tSlot the parent array is in
array_iduint32_tThe sf code of the field you are searching for.

To compute this manually take the serialized type and shift it into the 16 highest bits of uint32_t, then take the field and place it in the 16 lowest bits.

For example:
sfEmitNonce has type 5 and field 11 thus its value is 0x050BU
new_slotuint32_tNew slot number to place the object from the selected array index into. If null, choose the next available slot. May be null.

Return Code

int64_tThe slot number of the newly allocated object

If negative, an error:

- The specified array_id doesn't exist in the array pointed to by parent_slot

- The API would require a new slot to be allocated but the Hook is already at the maximum number of slots.

- The specified parent_slot does not contain an STArray.