@@ -45,6 +45,7 @@ def cdefs(features):
4545 typedef guint32 GType;
4646 '''
4747
48+ # ... means opaque
4849 code += '''
4950 typedef void (*GLogFunc) (const char* log_domain,
5051 int log_level,
@@ -58,9 +59,7 @@ def cdefs(features):
5859
5960 void g_log_remove_handler (const char* log_domain, int handler_id);
6061
61- typedef struct _VipsImage VipsImage;
62- typedef struct _VipsProgress VipsProgress;
63- typedef struct _GValue GValue;
62+ typedef ... VipsImage;
6463
6564 void* g_malloc (size_t size);
6665 void g_free (void* data);
@@ -73,7 +72,7 @@ def cdefs(features):
7372 const char* g_type_name (GType gtype);
7473 GType g_type_from_name (const char* name);
7574
76- typedef void* (* VipsTypeMap2Fn) (GType type, void* a, void* b) ;
75+ typedef ... VipsTypeMap2Fn;
7776 void* vips_type_map (GType base, VipsTypeMap2Fn fn, void* a, void* b);
7877
7978 const char* vips_error_buffer (void);
@@ -83,7 +82,11 @@ def cdefs(features):
8382
8483 typedef struct _GValue {
8584 GType g_type;
86- guint64 data[2];
85+ union {
86+ guint64 v_uint64;
87+
88+ // more
89+ } data[2];
8790 } GValue;
8891
8992 void g_value_init (GValue* value, GType gtype);
@@ -134,16 +137,19 @@ def cdefs(features):
134137 GType vips_saveable_get_type (void);
135138 GType vips_image_type_get_type (void);
136139
137- typedef struct _GData GData;
140+ typedef ... GData;
138141
139- typedef struct _GTypeClass GTypeClass;
142+ typedef struct _GTypeClass {
143+ GType g_type;
144+ } GTypeClass;
140145
141146 typedef struct _GTypeInstance {
142147 GTypeClass *g_class;
143148 } GTypeInstance;
144149
145150 typedef struct _GObject {
146151 GTypeInstance g_type_instance;
152+
147153 unsigned int ref_count;
148154 GData *qdata;
149155 } GObject;
@@ -173,7 +179,7 @@ def cdefs(features):
173179 } GEnumValue;
174180
175181 typedef struct _GEnumClass {
176- GTypeClass * g_type_class;
182+ GTypeClass g_type_class;
177183
178184 int minimum;
179185 int maximum;
@@ -189,7 +195,7 @@ def cdefs(features):
189195 } GFlagsValue;
190196
191197 typedef struct _GFlagsClass {
192- GTypeClass * g_type_class;
198+ GTypeClass g_type_class;
193199
194200 unsigned int mask;
195201 unsigned int n_values;
@@ -224,6 +230,8 @@ def cdefs(features):
224230 void vips_image_set_progress (VipsImage* image, int progress);
225231 void vips_image_set_kill (VipsImage* image, int kill);
226232
233+ typedef ... GTimer;
234+
227235 typedef struct _VipsProgress {
228236 VipsImage* im;
229237
@@ -232,35 +240,12 @@ def cdefs(features):
232240 gint64 tpels;
233241 gint64 npels;
234242 int percent;
235- void * start;
243+ GTimer * start;
236244 } VipsProgress;
237245
238- typedef struct _VipsObject {
239- '''
246+ typedef ... VipsObject;
240247
241- # this field changed name in libvips 8.4
242- if _at_least (features , 8 , 4 ):
243- code += '''
244- GObject parent_instance;
245- '''
246- else :
247- code += '''
248- GObject parent_object;
249- '''
250-
251- code += '''
252- int constructed;
253- int static_object;
254- void *argument_table;
255- char *nickname;
256- char *description;
257- int preclose;
258- int close;
259- int postclose;
260- size_t local_memory;
261- } VipsObject;
262-
263- typedef struct _VipsObjectClass VipsObjectClass;
248+ typedef ... VipsObjectClass;
264249
265250 typedef struct _VipsArgument {
266251 GParamSpec *pspec;
@@ -307,23 +292,6 @@ def cdefs(features):
307292
308293 const char* g_param_spec_get_blurb (GParamSpec* pspec);
309294
310- typedef struct _VipsImage {
311- '''
312-
313- # this field changed name in libvips 8.4
314- if _at_least (features , 8 , 4 ):
315- code += '''
316- VipsObject parent_instance;
317- '''
318- else :
319- code += '''
320- VipsObject parent_object;
321- '''
322-
323- code += '''
324- // more
325- } VipsImage;
326-
327295 const char* vips_foreign_find_load (const char* name);
328296 const char* vips_foreign_find_load_buffer (const void* data,
329297 size_t size);
@@ -353,19 +321,11 @@ def cdefs(features):
353321 int vips_image_write (VipsImage* image, VipsImage* out);
354322 void* vips_image_write_to_memory (VipsImage* in, size_t* size_out);
355323
356- typedef struct _VipsInterpolate {
357- VipsObject parent_object;
358-
359- // more
360- } VipsInterpolate;
324+ typedef ... VipsInterpolate;
361325
362326 VipsInterpolate* vips_interpolate_new (const char* name);
363327
364- typedef struct _VipsOperation {
365- VipsObject parent_instance;
366-
367- // more
368- } VipsOperation;
328+ typedef ... VipsOperation;
369329
370330 VipsOperation* vips_operation_new (const char* name);
371331
@@ -378,11 +338,7 @@ def cdefs(features):
378338 void* vips_argument_map (VipsObject* object,
379339 VipsArgumentMapFn fn, void* a, void* b);
380340
381- typedef struct _VipsRegion {
382- VipsObject parent_object;
383-
384- // more
385- } VipsRegion;
341+ typedef ... VipsRegion;
386342
387343 VipsRegion* vips_region_new (VipsImage*);
388344
@@ -448,31 +404,19 @@ def cdefs(features):
448404
449405 if _at_least (features , 8 , 9 ):
450406 code += '''
451- typedef struct _VipsConnection {
452- VipsObject parent_object;
453-
454- // more
455- } VipsConnection;
407+ typedef ... VipsConnection;
456408
457409 const char* vips_connection_filename (VipsConnection* stream);
458410 const char* vips_connection_nick (VipsConnection* stream);
459411
460- typedef struct _VipsSource {
461- VipsConnection parent_object;
462-
463- // more
464- } VipsSource;
412+ typedef ... VipsSource;
465413
466414 VipsSource* vips_source_new_from_descriptor (int descriptor);
467415 VipsSource* vips_source_new_from_file (const char* filename);
468416 VipsSource* vips_source_new_from_memory (const void* data,
469417 size_t size);
470418
471- typedef struct _VipsSourceCustom {
472- VipsSource parent_object;
473-
474- // more
475- } VipsSourceCustom;
419+ typedef ... VipsSourceCustom;
476420
477421 VipsSourceCustom* vips_source_custom_new (void);
478422
@@ -481,21 +425,13 @@ def cdefs(features):
481425 extern "Python" gint64 _marshal_seek (VipsSource*,
482426 gint64, int, void*);
483427
484- typedef struct _VipsTarget {
485- VipsConnection parent_object;
486-
487- // more
488- } VipsTarget;
428+ typedef ... VipsTarget;
489429
490430 VipsTarget* vips_target_new_to_descriptor (int descriptor);
491431 VipsTarget* vips_target_new_to_file (const char* filename);
492432 VipsTarget* vips_target_new_to_memory (void);
493433
494- typedef struct _VipsTargetCustom {
495- VipsTarget parent_object;
496-
497- // more
498- } VipsTargetCustom;
434+ typedef ... VipsTargetCustom;
499435
500436 VipsTargetCustom* vips_target_custom_new (void);
501437
@@ -528,9 +464,11 @@ def cdefs(features):
528464 '''
529465
530466 # ... means inherit from C defines
531- code += '#define VIPS_MAJOR_VERSION ...\n '
532- code += '#define VIPS_MINOR_VERSION ...\n '
533- code += '#define VIPS_MICRO_VERSION ...\n '
467+ code += '''
468+ #define VIPS_MAJOR_VERSION ...
469+ #define VIPS_MINOR_VERSION ...
470+ #define VIPS_MICRO_VERSION ...
471+ '''
534472
535473 # add contents of features as a comment ... handy for debugging
536474 for key , value in features .items ():
0 commit comments