Interrogating the Interface

Interrogating the Interface — Finding out what functions the Glk library exports

Functions

Types and Values

Includes

#include <libchimara/glk.h>
#include <libchimara/gi-dispa.h>

Description

These are the ancilliary functions that let you enumerate.

Functions

gidispatch_count_classes ()

glui32
gidispatch_count_classes (void);

Returns the number of opaque object classes used by the library. You will need to know this if you want to keep track of opaque objects as they are created; see Opaque Object Registry.

As of Glk API 0.7.0, there are four classes: windows, streams, filerefs, and sound channels (numbered 0, 1, 2, and 3 respectively.)

Returns

Number of opaque object classes used by the library.


gidispatch_get_class ()

gidispatch_intconst_t *
gidispatch_get_class (glui32 index);

Returns a structure describing an opaque class that the library exports. index can range from 0 to N - 1, where N is the value returned by gidispatch_count_classes().

Parameters

index

Unique integer index of the class.

 

Returns

A gidispatch_intconst_t structure describing the class.


gidispatch_count_intconst ()

glui32
gidispatch_count_intconst (void);

Returns the number of integer constants exported by the library.

Returns

Number of integer constants exported by the library.


gidispatch_get_intconst ()

gidispatch_intconst_t *
gidispatch_get_intconst (glui32 index);

Returns a structure describing an integer constant which the library exports. These are, roughly, all the constants defined in the glk.h file. index can range from 0 to N - 1, where N is the value returned by gidispatch_count_intconst().

Parameters

index

Unique integer index of the integer constant.

 

Returns

A gidispatch_intconst_t structure describing the integer constant.


gidispatch_count_functions ()

glui32
gidispatch_count_functions (void);

Returns the number of functions exported by the library.

Returns

Number of functions exported by the library.


gidispatch_get_function ()

gidispatch_function_t *
gidispatch_get_function (glui32 index);

Returns a structure describing a Glk function. index can range from 0 to N - 1, where N is the value returned by gidispatch_count_functions().

Again, it is safest to assume that the structure is only valid until the next gidispatch_get_function() or gidispatch_get_function_by_id() call.

Parameters

index

Unique integer index of the function.

 

Returns

A gidispatch_function_t structure describing the function.


gidispatch_get_function_by_id ()

gidispatch_function_t *
gidispatch_get_function_by_id (glui32 id);

Returns a structure describing the Glk function with selector id . If there is no such function in the library, this returns NULL.

Again, it is safest to assume that the structure is only valid until the next gidispatch_get_function() or gidispatch_get_function_by_id() call.

Parameters

id

A selector.

 

Returns

a gidispatch_function_t structure, or NULL.

Types and Values

gidispatch_intconst_t

typedef struct {
    char *name;
    glui32 val;
} gidispatch_intconst_t;

This structure simply contains a string and a value. The string is a symbolic name of the value, and can be re-exported to anyone interested in using Glk constants.

In the current gi_dispa.c library, these structures are static and immutable, and will never be deallocated. However, it is safer to assume that the structure may be reused in future gidispatch_get_intconst() calls.

Members

char *name;

Symbolic name of the integer constant.

 

glui32 val;

Value of the integer constant.

 

gidispatch_function_t

typedef struct {
    glui32 id;
    void *fnptr;
    char *name;
} gidispatch_function_t;

The id field is a selector — a numeric constant used to refer to the function in question. name is the function name, as it is given in the glk.h file, but without the “glk_” prefix. And fnptr is the address of the function itself.

This is included because it might be useful, but it is not recommended. To call an arbitrary Glk function, you should use gidispatch_call().

See Table of Selectors for the selector definitions. See Dispatching for more about calling Glk functions by selector.

Members

glui32 id;

Dispatch selector of the function.

 

void *fnptr;

Pointer to the function.

 

char *name;

Name of the function, without the glk_ prefix.

 

gidisp_Class_Window

#define gidisp_Class_Window (0)

Represents a winid_t opaque object.


gidisp_Class_Stream

#define gidisp_Class_Stream (1)

Represents a strid_t opaque object.


gidisp_Class_Fileref

#define gidisp_Class_Fileref (2)

Represents a frefid_t opaque object.


gidisp_Class_Schannel

#define gidisp_Class_Schannel (3)

Represents a schanid_t opaque object.