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;
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;
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;
395
395
} else if (nv[0] == "takes_ownership") {
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);
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__");
986
en.get_values ().remove (dummy);
987
en.scope.remove ("__DUMMY__");
987
991
en.has_type_id = (en_node.gtype_name != null && en_node.gtype_name != "");
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);
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 ());
1372
if (methods.index_of (finish_method) < method_n) {
1375
type_symbol.scope.remove (finish_method.name);
1376
methods.remove (finish_method);
1376
finish_methods.add (finish_method);
1381
foreach (Method m in finish_methods)
1383
type_symbol.scope.remove (m.name);
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;
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;
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;
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;
1871
1879
} else if (nv[0] == "nullable") {
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);
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);
1939
1947
unowned string endptr;
1940
1948
unowned string val_end = val.offset (val.len ());
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);
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);
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);
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);
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;
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;
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;
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));
2504
2512
} else if (nv[0] == "namespace_name") {
2505
2513
ns_name = eval (nv[1]);