pax_global_header00006660000000000000000000000064121553740540014520gustar00rootroot0000000000000052 comment=de5b3883acf99677a9231e169acfb445488f1f8a lua-coxpcall-1.14.0/000077500000000000000000000000001215537405400141675ustar00rootroot00000000000000lua-coxpcall-1.14.0/Makefile000066400000000000000000000005671215537405400156370ustar00rootroot00000000000000# $Id: Makefile,v 1.3 2008/01/22 18:39:18 mascarenhas Exp $ config_file:=config ifneq '$(wildcard $(config_file))' '' include $(config_file) endif $(config_file): chmod +x configure install: $(config_file) mkdir -p $(LUA_DIR) cp src/coxpcall.lua $(LUA_DIR)/ install-rocks: install mkdir -p $(PREFIX)/doc cp -r doc/* $(PREFIX)/doc echo "Go to $(PREFIX) for docs!" lua-coxpcall-1.14.0/Makefile.win000066400000000000000000000004371215537405400164270ustar00rootroot00000000000000# $Id: Makefile.win,v 1.3 2008/01/23 03:01:31 mascarenhas Exp $ LUA_DIR=C:\lua5.1\lua install: IF NOT EXIST "$(LUA_DIR)" mkdir "$(LUA_DIR)" copy src\coxpcall.lua "$(LUA_DIR)\" install-rocks: install IF NOT EXIST "$(PREFIX)\doc" mkdir "$(PREFIX)\doc" xcopy /E doc "$(PREFIX)\doc\" lua-coxpcall-1.14.0/README000066400000000000000000000012001215537405400150400ustar00rootroot00000000000000Coxpcall http://coxpcall.luaforge.net/ Coxpcall encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual pcall/xpcall issues with coroutines. Using Coxpcall usually consists in simply loading the module and then replacing Lua pcall and xpcall by copcall and coxpcall. Coxpcall is free software and uses the same license as Lua 5.1. Coxpcall can be downloaded from its LuaForge page. You can also get Coxpcall using LuaRocks: luarocks install coxpcall History Coxpcall 1.14 [30/Jan/2013] * Lua 5.2 support Coxpcall 1.13 [19/May/2008] * Fixed bug [#5275], found by Gary NGlua-coxpcall-1.14.0/configure000077500000000000000000000014161215537405400161000ustar00rootroot00000000000000#!/bin/bash if [ $1 == "--help" ]; then echo "Usage: configure lua51" echo "where lua51 is the name of your Lua executable" exit 0 fi echo "Trying to find where you installed Lua..." if [ $1 != "" ]; then lua=$1 else lua="lua51" fi lua_bin=`which $lua` lua_bin_dir=`dirname $lua_bin` lua_root=`dirname $lua_bin_dir` if [ $lua_root != "" ]; then echo "Lua is in $lua_root" echo "Writing config" lua_share=$lua_root/share/lua/5.1 lua_lib=$lua_root/lib/lua/5.1 bin_dir=$lua_root/bin echo "LUA_BIN= $lua_bin" > config echo "LUA_DIR= $lua_share" >> config echo "BIN_DIR= $bin_dir" >> config echo "LUA_LIBDIR= $lua_lib" >> config echo "Now run 'make && sudo make install'" else echo "Lua not found, please install Lua 5.1 (and put in your PATH)" fi lua-coxpcall-1.14.0/doc/000077500000000000000000000000001215537405400147345ustar00rootroot00000000000000lua-coxpcall-1.14.0/doc/us/000077500000000000000000000000001215537405400153635ustar00rootroot00000000000000lua-coxpcall-1.14.0/doc/us/coxpcall.png000066400000000000000000000273701215537405400177070ustar00rootroot00000000000000PNG  IHDRL\ pHYsHHFk>.bIDATx=ixTE-d'@HHB@.H7F?y (˧μϙ3OEEQDdUdQB $@! 餻UG/7%wNݺU:u:cy;{ t<*B=n0TԻw 8G}w 899 rssWBM6(=z}NNN~~>h4CKāAgЙP>(F1!!… `6tRPPhj(B)?vc2E_Ŝ!zcRRRAAfk׮FU`' 'f#!BG}VF.˔Rߌ1P&_wSс1ed2@||; zuYf0Tqڵ늢8Q͛g4).]z-.8 GR2%B6\Zjihp fQ$!HBuL:tرcMMM0{~uڵ{.\HHH$<66VB)5 c@Q;/^vb1b7IKcLpCo.lݚ]ZV I bTTȑя?2uj_( Kw*˫GW_]xqƌ{޽{Ν;1 999н{w|5N4_EYhhcvB-SYY9|X>`֮z㍃ׯW  f;+yf~+VL1#QQ(h{ʰAUBeeegNMM IMM-**r $&&VWW!""">?&|U7[T3""{޽{}}M?oڴfJQ(ƨiڴMQZZCH!FV1al-9s…"E[BǮ1v… 6-111$$DÇ@zzѣGCCC?m2.]{1ރ*hYL)odC Z\U{PhT|err(TQ'Ea cƺO>9|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iӦ{,<<@כ6mxkJo6M[YjeH- LEy/?/ExgweO4ܹsRHo~3jsn1b\_82 Կ2!8yr򫯎iHwh)}.yOs6hР{765($wܵNGDDaukG)mP9UWWBYt*22pÆ_"qAe f̫{JX,jyN1ֵk{.!!K%?":fL'< `=hМȘ}͚'Në/zO+We  FZ^,+sP&^|߄ R[o=``~ǧ߻w$I)))f~}L_|qX;Ȣf˲קnsy r ~G}_ϛSUL~nB$?ϐFyI绖 !Lr07',A_80%%E-y'zO<ϓYJY&kɒÄw?Ø0&1\ҥ|b4jAAAHHHHHn޽ޛmVۨC'KxݻեAQUJ;v99yuũc<{9rd/߯(vBH5y BEq,_>1#cQ||7w#+**Mr3;TACCڵA}X,ܹ  wfc`QC̘-1+Wŋ/oT|@ʕoyNꃂ_{me#yK>k2`7lp^xWoչs5-.4,/ox督WXtN3mvs2JE(5~I?n6m:s=j)'.\#g4wٖZVZ6J6b$Qs&(]p%Ch!$Iƍᄒ}\Uڙ(((XjUJJٳnZ,X;/_G9wO{J]m4k޼{|?%^{;r\k*k}GsqYO2G_ݛgO^zzQqq-G(Eu~ 5*fԾSnNnz-CٟN9/𬭭裏|xRRҶmտ3<_ss@Jڶmf[t)hD_}V@; 2@QQQ<@߾};.б+@;zAkB(##ԩS<@Ϟ=]̅>y-yΚjQ=zʕ+ljrU6/((ػwիW{1lذÇzR";>sͦl6B]u(`"==ҥKO?KHUixs&- Z!TWWw嬬LdY&tAAAvvvRRRdddPP>htRo=rH```޽SSS/Nj{'Кl .1իWϜ9Eq̙ PRSSXEw]V嚚ݻ5JiRRR|||||<5ȺE"4 Coxpcall - Coroutine Safe xpcall and pcall
Coxpcall
Coroutine-safe xpcall and pcall versions

Overview

Coxpcall encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual pcall/xpcall issues with coroutines.

Using Coxpcall usually consists in simply loading the module and then replacing Lua pcall and xpcall by copcall and coxpcall.

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

Status

Current version is 1.14. It supports Lua 5.1 and Lua 5.2.

Download

Coxpcall can be downloaded from its LuaForge page. You can also get Coxpcall using LuaRocks:

luarocks install coxpcall

History

Coxpcall 1.14 [30/Jan/2013]
  • Support for Lua 5.2
Coxpcall 1.13 [19/May/2008]
  • Fixed bug [#5275], found by Gary NG
Coxpcall 1.12 [09/May/2008]
  • Added stack traces
Coxpcall 1.11 [22/Jan/2008]
  • Moving Coxpcall to a standalone project since its now being used by more than only Xavante
  • Refactoring and bug fixes by Thomas Harning Jr., Ignacio Burgueño and Fábio Mascarenhas
Coxpcall 1.0 [18/Feb/2005]
Coxpcall 1.0 until 1.11 was released as part of Xavante

Reference

Coxpcall offers two functions that reproduce the behaviour of pcall and xpcall:

coxpcall(f, err)
Offers the same functionality as Lua xpcall(f, err).
copcall(f, ...)
Offers the same functionality as Lua pcall(f, ...).

Credits

Coxpcall was designed and implemented by Roberto Ierusalimschy and André Carregal with the colaboration of Thomas Harning Jr., Ignacio Burgueño, Gary NG and Fábio Mascarenhas as part of the Kepler Project which holds its copyright.

Contact us

For more information please contact us. Comments are welcome!

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

Valid XHTML 1.0!

$Id: index.html,v 1.4 2008/05/19 20:32:33 carregal Exp $

lua-coxpcall-1.14.0/doc/us/license.html000066400000000000000000000100611215537405400176710ustar00rootroot00000000000000 Coxpcall License
Coxpcall
Coroutine-safe xpcall and pcall versions

Coxpcall License

Coxpcall 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. Coxpcall qualifies as Open Source software. Its licenses are compatible with GPL. Coxpcall is not in the public domain and Kepler Project keep its copyright. The legal details are below.

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

Coxpcall was designed and implemented by Roberto Ierusalimschy and André Carregal. The implementation is not derived from licensed software.


Copyright © 2005 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.1 2008/01/17 20:41:05 carregal Exp $

lua-coxpcall-1.14.0/rockspec/000077500000000000000000000000001215537405400160005ustar00rootroot00000000000000lua-coxpcall-1.14.0/rockspec/coxpcall-1.11.0-1.rockspec000066400000000000000000000013041215537405400222100ustar00rootroot00000000000000package = "Coxpcall" version = "1.11.0-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "http://luaforge.net/frs/download.php/3047/coxpcall-1.11.0.tar.gz", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } lua-coxpcall-1.14.0/rockspec/coxpcall-1.12.0-1.rockspec000066400000000000000000000013041215537405400222110ustar00rootroot00000000000000package = "Coxpcall" version = "1.12.0-1" source = { url = "http://luaforge.net/frs/download.php/3351/coxpcall-1.12.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } lua-coxpcall-1.14.0/rockspec/coxpcall-1.12.0rc1-1.rockspec000066400000000000000000000012751215537405400226260ustar00rootroot00000000000000package = "Coxpcall" version = "1.12.0rc1-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "http://coxpcall.luaforge.net/coxpcall-1.12.0rc1.tar.gz", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } lua-coxpcall-1.14.0/rockspec/coxpcall-1.13.0-1.rockspec000066400000000000000000000013041215537405400222120ustar00rootroot00000000000000package = "Coxpcall" version = "1.13.0-1" source = { url = "http://luaforge.net/frs/download.php/3406/coxpcall-1.13.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } lua-coxpcall-1.14.0/rockspec/coxpcall-1.13.0-2.rockspec000066400000000000000000000011101215537405400222060ustar00rootroot00000000000000package = "Coxpcall" version = "1.13.0-2" source = { url = "http://luaforge.net/frs/download.php/3406/coxpcall-1.13.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "module", modules = { coxpcall = "src/coxpcall.lua" } } lua-coxpcall-1.14.0/rockspec/coxpcall-1.14.0-1.rockspec000066400000000000000000000011021215537405400222070ustar00rootroot00000000000000package = "Coxpcall" version = "1.14.0-1" source = { url = "http://www.keplerproject.org/files/coxpcall-1.14.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } lua-coxpcall-1.14.0/rockspec/coxpcall-cvs-1.rockspec000066400000000000000000000013201215537405400222630ustar00rootroot00000000000000package = "Coxpcall" version = "cvs-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/coxpcall", cvs_tag = "HEAD" } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } lua-coxpcall-1.14.0/rockspec/coxpcall-cvs-2.rockspec000066400000000000000000000010571215537405400222730ustar00rootroot00000000000000package = "Coxpcall" version = "cvs-2" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "git://github.com/keplerproject/coxpcall.git" } build = { type = "module", modules = { coxpcall = "src/coxpcall.lua" } } lua-coxpcall-1.14.0/src/000077500000000000000000000000001215537405400147565ustar00rootroot00000000000000lua-coxpcall-1.14.0/src/coxpcall.lua000066400000000000000000000043421215537405400172710ustar00rootroot00000000000000------------------------------------------------------------------------------- -- Coroutine safe xpcall and pcall versions -- -- Encapsulates the protected calls with a coroutine based loop, so errors can -- be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines -- yielding inside the call to pcall or xpcall. -- -- Authors: Roberto Ierusalimschy and Andre Carregal -- Contributors: Thomas Harning Jr., Ignacio Burgueño, Fabio Mascarenhas -- -- Copyright 2005 - Kepler Project (www.keplerproject.org) -- -- $Id: coxpcall.lua,v 1.13 2008/05/19 19:20:02 mascarenhas Exp $ ------------------------------------------------------------------------------- -- Lua 5.2 makes this module a no-op if _VERSION == "Lua 5.2" then copcall = pcall coxpcall = xpcall return { pcall = pcall, xpcall = xpcall } end ------------------------------------------------------------------------------- -- Implements xpcall with coroutines ------------------------------------------------------------------------------- local performResume, handleReturnValue local oldpcall, oldxpcall = pcall, xpcall local pack = table.pack or function(...) return {n = select("#", ...), ...} end local unpack = table.unpack or unpack function handleReturnValue(err, co, status, ...) if not status then return false, err(debug.traceback(co, (...)), ...) end if coroutine.status(co) == 'suspended' then return performResume(err, co, coroutine.yield(...)) else return true, ... end end function performResume(err, co, ...) return handleReturnValue(err, co, coroutine.resume(co, ...)) end function coxpcall(f, err, ...) local res, co = oldpcall(coroutine.create, f) if not res then local params = pack(...) local newf = function() return f(unpack(params, 1, params.n)) end co = coroutine.create(newf) end return performResume(err, co, ...) end ------------------------------------------------------------------------------- -- Implements pcall with coroutines ------------------------------------------------------------------------------- local function id(trace, ...) return ... end function copcall(f, ...) return coxpcall(f, id, ...) end return { pcall = copcall, xpcall = coxpcall }