-
Notifications
You must be signed in to change notification settings - Fork 11
/
gi_dispa.h
97 lines (85 loc) · 3.59 KB
/
gi_dispa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef _GI_DISPA_H
#define _GI_DISPA_H
/* gi_dispa.h: Header file for dispatch layer of Glk API, version 0.7.4.
Designed by Andrew Plotkin <[email protected]>
http://eblong.com/zarf/glk/index.html
This file is copyright 1998-2017 by Andrew Plotkin. It is
distributed under the MIT license; see the "LICENSE" file.
*/
/* These constants define the classes of opaque objects. It's a bit ugly
to put them in this header file, since more classes may be added in
the future. But if you find yourself stuck with an obsolete version
of this file, adding new class definitions will be easy enough --
they will be numbered sequentially, and the numeric constants can be
found in the Glk specification. */
#define gidisp_Class_Window (0)
#define gidisp_Class_Stream (1)
#define gidisp_Class_Fileref (2)
#define gidisp_Class_Schannel (3)
typedef union gluniversal_union {
glui32 uint; /* Iu */
glsi32 sint; /* Is */
void *opaqueref; /* Qa, Qb, Qc... */
unsigned char uch; /* Cu */
signed char sch; /* Cs */
char ch; /* Cn */
char *charstr; /* S */
glui32 *unicharstr; /* U */
void *array; /* all # arguments */
glui32 ptrflag; /* [ ... ] or *? */
} gluniversal_t;
/* Some well-known structures:
event_t : [4IuQaIuIu]
stream_result_t : [2IuIu]
*/
typedef struct gidispatch_function_struct {
glui32 id;
void *fnptr;
char *name;
} gidispatch_function_t;
typedef struct gidispatch_intconst_struct {
char *name;
glui32 val;
} gidispatch_intconst_t;
typedef union glk_objrock_union {
glui32 num;
void *ptr;
} gidispatch_rock_t;
/* The following functions are part of the Glk library itself, not the dispatch
layer (whose code is in gi_dispa.c). These functions are necessarily
implemented in platform-dependent code.
*/
extern void gidispatch_set_object_registry(
gidispatch_rock_t (*regi)(void *obj, glui32 objclass),
void (*unregi)(void *obj, glui32 objclass, gidispatch_rock_t objrock));
extern gidispatch_rock_t gidispatch_get_objrock(void *obj, glui32 objclass);
extern void gidispatch_set_retained_registry(
gidispatch_rock_t (*regi)(void *array, glui32 len, char *typecode),
void (*unregi)(void *array, glui32 len, char *typecode,
gidispatch_rock_t objrock));
/* This function is also part of the Glk library, but it only exists
on libraries that support autorestore. (Only iosglk, currently.)
Only call this if GIDISPATCH_AUTORESTORE_REGISTRY is defined.
*/
#define GIDISPATCH_AUTORESTORE_REGISTRY
extern void gidispatch_set_autorestore_registry(
long (*locatearr)(void *array, glui32 len, char *typecode,
gidispatch_rock_t objrock, int *elemsizeref),
gidispatch_rock_t (*restorearr)(long bufkey, glui32 len,
char *typecode, void **arrayref));
/* The following functions make up the Glk dispatch layer. Although they are
distributed as part of each Glk library (linked into the library file),
their code is in gi_dispa.c, which is platform-independent and identical
in every Glk library.
*/
extern void gidispatch_call(glui32 funcnum, glui32 numargs,
gluniversal_t *arglist);
extern char *gidispatch_prototype(glui32 funcnum);
extern glui32 gidispatch_count_classes(void);
extern gidispatch_intconst_t *gidispatch_get_class(glui32 index);
extern glui32 gidispatch_count_intconst(void);
extern gidispatch_intconst_t *gidispatch_get_intconst(glui32 index);
extern glui32 gidispatch_count_functions(void);
extern gidispatch_function_t *gidispatch_get_function(glui32 index);
extern gidispatch_function_t *gidispatch_get_function_by_id(glui32 id);
#endif /* _GI_DISPA_H */