You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: generalize config file records for HTAB and List ptr custom
Now they are in same format as internal represenatation: type, parent,
member - no specialization for member or variable.
Compatibility with previous format is saved, but schema.json changed to
new version without syntax help.
This is required to more convenient updating of configuration file in
callbacks (for now this is single update after new NodeTags found).
Copy file name to clipboardExpand all lines: docs/config_file.md
+68-36Lines changed: 68 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,11 +191,13 @@ This information stored in `customListTypes` member. This is array of objects:
191
191
"customListTypes": [
192
192
{
193
193
"type": "MyCustomType *",
194
-
"member": ["ParentStruct", "parent_member"]
194
+
"parent": "ParentStruct",
195
+
"member": "parent_member"
195
196
},
196
197
{
197
198
"type": "MyCustomType *",
198
-
"variable": ["ParentFunction", "variable_name"]
199
+
"parent": "ParentFunction",
200
+
"member": "variable_name"
199
201
}
200
202
]
201
203
}
@@ -204,24 +206,23 @@ This information stored in `customListTypes` member. This is array of objects:
204
206
Each object contain:
205
207
206
208
-`type` - fully-qualified type name (that is `struct` or `pointer` should be included) to which pointer will be casted.
207
-
-`member` - pair of struct name and member of this struct. Definition looks like this:
208
-
209
-
```c
210
-
typedefstruct ParentStruct
211
-
{
212
-
List *parent_member;
213
-
} ParentStruct;
214
-
```
215
-
216
-
-`variable` - pair of function name and variable inside it. Definition looks like this:
217
-
218
-
```c
219
-
void
220
-
ParentFunction()
221
-
{
222
-
List *variable_name;
223
-
}
224
-
```
209
+
-`parent` - name of struct or function (parent entity) containing this member or variable.
210
+
-`member` - name of member or variable that contains `List *` value.
211
+
212
+
As you can mention this configuration is generalized, because it's clear from context how to handle `parent`. Example above is for following code:
213
+
214
+
```c
215
+
typedefstruct ParentStruct
216
+
{
217
+
List *parent_member;
218
+
} ParentStruct;
219
+
220
+
void
221
+
ParentFunction()
222
+
{
223
+
List *variable_name;
224
+
}
225
+
```
225
226
226
227
With this 2 strategies extension detects `List`s with custom types.
227
228
@@ -237,11 +238,13 @@ This information stored in `htab` member. This is an array of objects similar to
237
238
"htab": [
238
239
{
239
240
"type": "SampleType *",
240
-
"member": ["ParentStruct", "parent_member"]
241
+
"parent": "ParentStruct",
242
+
"member": "parent_member"
241
243
},
242
244
{
243
245
"type": "SampleType *",
244
-
"variable": ["ParentFunction", "variable_name"]
246
+
"parent": "ParentFunction",
247
+
"member": "variable_name"
245
248
}
246
249
]
247
250
}
@@ -250,23 +253,24 @@ This information stored in `htab` member. This is an array of objects similar to
250
253
Each object contain:
251
254
252
255
-`type` - fully qualified type name of entry in `HTAB`
253
-
-`member` - array of struct name and member inside this struct with `HTAB *` type. Definition looks like this:
256
+
-`parent` - name of struct or function (parent entity) containing this member or variable.
257
+
-`member` - name of member or variable that contains `List *` value.
254
258
255
-
```c
256
-
typedefstruct ParentStruct
257
-
{
258
-
HTAB *parent_member;
259
-
} ParentStruct;
260
-
```
259
+
> You can notice that schema is the same as for custom `List *` type.
261
260
262
-
-`variable` - array of function name and variable inside this function with `HTAB *` type. Definition looks like this
261
+
Example aboves is for following code:
263
262
264
-
```c
265
-
voidParentFunction()
266
-
{
267
-
HTAB *variable_name;
268
-
}
269
-
```
263
+
```c
264
+
typedefstruct ParentStruct
265
+
{
266
+
HTAB *parent_member;
267
+
}
268
+
269
+
voidParentFunction()
270
+
{
271
+
HTAB *variable_name;
272
+
}
273
+
```
270
274
271
275
Also, there is support for `simplehash.c` hash tables ("simplehash" further). They are code generated using macros, so for each specific hash table there are functions and structures defined.
272
276
Several builtin simplehashes exists and using configuration file you can add your own.
@@ -323,3 +327,31 @@ Fields:
323
327
-`member` - name of the member with enum type (`type->member`)
324
328
-`flags` - array of enum value definitions: MACRO VALUE + NUMERIC VALUE
325
329
-`fields` - array of inner fields: human readable name of field + MACRO MASK for member + numeric value of mask
330
+
331
+
Example above is for following code:
332
+
333
+
```c
334
+
#defineEM_FIRST 0x01
335
+
#define EM_SECOND 0x02
336
+
#define EM_THIRD 0x04
337
+
338
+
#defineEM_FIELD_MASK 0xF
339
+
340
+
typedefstruct ParentType
341
+
{
342
+
int enum_member;
343
+
}
344
+
345
+
voidfunction()
346
+
{
347
+
ParentType *value;
348
+
if (value->enum_member & EM_FIRST) {
349
+
/* ... */
350
+
}
351
+
352
+
int innerField = value->enum_member & EM_FIELD_MASK;
Copy file name to clipboardExpand all lines: properties.schema.json
+15-23Lines changed: 15 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -79,21 +79,17 @@
79
79
"pattern": "\\*$",
80
80
"description": "Type to which 'ListCell's will be casted. Must be pointer."
81
81
},
82
-
"member": {
83
-
"type": "array",
84
-
"minItems": 2,
85
-
"maxItems": 2,
86
-
"description": "Pair of parent struct name and member name inside this struct, identifying this List*"
82
+
"parent": {
83
+
"type": "string",
84
+
"description": "Name of struct or function which this 'List *' belongs to. If this is a member then name of structure, otherwise if this is variable in function, then enter function name."
87
85
},
88
-
"variable": {
89
-
"type": "array",
90
-
"minItems": 2,
91
-
"maxItems": 2,
92
-
"description": "Pair of function name and variable name inside this function, identifying this List*"
86
+
"member": {
87
+
"type": "string",
88
+
"description": "Name of member of variable which contains this 'List *'."
93
89
}
94
90
},
95
91
"required": [
96
-
"type"
92
+
"type", "parent", "member"
97
93
]
98
94
},
99
95
"htab": {
@@ -103,23 +99,19 @@
103
99
"type": {
104
100
"type": "string",
105
101
"pattern": "\\*$",
106
-
"description": "Type of entry in Hash Table. Must be pointer."
102
+
"description": "Type of entry in Hash Table to which entry will be casted. Must be pointer."
107
103
},
108
-
"member": {
109
-
"type": "array",
110
-
"minItems": 2,
111
-
"maxItems": 2,
112
-
"description": "Pair of parent struct name and member name inside this struct, identifying this HTAB*"
104
+
"parent": {
105
+
"type": "string",
106
+
"description": "Name of struct or function which this 'HTAB *' belongs to. If this is a member then name of structure, otherwise if this is variable in function, then enter function name."
113
107
},
114
-
"variable": {
115
-
"type": "array",
116
-
"minItems": 2,
117
-
"maxItems": 2,
118
-
"description": "Pair of function name and variable inside this function, identifying this HTAB*"
108
+
"member": {
109
+
"type": "string",
110
+
"description": "Name of member of variable which contains this 'HTAB *'"
0 commit comments