1 /****************************************************************************
2 **
3 ** This file is part of GAP, a system for computational discrete algebra.
4 **
5 ** Copyright of GAP belongs to its developers, whose names are too numerous
6 ** to list here. Please refer to the COPYRIGHT file for details.
7 **
8 ** SPDX-License-Identifier: GPL-2.0-or-later
9 **
10 ** This file declares the functions of the generic record package.
11 **
12 ** This package provides a uniform interface to the functions that access
13 ** records and the elements for the other packages in the GAP kernel.
14 */
15
16 #ifndef GAP_RECORDS_H
17 #define GAP_RECORDS_H
18
19 #include "objects.h"
20
21 /****************************************************************************
22 **
23 *F NAME_RNAM(<rnam>) . . . . . . . . . . . name for a record name as an Obj
24 **
25 ** 'NAME_RNAM' returns the name (as an Obj) for the record name <rnam>.
26 */
27 Obj NAME_RNAM(UInt rnam);
28
29
30 /****************************************************************************
31 **
32 *F RNamName(<name>) . . . . . . . . . . . . convert a name to a record name
33 **
34 ** 'RNamName' returns the record name with the name <name> (which is a C
35 ** string).
36 */
37 UInt RNamName(const Char * name);
38
39 UInt RNamNameWithLen(const Char * name, UInt len);
40
41
42 /****************************************************************************
43 **
44 *F RNamIntg(<intg>) . . . . . . . . . . convert an integer to a record name
45 **
46 ** 'RNamIntg' returns the record name corresponding to the integer <intg>.
47 */
48 UInt RNamIntg(Int intg);
49
50
51 /****************************************************************************
52 **
53 *F RNamObj(<obj>) . . . . . . . . . . . convert an object to a record name
54 **
55 ** 'RNamObj' returns the record name corresponding to the object <obj>,
56 ** which currently must be a string or an integer.
57 */
58 UInt RNamObj(Obj obj);
59
60
61 /****************************************************************************
62 **
63 *F IS_REC(<obj>) . . . . . . . . . . . . . . . . . . . is an object a record
64 *V IsRecFuncs[<type>] . . . . . . . . . . . . . . . . table of record tests
65 */
66 extern Int (*IsRecFuncs[LAST_REAL_TNUM + 1])(Obj obj);
67
IS_REC(Obj obj)68 EXPORT_INLINE Int IS_REC(Obj obj)
69 {
70 return (*IsRecFuncs[TNUM_OBJ(obj)])(obj);
71 }
72
73
74 /****************************************************************************
75 **
76 *F ELM_REC(<rec>,<rnam>) . . . . . . . . . . select an element from a record
77 **
78 ** 'ELM_REC' returns the element, i.e., the value of the component, with the
79 ** record name <rnam> in the record <rec>. An error is signalled if <rec>
80 ** is not a record or if <rec> has no component with the record name <rnam>.
81 */
82 extern Obj (*ElmRecFuncs[LAST_REAL_TNUM + 1])(Obj rec, UInt rnam);
83
ELM_REC(Obj rec,UInt rnam)84 EXPORT_INLINE Obj ELM_REC(Obj rec, UInt rnam)
85 {
86 return (*ElmRecFuncs[TNUM_OBJ(rec)])(rec, rnam);
87 }
88
89
90 /****************************************************************************
91 **
92 *F ISB_REC(<rec>,<rnam>) . . . . . . . . . test for an element from a record
93 **
94 ** 'ISB_REC' returns 1 if the record <rec> has a component with the record
95 ** name <rnam> and 0 otherwise. An error is signalled if <rec> is not a
96 ** record.
97 */
98 extern Int (*IsbRecFuncs[LAST_REAL_TNUM + 1])(Obj rec, UInt rnam);
99
ISB_REC(Obj rec,UInt rnam)100 EXPORT_INLINE Int ISB_REC(Obj rec, UInt rnam)
101 {
102 return (*IsbRecFuncs[TNUM_OBJ(rec)])(rec, rnam);
103 }
104
105 /****************************************************************************
106 **
107 *F ASS_REC(<rec>,<rnam>,<obj>) . . . . . . . . . . . . . assign to a record
108 **
109 ** 'ASS_REC' assigns the object <obj> to the record component with the
110 ** record name <rnam> in the record <rec>. An error is signalled if <rec>
111 ** is not a record.
112 */
113 extern void (*AssRecFuncs[LAST_REAL_TNUM + 1])(Obj rec, UInt rnam, Obj obj);
114
ASS_REC(Obj rec,UInt rnam,Obj obj)115 EXPORT_INLINE void ASS_REC(Obj rec, UInt rnam, Obj obj)
116 {
117 (*AssRecFuncs[TNUM_OBJ(rec)])(rec, rnam, obj);
118 }
119
120 /****************************************************************************
121 **
122 *F UNB_REC(<rec>,<rnam>) . . . . . . unbind a record component from a record
123 **
124 ** 'UNB_REC' removes the record component with the record name <rnam> from
125 ** the record <rec>.
126 */
127 extern void (*UnbRecFuncs[LAST_REAL_TNUM + 1])(Obj rec, UInt rnam);
128
UNB_REC(Obj rec,UInt rnam)129 EXPORT_INLINE void UNB_REC(Obj rec, UInt rnam)
130 {
131 (*UnbRecFuncs[TNUM_OBJ(rec)])(rec, rnam);
132 }
133
134
135 /****************************************************************************
136 **
137 *F iscomplete_rnam( <name>, <len> ) . . . . . . . . . . . . . check <name>
138 */
139 UInt iscomplete_rnam(Char * name, UInt len);
140
141
142 /****************************************************************************
143 **
144 *F completion_rnam( <name>, <len> ) . . . . . . . . . . . . find completion
145 */
146 UInt completion_rnam(Char * name, UInt len);
147
148
149 /****************************************************************************
150 **
151 *F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *
152 */
153
154 /****************************************************************************
155 **
156 *F InitInfoRecords() . . . . . . . . . . . . . . . . table of init functions
157 */
158 StructInitInfo * InitInfoRecords ( void );
159
160
161 #endif // GAP_RECORDS_H
162