Skip Menu |

This queue is for tickets about the Inline-CPP CPAN distribution.

Report information
The Basics
Id: 62024
Status: stalled
Worked: 2.5 hours (150 min)
Priority: 0/
Queue: Inline-CPP

People
Owner: davido [...] cpan.org
Requestors: intangir [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: member arrays in classes derail inline CPP
Date: Sat, 9 Oct 2010 23:48:04 -0500
To: bug-Inline-CPP [...] rt.cpan.org
From: Intangir <intangir [...] gmail.com>
if you include an array as a member data in a class whatever parsing is involved in Inline CPP messes up and fails to create compilable code it seems to not recognize member data arrays with the grammar definitions im using Inline-CPP-0.27 here is an example of the problem ----------------------------------------------- #!/usr/bin/perl use strict; use warnings; my $obj = new Foo; $obj->set_data(5); use Inline CPP => <<'END'; class Foo { public: Foo(); ~Foo(); int get_data() { return data; } void set_data(int a) { data = a; } private: int data; int thiscauseserror[10]; }; Foo::Foo() { cout << "creating a Foo()" << endl; } Foo::~Foo() { cout << "deleting a Foo()" << endl; } END ------------------------------------------------------ commenting out the line with 'thiscauseserror' makes it run again i got help from tc604 in #perl, he found a fix to the grammar file that will fix it first here is the code as it was: ./grammar/grammar.pm: line 274: member_def: anytype <leftop: var ',' var> ';' { my @retval; for my $def (@{$item[2]}) { my $type = join '', $item[1], @{$def->[0]}; my $name = $def->[1]; # print "member found: type=$type, name=$name\n"; push @retval, { name => $name, type => $type }; } \@retval; } var: star(s?) IDENTIFIER '=' expr { [@item[1,2]] } | star(s?) IDENTIFIER { [@item[1,2]] } i added in this line near the bottom: | star(s?) IDENTIFIER '[' expr ']' { [@item[1,2]] } see it here below: ---------------------------------------------------------------------- member_def: anytype <leftop: var ',' var> ';' { my @retval; for my $def (@{$item[2]}) { my $type = join '', $item[1], @{$def->[0]}; my $name = $def->[1]; # print "member found: type=$type, name=$name\n"; push @retval, { name => $name, type => $type }; } \@retval; } var: star(s?) IDENTIFIER '=' expr { [@item[1,2]] } | star(s?) IDENTIFIER '[' expr ']' { [@item[1,2]] } | star(s?) IDENTIFIER { [@item[1,2]] } --------------------------------------------------------------- i added that, reinstalled it, reran my script and it works! :)
Subject: Re: [rt.cpan.org #62024] AutoReply: member arrays in classes derail inline CPP
Date: Sun, 10 Oct 2010 00:07:20 -0500
To: bug-Inline-CPP [...] rt.cpan.org
From: Intangir <intangir [...] gmail.com>
the suggested fix doesnt handle multi dimensional arrays.. guess a more robust fix is needed i half-assed a second test for 2 dimentional arrays in mine for now.. but id imagine thats to sloppy for the whole world ;)
Single dimensional member arrays have been added to Inline::CPP, along with a test to verify operability. This fix will be available in Inline::CPP v0.33_008 (Developer's release), and eventually v0.34 stable release. Multi-dimensional member arrays will be addressed when I figure out the grammar rules for them. For immediate gratification fork the current dev branch of the Inline-CPP repo for daoswald on github.
Single dimensional member arrays have been added to Inline::CPP, along with a test to verify operability. This fix is available in v0.34 and beyond. If someone understands how to adapt the Parse::RecDescent based grammar to work for multi-dimensional member arrays please submit a patch, or follow up on inline@perl.org. This issue only affects multi-dimensional arrays as class member data. STL data-types are not affected. Since multi-dimensional arrays remain broken as member (despite single-dimensional member arrays being fixed) I'm marking the ticket as 'stalled' until we find a solution that works.