Skip Menu |
Report information
Id: 128815
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: vlmarek [at] volny.cz
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Make nativecall CPPStruct accept unmapped attributes.
Download (untitled) / with headers
text/plain 2.2k
class A is repr<CPPStruct>{ has $x; } I don't want $x mapped to C++ object attribute, I want it to be only part of it's perl 6 representation. I was thinking about adding a trait, something like. multi sub trait_mod:<is>(Attribute $r, :$native-private!) is export(:DEFAULT){} class A is repr<CPPStruct>{ has $x is native-private; } But I'm not enough skilled to implement it :) I was not able to find in CPPStruct.c how to detect that attribute has given trait. So I have tried to disable the warnings diff --git a/src/6model/reprs/CPPStruct.c b/src/6model/reprs/CPPStruct.c index f987734..5c0d6a5 100644 --- a/src/6model/reprs/CPPStruct.c +++ b/src/6model/reprs/CPPStruct.c @@ -235,8 +235,8 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in repr_data->member_types[i] = type; } else { - MVM_exception_throw_adhoc(tc, - "CPPStruct representation only handles int, num, CArray, CPointer, CStruct, CPPStruct and CUnion"); +// MVM_exception_throw_adhoc(tc, +// "CPPStruct representation only handles int, num, CArray, CPointer, CStruct, CPPStruct and CUnion"); } } else { @@ -393,8 +393,8 @@ static void get_attribute(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, MVMint32 real_slot = repr_data->attribute_locations[slot] >> MVM_CPPSTRUCT_ATTR_SHIFT; if (type == MVM_CPPSTRUCT_ATTR_IN_STRUCT) { - MVM_exception_throw_adhoc(tc, - "CPPStruct can't perform boxed get on flattened attributes yet"); +// MVM_exception_throw_adhoc(tc, +// "CPPStruct can't perform boxed get on flattened attributes yet"); } else { MVMObject *typeobj = repr_data->member_types[slot]; That at first seems to work: class A is repr<CPPStruct>{ has $x; method m() { $x //= do { my $s = Supplier.new; $s.Supply; } } } my $x=A.new(); say $x.m(); But now my method does not return Supply.new, but rather A.new; If I replace 'has $x' by 'my $x', it returns what I would expect - Supply.new And I got stuck :) Thank you __ Vlad
Also if the class A is not repr<CPPStruct>, $x.m() returns Supply.new.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org