pax_global_header00006660000000000000000000000064120772320440014513gustar00rootroot0000000000000052 comment=7fff14e1eea1fc47380919ced94a0f0bac943804 lua-rings-1.3.0/000077500000000000000000000000001207723204400134155ustar00rootroot00000000000000lua-rings-1.3.0/Makefile000066400000000000000000000006551207723204400150630ustar00rootroot00000000000000# $Id: Makefile,v 1.6 2008/05/08 22:08:31 carregal Exp $ T= rings CONFIG= ./config include $(CONFIG) SRCS= src/rings.c OBJS= src/rings.o all: src/rings.so src/rings.so: $(OBJS) export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) $(CFLAGS) $(LIB_OPTION) -o src/rings.so $(OBJS) install: mkdir -p $(LUA_LIBDIR) cp src/rings.so $(LUA_LIBDIR) mkdir -p $(LUA_DIR) cp src/stable.lua $(LUA_DIR) clean: rm -f src/rings.so $(OBJS) lua-rings-1.3.0/Makefile.win000066400000000000000000000012651207723204400156550ustar00rootroot00000000000000# $Id: Makefile.win,v 1.13 2008/02/15 21:33:02 carregal Exp $ include config.win SRCS= src\rings.c OBJS= src\rings.obj .c.obj: $(CC) /c /Fo$@ $(CFLAGS) $< all: src\rings.dll src\rings.dll: src\rings.obj link /dll /def:src\rings.def /out:src\rings.dll "$(LUA_LIB)" src\rings.obj IF EXIST src\rings.dll.manifest mt -manifest src\rings.dll.manifest -outputresource:src\rings.dll;2 install: IF NOT EXIST "$(LUA_LIBDIR)" mkdir "$(LUA_LIBDIR)" copy src\rings.dll "$(LUA_LIBDIR)" IF NOT EXIST "$(LUA_DIR)" mkdir "$(LUA_DIR)" copy src\stable.lua "$(LUA_DIR)" clean: del src\rings.dll src\rings.obj src\rings.lib src\rings.exp IF EXIST src\rings.dll.manifest del src\rings.dll.manifest lua-rings-1.3.0/README000066400000000000000000000025611207723204400143010ustar00rootroot00000000000000Rings - Multiple Lua States (http://www.keplerproject.org/rings/) Overview Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. Rings is free software and uses the same license as Lua 5.1. Download Rings can be downloaded in source code from its Github page: http://github.com/keplerproject/rings Installation If you are using LuaRocks just type luarocks install rings If you prefer to install manually, the compiled binary file should be copied to a directory in your C path. The file stable.lua should be copied to a directory in your Lua path. History Version 1.3.0 [30/Jan/2013] * Support for Lua 5.2 Version 1.2.3 [20/Oct/2009] * Fixing an old reference to "arg" instead of {...} - Reported by MFarm Version 1.2.2 [30/Jun/2008] * Fixed a stack handling issue (bug report and patch by Shmuel Zeigerman) Credits Rings was designed by Roberto Ierusalimschy and Tomas Guisasola as part of the Kepler Project. The implementation was coded by Tomas Guisasola. Rings development was sponsored by Fabrica Digital. For more information please contact us (info at keplerproject dot org). Comments are welcome! You can also reach other Kepler developers and users on the Kepler Project mailing list. lua-rings-1.3.0/config000066400000000000000000000013231207723204400146040ustar00rootroot00000000000000# Installation directories # Default prefix PREFIX = /usr/local # System's libraries directory (where binary libraries are installed) LUA_LIBDIR= $(PREFIX)/lib/lua/5.1 # System's lua directory (where Lua libraries are installed) LUA_DIR= $(PREFIX)/share/lua/5.1 # Lua includes directory LUA_INC= $(PREFIX)/include # OS dependent LIB_OPTION= -shared #for Linux #LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X LIBNAME= $T.so.$V # Compilation directives WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -Wpointer-arith -pedantic INCS= -I$(LUA_INC) CFLAGS= $(WARN) $(INCS) CC= gcc # $Id: config,v 1.7 2007/10/29 22:51:39 carregal Exp $ lua-rings-1.3.0/config.win000066400000000000000000000010301207723204400153730ustar00rootroot00000000000000# Installation directories # Lua binary libraries directory (where Lua binary libraries will be installed) # This is the LUA_CPATH LUA_LIBDIR= c:\lua5.1 # Lua directory (where Lua source libraries will be installed) # This is the LUA_PATH LUA_DIR= c:\lua5.1\lua # Lua includes directory LUA_INC= c:\lua5.1\include # Lua library LUA_LIB= c:\lua5.1\lua5.1.lib # OS dependent LIBNAME= $T.dll # Compilation directives WARN= /O2 INCS= /I$(LUA_INC) CFLAGS= $(WARN) $(INCS) CC= cl # $Id: config.win,v 1.4 2007/05/18 19:53:06 carregal Exp $ lua-rings-1.3.0/configure000077500000000000000000000010301207723204400153160ustar00rootroot00000000000000#!/bin/sh if [ -f config.orig ]; then mv config.orig config fi echo "Trying to where you installed Lua..." if which lua; then lua_bin=`which lua` lua_bin_dir=`dirname $lua_bin` else lua_bin=`which lua51` lua_bin_dir=`dirname $lua_bin` fi lua_root=`dirname $lua_bin_dir` if [ $lua_root != "" ]; then echo "Lua is in $lua_root" echo "Changing config" sed -i.orig -e "s|/usr/local|$lua_root|" config echo "Now run 'make' and 'make install'" else echo "Lua not found, please install Lua (and put in your PATH)" fi lua-rings-1.3.0/doc/000077500000000000000000000000001207723204400141625ustar00rootroot00000000000000lua-rings-1.3.0/doc/us/000077500000000000000000000000001207723204400146115ustar00rootroot00000000000000lua-rings-1.3.0/doc/us/index.html000066400000000000000000000132021207723204400166040ustar00rootroot00000000000000 Rings: Multiple Lua States
Rings
Multiple Lua States

Overview

Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states.

Rings is free software and uses the same license as Lua 5.1.

Status

Rings version 1.3.0 is now available for download.

Download

Rings can be downloaded in source code from its Github page.

History

Version 1.3.0 [30/Jan/2013]
  • Support for Lua 5.2
Version 1.2.3 [20/Oct/2009]
  • Fixing an old reference to "arg" instead of {...} - Reported by MFarm
Version 1.2.2 [30/Jun/2008]
  • Fixed a stack handling issue (bug report and patch by Shmuel Zeigerman)
Version 1.2.1 [8/May/2008]
  • Fixed bug [#2074] - Rings uses the deprecated function luaL_openlib (patch by Ignacio Burgueño)
Version 1.2 [18/Feb/2008]
  • rings.new now takes an optional environment to be used by remotedostring. If the environment is nil, it defaults to _M or _G.
  • Fixed a bug with interaction of rings and coroutines, rings was assuming a 1:1 mapping between lua_States and rings master and slave states, which is not true when coroutines/threads are involved. (bug found by Ignacio Burgueño)
Version 1.1 [11/Jun/2007]
Adapted to work with Lua 5.1.
Version 1.0 [10/Mar/2006]
First public version, works with Lua 5.0.

Credits

Rings was designed by Roberto Ierusalimschy and Tomás Guisasola as part of the Kepler Project. The implementation was coded by Tomás Guisasola.

Rings development was sponsored by Fábrica Digital.

Contact us

For more information please contact us. Comments are welcome!

You can also reach other Kepler developers and users on the Kepler Project mailing list.

Valid XHTML 1.0!

$Id: index.html,v 1.17 2008/06/30 17:52:31 carregal Exp $

lua-rings-1.3.0/doc/us/license.html000066400000000000000000000111031207723204400171150ustar00rootroot00000000000000 Rings License
Rings
Multiple Lua States

License

Rings is free software: it can be used for both academic and commercial purposes at absolutely no cost. There are no royalties or GNU-like "copyleft" restrictions. Rings qualifies as Open Source software. Its licenses are compatible with GPL. Rings is not in the public domain and the Kepler Project keeps its copyright. The legal details are below.

The spirit of the license is that you are free to use Rings for any purpose at no cost without having to ask us. The only requirement is that if you do use Rings, then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.

The Rings library is designed and implemented by Roberto Ierusalimschy and Tomás Guisasola. The implementation is not derived from licensed software.


Copyright © 2006 Kepler Project.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Valid XHTML 1.0!

$Id: license.html,v 1.9 2008/02/15 20:45:51 carregal Exp $

lua-rings-1.3.0/doc/us/manual.html000066400000000000000000000202511207723204400167540ustar00rootroot00000000000000 Rings: Multiple Lua States
Rings
Multiple Lua States

Introduction

Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states.

Rings is free software and uses the same license as Lua 5.1.

Rings also offers Stable, a very simple API to manage a shared table at the master state.

Building

Rings works with Lua 5.1 only. In order to build it the language library and header files for the desired Lua version must be installed properly.

Rings comprises a single C source file. The distribution provides a Makefile prepared to compile the library and install it. The file config should be edited to suit the particularities of the target platform before running make. This file has some definitions like paths to the external libraries, compiler options and the like. One important definition is the Lua version, which is not obtained from the installed software.

Installation

If you are using LuaRocks, just type

luarocks install rings

If you prefer to install manually, the compiled binary file should be copied to a directory in your C path. The file stable.lua should be copied to a directory in your Lua path.

Reference

Master functions

Rings offers a single function which creates a new Lua state and returns an object representing it. The state which creates other states is called the master and the created ones are called slaves. The master can execute code in any of its slaves but each slave only has direct access to its master (or its own slaves).

All standard Lua libraries are opened automatically in a new state; other libraries have to be loaded explicitly.

The object representing a slave state has a method (dostring) which can execute Lua code in the corresponding state. This method can receive arguments (only numbers, strings, booleans and userdata, which are converted to lightuserdata) and always returns a boolean indicating whether the code executed correctly or not, followed by eventual return values or an error message.

rings.new (env)
Returns a newly created Lua state. Takes an optional environment to be used by remotedostring. If the environment is nil, it defaults to the master_M or _G tables.
state:close ()
Closes the state.
state:dostring (string, ...)
Executes a string in the slave state. The arguments could be accessed exactly as in a vararg function. Valid types of arguments and return values are: number, string, boolean, nil and userdata (which are converted to lightuserdata).
Returns a boolean indicating the status of the operation, followed by the returned values or an error message in case of error.

Slave function

The following function is registered in the newly created slave state.

remotedostring (string, ...)
Executes a string in the master state. Behaves exactly as the method dostring except that it acts in the master state.

Stable

Stable is a simple API which provides a way for a slave state to store and retrieve data to and from its master state. This library is not opened automatically in a slave state.

stable.get (key)
Returns the value of a given key.
stable.set (key, value)
Stores a value associated to a key. Returns nothing.

Examples

The following sample shows how to execute code in another state passing arguments and returning values:

require"rings"
S = rings.new ()

data = { 12, 13, 14, }
print (S:dostring ([[
aux = {}
for i, v in ipairs ({...}) do
   table.insert (aux, 1, v)
end
return unpack (aux)]], unpack (data))) -- true, 14, 13, 12

S:close ()

The following example uses Stable to store a value in the master state:

require"rings"

local init_cmd = [[
require"stable"]]

local count_cmd = [[
count = stable.get"shared_counter" or 0
stable.set ("shared_counter", count + 1)
return count
]]

S = rings.new () -- new state
assert(S:dostring (init_cmd))
print (S:dostring (count_cmd)) -- true, 0
print (S:dostring (count_cmd)) -- true, 1
S:close ()

S = rings.new () -- another new state
assert (S:dostring (init_cmd))
print (S:dostring (count_cmd)) -- true, 2
S:close ()

Valid XHTML 1.0!

$Id: manual.html,v 1.17 2008/12/09 17:08:36 carregal Exp $

lua-rings-1.3.0/doc/us/rings.png000066400000000000000000000164301207723204400164450ustar00rootroot00000000000000PNG  IHDRL\ pHYsHHFk>IDATxy\׾g!Vh$.(eQPoҪV޾ھz֥ԂRRAE  ɼ?&!3Id7g9 AǁqtyZk8 p0`^+V9:@TxGGNcd)ҥKDHbŊ37ndFlذyURiuuLbmF'c03Rp8r… SN3g$999QT,k2J$!Vl2tc. sCee[oT51ۑ!85 FSSSLfww#G6n[T*U__eeeb8,,`Khٵ_}[g،XX@B[Rʕ+@ `0*~zV{AJErL&#qqq111GmmmX,644455V,,)!_vҡC)$ތ]AЙ3g$ŋI$RYYǏWX*?~,˝|~ccF#&CCC\.-^XyS}://oڵ+)) ^\XXͺb/xQQbJ"矙d iii'OSN1xD"quu]jkll@Vk'N<,.nQh%^ .XܰdM?j>#Euӧϝ;Ww]{fx|___NN΄ ~m \>}}UB$6L裸W+e2^Hnbbkk7:~~~l6[q\2>ww+W2L$j4ڜڈ7_OY^ f_2׭_?dAH$gvuuN4 A@ `www~~PddŋJm&v#&v@rBd28&/D@ oV4~5...j:..nܸqC>f~wtwLv7o"݇1槟2h&oY ǠNNNd29++H$ZȽ{{C9/mf̜`p].Yrea~ɌoM53alvFFJ`0 ¢!:x~Bɱ٧2(X,&?ɂlyflZ }Źsp8Z(-[fg?,Dwߍ9~<͠9R*5%C:M$v}{达pbbɒ%%엑6x;ݶ>YQb1pѢmnx'[Pd.\P(֭33jk.GX,AF5St6AP]]waa|_x+11pٲHpΆFQ(^c ޻a5  ΙȈ1ß4WZ_]Z;wsSStRa!~h oW찰Z }Vj3KJ39Qh}*wΞ]f&0U_em{݋ ҅2%{7 G-#zvVzz8ByBvv7ŋO7d .DزܸѲ~}]] ni : &$bxSF^W@b`Qݒ5k~Ѡ>9:ۊAyӧ Au̙3V@сi h+]][rf XzՏCR EHGTTԳg3 O8!65+'h9 a755bq17?Qh"X1 *00pbbےx ̝˰=Hgx<Tb)66]w::¼p!E{??@0<3?SVTƲnܸqm]5Zi1vvGFz_?t>?+*d[HN]94d*Q J.WymmmgϞ53rAoo7xVL(eEc -bSwwÏH$ikkIyc^Ttfw&:q͖ASj_hkCL[STj?`hhhSSHJ\.G2*+kmmr[x BIHw;:o܀j 荔 WӧO8;7OATm;{ *K eeGjt رc$;Lx|oooJh`4hn޽f{8N=6/pj31s"`Ūڑ-ہƽ&GPXh^fpPqMg{` z{{a~ŖxNqq-QZ-uk1`RL/p6xVy) Y$߂QL^j+A\vqIB…yI!:~ wK$JXfR_p}3fdWV"mU*_Ry(RDɕ|tjw##kL鬬DaK{`b-[}yɳ: *+{'׭pIP_~eV.Y{׮;Qj]0 Jkj: >...&̢`P^^ ky?0JUyyuyyu]\:c*MSFs玧'kAˌ&~) t\'j5 ^ "Z|hZ[3Ũ?"T&s PTpB-7"tR$^h}e# T'WWV,H/Ξ=+vJ78q"pL՝JU{I,*@ =rՓRRBcbhD j!DQ_s*7'@`A$2$''\Gg@ ,Wl!3 &yݻ绺B PHxܰ)ˆ׹J5^Gzxپ=}kP(K*5J_;aHo(J;-9Og60 ߶n_߽.._GE>~Fנ/8ΰ22 a!>{@Vf,;Bg~A@C`Ӧ+ʪl$d0~?؉1&A&N|eVUVVܤLnn DBԷ1X"hҬT*6/D"x\P?Dn\8H(BF0S(f78bo' J6)&OQ7o o?wwRPL AАI#0qĉ':`8a|X,pO&ӝ9;#7 6v)6nh ~`v옹iF3]eeT9sO|AOO]j3X+<7W?H>.^'6frY5GFz54 :A6er#Gjn|fbA'nN|| Rd2xe"Hk6ݶLfj.5+'7w.lAT*u$y jEEEHN\\mGFj|+pB/)i y@X2 j.DK ^p0D%C"GjgdbRFIyߌ]?9͌H 䄇7550N@7mWBiL;ۯM6R1?~Ν< ߴ75N8""<oz'--,$ă˅bl݊H[%%<ݷZZ_s6،ݼye ;uݰaʱcӦ9G'ǏhO,?4 RA t:~{dmVe[ZY޻we3^jx?pR{1pģY46 "#!t+6?i[ LOOK b1"L&TU ȍpH`#u778[Ju"lWk 6@t]xۍ̢gս\Bi qOnOp `7r޽{L2 [xEr ->65D"A޳Z*a$St̘៓߅DcfD")ˏ=Z[[0dk*/a={ˏ5zH]ZZ jZ>(?Y ϯINNFeFV~].4׿AZ_ C^g!33a!ήݲFs@OP(M5`O$SCCC&#}r\PX߽۶q =V<.ǎ&$ZJ:}4]~}$y ǜuuu%|y¶m-uvhΟ?޾n:$GMxzߴi꧟L Zŋ\.wվg(+?z(-- ]czz~pȃ!+GSlcZRvU[6mڄbg;uo#* 4-)))00sps\[[pZܽ{kҥvk/~V//ɓ'X,"h{Q*( <ofg8cbѣDJݐ644T1cB:45'O۸4Z<j-Z!roݺӣhdrRRJb0Z D> bw[[[Z-N#ӑ1 (ή.;lPq8ݺu Ç@"(G>Qd󴵵bBVjull*jP,TCZ= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-1.2.0-2.rockspec000066400000000000000000000021741207723204400210650ustar00rootroot00000000000000package = "Rings" version = "1.2.0-2" source = { url = "http://luaforge.net/frs/download.php/3168/rings-1.2.0.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-1.2.1-1.rockspec000066400000000000000000000021741207723204400210650ustar00rootroot00000000000000package = "Rings" version = "1.2.1-1" source = { url = "http://luaforge.net/frs/download.php/3348/rings-1.2.1.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-1.2.1rc1-1.rockspec000066400000000000000000000021621207723204400214700ustar00rootroot00000000000000package = "Rings" version = "1.2.1rc1-1" source = { url = "http://rings.luaforge.net/rings-1.2.1rc1.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-1.2.2-1.rockspec000066400000000000000000000021761207723204400210700ustar00rootroot00000000000000package = "Rings" version = "1.2.2-1" source = { url = "http://luaforge.net/frs/download.php/3511/rings-1.2.2.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-1.2.2-2.rockspec000066400000000000000000000012061207723204400210620ustar00rootroot00000000000000package = "Rings" version = "1.2.2-2" source = { url = "http://luaforge.net/frs/download.php/3511/rings-1.2.2.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { type = "module", modules = { rings = "src/rings.c", stable = "src/stable.lua" } } lua-rings-1.3.0/rockspecs/rings-1.2.3-1.rockspec000066400000000000000000000012221207723204400210600ustar00rootroot00000000000000package = "Rings" version = "1.2.3-1" source = { url = "http://cloud.github.com/downloads/keplerproject/rings/rings-1.2.3.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { type = "module", modules = { rings = "src/rings.c", stable = "src/stable.lua" } } lua-rings-1.3.0/rockspecs/rings-1.3.0-1.rockspec000066400000000000000000000012001207723204400210520ustar00rootroot00000000000000package = "Rings" version = "1.3.0-1" source = { url = "http://www.keplerproject.org/rings/rings-1.3.0.tar.gz", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { type = "builtin", modules = { rings = "src/rings.c", stable = "src/stable.lua" } } lua-rings-1.3.0/rockspecs/rings-cvs-2.rockspec000066400000000000000000000022101207723204400212110ustar00rootroot00000000000000package = "Rings" version = "cvs-2" source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/rings", cvs_tag = "HEAD", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "$(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-cvs-3.rockspec000066400000000000000000000022141207723204400212160ustar00rootroot00000000000000package = "Rings" version = "cvs-3" source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/rings", cvs_tag = "HEAD", } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { platforms = { unix = { type = "make", build_variables = { LIB_OPTION = "$(LIBFLAG)", CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)" } }, win32 = { type = "make", build_variables = { LUA_LIB = "$(LUA_LIBDIR)\\lua5.1.lib", CFLAGS = "/MD $(CFLAGS) /I$(LUA_INCDIR)", }, install_variables = { LUA_LIBDIR = "$(LIBDIR)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } } } lua-rings-1.3.0/rockspecs/rings-cvs-4.rockspec000066400000000000000000000011561207723204400212230ustar00rootroot00000000000000package = "Rings" version = "cvs-4" source = { url = "git://github.com/keplerproject/rings.git" } description = { summary = "Create new Lua states from within Lua", detailed = [[ Rings is a library which provides a way to create new Lua states from within Lua. It also offers a simple way to communicate between the creator (master) and the created (slave) states. ]], license = "MIT/X11", homepage = "http://www.keplerproject.org/rings/" } dependencies = { "lua >= 5.1" } build = { type = "builtin", modules = { rings = "src/rings.c", stable = "src/stable.lua" } } lua-rings-1.3.0/src/000077500000000000000000000000001207723204400142045ustar00rootroot00000000000000lua-rings-1.3.0/src/rings.c000066400000000000000000000247541207723204400155060ustar00rootroot00000000000000/* ** Rings: Multiple Lua States ** $Id: rings.c,v 1.24 2008/06/30 17:52:31 carregal Exp $ ** See Copyright Notice in license.html */ #include "string.h" #include "lua.h" #include "lualib.h" #include "lauxlib.h" #define RINGS_STATE "rings state" #define RINGS_TABLENAME "rings" #define RINGS_ENV "rings environment" #define STATE_METATABLE "rings state metatable" #define RINGS_CACHE "rings cache" /* default initialization for fresh states */ #define RINGS_INITIALIZE luaL_openlibs #if LUA_VERSION_NUM < 502 # define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l)) # define luaL_setfuncs(L,l,n) luaL_register(L,NULL,l) #else # define lua_setfenv(L,i) lua_setupvalue(L, i, 1) # define lua_strlen(L,i) lua_rawlen(L, (i)) #endif typedef struct { lua_State *L; } state_data; int luaopen_rings (lua_State *L); /* ** Get a State object from the first call stack position. */ static state_data *getstate (lua_State *L) { state_data *s = (state_data *)luaL_checkudata (L, 1, STATE_METATABLE); luaL_argcheck (L, s != NULL, 1, "not a Lua State"); luaL_argcheck (L, s->L, 1, "already closed state"); return s; } /* ** */ static int state_tostring (lua_State *L) { state_data *s = (state_data *)luaL_checkudata (L, 1, STATE_METATABLE); lua_pushfstring (L, "Lua State (%p)", s); return 1; } /* ** Copies values from State src to State dst. */ static void copy_values (lua_State *dst, lua_State *src, int i, int top) { lua_checkstack(dst, top - i + 1); for (; i <= top; i++) { switch (lua_type (src, i)) { case LUA_TNUMBER: lua_pushnumber (dst, lua_tonumber (src, i)); break; case LUA_TBOOLEAN: lua_pushboolean (dst, lua_toboolean (src, i)); break; case LUA_TSTRING: { const char *string = lua_tostring (src, i); size_t length = lua_strlen (src, i); lua_pushlstring (dst, string, length); break; } case LUA_TLIGHTUSERDATA: { lua_pushlightuserdata (dst, lua_touserdata (src, i)); break; } case LUA_TFUNCTION: { lua_CFunction f = lua_tocfunction(src, i); if(f) lua_pushcfunction(dst, f); else lua_pushnil(dst); } case LUA_TNIL: default: lua_pushnil (dst); break; } } } /* ** Obtains a function which is the compiled string in the given state. ** It also caches the resulting function to optimize future uses. ** Leaves the compiled function on top of the stack or the error message ** produced by luaL_loadbuffer. */ static int compile_string (lua_State *L, void *cache, const char *str) { if(cache == NULL) { lua_pushliteral(L, RINGS_CACHE); } else { lua_pushlightuserdata(L, cache); } lua_gettable (L, LUA_REGISTRYINDEX); /* push cache table */ lua_pushstring (L, str); lua_gettable (L, -2); /* cache[str] */ if (!lua_isfunction (L, -1)) { int status; lua_pop (L, 1); /* remove cache[str] (= nil) from top of the stack */ status = luaL_loadbuffer (L, str, strlen(str), str); /* Compile */ if (status != 0) { /* error? */ lua_remove (L, -2); /* removes cache table; leaves the error message */ return status; } /* Sets environment */ lua_pushliteral(L, RINGS_ENV); lua_gettable(L, LUA_REGISTRYINDEX); if(cache == NULL) { lua_pushliteral(L, RINGS_CACHE); } else { lua_pushlightuserdata(L, cache); } lua_gettable(L, -2); if(!lua_isnil(L, -1)) { lua_setfenv(L, -3); lua_pop(L, 1); } else lua_pop(L, 2); /* Stores the produced function at cache[str] */ lua_pushstring (L, str); lua_pushvalue (L, -2); lua_settable (L, -4); /* cache[str] = func */ } lua_remove (L, -2); /* removes cache table; leaves the function */ return 0; } /* ** Executes a string of code from State src into State dst. ** idx is the index of the string of code. */ static int dostring (lua_State *dst, lua_State *src, void *cache, int idx) { int base; const char *str = luaL_checkstring (src, idx); lua_pushliteral(dst, "rings_traceback"); lua_gettable(dst, LUA_REGISTRYINDEX); base = lua_gettop (dst); idx++; /* ignore first argument (string of code) */ if (compile_string (dst, cache, str) == 0) { /* Compile OK? => push function */ int arg_top = lua_gettop (src); copy_values (dst, src, idx, arg_top); /* Push arguments to dst stack */ if (lua_pcall (dst, arg_top-idx+1, LUA_MULTRET, base) == 0) { /* run OK? */ int ret_top = lua_gettop (dst); lua_pushboolean (src, 1); /* Push status = OK */ copy_values (src, dst, base+1, ret_top); /* Return values to src */ lua_pop (dst, ret_top - base+1); return 1+(ret_top-base); /* Return true (success) plus return values */ } } lua_pushboolean (src, 0); /* Push status = ERR */ lua_pushstring (src, lua_tostring (dst, -1)); lua_pop (dst, 2); /* pops debug.traceback and result from dst state */ return 2; } /* ** Executes a string of Lua code in the master state. */ static int master_dostring (lua_State *S) { lua_State *M; void *C; lua_pushliteral(S, RINGS_STATE); lua_gettable(S, LUA_REGISTRYINDEX); M = (lua_State *)lua_touserdata (S, -1); lua_pop(S, 1); C = lua_touserdata (S, lua_upvalueindex (1)); return dostring (M, S, C, 1); } /* ** Executes a string of Lua code in a given slave state. */ static int slave_dostring (lua_State *M) { state_data *s = getstate (M); /* S == s->L */ lua_pushliteral(s->L, RINGS_STATE); lua_pushlightuserdata(s->L, M); lua_settable(s->L, LUA_REGISTRYINDEX); return dostring (s->L, M, NULL, 2); } /* ** Creates a weak table in the registry. */ static void create_cache (lua_State *L) { lua_newtable (L); lua_newtable (L); /* cache metatable */ lua_pushliteral (L, "__mode"); lua_pushliteral (L, "v"); lua_settable (L, -3); /* metatable.__mode = "v" */ lua_setmetatable (L, -2); lua_settable (L, LUA_REGISTRYINDEX); } /* ** Creates a new Lua State and returns an userdata that represents it. */ static int state_new (lua_State *L) { state_data *s; if(lua_gettop(L) == 0) { lua_getglobal(L, "_M"); if(lua_isnil(L, 1)) { lua_settop(L, 0); lua_getglobal(L, "_G"); if(lua_isnil(L, 1)) { lua_settop(L, 0); lua_newtable(L); } } } s = (state_data *)lua_newuserdata (L, sizeof (state_data)); if(s == NULL) { lua_pushliteral(L, "rings: could not create state data"); lua_error(L); } s->L = NULL; luaL_getmetatable (L, STATE_METATABLE); lua_setmetatable (L, -2); s->L = luaL_newstate (); if(s->L == NULL) { lua_pushliteral(L, "rings: could not create new state"); lua_error(L); } /* Initialize environment */ lua_pushliteral(L, RINGS_ENV); lua_gettable(L, LUA_REGISTRYINDEX); lua_pushlightuserdata(L, s->L); lua_pushvalue(L, 1); lua_settable(L, -3); lua_pop(L, 1); /* load base libraries */ RINGS_INITIALIZE(s->L); /* define dostring function (which runs strings on the master state) */ lua_pushlightuserdata (s->L, s->L); lua_pushcclosure (s->L, master_dostring, 1); lua_setglobal (s->L, "remotedostring"); /* fetches debug.traceback to registry */ lua_getglobal(s->L, "debug"); lua_pushliteral(s->L, "traceback"); lua_gettable(s->L, -2); lua_pushliteral(s->L, "rings_traceback"); lua_pushvalue(s->L, -2); lua_settable(s->L, LUA_REGISTRYINDEX); /* Create caches */ lua_pushlightuserdata(L, s->L); create_cache (L); lua_pushliteral(s->L, RINGS_CACHE); create_cache (s->L); lua_pushliteral(s->L, RINGS_ENV); create_cache (s->L); return 1; } /* ** Closes a Lua State. ** Returns `true' in case of success; `nil' when the state was already closed. */ static int slave_close (lua_State *L) { state_data *s = (state_data *)luaL_checkudata (L, 1, STATE_METATABLE); luaL_argcheck (L, s != NULL, 1, "not a Lua State"); if (s->L != NULL) { lua_pushliteral(L, RINGS_ENV); lua_gettable(L, LUA_REGISTRYINDEX); lua_pushlightuserdata(L, s->L); lua_pushnil(L); lua_settable(L, -3); lua_close (s->L); s->L = NULL; } return 0; } /* ** Creates the metatable for the state on top of the stack. */ static int state_createmetatable (lua_State *L) { /* State methods */ struct luaL_Reg methods[] = { {"close", slave_close}, {"dostring", slave_dostring}, {NULL, NULL}, }; /* State metatable */ if (!luaL_newmetatable (L, STATE_METATABLE)) { return 0; } /* define methods */ luaL_setfuncs(L, methods, 0); /* define metamethods */ lua_pushliteral (L, "__gc"); lua_pushcfunction (L, slave_close); lua_settable (L, -3); lua_pushliteral (L, "__index"); lua_pushvalue (L, -2); lua_settable (L, -3); lua_pushliteral (L, "__tostring"); lua_pushcfunction (L, state_tostring); lua_settable (L, -3); lua_pushliteral (L, "__metatable"); lua_pushliteral (L, "You're not allowed to get the metatable of a Lua State"); lua_settable (L, -3); return 1; } /* ** */ static void set_info (lua_State *L) { lua_pushliteral (L, "_COPYRIGHT"); lua_pushliteral (L, "Copyright (C) 2006 Kepler Project"); lua_settable (L, -3); lua_pushliteral (L, "_DESCRIPTION"); lua_pushliteral (L, "Rings: Multiple Lua States"); lua_settable (L, -3); lua_pushliteral (L, "_VERSION"); lua_pushliteral (L, "Rings 1.2.2"); lua_settable (L, -3); } /* ** Opens library. */ int luaopen_rings (lua_State *L) { /* Library functions */ struct luaL_Reg rings[] = { {"new", state_new}, {NULL, NULL}, }; if (!state_createmetatable (L)) return 0; lua_pop (L, 1); /* define library functions */ lua_newtable(L); luaL_newlib(L, rings); lua_pushvalue(L, -1); lua_setglobal(L, RINGS_TABLENAME); lua_pushliteral(L, RINGS_ENV); lua_newtable (L); lua_settable (L, LUA_REGISTRYINDEX); set_info (L); /* fetches debug.traceback to registry */ lua_getglobal(L, "debug"); if(!lua_isnil(L, -1)) { lua_pushliteral(L, "traceback"); lua_gettable(L, -2); lua_pushliteral(L, "rings_traceback"); lua_pushvalue(L, -2); lua_settable(L, LUA_REGISTRYINDEX); lua_pop(L, 2); } else { lua_pop(L, 1); } return 1; } lua-rings-1.3.0/src/rings.def000066400000000000000000000001171207723204400160050ustar00rootroot00000000000000LIBRARY rings.dll DESCRIPTION "Rings" VERSION 1.2.2 EXPORTS luaopen_rings lua-rings-1.3.0/src/stable.lua000066400000000000000000000021731207723204400161640ustar00rootroot00000000000000---------------------------------------------------------------------------- -- Stable: State persistent table for Rings. -- -- Copyright (c) 2006-2007 Kepler Project -- $Id: stable.lua,v 1.7 2008/06/30 17:52:31 carregal Exp $ ---------------------------------------------------------------------------- local remotedostring = assert (remotedostring, "There is no `remotedostring'. Probably not in a slave state") -- creating persistent table at master state. assert (remotedostring[[_state_persistent_table_ = _state_persistent_table_ or {}]]) local _M = {} ---------------------------------------------------------------------------- _COPYRIGHT = "Copyright (C) 2006 Kepler Project" _DESCRIPTION = "State persistent table" _VERSION = "Stable 1.0" ---------------------------------------------------------------------------- function _M.get (i) local ok, value = remotedostring ("return _state_persistent_table_[...]", i) return value end ---------------------------------------------------------------------------- function _M.set (i, v) remotedostring ("_state_persistent_table_[select(1,...)] = select(2,...)", i, v) end return _M lua-rings-1.3.0/tests/000077500000000000000000000000001207723204400145575ustar00rootroot00000000000000lua-rings-1.3.0/tests/sample.lua000066400000000000000000000004411207723204400165420ustar00rootroot00000000000000-- $Id: sample.lua,v 1.4 2008/05/30 18:44:05 carregal Exp $ require"rings" S = rings.new () data = { 12, 13, 14, } print (S:dostring ([[ aux = {} for i, v in ipairs {...} do table.insert (aux, 1, v) end return unpack (aux)]], unpack (data))) S:close () print("OK!") lua-rings-1.3.0/tests/sample_state.lua000066400000000000000000000010331207723204400177400ustar00rootroot00000000000000-- $Id: sample_state.lua,v 1.2 2006/07/25 14:09:45 tomas Exp $ require"rings" local init_cmd = [[ stable = require"stable"]] local count_cmd = [[ count = stable.get"shared_counter" or 0 stable.set ("shared_counter", count + 1) return count ]] S = rings.new () -- new state assert(S:dostring (init_cmd)) print (S:dostring (count_cmd)) -- true, 0 print (S:dostring (count_cmd)) -- true, 1 S:close () S = rings.new () -- another new state assert (S:dostring (init_cmd)) print (S:dostring (count_cmd)) -- true, 2 S:close () print("OK!") lua-rings-1.3.0/tests/test.lua000077500000000000000000000153701207723204400162520ustar00rootroot00000000000000#!/usr/local/bin/lua5.1 --------------------------------------------------------------------- -- checks for a value and throw an error if it is invalid. --------------------------------------------------------------------- function assert2 (expected, value, msg) if not msg then msg = '' else msg = msg..'\n' end return assert (value == expected, msg.."wrong value (["..tostring(value).."] instead of ".. tostring(expected)..")") end --------------------------------------------------------------------- -- object test. --------------------------------------------------------------------- local objmethods = { "close", "dostring", } function test_object (obj) -- checking object type. assert2 (true, type(obj) == "userdata" or type(obj) == "table", "incorrect object type") -- trying to get metatable. assert2 ("You're not allowed to get the metatable of a Lua State", getmetatable(obj), "error permitting access to object's metatable") -- trying to set metatable. assert2 (false, pcall (setmetatable, S, {})) -- checking existence of object's methods. for i = 1, #objmethods do local method = obj[objmethods[i]] assert2 ("function", type(method)) assert2 (false, pcall (method), "no 'self' parameter accepted") end return obj end --------------------------------------------------------------------- --------------------------------------------------------------------- require"rings" print(rings._VERSION) S = test_object (rings.new()) S:dostring([[pcall(require, "luarocks.require")]]) -- How to handle errors on another Lua State? assert2 (false, S:dostring"bla()") assert2 (false, S:dostring"bla(") assert2 (true, S:dostring"print'Hello World!'") -- Checking returning value io.write(".") local ok, _x = S:dostring"return x" assert2 (true, ok, "Error while returning a value ("..tostring(_x)..")") assert2 (nil, _x, "Unexpected initialized variable (x = "..tostring(_x)..")") -- setting a value io.write(".") assert2 (nil, x, "I need an unitialized varible to do the test!") S:dostring"x = 1" assert2 (nil, x, "Changing original Lua State instead of the new one!") -- obtaining a value from the new state io.write(".") local ok, _x = S:dostring"return x" assert2 (true, ok, "Error while returning a value ("..tostring(_x)..")") assert2 (1, _x, "Unexpected initialized variable (x = "..tostring(_x)..")") -- executing code in the master state from the new state io.write(".") global = 2 local ok, _x = S:dostring[[ local ok, _x = remotedostring"return global" if not ok then error(_x) else return _x end ]] assert2 (true, ok, "Unexpected error: "..tostring(_x).." (status == "..tostring(ok)..")") assert2 (global, _x, "Unexpected error: "..tostring(_x).." (status == "..tostring(ok)..")") -- new state obtaining data from the master state by using remotedostring io.write(".") f1 = function () return "funcao 1" end f2 = function () return "funcao 2" end f3 = function () return "funcao 3" end data = { key1 = { f1, f2, f3, }, key2 = { f3, f1, f2, }, } local ok, k, i, f = S:dostring ([[ require"math" require"os" math.randomseed(os.time()) local key = "key"..math.random(2) local i = math.random(3) local ok, f = remotedostring("return data."..key.."["..i.."]()") return key, i, f ]], package.path) assert2 (true, ok, "Unexpected error: "..k) assert2 ("string", type(k), string.format ("Wrong #1 return value (expected string, got "..type(k)..")")) assert2 ("number", type(i), string.format ("Wrong #2 return value (expected number, got "..type(i)..")")) assert2 ("string", type(f), string.format ("Wrong #3 return value (expected string, got "..type(f)..")")) assert2 (f, data[k][i](), "Wrong #3 return value") -- Passing arguments and returning values io.write(".") local data = { 12, 13, 14, 15, } local cmd = string.format ([[ local arg = { ... } assert (type(arg) == "table") assert (arg[1] == %d) assert (arg[2] == %d) assert (arg[3] == %d) assert (arg[4] == %d) assert (arg[5] == nil) return unpack (arg)]], unpack (data)) local _data = { S:dostring(cmd, data[1], data[2], data[3], data[4]) } assert2 (true, table.remove (_data, 1), "Unexpected error: "..tostring(_data[2])) for i, v in ipairs (data) do assert2 (v, _data[i]) end -- Transfering userdata io.write(".") local ok, f1, f2, f3 = S:dostring([[ return ..., io.stdout ]], io.stdout) assert ((not f1) and (not f2), "Same file objects (io.stdout) in different states (user data objects were supposed not to be copyable") -- Checking cache io.write(".") local chunk = [[return tostring(debug.getinfo(1,'f').func)]] local ok, f1 = S:dostring(chunk) local ok, f2 = S:dostring(chunk) local ok, f3 = S:dostring([[return tostring (debug.getinfo(1,'f').func)]]) assert (f1 == f2, "Cache is not working") assert (f1 ~= f3, "Function `dostring' is producing the same function for different strings") assert (S:dostring"collectgarbage(); collectgarbage()") local ok, f4 = S:dostring(chunk) assert (f4 ~= f1, "Cache is not being collected") local ok, f5 = S:dostring(chunk) assert (f4 == f5, "Cache is not working") -- Checking Stable io.write(".") assert (S:dostring[[stable = require"stable"]]) assert (type(_state_persistent_table_) == "table", "Stable could not create persistent table") assert (S:dostring[[stable.set("key", "value")]]) assert (_state_persistent_table_.key == "value", "Stable could not store a value") assert (S:dostring[[assert(stable.get"key" == "value")]]) -- Closing new state io.write(".") S:close () assert2 (false, pcall (S.dostring, S, "print[[This won't work!]]")) collectgarbage() collectgarbage() -- Checking Stable's persistent table io.write(".") local NS = test_object (rings.new()) assert (NS:dostring ([[ pcall(require, "luarocks.require") package.path = ... ]], package.path)) assert (NS:dostring[[stable = require"stable"]]) assert (type(_state_persistent_table_) == "table", "Stable persistent table was removed") assert (_state_persistent_table_.key == "value", "Stable key vanished") assert (NS:dostring[[assert(stable.get"key" == "value")]]) -- Checking remotedostring environment S = rings.new({ a = 2, b = 3, assert = assert }) S:dostring([[pcall(require, "luarocks.require")]]) assert (S:dostring[[remotedostring[=[assert(a == 2)]=] ]]) assert (S:dostring[[remotedostring[=[assert(b == 3)]=] ]]) assert (S:dostring[[remotedostring[=[assert(print == nil)]=] ]]) -- Checking inherited environment local env = { msg = "Hi!"} local r = rings.new(env) r:dostring([[pcall(require, "luarocks.require")]]) r:dostring([==[remotedostring([[assert(msg == "Hi!", "Environment failure")]])]==]) print"Ok!" lua-rings-1.3.0/vc6/000077500000000000000000000000001207723204400141135ustar00rootroot00000000000000lua-rings-1.3.0/vc6/rings.def000066400000000000000000000001151207723204400157120ustar00rootroot00000000000000LIBRARY rings.dll DESCRIPTION "Rings" VERSION 1.0 EXPORTS luaopen_rings lua-rings-1.3.0/vc6/rings.dsw000066400000000000000000000011541207723204400157550ustar00rootroot00000000000000Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "rings_dll"=.\rings_dll.dsp - Package Owner=<4> Package=<5> {{{ begin source code control rings .. end source code control }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### lua-rings-1.3.0/vc6/rings_dll.dsp000066400000000000000000000113251207723204400166020ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="rings_dll" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=rings_dll - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "rings_dll.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "rings_dll.mak" CFG="rings_dll - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "rings_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "rings_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "rings_dll" # PROP Scc_LocalPath ".." CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "rings_dll - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "../lib/vc6" # PROP Intermediate_Dir "rings_dll/Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RINGS_EXPORTS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "../../external-src/lua50/include" /I "../../compat/src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RINGS_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x416 /d "NDEBUG" # ADD RSC /l 0x416 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 lua50.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../bin/vc6/rings.dll" /libpath:"../../external-src/lua50/lib/dll" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Cmds=cd ../bin/vc6 zip.exe rings-1.0-win32.zip rings.dll # End Special Build Tool !ELSEIF "$(CFG)" == "rings_dll - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "../lib/vc6" # PROP Intermediate_Dir "rings_dll/Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RINGS_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../external-src/lua50/include" /I "../../compat/src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RINGS_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x416 /d "_DEBUG" # ADD RSC /l 0x416 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 lua50.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../bin/vc6/ringsd.dll" /pdbtype:sept /libpath:"../../external-src/lua50/lib/dll" !ENDIF # Begin Target # Name "rings_dll - Win32 Release" # Name "rings_dll - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE="..\..\compat\src\compat-5.1.c" # End Source File # Begin Source File SOURCE=..\src\rings.c # End Source File # Begin Source File SOURCE=.\rings.def # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE="..\..\compat\src\compat-5.1.h" # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project