Inline???? - PowerPoint PPT Presentation

About This Presentation
Title:

Inline????

Description:

The Inline module allows you to put source code from other ... Inline::Octave. Inline::Python. Inline::Ruby. Inline::Slang. Inline::SMITH. Inline::TT ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 18
Provided by: ikebeto
Learn more at: http://shibuya.pm.org
Category:
Tags: google | inline | octave | search

less

Transcript and Presenter's Notes

Title: Inline????


1
Inline????
  • Tomohiro IKEBE ltikebe_at_shebang.jpgt
  • EDGE Co., ltd.
  • Shibuya.pm Techinical Talks

2
??
  • Inline ??
  • ??Inline???
  • InlineC
  • InlineJava
  • InlineRuby
  • ILSM ???
  • ???

3
Inline ??
DESCRIPTION
The Inline module allows you to put source code
from other programming languages directly
"inline" in a Perl script or module. The code is
automatically compiled as needed, and then loaded
for immediate access from Perl.
Perl ???????? ?? ????????????????? ?????????????
???????????????????????????????Perl???????????? C,
C ??? ILSM (Inline Language Support Module)
???????????????????????????
4
ILSM
  • InlineASM
  • InlineAwk
  • InlineBC
  • InlineBasic
  • InlineBefunge
  • InlineC
  • InlineCPP
  • InlineGuile
  • InlineJava
  • InlineOctave
  • InlinePython
  • InlineRuby
  • InlineSlang
  • InlineSMITH
  • InlineTT
  • InlineTcl
  • InlineWebChat
  • AcmeInlinePERL

5
Inline ??
  • XSPerl ??????????????????????????????
  • SWIG (http//www.swig.org/)Perl
    ?????????????????????????

6
??Inline???
  • ????????????????
  • ???????????
  • XS?SWIG????????
  • ???????????????

7
InlineC
  • ????????????????????
  • time ./ghttp.pl
  • 3.440u 1.140s 006.23 73.5 00k 6212io
    0pf0w
  • time ./ghttp.pl
  • 0.190u 0.060s 000.33 75.7 00k 01io 0pf0w
  • ??????????? _Inline ?????????????????
  • ?????????????
  • Perl ltgt C ????????
  • int
  • long
  • double
  • char
  • void
  • SV

8
InlineC
  • ???????????use Inline C gtltltC_SOURCE
  • void say_hello () printf(Hello World!\n)
  • C_SOURCE
  • say_hello()
  • __DATA__ ???
  • use Inline C gt DATA
  • say_hello()
  • __DATA__
  • __C__
  • void say_hello () printf(Hello World!\n)

9
??????????
????????????? use strict use Inline C gt Config
gt LIBS gt '-L/sw/lib -lghttp', INC gt
'-I/sw/include' print get('http//www.google.co.
jp/') __END__ __C__ include ltghttp.hgt SV
get(SV uri) SV buffer
malloc(sizeof(char) 1024 10)
ghttp_request request buffer NEWSV(0,0)
request ghttp_request_new()
ghttp_set_uri(request, SvPV(uri, PL_na))
ghttp_set_header(request, http_hdr_Connection,
"close") ghttp_prepare(request)
ghttp_process(request) sv_catpv(buffer,
ghttp_get_body(request)) ghttp_request_destroy
(request) return buffer
10
InlineJava
  • Java ?????Perl?????
  • ?? Java ??????
  • ?????????? RPC
  • JNI ???native ????????

11
Velocity ??????
Jakarta Project ? Velocity ? Perl ??? Web
????????? ?????????????????? ??????????????? use
strict use Inline ( Java gt DATA, DATA
?????????? CLASSPATH gt /path/to/velocity-1.3.jar
, CLASSPATH ??? DIRECTORY gt /tmp, httpd
???????????? SHARED_JVM gt 1, JVM ????? STUDY
gt java.util.HashMap, HashMap ????? ) use
CGI InlineJavarelease_JVM()
12
Velocity ??????
my q CGI-gtnew print q-gtheader my v
VelocityWrapper-gtnew my map
javautilHashMap-gtnew() STUDY! map-gtput(_,
q-gtparam(_)) for q-gtparam
????? v-gtset("request", map) print
v-gtprocess("test.vm") __DATA__ __Java__ .
13
Velocity ??????
import java.io.StringWriter import
org.apache.velocity.app.Velocity import
org.apache.velocity.VelocityContext import
java.util.Properties class VelocityWrapper
VelocityContext context null public
VelocityWrapper() try Velocity.init(new
Properties()) catch(Exception ex)
ex.printStackTrace() context new
VelocityContext() public void
set(String key, Object obj) context.put(key,
obj) public String process(String
filename) throws Exception StringWriter
w new StringWriter()
Velocity.mergeTemplate(filename, context, w
) return w.toString()
14
InlineRuby
  • Ruby ?????Perl???????
  • ???????????
  • rb_eval ??

15
HTMLERuby
http//search.cpan.org/dist/HTML-ERuby/ Eruby ?
Perl ???? Eruby ???? Perl ??????Ruby??????????
rb_eval ?????? Perl ? Web ????????????????????
my vars (_at_var gt foo, Ruby instance
variable ARRAY_REF gt qw(a b c),
Ruby constant hash_ref gt foo gt
bar, bar gt baz) my compiler
HTMLERuby-gtnew print compiler-gtcompile(filen
ame gt ./foo.rhtml,
vars gt \vars)
16
HTMLERuby
Ruby -gt Perl ???????????????????????? Perl ?
HASH_REF, ARRAY_REF ?????? Ruby
???????? ?????? ????DataDumper ? Dump ?? Ruby ?
eval ??????????? ??????? In Perl. my hash (a
gt foo, b gt bar) my str Dumper \hash
str s/\VAR1// In Ruby hash eval str
17
???
  • ????????? C, C
  • Java ??????????
  • ????????????????
  • ?? InlinePHP ????
Write a Comment
User Comments (0)
About PowerShow.com