Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Manual Introduction Tutorial Declarations Statements Types Parameters Objects File System Syntax Tokens Expressions OS access Actions Foreign funcs Errors
Foreign funcs C types Conversions Parameters Create results
Manual
Foreign funcs
 previous   up   next 

14. FOREIGN FUNCTION INTERFACE

Foreign functions cannot be called directly. It is necessary to write wrapper functions. Several things must be done to call a foreign function:

  • The C types used by Seed7 must be converted to the C types used by the foreign function (E.g.: string and path conversions). The result of the foreign function and parameters, which return a value, must be converted back. This conversions are usually done in a wrapper function.
  • A function with the action prototype (a function with a listType parameter and an objectType result) must be defined. Predefined macros help to access the action arguments and to create result values. The action function must be registered in the file "primitiv.c".
  • The new action must be introduced to Seed7. This is usually done in an *.s7i library file, which introduces an action definition.

In general two functions are needed: A wrapper function and an action function. The corresponding function definitions can be placed in two *.c files. Corresponding *.h files contain prototypes. Assume, we have the library "superlib" and the function doWurx1 from "superlib" should be called from a Seed7 program. The three letter abbreviation sup is used to determine the file and function names for wrapper and action. The following files and functions are used:

File Function Comment
superlib.a doWurx1 External library (the extension may vary)
superlib.h doWurx1 Prototype of the external C function
sup_rtl.c supDoWurx1 Wrapper function
sup_rtl.h supDoWurx1 Prototype of the wrapper function
suplib.c sup_doWurx1 Action function
suplib.h sup_doWurx1 Prototype of the action function
primitiv.c   Alphabetical list of all primitive actions
makefile   Makefile name depends on operating system and compiler
superlib.s7i doWurx1 Introduces the external function to a Seed7 program

The C prototype of doWurx1 is defined in the file "superlib.h":

int doWurx1 (char *name);

This function accepts an UTF-8 'name' and it returns 0 on success. Every other return value indicates that the string is too long. In this case the exception RANGE_ERROR should be raised. The wrapper function is defined in the file "sup_rtl.c" with:

#include "version.h"
#include "stdio.h"
#include "superlib.h"
#include "common.h"
#include "striutl.h"
#include "rtl_err.h"

void supDoWurx1 (const striType name)
  {
    cstriType cName;
    errInfoType err_info = OKAY_NO_ERROR;
    int wurxResult;

    cName = stri_to_cstri8(name, &err_info);
    if (cName == NULL) {
      raise_error(err_info);
    } else {
      wurxResult = doWurx1(cName);
      free_cstri8(cName, name);
      if (wurxResult != 0) {
        raise_error(RANGE_ERROR);
      }
    }
  }

The prototype of supDoWurx1 is defined in the file "sup_rtl.h" with:

void supDoWurx1 (const striType name);

The action function for supDoWurx1 is defined in the file "suplib.c" with:

#include "version.h"
#include "stdio.h"
#include "common.h"
#include "data.h"
#include "syvarutl.h"
#include "objutl.h"
#include "sup_rtl.h"

objectType sup_doWurx1 (listType arguments)
  {
    isit_stri(arg_1(arguments));
    supDoWurx1(take_stri(arg_1(arguments)));
    return SYS_EMPTY_OBJECT;
  }

The prototype of sup_doWurx1 is defined in the file "suplib.h" with:

objectType sup_doWurx1 (listType arguments);

The action is introduced to the interpreter, by changing the file "primitiv.c". An include directive for "suplib.h" must be added:

#include "strlib.h"
#include "suplib.h"
#include "timlib.h"

The file "primitiv.c" contains a list of alphabetically sorted primitive actions. Each action entry takes a line. It is important to add the new action "SUP_DO_WURX" at the correct place:

{ "STR_VALUE",               str_value,               },

{ "SUP_DO_WURX",             sup_doWurx1,             },

{ "TIM_AWAIT",               tim_await,               },

The new files must be added to the makefile. Depending on C compiler and operating system Seed7 uses several makefiles. In the correct "makefile" suplib and sup_rtl must be added to lists of source and object files. Adding the suplib object file results in:

LOBJ = actlib.o arrlib.o biglib.o blnlib.o bstlib.o chrlib.o cmdlib.o conlib.o dcllib.o drwlib.o \
       enulib.o fillib.o fltlib.o hshlib.o intlib.o itflib.o kbdlib.o lstlib.o pollib.o prclib.o \
       prglib.o reflib.o rfllib.o sctlib.o setlib.o soclib.o strlib.o suplib.o timlib.o typlib.o ut8lib.o

Adding the "suplib" source file results in:

LSRC = actlib.c arrlib.c biglib.c blnlib.c bstlib.c chrlib.c cmdlib.c conlib.c dcllib.c drwlib.c \
       enulib.c fillib.c fltlib.c hshlib.c intlib.c itflib.c kbdlib.c lstlib.c pollib.c prclib.c \
       prglib.c reflib.c rfllib.c sctlib.c setlib.c soclib.c strlib.c suplib.c timlib.c typlib.c ut8lib.c

and object files. Adding the sup_rtl object file results in:

ROBJ = arr_rtl.o bln_rtl.o bst_rtl.o chr_rtl.o cmd_rtl.o con_rtl.o dir_rtl.o drw_rtl.o fil_rtl.o \
       flt_rtl.o hsh_rtl.o int_rtl.o set_rtl.o soc_rtl.o str_rtl.o sup_rtl.o tim_rtl.o ut8_rtl.o \
       heaputl.o striutl.o

Adding the "sup_rtl" source file results in:

RSRC = arr_rtl.c bln_rtl.c bst_rtl.c chr_rtl.c cmd_rtl.c con_rtl.c dir_rtl.c drw_rtl.c fil_rtl.c \
       flt_rtl.c hsh_rtl.c int_rtl.c set_rtl.c soc_rtl.c str_rtl.c sup_rtl.c tim_rtl.c ut8_rtl.c \
       heaputl.c striutl.c

The external library "superlib" itself is added with:

SYSTEM_LIBS = -lm superlib.a

The interpreter must be compiled, so the changes can take effect. To actually call the new function it must be introduced in a Seed7 library. This is done with the library "super.s7i":

const proc: doWurx1 (in string: name) is action "SUP_DO_WURX";

14.1 C types used by the implementation

Several Seed7 types correspond to simple C types, which are defined in "common.h":

Seed7 type C type Comment
boolean boolType _Bool, bool or int
integer intType 32- or 64-bit signed int
float floatType float (or double)
char charType 32-bit unsigned int
clib_file fileType FILE *
PRIMITIVE_SOCKET socketType int or unsigned int

Other Seed7 types correspond to C pointers, which point to a struct. Some of this structs are used in all situations: In the interpreter and in the compiler and under different operation systems and with different runtime libraries. This invariant structs are defined in "common.h" and in "data.h":

Seed7 type C type C struct Comment
string striType struct striStruct UTF-32 encoded, can contain null chars
set setType struct setStruct  
bstring bstriType struct bstriStruct Byte sequence, can contain null bytes
reference objectType struct objectStruct Interpreter type for Seed7 objects
ref_list listType struct listStruct Interpreter type for Seed7 object lists

Other Seed7 types also correspond to struct pointers, but the structs are different in interpreted and compiled Seed7 programs. The structs for interpreted programs are defined in "data.h" and the structs for compiled programs are defined in "data_rtl.h":

Seed7 type C type (interpreted) C struct (interpreted) C type (compiled) C struct (compiled)
array arrayType struct arrayStruct rtlArrayType struct rtlArrayStruct
hash hashType struct hashStruct rtlHashType struct rtlHashStruct
struct structType struct structStruct rtlStructType struct rtlStructStruct

Because interpreter and compiler use different structs the functions from e.g. "arrlib.c" cannot use functions from "arr_rtl.c".

Some Seed7 types depend on the operating system or runtime library used:

Seed7 type C type Defined as Sourcefile Comment
bigInteger bigIntType struct bigIntStruct * big_rtl.c The built-in bigInteger library
bigIntType mpz_ptr big_gmp.c The GNU Multiple Precision Arithmetic Library
pollData pollType struct select_based_pollStruct * pol_sel.c Functions cast it to implementation dependent struct
pollType struct poll_based_pollStruct * pol_unx.c Functions cast it to implementation dependent struct
PRIMITIVE_WINDOW winType struct x11_winStruct * drw_x11.c Functions cast from winStruct * to x11_winStruct *
winType struct win_winStruct * drw_win.c Functions cast from winStruct * to win_winStruct *

There are also C types without corresponding Seed7 type. They are defined in "common.h":

C type C definition Comment
int16Type short int It is assumed that sizeof(short int) == 2
uint16Type unsigned short int Unsigned integer type with the size of int16Type
int32Type int When sizeof(int) == 4
long When sizeof(long) == 4
uint32Type unsigned int32Type Unsigned integer type with the size of int32Type
int64Type long When sizeof(long) == 8
long long When sizeof(long long) == 8
__int64 When sizeof(__int64) == 8
uint64Type unsigned int64Type Unsigned integer type with the size of int64Type
int128Type __int128 When sizeof(__int128) == 16
__int128_t When sizeof(__int128_t) == 16
uint128Type unsigned __int128 When sizeof(unsigned __int128) == 16
__uint128_t When sizeof(__uint128_t) == 16
uintType unsigned intType Unsigned integer type with the size of intType
cstriType char * String type of the C compiler
ustriType unsigned char * Helpful for unsigned comparisons
wstriType uint16Type * UTF-16 string
os_striType char * When the OS uses UTF-8 chars
wchar_t * When the OS uses UTF-16 chars
memSizeType uint32Type When C uses 32-bit pointers
uint64Type When C uses 64-bit pointers

14.2 String and path conversions

Seed7 strings are UTF-32 encoded and C strings are zero terminated byte sequences. To convert between the different representations, "striutl.h" defines conversion functions like stri_to_cstri, stri_to_cstri8, stri_to_bstri, stri_to_bstri8, cstri_to_stri, cstri_buf_to_stri, cstri8_to_stri and cstri8_or_cstri_to_stri. Operating systems disagree in their Unicode encoding (UTF-8 or UTF-16). To cope with this, "striutl.h" defines the type os_striType and the functions conv_from_os_stri, stri_to_os_stri and os_stri_to_stri. The different concepts to represent a file path (path delimiter and drive letter) are handled with cp_to_os_path and cp_from_os_path.

Function Summary
cstriType
stri_to_cstri (const_striType stri, errInfoType *err_info)
Create an ISO-8859-1 encoded C string from a Seed7 UTF-32 string.
cstriType
stri_to_cstri8 (const_striType stri, errInfoType *err_info)
Create an UTF-8 encoded C string from a Seed7 UTF-32 string.
cstriType
stri_to_cstri8_buf (const_striType stri, memSizeType *length, errInfoType *err_info)
Create an UTF-8 encoded C string buffer from a Seed7 UTF-32 string.
bstriType
stri_to_bstri (const_striType stri, errInfoType *err_info)
Create an ISO-8859-1 encoded bstring from a Seed7 UTF-32 string.
bstriType
stri_to_bstri8 (const_striType stri)
Create an UTF-8 encoded bstring from a Seed7 UTF-32 string.
striType
cstri_to_stri (const_cstriType cstri)
Copy an ISO-8859-1 (Latin-1) encoded C string to a Seed7 string.
striType
cstri_buf_to_stri (const_cstriType cstri, memSizeType length)
Copy an ISO-8859-1 (Latin-1) encoded C string buffer to a Seed7 string.
striType
cstri8_to_stri (const_cstriType cstri, errInfoType *err_info)
Copy an UTF-8 encoded C string to a Seed7 string.
striType
cstri8_buf_to_stri (const_cstriType cstri, memSizeType length, errInfoType *err_info)
Copy an UTF-8 encoded C string buffer to a Seed7 string.
striType
cstri8_or_cstri_to_stri (const_cstriType cstri)
Copy an UTF-8 or ISO-8859-1 encoded C string to a Seed7 string.
striType
conv_from_os_stri (const const_os_striType os_stri, memSizeType length)
Convert an os_striType string with length to a Seed7 UTF-32 string.
os_striType
stri_to_os_stri (const_striType stri, errInfoType *err_info)
Convert a Seed7 UTF-32 string to a null terminated os_striType string.
striType
os_stri_to_stri (const_os_striType os_stri, errInfoType *err_info)
Convert a null terminated os_striType string to a Seed7 UTF-32 string.
os_striType
cp_to_os_path (const_striType std_path, int *path_info, errInfoType *err_info)
Convert a Seed7 standard path to a path used by system calls.
striType
cp_from_os_path (const_os_striType os_path, errInfoType *err_info)
Convert a path returned by a system call to a Seed7 standard path.
boolType
os_stri_alloc (os_striType &var, memSizeType len)
Macro to allocate memory for an os_striType string.
void
os_stri_free (os_striType var)
Macro to free memory that has been allocated with os_stri_alloc.

Function Detail

stri_to_cstri

cstriType stri_to_cstri (const_striType stri, errInfoType *err_info)

Create an ISO-8859-1 encoded C string from a Seed7 UTF-32 string. The memory for the zero byte terminated C string is allocated. The C string result must be freed with the macro free_cstri().

Parameters:
stri - Seed7 UTF-32 string to be converted.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when stri contains a null character or a character that is higher than the highest allowed ISO-8859-1 character (255).
Returns:
an ISO-8859-1 encoded null terminated C string or NULL, when the memory allocation failed or when the conversion failed (the error is indicated by err_info).

stri_to_cstri8

cstriType stri_to_cstri8 (const_striType stri, errInfoType *err_info)

Create an UTF-8 encoded C string from a Seed7 UTF-32 string. The memory for the zero byte terminated C string is allocated. The C string result must be freed with the macro free_cstri8(). This function is intended to create temporary strings, that are used as parameters. To get good performance the allocated memory for the C string is oversized.

Parameters:
stri - Seed7 UTF-32 string to be converted.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when stri contains a null character or a character that is higher than the highest allowed Unicode character (U+10FFFF).
Returns:
an UTF-8 encoded null terminated C string or NULL, when the memory allocation failed or when the conversion failed (the error is indicated by err_info).

stri_to_cstri8_buf

cstriType stri_to_cstri8_buf (const_striType stri, memSizeType *length, errInfoType *err_info)

Create an UTF-8 encoded C string buffer from a Seed7 UTF-32 string. The memory for the zero byte terminated C string is allocated. The C string result must be freed with the macro free_cstri8(). This function is intended to create temporary strings, that are used as parameters. To get good performance the allocated memory for the C string is oversized.

Parameters:
stri - Seed7 UTF-32 string to be converted.
length - Place to return the length of the result (without '\0').
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed.
Returns:
an UTF-8 encoded null terminated C string or NULL, when the memory allocation failed (the error is indicated by err_info).

stri_to_bstri

bstriType stri_to_bstri (const_striType stri, errInfoType *err_info)

Create an ISO-8859-1 encoded bstring from a Seed7 UTF-32 string. The memory for the bstring is allocated. No zero byte is added to the end of the bstring. No special action is done, when the UTF-32 string contains a null character.

Parameters:
stri - Seed7 UTF-32 string to be converted.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when stri contains a character that is higher than the highest allowed ISO-8859-1 character (255).
Returns:
an ISO-8859-1 encoded bstring or NULL, when the memory allocation failed or when the conversion failed (the error is indicated by err_info).

stri_to_bstri8

bstriType stri_to_bstri8 (const_striType stri)

Create an UTF-8 encoded bstring from a Seed7 UTF-32 string. The memory for the bstring is allocated. No zero byte is added to the end of the bstring. No special action is done, when the original string contains a null character.

Parameters:
stri - Seed7 UTF-32 string to be converted.
Returns:
an UTF-8 encoded bstring or NULL, when the memory allocation failed.

cstri_to_stri

striType cstri_to_stri (const_cstriType cstri)

Copy an ISO-8859-1 (Latin-1) encoded C string to a Seed7 string. The memory for the UTF-32 encoded Seed7 string is allocated.

Parameters:
cstri - Null terminated ISO-8859-1 encoded C string.
Returns:
an UTF-32 encoded Seed7 string or NULL, when the memory allocation failed.

cstri_buf_to_stri

striType cstri_buf_to_stri (const_cstriType cstri, memSizeType length)

Copy an ISO-8859-1 (Latin-1) encoded C string buffer to a Seed7 string. The memory for the UTF-32 encoded Seed7 string is allocated.

Parameters:
cstri - ISO-8859-1 encoded C string buffer (not null terminated).
length - Byte length of the ISO-8859-1 encoded C string buffer.
Returns:
an UTF-32 encoded Seed7 string or NULL, when the memory allocation failed.

cstri8_to_stri

striType cstri8_to_stri (const_cstriType cstri, errInfoType *err_info)

Copy an UTF-8 encoded C string to a Seed7 string. The memory for the UTF-32 encoded Seed7 string is allocated.

Parameters:
cstri - Null terminated UTF-8 encoded C string.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when the conversion failed.
Returns:
an UTF-32 encoded Seed7 string or NULL, when the memory allocation failed or when illegal UTF-8 encodings are used.

cstri8_buf_to_stri

striType cstri8_buf_to_stri (const_cstriType cstri, memSizeType length, errInfoType *err_info)

Copy an UTF-8 encoded C string buffer to a Seed7 string. The memory for the UTF-32 encoded Seed7 string is allocated.

Parameters:
cstri - UTF-8 encoded C string buffer (not null terminated).
length - Byte length of the UTF-8 encoded C string buffer.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when the conversion failed.
Returns:
an UTF-32 encoded Seed7 string or NULL, when the memory allocation failed or when illegal UTF-8 encodings are used.

cstri8_or_cstri_to_stri

striType cstri8_or_cstri_to_stri (const_cstriType cstri)

Copy an UTF-8 or ISO-8859-1 encoded C string to a Seed7 string. The memory for the UTF-32 encoded Seed7 string is allocated.

Parameters:
cstri - Null terminated UTF-8 or ISO-8859-1 encoded C string.
Returns:
an UTF-32 encoded Seed7 string or NULL, when the memory allocation failed.

conv_from_os_stri

striType conv_from_os_stri (const const_os_striType os_stri, memSizeType length)

Convert an os_striType string with length to a Seed7 UTF-32 string. Many system calls return os_striType data with length. System calls are defined in "version.h" and "os_decls.h". They are prefixed with os_ and use strings of the type os_striType. Depending on the operating system os_striType can describe byte or wide char strings. The encoding can be Latin-1, UTF-8, UTF-16 or it can use a code page.

Parameters:
os_stri - Possibly binary string (may contain null characters).
length - Length of os_stri in characters.
Returns:
a Seed7 UTF-32 string or NULL, when an error occurred.

stri_to_os_stri

os_striType stri_to_os_stri (const_striType stri, errInfoType *err_info)

Convert a Seed7 UTF-32 string to a null terminated os_striType string. The memory for the null terminated os_striType string is allocated. The os_striType result is allocated with the macro os_stri_alloc() and it must be freed with the macro os_stri_free(). Strings allocated with os_stri_alloc() must be freed in the reverse order of their creation. This allows that allocations work in a stack like manner. Many system calls have parameters with null terminated os_striType strings. System calls are defined in "version.h" and "os_decls.h". They are prefixed with os_ and use strings of the type os_striType. Depending on the operating system os_striType can describe byte or wide char strings. The encoding can be Latin-1, UTF-8, UTF-16 or it can use a code page.

Parameters:
stri - Seed7 UTF-32 string to be converted.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when the conversion failed.
Returns:
a null terminated os_striType value used by system calls or NULL, when an error occurred.

os_stri_to_stri

striType os_stri_to_stri (const_os_striType os_stri, errInfoType *err_info)

Convert a null terminated os_striType string to a Seed7 UTF-32 string. Many system calls return null terminated os_striType strings. System calls are defined in "version.h" and "os_decls.h". They are prefixed with os_ and use strings of the type os_striType. Depending on the operating system os_striType can describe byte or wide char strings. The encoding can be Latin-1, UTF-8, UTF-16 or it can use a code page.

Parameters:
os_stri - Null terminated os_striType string to be converted.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed.
Returns:
a Seed7 UTF-32 string or NULL, when an error occurred.

cp_to_os_path

os_striType cp_to_os_path (const_striType std_path, int *path_info, errInfoType *err_info)

Convert a Seed7 standard path to a path used by system calls. The memory for the null terminated os_striType path is allocated. The os_striType result is allocated with the macro os_stri_alloc() and it must be freed with the macro os_stri_free(). Strings allocated with os_stri_alloc() must be freed in the reverse order of their creation. This allows that allocations work in a stack like manner. System calls are defined in "version.h" and "os_decls.h". They are prefixed with os_ and use system paths of the type os_striType. Depending on the operating system os_striType can describe byte or wide char strings. The encoding can be Latin-1, UTF-8, UTF-16 or it can use a code page. Beyond the conversion to os_striType a mapping to drive letters might take place on some operating systems.

Parameters:
std_path - UTF-32 encoded Seed7 standard path to be converted.
path_info - Unchanged when the function succeeds or PATH_IS_EMULATED_ROOT when the path is "/". PATH_NOT_MAPPED when the path cannot be mapped.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed or RANGE_ERROR when the path is not a standard path.
Returns:
a null terminated os_striType path used by system calls or NULL, when an error occurred.

cp_from_os_path

striType cp_from_os_path (const_os_striType os_path, errInfoType *err_info)

Convert a path returned by a system call to a Seed7 standard path. System calls are defined in "version.h" and "os_decls.h". They are prefixed with os_ and use system paths of the type os_striType. Depending on the operating system os_striType can describe byte or wide char strings. The encoding can be Latin-1, UTF-8, UTF-16 or it can use a code page. Beyond the conversion from os_striType a mapping from drive letters might take place on some operating systems.

Parameters:
os_path - Null terminated os_striType path to be converted.
err_info - Unchanged when the function succeeds or MEMORY_ERROR when the memory allocation failed.
Returns:
an UTF-32 encoded Seed7 standard path or NULL, when the memory allocation failed.

os_stri_alloc

boolType os_stri_alloc (os_striType &var, memSizeType len)

Macro to allocate memory for an os_striType string. Strings allocated with os_stri_alloc() must be freed with os_stri_free() in the reverse order of their creation. This allows that allocations work in a stack like manner.

Parameters:
var - Reference to a variable to which the allocated memory is assigned.
len - Size of the allocated memory in characters.
Returns:
TRUE, when the allocation succeeds or FALSE, when the memory allocation failed.

os_stri_free

void os_stri_free (os_striType var)

Macro to free memory that has been allocated with os_stri_alloc. Strings allocated with os_stri_alloc() must be freed with os_stri_free() in the reverse order of their creation. This allows that allocations work in a stack like manner. The strings returned by stri_to_os_stri and cp_to_os_path are also allocated with os_stri_alloc. Therefore they must also be freed with os_stri_free() in the reverse order of their creation.

Parameters:
var - The string to be freed.

14.3 Macros to access the action parameters

A primitive action function has one parameter named 'arguments'. The 'arguments' parameter has the type listType and contains a list of objects. Macros like arg_1, arg_2, arg_3, etc. get a specific object from the 'arguments'.

Functions (macros) to get a Seed7 object from a list
objectType
arg_1 (listType arguments)
Take the first object from the list.
objectType
arg_2 (listType arguments)
Take the second object from the list.
objectType
arg_3 (listType arguments)
Take the third object from the list.
. . .
. . .
objectType
arg_12 (listType arguments)
Take the twelfth object from the list.

An object value contains a specific C implementation type. Macros like isit_char and isit_set check if an object has the requested type. When the object has not the requested C implementation type and error message is written.

Functions (macros) to check the C type of Seed7 objects
void
isit_array (objectType arg)
Check if the object type is arrayType.
void
isit_bigint (objectType arg)
Check if the object type is bigIntType.
void
isit_bool (objectType arg)
Check if the object type is boolType.
void
isit_bstri (objectType arg)
Check if the object type is bstriType.
void
isit_char (objectType arg)
Check if the object type is charType.
void
isit_file (objectType arg)
Check if the object type is fileType.
void
isit_float (objectType arg)
Check if the object type is floatType.
void
isit_hash (objectType arg)
Check if the object type is hashType.
void
isit_int (objectType arg)
Check if the object type is intType.
void
isit_poll (objectType arg)
Check if the object type is pollType.
void
isit_set (objectType arg)
Check if the object type is setType.
void
isit_socket (objectType arg)
Check if the object type is socketType.
void
isit_stri (objectType arg)
Check if the object type is striType.
void
isit_struct (objectType arg)
Check if the object type is structType.
void
isit_win (objectType arg)
Check if the object type is winType.

Macros like take_bool and take_file return a value with the requested C implementation type.

Functions (macros) to get the C values of Seed7 objects
arrayType
take_array (objectType arg)
Take the array value from an object.
bigIntType
take_bigint (objectType arg)
Take the bigInteger value from an object.
boolType
take_bool (objectType arg)
Take the boolean value from an object.
bstriType
take_bstri (objectType arg)
Take the bstring value from an object.
charType
take_char (objectType arg)
Take the char value from an object.
fileType
take_file (objectType arg)
Take the file value from an object.
floatType
take_float (objectType arg)
Take the float value from an object.
hashType
take_hash (objectType arg)
Take the hash table value from an object.
intType
take_int (objectType arg)
Take the integer value from an object.
pollType
take_poll (objectType arg)
Take the poll data value from an object.
setType
take_set (objectType arg)
Take the set value from an object.
socketType
take_socket (objectType arg)
Take the socket value from an object.
striType
take_stri (objectType arg)
Take the string value from an object.
structType
take_struct (objectType arg)
Take the struct value from an object.
winType
take_win (objectType arg)
Take the struct value from an object.

14.4 Functions to create action results

A primitive action function has a result of type objectType. Functions like bld_bigint_temp and bld_stri_temp create an object with the specified type.

Functions to create Seed7 objects with a C value
objectType
bld_array_temp (arrayType temp_array)
Create an object with an arrayType value.
objectType
bld_bigint_temp (bigIntType temp_bigint)
Create an object with a bigIntType value.
objectType
bld_bstri_temp (bstriType temp_bstri)
Create an object with a bstriType value.
objectType
bld_char_temp (charType temp_char)
Create an object with a charType value.
objectType
bld_file_temp (fileType temp_file)
Create an object with a fileType value.
objectType
bld_float_temp (floatType temp_float)
Create an object with a floatType value.
objectType
bld_hash_temp (hashType temp_hash)
Create an object with a hashType value.
objectType
bld_int_temp (intType temp_int)
Create an object with an intType value.
objectType
bld_poll_temp (pollType temp_poll)
Create an object with a pollType value.
objectType
bld_set_temp (setType temp_set)
Create an object with a setType value.
objectType
bld_socket_temp (socketType temp_socket)
Create an object with a socketType value.
objectType
bld_stri_temp (striType temp_stri)
Create an object with a striType value.
objectType
bld_struct_temp (structType temp_struct)
Create an object with a structType value.
objectType
bld_win_temp (winType temp_win)
Create an object with a winType value.


 previous   up   next