~ubuntu-branches/ubuntu/quantal/vala/quantal

« back to all changes in this revision

Viewing changes to vala/valacodecontext.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Terry
  • Date: 2011-01-18 09:51:15 UTC
  • mfrom: (1.5.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20110118095115-r2jr7c63lr0jzj0y
Tags: 0.11.4-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
873
873
 * @param is_source true to force adding the file as .vala or .gs
874
874
 * @return false if the file is not recognized or the file does not exist
875
875
 */
 
876
static gchar* string_substring (const gchar* self, glong offset, glong len) {
 
877
        gchar* result = NULL;
 
878
        gint _tmp0_;
 
879
        glong string_length;
 
880
        gchar* _tmp1_ = NULL;
 
881
        g_return_val_if_fail (self != NULL, NULL);
 
882
        _tmp0_ = strlen (self);
 
883
        string_length = (glong) _tmp0_;
 
884
        if (offset < 0) {
 
885
                offset = string_length + offset;
 
886
                g_return_val_if_fail (offset >= 0, NULL);
 
887
        } else {
 
888
                g_return_val_if_fail (offset <= string_length, NULL);
 
889
        }
 
890
        if (len < 0) {
 
891
                len = string_length - offset;
 
892
        }
 
893
        g_return_val_if_fail ((offset + len) <= string_length, NULL);
 
894
        _tmp1_ = g_strndup (((gchar*) self) + offset, (gsize) len);
 
895
        result = _tmp1_;
 
896
        return result;
 
897
}
 
898
 
 
899
 
876
900
gboolean vala_code_context_add_source_filename (ValaCodeContext* self, const gchar* filename, gboolean is_source) {
877
901
        gboolean result = FALSE;
878
902
        gboolean _tmp0_;
995
1019
                        vala_code_context_add_source_file (self, source_file);
996
1020
                        _tmp28_ = strlen (filename);
997
1021
                        _tmp29_ = strlen (".vapi");
998
 
                        _tmp30_ = g_strndup (filename, (gsize) (_tmp28_ - _tmp29_));
 
1022
                        _tmp30_ = string_substring (filename, (glong) 0, (glong) (_tmp28_ - _tmp29_));
999
1023
                        _tmp31_ = _tmp30_;
1000
1024
                        _tmp32_ = g_strdup_printf ("%s.deps", _tmp31_);
1001
1025
                        deps_filename = (_tmp33_ = _tmp32_, _g_free0 (_tmp31_), _tmp33_);
1326
1350
}
1327
1351
 
1328
1352
 
1329
 
static const gchar* string_offset (const gchar* self, glong offset) {
1330
 
        const gchar* result = NULL;
1331
 
        g_return_val_if_fail (self != NULL, NULL);
1332
 
        result = (const gchar*) (((gchar*) self) + offset);
1333
 
        return result;
1334
 
}
1335
 
 
1336
 
 
1337
 
static gunichar string_get_char (const gchar* self, gint index) {
 
1353
static gunichar string_get_char (const gchar* self, glong index) {
1338
1354
        gunichar result = 0U;
1339
1355
        gunichar _tmp0_;
1340
1356
        g_return_val_if_fail (self != NULL, 0U);
1347
1363
static gboolean vala_code_context_ends_with_dir_separator (const gchar* s) {
1348
1364
        gboolean result = FALSE;
1349
1365
        gint _tmp0_;
1350
 
        const gchar* _tmp1_ = NULL;
1351
 
        gunichar _tmp2_;
1352
 
        gboolean _tmp3_;
 
1366
        gunichar _tmp1_;
 
1367
        gboolean _tmp2_;
1353
1368
        g_return_val_if_fail (s != NULL, FALSE);
1354
1369
        _tmp0_ = strlen (s);
1355
 
        _tmp1_ = string_offset (s, (glong) (_tmp0_ - 1));
1356
 
        _tmp2_ = string_get_char (_tmp1_, 0);
1357
 
        _tmp3_ = G_IS_DIR_SEPARATOR (_tmp2_);
1358
 
        result = _tmp3_;
1359
 
        return result;
1360
 
}
1361
 
 
1362
 
 
1363
 
static gchar* string_substring (const gchar* self, glong offset, glong len) {
1364
 
        gchar* result = NULL;
1365
 
        gint _tmp0_;
1366
 
        glong string_length;
1367
 
        const gchar* _tmp1_ = NULL;
1368
 
        const gchar* start;
1369
 
        const gchar* _tmp2_ = NULL;
1370
 
        gchar* _tmp3_ = NULL;
1371
 
        g_return_val_if_fail (self != NULL, NULL);
1372
 
        _tmp0_ = strlen (self);
1373
 
        string_length = (glong) _tmp0_;
1374
 
        if (offset < 0) {
1375
 
                offset = string_length + offset;
1376
 
                g_return_val_if_fail (offset >= 0, NULL);
1377
 
        } else {
1378
 
                g_return_val_if_fail (offset <= string_length, NULL);
1379
 
        }
1380
 
        if (len < 0) {
1381
 
                len = string_length - offset;
1382
 
        }
1383
 
        g_return_val_if_fail ((offset + len) <= string_length, NULL);
1384
 
        _tmp1_ = string_offset (self, offset);
1385
 
        start = _tmp1_;
1386
 
        _tmp2_ = string_offset (start, len);
1387
 
        _tmp3_ = g_strndup (start, ((gchar*) _tmp2_) - ((gchar*) start));
1388
 
        result = _tmp3_;
1389
 
        return result;
1390
 
}
1391
 
 
1392
 
 
1393
 
static glong string_pointer_to_offset (const gchar* self, const gchar* pos) {
1394
 
        glong result = 0L;
1395
 
        g_return_val_if_fail (self != NULL, 0L);
1396
 
        g_return_val_if_fail (pos != NULL, 0L);
1397
 
        result = (glong) (((gchar*) pos) - ((gchar*) self));
 
1370
        _tmp1_ = string_get_char (s, (glong) (_tmp0_ - 1));
 
1371
        _tmp2_ = G_IS_DIR_SEPARATOR (_tmp1_);
 
1372
        result = _tmp2_;
1398
1373
        return result;
1399
1374
}
1400
1375
 
1405
1380
        const gchar* start;
1406
1381
        const gchar* end;
1407
1382
        gboolean _tmp0_;
1408
 
        const gchar* _tmp7_ = NULL;
1409
 
        glong _tmp8_;
 
1383
        const gchar* _tmp6_ = NULL;
1410
1384
        glong root_len;
1411
 
        gboolean _tmp35_ = FALSE;
1412
 
        gint _tmp36_;
 
1385
        gboolean _tmp33_ = FALSE;
 
1386
        gint _tmp34_;
1413
1387
        g_return_val_if_fail (name != NULL, NULL);
1414
1388
        rpath = NULL;
1415
1389
        start = NULL;
1426
1400
                start = end;
1427
1401
        } else {
1428
1402
                const gchar* _tmp3_ = NULL;
1429
 
                glong _tmp4_;
1430
 
                gchar* _tmp5_ = NULL;
1431
 
                gchar* _tmp6_;
 
1403
                gchar* _tmp4_ = NULL;
 
1404
                gchar* _tmp5_;
1432
1405
                _tmp3_ = g_path_skip_root (name);
1433
1406
                end = _tmp3_;
1434
1407
                start = end;
1435
 
                _tmp4_ = string_pointer_to_offset (name, start);
1436
 
                _tmp5_ = string_substring (name, (glong) 0, _tmp4_);
1437
 
                _tmp6_ = _tmp5_;
 
1408
                _tmp4_ = string_substring (name, (glong) 0, (glong) ((gint) (((gchar*) start) - ((gchar*) name))));
 
1409
                _tmp5_ = _tmp4_;
1438
1410
                _g_free0 (rpath);
1439
 
                rpath = _tmp6_;
 
1411
                rpath = _tmp5_;
1440
1412
        }
1441
 
        _tmp7_ = g_path_skip_root (rpath);
1442
 
        _tmp8_ = string_pointer_to_offset (rpath, _tmp7_);
1443
 
        root_len = _tmp8_;
 
1413
        _tmp6_ = g_path_skip_root (rpath);
 
1414
        root_len = (glong) (((gchar*) _tmp6_) - ((gchar*) rpath));
1444
1415
        {
1445
 
                gboolean _tmp9_;
1446
 
                _tmp9_ = TRUE;
 
1416
                gboolean _tmp7_;
 
1417
                _tmp7_ = TRUE;
1447
1418
                while (TRUE) {
1448
 
                        gunichar _tmp10_;
 
1419
                        gunichar _tmp8_;
1449
1420
                        glong len;
1450
 
                        if (!_tmp9_) {
 
1421
                        if (!_tmp7_) {
1451
1422
                                start = end;
1452
1423
                        }
1453
 
                        _tmp9_ = FALSE;
1454
 
                        _tmp10_ = string_get_char (start, 0);
1455
 
                        if (!(_tmp10_ != 0)) {
 
1424
                        _tmp7_ = FALSE;
 
1425
                        _tmp8_ = string_get_char (start, (glong) 0);
 
1426
                        if (!(_tmp8_ != 0)) {
1456
1427
                                break;
1457
1428
                        }
1458
1429
                        while (TRUE) {
1459
 
                                gunichar _tmp11_;
1460
 
                                gboolean _tmp12_;
1461
 
                                const gchar* _tmp13_ = NULL;
1462
 
                                _tmp11_ = string_get_char (start, 0);
1463
 
                                _tmp12_ = G_IS_DIR_SEPARATOR (_tmp11_);
1464
 
                                if (!_tmp12_) {
 
1430
                                gunichar _tmp9_;
 
1431
                                gboolean _tmp10_;
 
1432
                                const gchar* _tmp11_ = NULL;
 
1433
                                _tmp9_ = string_get_char (start, (glong) 0);
 
1434
                                _tmp10_ = G_IS_DIR_SEPARATOR (_tmp9_);
 
1435
                                if (!_tmp10_) {
1465
1436
                                        break;
1466
1437
                                }
1467
 
                                _tmp13_ = g_utf8_next_char (start);
1468
 
                                start = _tmp13_;
 
1438
                                _tmp11_ = g_utf8_next_char (start);
 
1439
                                start = _tmp11_;
1469
1440
                        }
1470
1441
                        len = (glong) 0;
1471
1442
                        {
1472
 
                                gboolean _tmp14_;
 
1443
                                gboolean _tmp12_;
1473
1444
                                end = start;
1474
 
                                _tmp14_ = TRUE;
 
1445
                                _tmp12_ = TRUE;
1475
1446
                                while (TRUE) {
1476
 
                                        gboolean _tmp16_ = FALSE;
1477
 
                                        gunichar _tmp17_;
 
1447
                                        gboolean _tmp14_ = FALSE;
 
1448
                                        gunichar _tmp15_;
 
1449
                                        if (!_tmp12_) {
 
1450
                                                const gchar* _tmp13_ = NULL;
 
1451
                                                _tmp13_ = g_utf8_next_char (end);
 
1452
                                                end = _tmp13_;
 
1453
                                        }
 
1454
                                        _tmp12_ = FALSE;
 
1455
                                        _tmp15_ = string_get_char (end, (glong) 0);
 
1456
                                        if (_tmp15_ != 0) {
 
1457
                                                gunichar _tmp16_;
 
1458
                                                gboolean _tmp17_;
 
1459
                                                _tmp16_ = string_get_char (end, (glong) 0);
 
1460
                                                _tmp17_ = G_IS_DIR_SEPARATOR (_tmp16_);
 
1461
                                                _tmp14_ = !_tmp17_;
 
1462
                                        } else {
 
1463
                                                _tmp14_ = FALSE;
 
1464
                                        }
1478
1465
                                        if (!_tmp14_) {
1479
 
                                                const gchar* _tmp15_ = NULL;
1480
 
                                                _tmp15_ = g_utf8_next_char (end);
1481
 
                                                end = _tmp15_;
1482
 
                                        }
1483
 
                                        _tmp14_ = FALSE;
1484
 
                                        _tmp17_ = string_get_char (end, 0);
1485
 
                                        if (_tmp17_ != 0) {
1486
 
                                                gunichar _tmp18_;
1487
 
                                                gboolean _tmp19_;
1488
 
                                                _tmp18_ = string_get_char (end, 0);
1489
 
                                                _tmp19_ = G_IS_DIR_SEPARATOR (_tmp18_);
1490
 
                                                _tmp16_ = !_tmp19_;
1491
 
                                        } else {
1492
 
                                                _tmp16_ = FALSE;
1493
 
                                        }
1494
 
                                        if (!_tmp16_) {
1495
1466
                                                break;
1496
1467
                                        }
1497
1468
                                        len++;
1500
1471
                        if (len == 0) {
1501
1472
                                break;
1502
1473
                        } else {
1503
 
                                gboolean _tmp20_ = FALSE;
 
1474
                                gboolean _tmp18_ = FALSE;
1504
1475
                                if (len == 1) {
1505
 
                                        gunichar _tmp21_;
1506
 
                                        _tmp21_ = string_get_char (start, 0);
1507
 
                                        _tmp20_ = _tmp21_ == '.';
 
1476
                                        gunichar _tmp19_;
 
1477
                                        _tmp19_ = string_get_char (start, (glong) 0);
 
1478
                                        _tmp18_ = _tmp19_ == '.';
1508
1479
                                } else {
1509
 
                                        _tmp20_ = FALSE;
 
1480
                                        _tmp18_ = FALSE;
1510
1481
                                }
1511
 
                                if (_tmp20_) {
 
1482
                                if (_tmp18_) {
1512
1483
                                } else {
1513
 
                                        gboolean _tmp22_ = FALSE;
 
1484
                                        gboolean _tmp20_ = FALSE;
1514
1485
                                        if (len == 2) {
1515
 
                                                gboolean _tmp23_;
1516
 
                                                _tmp23_ = g_str_has_prefix (start, "..");
1517
 
                                                _tmp22_ = _tmp23_;
 
1486
                                                gboolean _tmp21_;
 
1487
                                                _tmp21_ = g_str_has_prefix (start, "..");
 
1488
                                                _tmp20_ = _tmp21_;
1518
1489
                                        } else {
1519
 
                                                _tmp22_ = FALSE;
 
1490
                                                _tmp20_ = FALSE;
1520
1491
                                        }
1521
 
                                        if (_tmp22_) {
1522
 
                                                gint _tmp24_;
1523
 
                                                _tmp24_ = strlen (rpath);
1524
 
                                                if (_tmp24_ > root_len) {
 
1492
                                        if (_tmp20_) {
 
1493
                                                gint _tmp22_;
 
1494
                                                _tmp22_ = strlen (rpath);
 
1495
                                                if (_tmp22_ > root_len) {
1525
1496
                                                        {
1526
 
                                                                gboolean _tmp25_;
1527
 
                                                                _tmp25_ = TRUE;
 
1497
                                                                gboolean _tmp23_;
 
1498
                                                                _tmp23_ = TRUE;
1528
1499
                                                                while (TRUE) {
1529
 
                                                                        gint _tmp27_;
1530
 
                                                                        gchar* _tmp28_ = NULL;
1531
 
                                                                        gchar* _tmp29_;
1532
 
                                                                        if (!_tmp25_) {
1533
 
                                                                                gboolean _tmp26_;
1534
 
                                                                                _tmp26_ = vala_code_context_ends_with_dir_separator (rpath);
1535
 
                                                                                if (!(!_tmp26_)) {
 
1500
                                                                        gint _tmp25_;
 
1501
                                                                        gchar* _tmp26_ = NULL;
 
1502
                                                                        gchar* _tmp27_;
 
1503
                                                                        if (!_tmp23_) {
 
1504
                                                                                gboolean _tmp24_;
 
1505
                                                                                _tmp24_ = vala_code_context_ends_with_dir_separator (rpath);
 
1506
                                                                                if (!(!_tmp24_)) {
1536
1507
                                                                                        break;
1537
1508
                                                                                }
1538
1509
                                                                        }
1539
 
                                                                        _tmp25_ = FALSE;
1540
 
                                                                        _tmp27_ = strlen (rpath);
1541
 
                                                                        _tmp28_ = string_substring (rpath, (glong) 0, (glong) (_tmp27_ - 1));
1542
 
                                                                        _tmp29_ = _tmp28_;
 
1510
                                                                        _tmp23_ = FALSE;
 
1511
                                                                        _tmp25_ = strlen (rpath);
 
1512
                                                                        _tmp26_ = string_substring (rpath, (glong) 0, (glong) (_tmp25_ - 1));
 
1513
                                                                        _tmp27_ = _tmp26_;
1543
1514
                                                                        _g_free0 (rpath);
1544
 
                                                                        rpath = _tmp29_;
 
1515
                                                                        rpath = _tmp27_;
1545
1516
                                                                }
1546
1517
                                                        }
1547
1518
                                                }
1548
1519
                                        } else {
1549
 
                                                gboolean _tmp30_;
1550
 
                                                gchar* _tmp32_ = NULL;
1551
 
                                                gchar* _tmp33_;
1552
 
                                                gchar* _tmp34_;
1553
 
                                                _tmp30_ = vala_code_context_ends_with_dir_separator (rpath);
1554
 
                                                if (!_tmp30_) {
1555
 
                                                        gchar* _tmp31_;
1556
 
                                                        _tmp31_ = g_strconcat (rpath, G_DIR_SEPARATOR_S, NULL);
 
1520
                                                gboolean _tmp28_;
 
1521
                                                gchar* _tmp30_ = NULL;
 
1522
                                                gchar* _tmp31_;
 
1523
                                                gchar* _tmp32_;
 
1524
                                                _tmp28_ = vala_code_context_ends_with_dir_separator (rpath);
 
1525
                                                if (!_tmp28_) {
 
1526
                                                        gchar* _tmp29_;
 
1527
                                                        _tmp29_ = g_strconcat (rpath, G_DIR_SEPARATOR_S, NULL);
1557
1528
                                                        _g_free0 (rpath);
1558
 
                                                        rpath = _tmp31_;
 
1529
                                                        rpath = _tmp29_;
1559
1530
                                                }
1560
 
                                                _tmp32_ = string_substring (start, (glong) 0, len);
1561
 
                                                _tmp33_ = _tmp32_;
1562
 
                                                _tmp34_ = g_strconcat (rpath, _tmp33_, NULL);
 
1531
                                                _tmp30_ = string_substring (start, (glong) 0, len);
 
1532
                                                _tmp31_ = _tmp30_;
 
1533
                                                _tmp32_ = g_strconcat (rpath, _tmp31_, NULL);
1563
1534
                                                _g_free0 (rpath);
1564
 
                                                rpath = _tmp34_;
1565
 
                                                _g_free0 (_tmp33_);
 
1535
                                                rpath = _tmp32_;
 
1536
                                                _g_free0 (_tmp31_);
1566
1537
                                        }
1567
1538
                                }
1568
1539
                        }
1569
1540
                }
1570
1541
        }
1571
 
        _tmp36_ = strlen (rpath);
1572
 
        if (_tmp36_ > root_len) {
1573
 
                gboolean _tmp37_;
1574
 
                _tmp37_ = vala_code_context_ends_with_dir_separator (rpath);
1575
 
                _tmp35_ = _tmp37_;
 
1542
        _tmp34_ = strlen (rpath);
 
1543
        if (_tmp34_ > root_len) {
 
1544
                gboolean _tmp35_;
 
1545
                _tmp35_ = vala_code_context_ends_with_dir_separator (rpath);
 
1546
                _tmp33_ = _tmp35_;
1576
1547
        } else {
1577
 
                _tmp35_ = FALSE;
 
1548
                _tmp33_ = FALSE;
1578
1549
        }
1579
 
        if (_tmp35_) {
1580
 
                gint _tmp38_;
1581
 
                gchar* _tmp39_ = NULL;
1582
 
                gchar* _tmp40_;
1583
 
                _tmp38_ = strlen (rpath);
1584
 
                _tmp39_ = string_substring (rpath, (glong) 0, (glong) (_tmp38_ - 1));
1585
 
                _tmp40_ = _tmp39_;
 
1550
        if (_tmp33_) {
 
1551
                gint _tmp36_;
 
1552
                gchar* _tmp37_ = NULL;
 
1553
                gchar* _tmp38_;
 
1554
                _tmp36_ = strlen (rpath);
 
1555
                _tmp37_ = string_substring (rpath, (glong) 0, (glong) (_tmp36_ - 1));
 
1556
                _tmp38_ = _tmp37_;
1586
1557
                _g_free0 (rpath);
1587
 
                rpath = _tmp40_;
 
1558
                rpath = _tmp38_;
1588
1559
        }
1589
1560
        if (G_DIR_SEPARATOR != '/') {
1590
 
                gchar** _tmp41_;
1591
 
                gchar** _tmp42_ = NULL;
 
1561
                gchar** _tmp39_;
 
1562
                gchar** _tmp40_ = NULL;
1592
1563
                gint components_length1;
1593
1564
                gint _components_size_;
1594
 
                gchar** _tmp43_;
 
1565
                gchar** _tmp41_;
1595
1566
                gchar** components;
1596
 
                gchar* _tmp44_ = NULL;
1597
 
                gchar* _tmp45_;
1598
 
                _tmp42_ = _tmp41_ = g_strsplit (rpath, "\\", 0);
 
1567
                gchar* _tmp42_ = NULL;
 
1568
                gchar* _tmp43_;
 
1569
                _tmp40_ = _tmp39_ = g_strsplit (rpath, "\\", 0);
 
1570
                _tmp41_ = _tmp40_;
 
1571
                components_length1 = _vala_array_length (_tmp39_);
 
1572
                _components_size_ = components_length1;
 
1573
                components = _tmp41_;
 
1574
                _tmp42_ = g_strjoinv ("/", components);
1599
1575
                _tmp43_ = _tmp42_;
1600
 
                components_length1 = _vala_array_length (_tmp41_);
1601
 
                _components_size_ = components_length1;
1602
 
                components = _tmp43_;
1603
 
                _tmp44_ = g_strjoinv ("/", components);
1604
 
                _tmp45_ = _tmp44_;
1605
1576
                _g_free0 (rpath);
1606
 
                rpath = _tmp45_;
 
1577
                rpath = _tmp43_;
1607
1578
                components = (_vala_array_free (components, components_length1, (GDestroyNotify) g_free), NULL);
1608
1579
        }
1609
1580
        result = rpath;