Created
June 5, 2011 14:08
-
-
Save aktowns/1008985 to your computer and use it in GitHub Desktop.
INCEPTION
This file contains 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
;;; Lua running in Ruby running in Python running in Lisp by [email protected] | |
;;; TODO: | |
;;; Lua | |
;;; Javascript | |
;;; ??? | |
;;; OUTPUT: | |
;;; ~| newlisp inception.lisp | |
;;; [Entered lisp state] | |
;;; [Entered python state] | |
;;; [Entered ruby state] | |
;;; [Entered lua state] | |
;;; Hello, im lua running in ruby which is running in python which is running in lisp. | |
;;; [Leaving lua state] | |
;;; [Leaving ruby state] | |
;;; [Leaving python state] | |
;;; [Leaving lisp state] | |
;;; ~| | |
(println "[Entered lisp state]") | |
(setq python "libpython2.6.dylib") | |
(setq py-initialize (import python "Py_Initialize")) | |
(setq py-run-simplestring (import python "PyRun_SimpleString")) | |
(setq py-finalize (import python "Py_Finalize")) | |
(setq py-content (join '( | |
"print '[Entered python state]'" | |
"import sys" | |
"from ctypes import *" | |
"ruby = cdll.LoadLibrary('libruby.dylib')" | |
"ruby.ruby_init()" | |
"ruby.ruby_init_loadpath()" | |
"ruby.rb_eval_string('''" | |
"puts '[Entered ruby state]'" | |
"require 'rubygems'" | |
"require 'ffi'" | |
"module Lua" | |
" extend FFI::Library" | |
" ffi_lib 'lua'" | |
" attach_function :luaL_newstate, [], :pointer" | |
" attach_function :luaL_openlibs, [ :pointer ], :void" | |
" attach_function :luaL_loadstring, [ :pointer , :string], :void" | |
" attach_function :lua_pcall, [ :pointer, :int, :int, :int ], :int" | |
"end" | |
"l = Lua.luaL_newstate" | |
"Lua.luaL_openlibs(l)" | |
"Lua.luaL_loadstring l, <<-LUACODE" | |
"print '[Entered lua state]'" | |
"print 'Hello, im lua running in ruby which is running in python which is running in lisp.'" | |
"print '[Leaving lua state]'" | |
"LUACODE" | |
"Lua.lua_pcall(l, 0, -1, 0)" | |
"puts '[Leaving ruby state]'" | |
"''')" | |
"ruby.ruby_finalize()" | |
"print '[Leaving python state]'") "\n")) | |
(py-initialize) | |
(py-run-simplestring py-content) | |
(py-finalize) | |
(println "[Leaving lisp state]") | |
(exit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment