~ubuntu-branches/ubuntu/vivid/vala/vivid

« back to all changes in this revision

Viewing changes to vapigen/valagidlparser.vala

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-07-28 07:58:01 UTC
  • mfrom: (1.5.5 upstream) (7.3.14 experimental)
  • Revision ID: james.westby@ubuntu.com-20100728075801-18u9cg5hv5oety6m
Tags: 0.9.4-1
New upstream development release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
367
367
                                                } else if (nv[0] == "is_array") {
368
368
                                                        if (eval (nv[1]) == "1") {
369
369
                                                                param_type = new ArrayType (param_type, 1, param_type.source_reference);
370
 
                                                                p.parameter_type = param_type;
 
370
                                                                p.variable_type = param_type;
371
371
                                                                if (!out_requested) {
372
372
                                                                        p.direction = ParameterDirection.IN;
373
373
                                                                }
380
380
                                                                if (!array_requested && param_type is ArrayType) {
381
381
                                                                        var array_type = (ArrayType) param_type;
382
382
                                                                        param_type = array_type.element_type;
383
 
                                                                        p.parameter_type = param_type;
 
383
                                                                        p.variable_type = param_type;
384
384
                                                                }
385
385
                                                        }
386
386
                                                } else if (nv[0] == "is_ref") {
389
389
                                                                if (!array_requested && param_type is ArrayType) {
390
390
                                                                        var array_type = (ArrayType) param_type;
391
391
                                                                        param_type = array_type.element_type;
392
 
                                                                        p.parameter_type = param_type;
 
392
                                                                        p.variable_type = param_type;
393
393
                                                                }
394
394
                                                        }
395
395
                                                } else if (nv[0] == "takes_ownership") {
416
416
                                                        } else {
417
417
                                                                // Overwrite old param_type, so "type_name" must be before any
418
418
                                                                // other param type modifying metadata
419
 
                                                                p.parameter_type = param_type = new UnresolvedType.from_symbol (sym, return_type.source_reference);
 
419
                                                                p.variable_type = param_type = new UnresolvedType.from_symbol (sym, return_type.source_reference);
420
420
                                                        }
421
421
                                                }
422
422
                                        }
981
981
                } else {
982
982
                        // ignore dummy enum values in -custom.vala files
983
983
                        // they exist for syntactical reasons
984
 
                        en.remove_all_values ();
 
984
                        var dummy = (EnumValue) en.scope.lookup ("__DUMMY__");
 
985
                        if (dummy != null) {
 
986
                                en.get_values ().remove (dummy);
 
987
                                en.scope.remove ("__DUMMY__");
 
988
                        }
985
989
                }
986
990
 
987
991
                en.has_type_id = (en_node.gtype_name != null && en_node.gtype_name != "");
1080
1084
                        }
1081
1085
 
1082
1086
                        if (!is_hidden) {
1083
 
                                var ev = new EnumValue (value2.name.offset (common_prefix.len ()));
 
1087
                                var ev = new EnumValue (value2.name.offset (common_prefix.len ()), null);
1084
1088
                                en.add_value (ev);
1085
1089
                        }
1086
1090
                }
1328
1332
        }
1329
1333
 
1330
1334
        void handle_async_methods (ObjectTypeSymbol type_symbol) {
 
1335
                Set<Method> finish_methods = new HashSet<Method> ();
1331
1336
                var methods = type_symbol.get_methods ();
1332
 
                for (int method_n = 0 ; method_n < methods.size ; method_n++) {
1333
 
                        var m = methods.get (method_n);
1334
1337
 
 
1338
                foreach (Method m in methods) {
1335
1339
                        if (m.coroutine) {
1336
1340
                                string finish_method_base;
1337
1341
                                if (m.name.has_suffix ("_async")) {
1369
1373
                                        foreach (DataType error_type in finish_method.get_error_types ()) {
1370
1374
                                                m.add_error_type (error_type.copy ());
1371
1375
                                        }
1372
 
                                        if (methods.index_of (finish_method) < method_n) {
1373
 
                                                method_n--;
1374
 
                                        }
1375
 
                                        type_symbol.scope.remove (finish_method.name);
1376
 
                                        methods.remove (finish_method);
 
1376
                                        finish_methods.add (finish_method);
1377
1377
                                }
1378
1378
                        }
1379
1379
                }
 
1380
 
 
1381
                foreach (Method m in finish_methods)
 
1382
                {
 
1383
                        type_symbol.scope.remove (m.name);
 
1384
                        methods.remove (m);
 
1385
                }
1380
1386
        }
1381
1387
        
1382
1388
        private DataType? parse_type (IdlNodeType type_node, out ParameterDirection direction = null) {
1725
1731
                                                m.no_array_length = true;
1726
1732
                                                m.array_null_terminated = true;
1727
1733
                                        }
 
1734
                                } else if (nv[0] == "array_length_type") {
 
1735
                                        m.array_length_type = eval (nv[1]);
1728
1736
                                } else if (nv[0] == "type_name") {
1729
1737
                                        var sym = new UnresolvedSymbol (null, eval (nv[1]));
1730
1738
                                        if (return_type is UnresolvedType) {
1843
1851
                                        if (nv[0] == "is_array") {
1844
1852
                                                if (eval (nv[1]) == "1") {
1845
1853
                                                        param_type = new ArrayType (param_type, 1, param_type.source_reference);
1846
 
                                                        p.parameter_type = param_type;
 
1854
                                                        p.variable_type = param_type;
1847
1855
                                                        if (!out_requested) {
1848
1856
                                                                p.direction = ParameterDirection.IN;
1849
1857
                                                        }
1856
1864
                                                        if (!array_requested && param_type is ArrayType) {
1857
1865
                                                                var array_type = (ArrayType) param_type;
1858
1866
                                                                param_type = array_type.element_type;
1859
 
                                                                p.parameter_type = param_type;
 
1867
                                                                p.variable_type = param_type;
1860
1868
                                                        }
1861
1869
                                                }
1862
1870
                                        } else if (nv[0] == "is_ref") {
1865
1873
                                                        if (!array_requested && param_type is ArrayType) {
1866
1874
                                                                var array_type = (ArrayType) param_type;
1867
1875
                                                                param_type = array_type.element_type;
1868
 
                                                                p.parameter_type = param_type;
 
1876
                                                                p.variable_type = param_type;
1869
1877
                                                        }
1870
1878
                                                }
1871
1879
                                        } else if (nv[0] == "nullable") {
1916
1924
                                                } else {
1917
1925
                                                        // Overwrite old param_type, so "type_name" must be before any
1918
1926
                                                        // other param type modifying metadata
1919
 
                                                        p.parameter_type = param_type = new UnresolvedType.from_symbol (sym, return_type.source_reference);
 
1927
                                                        p.variable_type = param_type = new UnresolvedType.from_symbol (sym, return_type.source_reference);
1920
1928
                                                }
1921
1929
                                        } else if (nv[0] == "ctype") {
1922
1930
                                                p.ctype = eval (nv[1]);
1928
1936
                                        } else if (nv[0] == "default_value") {
1929
1937
                                                var val = eval (nv[1]);
1930
1938
                                                if (val == "null") {
1931
 
                                                        p.default_expression = new NullLiteral (param_type.source_reference);
 
1939
                                                        p.initializer = new NullLiteral (param_type.source_reference);
1932
1940
                                                } else if (val == "true") {
1933
 
                                                        p.default_expression = new BooleanLiteral (true, param_type.source_reference);
 
1941
                                                        p.initializer = new BooleanLiteral (true, param_type.source_reference);
1934
1942
                                                } else if (val == "false") {
1935
 
                                                        p.default_expression = new BooleanLiteral (false, param_type.source_reference);
 
1943
                                                        p.initializer = new BooleanLiteral (false, param_type.source_reference);
1936
1944
                                                } else if (val == "") {
1937
 
                                                        p.default_expression = new StringLiteral ("\"\"", param_type.source_reference);
 
1945
                                                        p.initializer = new StringLiteral ("\"\"", param_type.source_reference);
1938
1946
                                                } else {
1939
1947
                                                        unowned string endptr;
1940
1948
                                                        unowned string val_end = val.offset (val.len ());
1941
1949
 
1942
1950
                                                        val.to_long (out endptr);
1943
1951
                                                        if ((long)endptr == (long)val_end) {
1944
 
                                                                p.default_expression = new IntegerLiteral (val, param_type.source_reference);
 
1952
                                                                p.initializer = new IntegerLiteral (val, param_type.source_reference);
1945
1953
                                                        } else {
1946
1954
                                                                val.to_double (out endptr);
1947
1955
                                                                if ((long)endptr == (long)val_end) {
1948
 
                                                                        p.default_expression = new RealLiteral (val, param_type.source_reference);
 
1956
                                                                        p.initializer = new RealLiteral (val, param_type.source_reference);
1949
1957
                                                                } else {
1950
1958
                                                                        if (val.has_prefix ("\"") && val.has_suffix ("\"")) {
1951
 
                                                                                p.default_expression = new StringLiteral (val, param_type.source_reference);
 
1959
                                                                                p.initializer = new StringLiteral (val, param_type.source_reference);
1952
1960
                                                                        } else {
1953
1961
                                                                                foreach (var member in val.split (".")) {
1954
 
                                                                                        p.default_expression = new MemberAccess (p.default_expression, member, param_type.source_reference);
 
1962
                                                                                        p.initializer = new MemberAccess (p.initializer, member, param_type.source_reference);
1955
1963
                                                                                }
1956
1964
                                                                        }
1957
1965
                                                                }
1965
1973
                                if (!(last_param_type is ArrayType)) {
1966
1974
                                        // last_param is array, p is array length
1967
1975
                                        last_param_type = new ArrayType (last_param_type, 1, last_param_type.source_reference);
1968
 
                                        last_param.parameter_type = last_param_type;
 
1976
                                        last_param.variable_type = last_param_type;
1969
1977
                                        last_param.direction = ParameterDirection.IN;
1970
1978
                                }
1971
1979
 
2471
2479
                                        if (nv[0] == "is_array") {
2472
2480
                                                if (eval (nv[1]) == "1") {
2473
2481
                                                        param_type = new ArrayType (param_type, 1, param_type.source_reference);
2474
 
                                                        p.parameter_type = param_type;
 
2482
                                                        p.variable_type = param_type;
2475
2483
                                                        p.direction = ParameterDirection.IN;
2476
2484
                                                }
2477
2485
                                        } else if (nv[0] == "is_out") {
2493
2501
                                        } else if (nv[0] == "type_name") {
2494
2502
                                                if (!(param_type is UnresolvedType)) {
2495
2503
                                                        param_type = new UnresolvedType ();
2496
 
                                                        p.parameter_type = param_type;
 
2504
                                                        p.variable_type = param_type;
2497
2505
                                                }
2498
2506
                                                ((UnresolvedType) param_type).unresolved_symbol = new UnresolvedSymbol (null, eval (nv[1]));
2499
2507
                                        } else if (nv[0] == "type_arguments") {
2500
2508
                                                var type_args = eval (nv[1]).split (",");
2501
2509
                                                foreach (string type_arg in type_args) {
2502
 
                                                        p.parameter_type.add_type_argument (get_type_from_string (type_arg));
 
2510
                                                        p.variable_type.add_type_argument (get_type_from_string (type_arg));
2503
2511
                                                }
2504
2512
                                        } else if (nv[0] == "namespace_name") {
2505
2513
                                                ns_name = eval (nv[1]);