# gratuitious abuse of the swanky Inline::* modules. # # (the perl code is at the end :-) # # here's some tasty raw x86 assembler code # no muss, no fuss, no xs macros use Inline ASM => <<'END_ASM', PROTOTYPES => {JAxH => 'void(char*)'}; .globl JAxH .text # prototype: void JAxH(char *x); JAxH: pushl %ebp movl %esp,%ebp movl 8(%ebp),%eax pushl %eax pushl $jaxhstr call printf movl %ebp,%esp popl %ebp ret .data jaxhstr: .string "This text comes from an assembler function. %s\n" END_ASM # and now some java use Inline Java => <<'END_OF_JAVA_CODE'; class alu { public alu(String x){ System.out.println("Java Says " + x); } } END_OF_JAVA_CODE # and some C++ - whee! use Inline CPP => <<'END_OF_CPP'; int add(int x, int y) { return x + y; } int subtract(int x, int y) { return x - y; } END_OF_CPP # some python with that sir?? use Inline Python => <<'END_OF_PYTHON_CODE'; def python_add(x,y): return x + y def python_subtract(x,y): return x - y END_OF_PYTHON_CODE # now back to perl! - all the bindings get generated automagically print JAxH('Cool Eh?'); my $foo = new alu("BEEP!"); print "Adding 12 and 5 in C++: " . add(12,5),"\n"; print "Subtracting 9 from 20 in C++: " . subtract(20,9),"\n"; print "Adding 4 and 21 in python: " . python_add(4,21),"\n"; print "Subtracting 8 from 17 in python: " .python_subtract(17,8),"\n";