Macaulay2 » Documentation
Packages » ForeignFunctions » ForeignType » ForeignPointerArrayType
next | previous | forward | backward | up | index | toc

# ForeignPointerArrayType -- foreign type for NULL-terminated arrays of pointers

## Description

This is the class for a particular kind of array type, where the entries of each array are some sort of pointer type and the lengths are arbitrary. There are two built-in types, charstarstar (for arrays of strings) and voidstarstar (for arrays of pointers), but more types may be constructed using foreignPointerArrayType.

    i1 : charstarstar {"foo", "bar", "baz"}

    o1 = {foo, bar, baz}

    o1 : ForeignObject of type char**

    i2 : charstarstar {"the", "quick", "brown", "fox", "jumps", "over", "the",
             "lazy", "dog"}

    o2 = {the, quick, brown, fox, jumps, over, the, lazy, dog}

    o2 : ForeignObject of type char**

    i3 : voidstarstar {address int 0, address int 1, address int 2}

    o3 = {0x7728fbfd68a0, 0x7728fbfd6890, 0x7728fbfd6870}

    o3 : ForeignObject of type void**

Foreign pointer arrays may be subscripted using _.

    i4 : x = charstarstar {"foo", "bar", "baz"}

    o4 = {foo, bar, baz}

    o4 : ForeignObject of type char**

    i5 : x_1

    o5 = bar

    o5 : ForeignObject of type char*

    i6 : x_(-1)

    o6 = baz

    o6 : ForeignObject of type char*

Their lengths may be found using length.

    i7 : length x

    o7 = 3

They are also iterable.

    i8 : i = iterator x;

    i9 : next i

    o9 = foo

    o9 : ForeignObject of type char*

    i10 : next i

    o10 = bar

    o10 : ForeignObject of type char*

    i11 : scan(x, print)
    foo
    bar
    baz

They may also be modified using subscripted assignment.

    i12 : x_0 = "qux"

    o12 = qux

    o12 : ForeignObject of type char*

    i13 : x

    o13 = {qux, bar, baz}

    o13 : ForeignObject of type char**

### Menu

- foreignPointerArrayType -- construct a foreign pointer array type
- ForeignPointerArrayType VisibleList -- cast a Macaulay2 list to a foreign pointer array

## Functions and methods returning a foreign array type:

- foreignPointerArrayType -- construct a foreign pointer array type

## Methods that use a foreign array type:

- ForeignPointerArrayType VisibleList -- cast a Macaulay2 list to a foreign pointer array

## Protected objects of class ForeignPointerArrayType:

- `charstarstar`
- `voidstarstar`

## For the programmer

The object ForeignPointerArrayType is a type, with ancestor classes ForeignType < Type < MutableHashTable < HashTable < Thing.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/ForeignFunctions.m2:1318:0.