Skip Menu |

This queue is for tickets about the JavaScript-SpiderMonkey CPAN distribution.

Report information
The Basics
Id: 17629
Status: open
Priority: 0/
Queue: JavaScript-SpiderMonkey

People
Owner: Nobody in particular
Requestors: whatever [...] davidnicol.com
Cc:
AdminCc:

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



Subject: aliasing does not work as documented
The documentation claims that the object_by_path method can create an alias: $js->object_by_path($path, [$newobj]) Get a pointer to an object with the path specified. Create it if it's not there yet. If $newobj is provided, the ref is used to bind the exist- ing object to the name in $path. When I ran: use JavaScript::SpiderMonkey; my $js = new JavaScript::SpiderMonkey; $js->init; $js->property_by_path('a.b.c.d.e.f',"ghijkl"); my $abcd = $js->object_by_path('a.b.c.d'); my $abcd2 = $js->object_by_path('abcd',$abcd); print "Expecting ghijkl: [",$js->property_get('abcd.e.f'),"]\n"; __END__ I get: perl -w alias_test.pl Cannot find object abcd.e via SpiderMonkey at /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/JavaScript/SpiderMonkey.pm line 506 Expecting ghijkl: []
Subject: alias_test.pl
use JavaScript::SpiderMonkey; my $js = new JavaScript::SpiderMonkey; $js->init; $js->property_by_path('a.b.c.d.e.f',"ghijkl"); my $abcd = $js->object_by_path('a.b.c.d'); my $abcd2 = $js->object_by_path('abcd',$abcd); print "Expecting ghijkl: [",$js->property_get('abcd.e.f'),"]\n"; __END__
From: benkasminbullock [...] gmail.com
On Mon Feb 13 21:24:10 2006, guest wrote: Show quoted text
> Cannot find object abcd.e via SpiderMonkey at > /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread- > multi/JavaScript/SpiderMonkey.pm > line 506 > Expecting ghijkl: []
This is due to the regular expression my($path, $property) = ($string =~ /(.*)\.([^\.]+)$/); on line 504 of SpiderMonkey.pm. It only accepts one ending. So the following works OK: use JavaScript::SpiderMonkey; my $js = JavaScript::SpiderMonkey->new (); $js->init; $js->property_by_path('a.b.c.d.e',"ghijkl"); print "\$js->object_by_path('a.b.c.d');\n"; my $abcd = $js->object_by_path('a.b.c.d'); print "Expecting ghijkl: [",$js->property_get('a.b.c.d.e'),"]\n"; print "\$js->object_by_path('abcd',\$abcd);\n"; my $abcd2 = $js->object_by_path('abcd',$abcd); print "Expecting ghijkl: [",$js->property_get('abcd.e'),"]\n"; Gives me: $ ./alias_test.pl $js->object_by_path('a.b.c.d'); Expecting ghijkl: [ghijkl] $js->object_by_path('abcd',$abcd); Expecting ghijkl: [ghijkl] But I'm not sure how to fix this, or whether it really is a bug or not.