[vala/wip/issue/658: 15/30] Refactored code
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/658: 15/30] Refactored code
- Date: Wed, 21 Oct 2020 10:33:11 +0000 (UTC)
commit 80395ea8dcf544177573f0845a1bcfb8f9574eec
Author: Nick Schrader <nick schrader mailbox org>
Date: Mon Jul 20 14:06:46 2020 +0200
Refactored code
tmp/delegate.vala | 13 -------------
tmp/deltest.vala | 19 -------------------
tmp/deltest2.vala | 13 -------------
tmp/with.vala | 10 ----------
vala-lint.conf | 27 ---------------------------
vala/valadelegatetype.vala | 5 +++--
vala/valaparser.vala | 28 ++++++++++++++--------------
valac | 3 ---
workspace.code-workspace | 8 --------
9 files changed, 17 insertions(+), 109 deletions(-)
---
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 9301c9d69..dfeaae87a 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -29,6 +29,7 @@ public class Vala.DelegateType : CallableType {
public weak Delegate delegate_symbol {
get {
if (marker && symbol != null) {
+ var del = delegate_symbol_ref;
stderr.printf("[*%p] delegate_symbol name: %s, type: %s ", &(this.marker),
symbol.name, Type.from_instance(symbol).name());
stderr.printf("constr del name %s, type: %s, address %p\n", del.name,
Type.from_instance(del).name(), &del);
}
@@ -48,7 +49,7 @@ public class Vala.DelegateType : CallableType {
* Maybe the symbol of type ValaDelegate is discarded because of its weak reference and
* memory for a new one of type ValaLocalVariable is allocated at the exact same address?
*/
- Delegate del;
+ Delegate delegate_symbol_ref;
public DelegateType.anonymous (Delegate delegate_symbol) {
if (delegate_symbol!= null) {
@@ -64,7 +65,7 @@ public class Vala.DelegateType : CallableType {
public DelegateType (Delegate delegate_symbol) {
base (delegate_symbol);
- del = delegate_symbol;
+ delegate_symbol_ref = delegate_symbol;
this.is_called_once = (delegate_symbol.get_attribute_string ("CCode", "scope") == "async");
}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index ba4661e03..d059bd592 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -474,21 +474,21 @@ public class Vala.Parser : CodeVisitor {
return result;
}
- DataType parse_type (bool owned_by_default, bool can_weak_ref, bool require_unowned = false, Symbol?
parent=null) throws ParseError {
- var type_loc = get_location ();
- if (!accept (TokenType.DELEGATE)) {
- rollback (type_loc);
- return parse_type2(owned_by_default, can_weak_ref, require_unowned);
- } else {
- stderr.printf("parse delegate");
- rollback (type_loc);
- return parse_anonymous_delegate (parent);
- }
+ DataType parse_type_with_parent (bool owned_by_default, bool can_weak_ref, Symbol? parent) throws
ParseError {
+ return parse_type(owned_by_default, can_weak_ref, false, parent);
}
- DataType parse_type2 (bool owned_by_default, bool can_weak_ref, bool require_unowned = false) throws
ParseError {
+ DataType parse_type (bool owned_by_default, bool can_weak_ref, bool require_unowned = false, Symbol?
parent=null) throws ParseError {
var begin = get_location ();
+ // TODO: Can anonymous delegates be unowned or weak?
+ if (accept (TokenType.DELEGATE)) {
+ rollback (begin);
+ return parse_anonymous_delegate (parent);
+ } else {
+ rollback (begin);
+ }
+
bool is_dynamic = accept (TokenType.DYNAMIC);
bool value_owned = owned_by_default;
@@ -3554,13 +3554,13 @@ public class Vala.Parser : CodeVisitor {
DataType type;
if (direction == ParameterDirection.IN) {
// in parameters are unowned by default
- type = parse_type (false, false, false, parent);
+ type = parse_type_with_parent (false, false, parent);
} else if (direction == ParameterDirection.REF) {
// ref parameters own the value by default
- type = parse_type (true, true, false, parent);
+ type = parse_type_with_parent (true, true, parent);
} else {
// out parameters own the value by default
- type = parse_type (true, false, false, parent);
+ type = parse_type_with_parent (true, false, parent);
}
string id = parse_identifier ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]