SMOP

 view release on metacpan or  search on metacpan

lib/SMOP/Interoperability.pm  view on Meta::CPAN

package SMOP;
BEGIN {
  $SMOP::VERSION = '0.6';
}

use 5.010000;
use strict;
use warnings;
use Carp;
use Coro;
our $main_coro = new Coro::State;


require XSLoader;
XSLoader::load('SMOP::Interoperability');

sub coro_from_eval {
    my $code = shift;
    Coro::State->new(sub {
       my $ret = eval $code;
       die if $@;
       SMOP::Interoperability::goto_back($ret);
    });
}
sub coro_from_methodcall {
    my $invocant = shift;
    my $method = shift;
    my $args = \@_;
    Coro::State->new(sub {
        my $ret = $invocant->$method(@$args);
        SMOP::Interoperability::goto_back($ret);
    });
}
sub coro_from_subcall {
    my $sub = shift;
    my $args = \@_;
    Coro::State->new(sub {
        my $ret = $sub->(@$args);
        SMOP::Interoperability::goto_back($ret);
    });
}

package SMOP::Object;
BEGIN {
  $SMOP::Object::VERSION = '0.6';
}
use overload
#'fallback' =>0,
    'bool' => sub {
        SMOP::NATIVE::bool::fetch($_[0]->true);
    },
    '""' => sub {
         SMOP::NATIVE::idconst::fetch($_[0]);
    },
    '0+' => sub {
         SMOP::NATIVE::int::fetch($_[0]);
    },
    '.' => sub {
        "$_[0]" . "$_[1]";
    },
    'eq' => sub {
        "$_[0]" eq "$_[1]";
    },
    'ne' => sub {
        "$_[0]" eq "$_[1]";
    }
    ;
sub DESTROY {
    #print "DESTROY :)\n";
}
1;
__END__

=head1 NAME

SMOP - Perl extension for SMOP



=head1 DESCRIPTION

This module provides access to the SMOP runtime from Perl 5.

=head1 SEE ALSO

http://www.perlfoundation.org/perl6/index.cgi?smop

=head1 AUTHOR

Daniel Ruoso, E<lt>daniel at ruoso.com<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2008 by Daniel Ruoso and others



( run in 0.666 second using v1.01-cache-2.11-cpan-df04353d9ac )