4 /* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.7.3.
5 Designed by Andrew Plotkin <erkyrath@eblong.com>
6 http://www.eblong.com/zarf/glk/index.html
8 This file is copyright 1998-2011 by Andrew Plotkin. You may copy,
9 distribute, and incorporate it into your own programs, by any means
10 and under any conditions, as long as you do not modify it. You may
11 also modify this file, incorporate it into your own programs,
12 and distribute the modified version, as long as you retain a notice
13 in your program or documentation which mentions my name and the URL
17 /* These constants define the classes of opaque objects. It's a bit ugly
18 to put them in this header file, since more classes may be added in
19 the future. But if you find yourself stuck with an obsolete version
20 of this file, adding new class definitions will be easy enough --
21 they will be numbered sequentially, and the numeric constants can be
22 found in the Glk specification. */
23 #define gidisp_Class_Window (0)
24 #define gidisp_Class_Stream (1)
25 #define gidisp_Class_Fileref (2)
26 #define gidisp_Class_Schannel (3)
28 typedef union gluniversal_union {
31 void *opaqueref; /* Qa, Qb, Qc... */
32 unsigned char uch; /* Cu */
33 signed char sch; /* Cs */
35 char *charstr; /* S */
36 glui32 *unicharstr; /* U */
37 void *array; /* all # arguments */
38 glui32 ptrflag; /* [ ... ] or *? */
41 /* Some well-known structures:
43 stream_result_t : [2IuIu]
46 typedef struct gidispatch_function_struct {
50 } gidispatch_function_t;
52 typedef struct gidispatch_intconst_struct {
55 } gidispatch_intconst_t;
57 typedef union glk_objrock_union {
62 /* The following functions are part of the Glk library itself, not the dispatch
63 layer (whose code is in gi_dispa.c). These functions are necessarily
64 implemented in platform-dependent code.
66 extern void gidispatch_set_object_registry(
67 gidispatch_rock_t (*regi)(void *obj, glui32 objclass),
68 void (*unregi)(void *obj, glui32 objclass, gidispatch_rock_t objrock));
69 extern gidispatch_rock_t gidispatch_get_objrock(void *obj, glui32 objclass);
70 extern void gidispatch_set_retained_registry(
71 gidispatch_rock_t (*regi)(void *array, glui32 len, char *typecode),
72 void (*unregi)(void *array, glui32 len, char *typecode,
73 gidispatch_rock_t objrock));
75 /* The following functions make up the Glk dispatch layer. Although they are
76 distributed as part of each Glk library (linked into the library file),
77 their code is in gi_dispa.c, which is platform-independent and identical
80 extern void gidispatch_call(glui32 funcnum, glui32 numargs,
81 gluniversal_t *arglist);
82 extern char *gidispatch_prototype(glui32 funcnum);
83 extern glui32 gidispatch_count_classes(void);
84 extern gidispatch_intconst_t *gidispatch_get_class(glui32 index);
85 extern glui32 gidispatch_count_intconst(void);
86 extern gidispatch_intconst_t *gidispatch_get_intconst(glui32 index);
87 extern glui32 gidispatch_count_functions(void);
88 extern gidispatch_function_t *gidispatch_get_function(glui32 index);
89 extern gidispatch_function_t *gidispatch_get_function_by_id(glui32 id);
91 #endif /* _GI_DISPA_H */