• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
5分で始める XS - tsukuba.xs#1
 

5分で始める XS - tsukuba.xs#1

on

  • 952 views

 

Statistics

Views

Total Views
952
Views on SlideShare
952
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    5分で始める XS - tsukuba.xs#1 5分で始める XS - tsukuba.xs#1 Presentation Transcript

    • 5 XS Tsukuba.xs Beer Talks #1 xaicron 2010 7 24
    • • @xaicron • http://blog.livedoor.jp/xaicron/ • XS 2010 7 24
    • 2010 7 24
    • 2010 7 24
    • • • PL_Cehck Hack • Perl • /* Polyglot */ • VM 2010 7 24
    • 2010 7 24
    • XS 2010 7 24
    • C 2010 7 24
    • • make, gcc C • Module::Install::XSUtil 2010 7 24
    • $ h2xs -A -b 5.8.1 -n Foo::Bar $ cd Foo-Bar $ tree . |-- Bar.xs |-- Changes |-- MANIFEST |-- Makefile.PL |-- README |-- lib | `-- Foo | `-- Bar.pm |-- ppport.h `-- t `-- Foo-Bar.t 2010 7 24
    • make && make test $ perl Makefile.PL $ make && make test 2010 7 24
    • 2010 7 24
    • 2010 7 24
    • Makefile.PL use inc::Module::Install; use Module::Install::XSUtil; name 'Foo-Bar'; all_from 'lib/Foo/Bar.pm'; use_ppport 3.19; cc_warnings; cc_src_paths qw(xs); tests 't/*.t'; test_requires 'Test::More'; auto_include; WriteAll; 2010 7 24
    • $ rm ppport.h $ mkdir xs $ mv Bar.xs xs $ tree . |-- Changes |-- MANIFEST |-- Makefile.PL |-- README |-- lib | `-- Foo | `-- Bar.pm |-- t | `-- Foo-Bar.t `-- xs `-- Bar.xs 2010 7 24
    • xs/Bar.xs #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = Foo::Bar PACKAGE = Foo::Bar PROTOTYPES: DISABLE int sum(int x, int y) CODE: RETVAL = x + y; OUTPUT: RETVAL 2010 7 24
    • $ perl Makefile.PL $ make $ perl -Mblib -MFoo::Bar -le “print Foo::Bar::sum(1 ,2)” 3 2010 7 24
    • 2010 7 24
    • XS 2010 7 24
    • Foo::Bar / Foo::Baz xs 2010 7 24
    • $ h2xs -A -b 5.8.1 -n Foo::XS 2010 7 24
    • • xs/Bar.xs, xs/Baz.xs • foo.h • xs/XS.xs • lib/Foo/Bar.pm, lib/Foo/Baz/pm 2010 7 24
    • xs/Bar.xs #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = Foo::Bar PACKAGE = Foo::Bar PROTOTYPES: DISABLE int sum(int x, int y) CODE: RETVAL = x + y; OUTPUT: RETVAL 2010 7 24
    • xs/Baz.xs #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = Foo::Baz PACKAGE = Foo::Baz PROTOTYPES: DISABLE int double(int x) CODE: RETVAL = x * 2; OUTPUT: RETVAL 2010 7 24
    • foo.h 2010 7 24
    • xs/XS.xs #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "foo.h" MODULE = Foo::XS BOOT: FOO_CALL_BOOT(Foo__Bar); FOO_CALL_BOOT(Foo__Baz); 2010 7 24
    • Foo/Bar.pm Foo/Baz.pm package Foo::Bar; # or Baz use strict; use warnings; use Foo::XS; our $VERSION = ‘0.01’; 1; 2010 7 24
    • $ perl Makefile.pl $ make test $ perl -Mblib -MFoo::Bar -le “print Foo::Bar::sum(1,2)” 3 $ perl -Mblib -MFoo::Baz -le “print Foo::Baz::double(1)” 2 2010 7 24
    • 2010 7 24
    • • C XS • SV typemap 2010 7 24