228
244
static gint vala_vapi_gen_run (ValaVAPIGen* self) {
230
246
ValaCodeContext* _tmp0_ = NULL;
231
ValaCodeContext* _tmp1_;
238
ValaReport* _tmp8_ = NULL;
239
ValaReport* _tmp9_ = NULL;
240
ValaReport* _tmp10_ = NULL;
242
ValaReport* _tmp20_ = NULL;
244
ValaReport* _tmp23_ = NULL;
246
ValaReport* _tmp28_ = NULL;
248
ValaReport* _tmp37_ = NULL;
250
ValaParser* _tmp40_ = NULL;
251
ValaReport* _tmp5_ = NULL;
252
ValaReport* _tmp6_ = NULL;
253
ValaReport* _tmp7_ = NULL;
255
ValaReport* _tmp18_ = NULL;
257
ValaReport* _tmp22_ = NULL;
259
ValaReport* _tmp26_ = NULL;
261
ValaReport* _tmp35_ = NULL;
263
ValaParser* _tmp38_ = NULL;
251
264
ValaParser* parser;
252
ValaReport* _tmp41_ = NULL;
254
ValaGirParser* _tmp44_ = NULL;
265
ValaReport* _tmp39_ = NULL;
267
ValaGirParser* _tmp42_ = NULL;
255
268
ValaGirParser* girparser;
256
ValaReport* _tmp45_ = NULL;
258
ValaGIdlParser* _tmp48_ = NULL;
269
ValaReport* _tmp43_ = NULL;
271
ValaGIdlParser* _tmp46_ = NULL;
259
272
ValaGIdlParser* gidlparser;
260
ValaReport* _tmp49_ = NULL;
262
ValaReport* _tmp52_ = NULL;
264
ValaCodeWriter* _tmp71_ = NULL;
273
ValaReport* _tmp47_ = NULL;
275
ValaReport* _tmp50_ = NULL;
277
ValaCodeWriter* _tmp69_ = NULL;
265
278
ValaCodeWriter* interface_writer;
266
gchar* _tmp72_ = NULL;
279
gchar* _tmp70_ = NULL;
267
280
gchar* vapi_filename;
270
282
g_return_val_if_fail (self != NULL, 0);
271
283
_tmp0_ = vala_code_context_new ();
273
284
_vala_code_context_unref0 (self->priv->context);
274
self->priv->context = _tmp1_;
285
self->priv->context = _tmp0_;
275
286
vala_code_context_set_profile (self->priv->context, VALA_PROFILE_GOBJECT);
276
_tmp2_ = (_tmp3_ = vala_vapi_gen_vapi_directories, (_tmp3_ == NULL) ? ((gpointer) _tmp3_) : _vala_array_dup1 (_tmp3_, _vala_array_length (vala_vapi_gen_vapi_directories)));
287
_tmp1_ = (_tmp2_ = vala_vapi_gen_vapi_directories, (_tmp2_ == NULL) ? ((gpointer) _tmp2_) : _vala_array_dup1 (_tmp2_, _vala_array_length (vala_vapi_gen_vapi_directories)));
278
288
self->priv->context->vapi_directories = (_vala_array_free (self->priv->context->vapi_directories, self->priv->context->vapi_directories_length1, (GDestroyNotify) g_free), NULL);
289
self->priv->context->vapi_directories = _tmp1_;
279
290
self->priv->context->vapi_directories_length1 = _vala_array_length (vala_vapi_gen_vapi_directories);
280
self->priv->context->vapi_directories = _tmp4_;
281
_tmp5_ = (_tmp6_ = vala_vapi_gen_gir_directories, (_tmp6_ == NULL) ? ((gpointer) _tmp6_) : _vala_array_dup2 (_tmp6_, _vala_array_length (vala_vapi_gen_gir_directories)));
291
_tmp3_ = (_tmp4_ = vala_vapi_gen_gir_directories, (_tmp4_ == NULL) ? ((gpointer) _tmp4_) : _vala_array_dup2 (_tmp4_, _vala_array_length (vala_vapi_gen_gir_directories)));
283
292
self->priv->context->gir_directories = (_vala_array_free (self->priv->context->gir_directories, self->priv->context->gir_directories_length1, (GDestroyNotify) g_free), NULL);
293
self->priv->context->gir_directories = _tmp3_;
284
294
self->priv->context->gir_directories_length1 = _vala_array_length (vala_vapi_gen_gir_directories);
285
self->priv->context->gir_directories = _tmp7_;
286
_tmp8_ = vala_code_context_get_report (self->priv->context);
287
vala_report_set_enable_warnings (_tmp8_, !vala_vapi_gen_disable_warnings);
288
_tmp9_ = vala_code_context_get_report (self->priv->context);
289
vala_report_set_verbose_errors (_tmp9_, !vala_vapi_gen_quiet_mode);
295
_tmp5_ = vala_code_context_get_report (self->priv->context);
296
vala_report_set_enable_warnings (_tmp5_, !vala_vapi_gen_disable_warnings);
297
_tmp6_ = vala_code_context_get_report (self->priv->context);
298
vala_report_set_verbose_errors (_tmp6_, !vala_vapi_gen_quiet_mode);
290
299
vala_code_context_push (self->priv->context);
291
300
vala_code_context_add_external_package (self->priv->context, "glib-2.0");
292
301
vala_code_context_add_external_package (self->priv->context, "gobject-2.0");
293
_tmp10_ = vala_code_context_get_report (self->priv->context);
294
_tmp11_ = vala_report_get_errors (_tmp10_);
297
_tmp12_ = vala_vapi_gen_quit (self);
302
_tmp7_ = vala_code_context_get_report (self->priv->context);
303
_tmp8_ = vala_report_get_errors (_tmp7_);
306
_tmp9_ = vala_vapi_gen_quit (self);
305
314
source_collection = vala_vapi_gen_sources;
306
315
source_collection_length1 = _vala_array_length (vala_vapi_gen_sources);
307
316
for (source_it = 0; source_it < _vala_array_length (vala_vapi_gen_sources); source_it = source_it + 1) {
310
_tmp13_ = g_strdup (source_collection[source_it]);
319
_tmp10_ = g_strdup (source_collection[source_it]);
316
gchar* _tmp17_ = NULL;
325
gchar* _tmp14_ = NULL;
320
_tmp14_ = g_str_has_suffix (source, ".gi");
330
_tmp11_ = g_str_has_suffix (source, ".gi");
322
332
_g_free0 (source);
325
_tmp15_ = strlen (source);
326
_tmp16_ = strlen ("gi");
327
_tmp17_ = string_substring (source, (glong) 0, (glong) (_tmp15_ - _tmp16_));
329
depsfile = (_tmp19_ = g_strconcat (_tmp18_, "deps", NULL), _g_free0 (_tmp18_), _tmp19_);
335
_tmp12_ = strlen (source);
336
_tmp13_ = strlen ("gi");
337
_tmp14_ = string_substring (source, (glong) 0, (glong) (_tmp12_ - _tmp13_));
339
_tmp16_ = g_strconcat (_tmp15_, "deps", NULL);
330
343
vala_code_context_add_packages_from_file (self->priv->context, depsfile);
331
344
_g_free0 (depsfile);
332
345
_g_free0 (source);
336
_tmp20_ = vala_code_context_get_report (self->priv->context);
337
_tmp21_ = vala_report_get_errors (_tmp20_);
340
_tmp22_ = vala_vapi_gen_quit (self);
349
_tmp18_ = vala_code_context_get_report (self->priv->context);
350
_tmp19_ = vala_report_get_errors (_tmp18_);
353
_tmp20_ = vala_vapi_gen_quit (self);
344
357
if (vala_vapi_gen_library != NULL) {
346
depsfile = g_strconcat (vala_vapi_gen_library, ".deps", NULL);
360
_tmp21_ = g_strconcat (vala_vapi_gen_library, ".deps", NULL);
347
362
vala_code_context_add_packages_from_file (self->priv->context, depsfile);
348
363
_g_free0 (depsfile);
350
365
vala_report_error (NULL, "--library option must be specified");
352
_tmp23_ = vala_code_context_get_report (self->priv->context);
353
_tmp24_ = vala_report_get_errors (_tmp23_);
356
_tmp25_ = vala_vapi_gen_quit (self);
367
_tmp22_ = vala_code_context_get_report (self->priv->context);
368
_tmp23_ = vala_report_get_errors (_tmp22_);
371
_tmp24_ = vala_vapi_gen_quit (self);
360
375
if (vala_vapi_gen_packages != NULL) {
363
377
gchar** package_collection;
364
378
int package_collection_length1;
395
408
source_collection = vala_vapi_gen_sources;
396
409
source_collection_length1 = _vala_array_length (vala_vapi_gen_sources);
397
410
for (source_it = 0; source_it < _vala_array_length (vala_vapi_gen_sources); source_it = source_it + 1) {
400
_tmp31_ = g_strdup (source_collection[source_it]);
413
_tmp29_ = g_strdup (source_collection[source_it]);
404
_tmp32_ = g_file_test (source, G_FILE_TEST_EXISTS);
406
ValaSourceFile* _tmp33_ = NULL;
407
ValaSourceFile* _tmp34_;
408
_tmp33_ = vala_source_file_new (self->priv->context, VALA_SOURCE_FILE_TYPE_PACKAGE, source, NULL);
417
_tmp30_ = g_file_test (source, G_FILE_TEST_EXISTS);
419
ValaSourceFile* _tmp31_ = NULL;
420
ValaSourceFile* _tmp32_;
421
_tmp31_ = vala_source_file_new (self->priv->context, VALA_SOURCE_FILE_TYPE_PACKAGE, source, NULL);
423
vala_code_context_add_source_file (self->priv->context, _tmp32_);
424
_vala_source_file_unref0 (_tmp32_);
426
gchar* _tmp33_ = NULL;
428
_tmp33_ = g_strdup_printf ("%s not found", source);
409
429
_tmp34_ = _tmp33_;
410
vala_code_context_add_source_file (self->priv->context, _tmp34_);
411
_vala_source_file_unref0 (_tmp34_);
413
gchar* _tmp35_ = NULL;
415
_tmp35_ = g_strdup_printf ("%s not found", source);
417
vala_report_error (NULL, _tmp36_);
430
vala_report_error (NULL, _tmp34_);
420
433
_g_free0 (source);
424
_tmp37_ = vala_code_context_get_report (self->priv->context);
425
_tmp38_ = vala_report_get_errors (_tmp37_);
428
_tmp39_ = vala_vapi_gen_quit (self);
437
_tmp35_ = vala_code_context_get_report (self->priv->context);
438
_tmp36_ = vala_report_get_errors (_tmp35_);
441
_tmp37_ = vala_vapi_gen_quit (self);
432
_tmp40_ = vala_parser_new ();
445
_tmp38_ = vala_parser_new ();
434
447
vala_parser_parse (parser, self->priv->context);
435
_tmp41_ = vala_code_context_get_report (self->priv->context);
436
_tmp42_ = vala_report_get_errors (_tmp41_);
439
_tmp43_ = vala_vapi_gen_quit (self);
448
_tmp39_ = vala_code_context_get_report (self->priv->context);
449
_tmp40_ = vala_report_get_errors (_tmp39_);
452
_tmp41_ = vala_vapi_gen_quit (self);
441
454
_vala_code_visitor_unref0 (parser);
444
_tmp44_ = vala_gir_parser_new ();
457
_tmp42_ = vala_gir_parser_new ();
446
459
vala_gir_parser_parse (girparser, self->priv->context);
447
_tmp45_ = vala_code_context_get_report (self->priv->context);
448
_tmp46_ = vala_report_get_errors (_tmp45_);
451
_tmp47_ = vala_vapi_gen_quit (self);
460
_tmp43_ = vala_code_context_get_report (self->priv->context);
461
_tmp44_ = vala_report_get_errors (_tmp43_);
464
_tmp45_ = vala_vapi_gen_quit (self);
453
466
_vala_code_visitor_unref0 (girparser);
454
467
_vala_code_visitor_unref0 (parser);
457
_tmp48_ = vala_gidl_parser_new ();
458
gidlparser = _tmp48_;
470
_tmp46_ = vala_gidl_parser_new ();
471
gidlparser = _tmp46_;
459
472
vala_gidl_parser_parse (gidlparser, self->priv->context);
460
_tmp49_ = vala_code_context_get_report (self->priv->context);
461
_tmp50_ = vala_report_get_errors (_tmp49_);
464
_tmp51_ = vala_vapi_gen_quit (self);
473
_tmp47_ = vala_code_context_get_report (self->priv->context);
474
_tmp48_ = vala_report_get_errors (_tmp47_);
477
_tmp49_ = vala_vapi_gen_quit (self);
466
479
_vala_code_visitor_unref0 (gidlparser);
467
480
_vala_code_visitor_unref0 (girparser);
468
481
_vala_code_visitor_unref0 (parser);
471
484
vala_code_context_check (self->priv->context);
472
_tmp52_ = vala_code_context_get_report (self->priv->context);
473
_tmp53_ = vala_report_get_errors (_tmp52_);
485
_tmp50_ = vala_code_context_get_report (self->priv->context);
486
_tmp51_ = vala_report_get_errors (_tmp50_);
489
_tmp52_ = vala_vapi_gen_quit (self);
491
_vala_code_visitor_unref0 (gidlparser);
492
_vala_code_visitor_unref0 (girparser);
493
_vala_code_visitor_unref0 (parser);
497
ValaList* _tmp53_ = NULL;
498
ValaList* _file_list;
476
_tmp54_ = vala_vapi_gen_quit (self);
478
_vala_code_visitor_unref0 (gidlparser);
479
_vala_code_visitor_unref0 (girparser);
480
_vala_code_visitor_unref0 (parser);
484
ValaList* _tmp55_ = NULL;
485
ValaList* _file_list;
488
501
gint _file_index;
489
_tmp55_ = vala_code_context_get_source_files (self->priv->context);
490
_file_list = _tmp55_;
491
_tmp56_ = vala_collection_get_size ((ValaCollection*) _file_list);
492
_file_size = _tmp56_;
502
_tmp53_ = vala_code_context_get_source_files (self->priv->context);
503
_file_list = _tmp53_;
504
_tmp54_ = vala_collection_get_size ((ValaCollection*) _file_list);
505
_file_size = _tmp54_;
493
506
_file_index = -1;
495
gpointer _tmp57_ = NULL;
508
gpointer _tmp55_ = NULL;
496
509
ValaSourceFile* file;
510
const gchar* _tmp56_ = NULL;
497
512
const gchar* _tmp58_ = NULL;
499
const gchar* _tmp60_ = NULL;
500
513
_file_index = _file_index + 1;
501
514
if (!(_file_index < _file_size)) {
504
_tmp57_ = vala_list_get (_file_list, _file_index);
505
file = (ValaSourceFile*) _tmp57_;
506
_tmp58_ = vala_source_file_get_filename (file);
507
_tmp59_ = g_str_has_suffix (_tmp58_, ".vapi");
517
_tmp55_ = vala_list_get (_file_list, _file_index);
518
file = (ValaSourceFile*) _tmp55_;
519
_tmp56_ = vala_source_file_get_filename (file);
520
_tmp57_ = g_str_has_suffix (_tmp56_, ".vapi");
509
522
_vala_source_file_unref0 (file);
512
_tmp60_ = vala_source_file_get_filename (file);
513
if (_vala_string_array_contains (vala_vapi_gen_sources, _vala_array_length (vala_vapi_gen_sources), _tmp60_)) {
525
_tmp58_ = vala_source_file_get_filename (file);
526
if (_vala_string_array_contains (vala_vapi_gen_sources, _vala_array_length (vala_vapi_gen_sources), _tmp58_)) {
514
527
vala_source_file_set_file_type (file, VALA_SOURCE_FILE_TYPE_SOURCE);
516
const gchar* _tmp61_ = NULL;
518
_tmp61_ = vala_source_file_get_filename (file);
519
_tmp62_ = g_str_has_suffix (_tmp61_, ".metadata");
521
const gchar* _tmp63_ = NULL;
522
const gchar* _tmp64_ = NULL;
529
const gchar* _tmp59_ = NULL;
531
_tmp59_ = vala_source_file_get_filename (file);
532
_tmp60_ = g_str_has_suffix (_tmp59_, ".metadata");
534
const gchar* _tmp61_ = NULL;
535
const gchar* _tmp62_ = NULL;
538
gchar* _tmp65_ = NULL;
525
540
gchar* _tmp67_ = NULL;
527
gchar* _tmp69_ = NULL;
529
542
gchar* gir_filename;
530
_tmp63_ = vala_source_file_get_filename (file);
531
_tmp64_ = vala_source_file_get_filename (file);
532
_tmp65_ = strlen (_tmp64_);
533
_tmp66_ = strlen (".metadata");
534
_tmp67_ = string_substring (_tmp63_, (glong) 0, (glong) (_tmp65_ - _tmp66_));
543
_tmp61_ = vala_source_file_get_filename (file);
544
_tmp62_ = vala_source_file_get_filename (file);
545
_tmp63_ = strlen (_tmp62_);
546
_tmp64_ = strlen (".metadata");
547
_tmp65_ = string_substring (_tmp61_, (glong) 0, (glong) (_tmp63_ - _tmp64_));
549
_tmp67_ = g_strdup_printf ("%s.gir", _tmp66_);
535
550
_tmp68_ = _tmp67_;
536
_tmp69_ = g_strdup_printf ("%s.gir", _tmp68_);
537
gir_filename = (_tmp70_ = _tmp69_, _g_free0 (_tmp68_), _tmp70_);
552
gir_filename = _tmp68_;
538
553
if (_vala_string_array_contains (vala_vapi_gen_sources, _vala_array_length (vala_vapi_gen_sources), gir_filename)) {
539
554
vala_source_file_set_file_type (file, VALA_SOURCE_FILE_TYPE_SOURCE);