-
-
Notifications
You must be signed in to change notification settings - Fork 74
Process @{namespace}::EXPORT correctly
#2896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
blindpirate
wants to merge
3
commits into
Camelcade:master
Choose a base branch
from
blindpirate:fix-2494
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package Opcode 1.64; | ||
|
|
||
| use strict; | ||
|
|
||
| use Carp; | ||
| use Exporter 'import'; | ||
| use XSLoader; | ||
|
|
||
| sub opset (;@); | ||
| sub opset_to_hex ($); | ||
| sub opdump (;$); | ||
| use subs our @EXPORT_OK = qw( | ||
| opset opset_to_hex opdump | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| use strict; use warnings; | ||
| package boolean; | ||
| our $VERSION = '0.46'; | ||
|
|
||
| my ($true, $false); | ||
|
|
||
| use overload | ||
| '""' => sub { ${$_[0]} }, | ||
| '!' => sub { ${$_[0]} ? $false : $true }, | ||
| fallback => 1; | ||
|
|
||
| use base 'Exporter'; | ||
| @boolean::EXPORT = qw(true false boolean); | ||
| @boolean::EXPORT_OK = qw(isTrue isFalse isBoolean); | ||
| %boolean::EXPORT_TAGS = ( | ||
| all => [@boolean::EXPORT, @boolean::EXPORT_OK], | ||
| test => [qw(isTrue isFalse isBoolean)], | ||
| ); | ||
|
|
||
| sub import { | ||
| my @options = grep $_ ne '-truth', @_; | ||
| $_[0]->truth if @options != @_; | ||
| @_ = @options; | ||
| goto &Exporter::import; | ||
| } | ||
|
|
||
| my ($true_val, $false_val, $bool_vals); | ||
|
|
||
| BEGIN { | ||
| my $t = 1; | ||
| my $f = 0; | ||
| $true = do {bless \$t, 'boolean'}; | ||
| $false = do {bless \$f, 'boolean'}; | ||
|
|
||
| $true_val = overload::StrVal($true); | ||
| $false_val = overload::StrVal($false); | ||
| $bool_vals = {$true_val => 1, $false_val => 1}; | ||
| } | ||
|
|
||
| # refaddrs change on thread spawn, so CLONE fixes them up | ||
| sub CLONE { | ||
| $true_val = overload::StrVal($true); | ||
| $false_val = overload::StrVal($false); | ||
| $bool_vals = {$true_val => 1, $false_val => 1}; | ||
| } | ||
|
|
||
| sub true() { $true } | ||
| sub false() { $false } | ||
| sub boolean($) { | ||
| die "Not enough arguments for boolean::boolean" if scalar(@_) == 0; | ||
| die "Too many arguments for boolean::boolean" if scalar(@_) > 1; | ||
| return not(defined $_[0]) ? false : | ||
| "$_[0]" ? $true : $false; | ||
| } | ||
| sub isTrue($) { | ||
| not(defined $_[0]) ? false : | ||
| (overload::StrVal($_[0]) eq $true_val) ? true : false; | ||
| } | ||
| sub isFalse($) { | ||
| not(defined $_[0]) ? false : | ||
| (overload::StrVal($_[0]) eq $false_val) ? true : false; | ||
| } | ||
| sub isBoolean($) { | ||
| not(defined $_[0]) ? false : | ||
| (exists $bool_vals->{overload::StrVal($_[0])}) ? true : false; | ||
| } | ||
|
|
||
| sub truth { | ||
| die "-truth not supported on Perl 5.22 or later" if $] >= 5.021005; | ||
| # enable modifying true and false | ||
| &Internals::SvREADONLY( \ !!0, 0); | ||
| &Internals::SvREADONLY( \ !!1, 0); | ||
| # turn perl internal booleans into blessed booleans: | ||
| ${ \ !!0 } = $false; | ||
| ${ \ !!1 } = $true; | ||
| # make true and false read-only again | ||
| &Internals::SvREADONLY( \ !!0, 1); | ||
| &Internals::SvREADONLY( \ !!1, 1); | ||
| } | ||
|
|
||
| sub TO_JSON { ${$_[0]} ? \1 : \0 } | ||
|
|
||
| 1; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.