-
Notifications
You must be signed in to change notification settings - Fork 6
/
Common.winxed
329 lines (294 loc) · 6.85 KB
/
Common.winxed
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
$include_const 'datatypes.pasm';
$include_const "iglobals.pasm";
const int DATATYPE_SIZE_T = DATATYPE_LONG; // TODO: probe for appropriate type
const int DATATYPE_GIT_TIME_T = DATATYPE_INT64; // TODO: probe for support
const int DATATYPE_GIT_OFF_T = DATATYPE_INT64; // ditto
const int GIT_OID_RAWSZ = 20; // TODO: probe for value
function int_t[anon]() {
return new 'StructView'([DATATYPE_STRUCT, 1, DATATYPE_INT]);
}
function char_t[anon]() {
return new 'StructView'([DATATYPE_STRUCT, 1, DATATYPE_CHAR]);
}
function cstring(string s) {
var str_to_cstring = dlfunc(null, 'Parrot_str_to_cstring', 'ppS');
return str_to_cstring(getinterp(), s);
}
function atos(var x) {
var cstring_to_str = dlfunc(null, 'Parrot_str_new', 'Sppi');
return cstring_to_str(getinterp(), x, 0);
}
namespace Git2 {
class Branch {
function Branch() {
/*
struct git_branch {
char *remote;
char *merge;
};
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_PTR,
DATATYPE_PTR
]);
}
}
class Common {
function git_strarray() {
/*
typedef struct {
char **strings;
size_t count;
} git_strarray;
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_PTR,
DATATYPE_SIZE_T
]);
}
function git_config_file() {
/*
struct git_config_file {
struct git_config *cfg;
int (*open)(struct git_config_file *);
int (*get)(struct git_config_file *, const char *key, const char **value);
int (*set)(struct git_config_file *, const char *key, const char *value);
int (*foreach)(struct git_config_file *, int (*fn)(const char *, void *), void *data);
void (*free)(struct git_config_file *);
};
*/
return new 'StructView'([ DATATYPE_STRUCT, 6,
DATATYPE_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR
]);
}
function git_index_time() {
/*
typedef struct {
git_time_t seconds;
unsigned int nanoseconds;
} git_index_time;
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_GIT_TIME_T,
DATATYPE_UINT
]);
}
function git_index_entry() {
/*
typedef struct git_index_entry {
git_index_time ctime;
git_index_time mtime;
unsigned int dev;
unsigned int ino;
unsigned int mode;
unsigned int uid;
unsigned int gid;
git_off_t file_size;
git_oid oid;
unsigned short flags;
unsigned short flags_extended;
const char *path;
} git_index_entry;
*/
return new 'StructView'([ DATATYPE_STRUCT, 12,
DATATYPE_SIZED, git_index_time().size(), git_index_time().align(),
DATATYPE_SIZED, git_index_time().size(), git_index_time().align(),
DATATYPE_UINT,
DATATYPE_UINT,
DATATYPE_UINT,
DATATYPE_UINT,
DATATYPE_UINT,
DATATYPE_GIT_OFF_T,
DATATYPE_SIZED, git_oid().size(), git_oid().align(),
DATATYPE_USHORT,
DATATYPE_USHORT,
DATATYPE_PTR
]);
}
function git_index_entry_unmerged() {
/*
typedef struct git_index_entry_unmerged {
unsigned int mode[3];
git_oid oid[3];
const char *path;
} git_index_entry_unmerged;
*/
return new 'StructView'([ DATATYPE_STRUCT, 3,
DATATYPE_SIZED, int_t().size()*3, int_t().align(),
DATATYPE_SIZED, git_oid().aligned_size()*2 + git_oid().size(), git_oid().align,
DATATYPE_PTR
]);
}
function git_remote_head() {
/*
struct git_remote_head {
git_oid oid;
char *name;
};
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_SIZED, git_oid().size(), git_oid().align(),
DATATYPE_PTR
]);
}
function git_head_array() {
/*
struct git_headarray {
unsigned int len;
struct git_remote_head **heads;
};
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_UINT,
DATATYPE_PTR
]);
}
function git_odb_backend() {
/*
struct git_odb_backend {
git_odb *odb;
int (* read)(
void **, size_t *, git_otype *,
struct git_odb_backend *,
const git_oid *);
int (* read_prefix)(
git_oid *,
void **, size_t *, git_otype *,
struct git_odb_backend *,
const git_oid *,
unsigned int);
int (* read_header)(
size_t *, git_otype *,
struct git_odb_backend *,
const git_oid *);
int (* write)(
git_oid *,
struct git_odb_backend *,
const void *,
size_t,
git_otype);
int (* writestream)(
struct git_odb_stream **,
struct git_odb_backend *,
size_t,
git_otype);
int (* readstream)(
struct git_odb_stream **,
struct git_odb_backend *,
const git_oid *);
int (* exists)(
struct git_odb_backend *,
const git_oid *);
void (* free)(struct git_odb_backend *);
};
*/
return new 'StructView'([ DATATYPE_STRUCT, 9,
DATATYPE_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR
]);
}
function git_odb_stream() {
/*
struct git_odb_stream {
struct git_odb_backend *backend;
int mode;
int (*read)(struct git_odb_stream *stream, char *buffer, size_t len);
int (*write)(struct git_odb_stream *stream, const char *buffer, size_t len);
int (*finalize_write)(git_oid *oid_p, struct git_odb_stream *stream);
void (*free)(struct git_odb_stream *stream);
};
*/
return new 'StructView'([ DATATYPE_STRUCT, 6,
DATATYPE_PTR,
DATATYPE_INT,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR,
DATATYPE_FUNC_PTR
]);
}
function git_oid() {
/*
typedef struct {
unsigned char id[GIT_OID_RAWSZ];
} git_oid;
*/
return new 'StructView'([ DATATYPE_STRUCT, 1,
DATATYPE_SIZED, char_t().size()*GIT_OID_RAWSZ, char_t().align()
]);
}
function git_time() {
/*
typedef struct git_time {
git_time_t time;
int offset;
} git_time;
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_GIT_TIME_T,
DATATYPE_INT
]);
}
function git_signature() {
/*
typedef struct git_signature {
char *name;
char *email;
git_time when;
} git_signature;
*/
return new 'StructView'([ DATATYPE_STRUCT, 3,
DATATYPE_PTR,
DATATYPE_PTR,
DATATYPE_SIZED, git_time().size(), git_time().align()
]);
}
function git_refcount() {
/*
typedef struct {
git_atomic refcount;
void *owner;
} git_refcount;
*/
return new 'StructView'([ DATATYPE_STRUCT, 2,
DATATYPE_LONG,
DATATYPE_PTR
]);
}
function git_futils_filestamp() {
/*
typedef struct {
git_time_t mtime;
git_off_t size;
unsigned int ino;
} git_futils_filestamp;
*/
return new 'StructView'([ DATATYPE_STRUCT, 3,
DATATYPE_GIT_TIME_T,
DATATYPE_GIT_OFF_T,
DATATYPE_UINT
]);
}
function git_vector() {
return new 'StructView'([DATATYPE_STRUCT, 5,
DATATYPE_SIZE_T,
DATATYPE_PTR,
DATATYPE_PTR,
DATATYPE_SIZE_T,
DATATYPE_INT
]);
}
}
}