Top |
Interrogating the InterfaceInterrogating the Interface — Finding out what functions the Glk library exports |
gidispatch_intconst_t | |
gidispatch_function_t | |
#define | gidisp_Class_Window |
#define | gidisp_Class_Stream |
#define | gidisp_Class_Fileref |
#define | gidisp_Class_Schannel |
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.)
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()
.
glui32
gidispatch_count_intconst (void
);
Returns the number of integer constants exported by the library.
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()
.
glui32
gidispatch_count_functions (void
);
Returns the number of functions exported by the library.
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.
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.
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.
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.
glui32 |
Dispatch selector of the function. |
|
Pointer to the function. |
||
Name of the function, without the |