((Delegate) s).add_error_type (error_type);
}
}
- throws_string = "1";
} else if (throws_string == "1") {
if (s is Method) {
((Method) s).add_error_type (new ErrorType (null, null));
}
var info = new ParameterInfo (param, array_length_idx, closure_idx, destroy_idx, scope == "async");
- unowned UnresolvedType? unresolved_type = param.variable_type as UnresolvedType;
-
- if (s is Method && scope == "async") {
- if (unresolved_type != null && unresolved_type.unresolved_symbol.name == "AsyncReadyCallback") {
- // GAsync-style method
- ((Method) s).coroutine = true;
- info.keep = false;
- }
- }
-
- if (s is Delegate && throws_string != "1" && param.direction == ParameterDirection.OUT) {
- if (unresolved_type != null && unresolved_type.unresolved_symbol.to_string () == "GLib.Error") {
- ((Delegate) s).add_error_type (new ErrorType (null, null));
- info.is_error = true;
- info.keep = false;
- }
- }
-
parameters.add (info);
pop_metadata ();
}
}
current.parameters = parameters;
- for (int param_n = parameters.size - 1 ; param_n >= 0 ; param_n--) {
- ParameterInfo pi = parameters[param_n];
- if (!pi.param.ellipsis && pi.param.initializer == null) {
- string type_string = pi.param.variable_type.to_string ();
- if (type_string == "Gio.Cancellable?") {
- pi.param.initializer = new Vala.NullLiteral ();
- } else {
- break;
- }
- }
- }
-
pop_node ();
end_element (element_name);
}
}
}
- // Do not mark out-parameters as nullable if they are simple-types,
- // since it would result in a boxed-type in vala
foreach (ParameterInfo info in parameters) {
- var type = info.param.variable_type;
+ unowned DataType type = info.param.variable_type;
+
+ // Do not mark out-parameters as nullable if they are simple-types,
+ // since it would result in a boxed-type in vala
if (info.param.direction == ParameterDirection.OUT && type.nullable) {
Struct? st = null;
if (type is UnresolvedType) {
type.nullable = false;
}
}
+
+ // Check and mark GAsync-style methods
+ if (info.is_async && s is Method) {
+ unowned UnresolvedType? unresolved_type = type as UnresolvedType;
+ if (unresolved_type != null && unresolved_type.unresolved_symbol.name == "AsyncReadyCallback") {
+ ((Method) s).coroutine = true;
+ info.keep = false;
+ }
+ }
+
+ // More thorough check for delegates throwing an error
+ if (info.param.direction == ParameterDirection.OUT && s is Delegate && !s.tree_can_fail) {
+ unowned UnresolvedType? unresolved_type = type as UnresolvedType;
+ if (unresolved_type != null && unresolved_type.unresolved_symbol.to_string () == "GLib.Error") {
+ ((Delegate) s).add_error_type (new ErrorType (null, null));
+ info.is_error = true;
+ info.keep = false;
+ }
+ }
+ }
+
+ // Add null-literal as default-value for trailing GLib.Cancellable parameters
+ for (int param_n = parameters.size - 1 ; param_n >= 0 ; param_n--) {
+ ParameterInfo info = parameters[param_n];
+ if (!info.param.ellipsis && info.param.initializer == null) {
+ string type_string = info.param.variable_type.to_string ();
+ if (type_string == "GLib.Cancellable?" || type_string == "Gio.Cancellable?") {
+ info.param.initializer = new Vala.NullLiteral ();
+ } else {
+ break;
+ }
+ }
}
if (parameters.size > 1) {