Skip to content

Commit 2c89ff1

Browse files
committed
Fix .type and disable not-really-right accessor generation for now (regresses a test, but the test is bogus too).
1 parent 3dcf683 commit 2c89ff1

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

src/how/NQPAttribute.pm

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
knowhow NQPAttribute {
22
has $!name;
33
has $!type;
4+
has $!has_type;
45
has $!box_target;
56

6-
method new(:$name!, :$type, :$box_target) {
7+
method new(:$name!, :$box_target, *%extra) {
78
my $attr := pir::repr_instance_of__PP(self);
8-
$attr.BUILD(:name($name), :type($type), :box_target($box_target));
9+
$attr.BUILD(:name($name), |%extra, :box_target($box_target),
10+
:has_type(pir::exists(%extra, 'type')));
911
$attr
1012
}
1113

12-
method BUILD(:$name, :$type, :$box_target) {
14+
method BUILD(:$name, :$type, :$has_type, :$box_target) {
1315
$!name := $name;
1416
$!type := $type;
17+
$!has_type := $has_type;
1518
$!box_target := $box_target;
1619
}
1720

@@ -20,7 +23,7 @@ knowhow NQPAttribute {
2023
}
2124

2225
method type() {
23-
$!type // pir::null__P()
26+
$!has_type ?? $!type !! pir::null__P()
2427
}
2528

2629
method has_accessor() {
@@ -36,29 +39,29 @@ knowhow NQPAttribute {
3639
}
3740

3841
method compose($obj) {
39-
my $long_name := ~$!name;
40-
if self.has_mutator {
41-
my $method := pir::substr($long_name, 1);
42-
unless has_method($obj, $method, 0) {
43-
$obj.HOW.add_method($obj.WHAT, $method, method ($value?) {
44-
pir::setattribute__vppsp(self, $obj.WHAT, $long_name, $value)
45-
if pir::defined($value);
46-
47-
pir::getattribute__ppps(self, $obj.WHAT, $long_name);
48-
}
49-
);
50-
}
51-
}
52-
else {
53-
my $method := pir::substr($long_name, 2);
54-
unless has_method($obj, $method, 0) {
55-
$obj.HOW.add_method($obj, $method,
56-
method () {
57-
pir::getattribute__PPPs(self, $obj.WHAT, $long_name);
58-
}
59-
);
60-
}
61-
}
42+
#my $long_name := ~$!name;
43+
#if self.has_mutator {
44+
# my $method := pir::substr($long_name, 1);
45+
# unless has_method($obj, $method, 0) {
46+
# $obj.HOW.add_method($obj.WHAT, $method, method ($value?) {
47+
# pir::setattribute__vppsp(self, $obj.WHAT, $long_name, $value)
48+
# if pir::defined($value);
49+
# pir::getattribute__ppps(self, $obj.WHAT, $long_name);
50+
# }
51+
# );
52+
# }
53+
#}
54+
#else {
55+
# my $method := pir::substr($long_name, 2);
56+
# unless has_method($obj, $method, 0) {
57+
# $obj.HOW.add_method($obj, $method,
58+
# method () {
59+
# pir::getattribute__PPPs(self, $obj.WHAT, $long_name);
60+
# }
61+
# );
62+
# }
63+
#}
64+
$obj
6265
}
6366

6467
# Hack to check twigil.

0 commit comments

Comments
 (0)