aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-zmq
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-10-09 12:32:19 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-10-09 12:32:19 +0000
commit33c6ff68a8f4636af737bcb8835b246628ce327a (patch)
treea07ba38227cf5af80286ab35be4a45420c9cab38 /main/lua-zmq
parent22cdb9ccdfc90c1087dc7db9c4138aca7fb823ef (diff)
downloadaports-33c6ff68a8f4636af737bcb8835b246628ce327a.tar.bz2
aports-33c6ff68a8f4636af737bcb8835b246628ce327a.tar.xz
main/lua-zmq: upgrade to git 20130709 and build for both lua 5.1 and 5.2
Diffstat (limited to 'main/lua-zmq')
-rw-r--r--main/lua-zmq/APKBUILD64
-rw-r--r--main/lua-zmq/git-20130709.patch (renamed from main/lua-zmq/git-20121231.patch)2612
2 files changed, 1712 insertions, 964 deletions
diff --git a/main/lua-zmq/APKBUILD b/main/lua-zmq/APKBUILD
index bf80a51b8b..4eb764808e 100644
--- a/main/lua-zmq/APKBUILD
+++ b/main/lua-zmq/APKBUILD
@@ -1,48 +1,80 @@
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+
+_luaversions="5.1 5.2"
+
pkgname=lua-zmq
-pkgver=1.1_git20121231
+pkgver=1.1_git20130709
_ver=${pkgver%_git*}
pkgrel=0
pkgdesc="Lua zeromq2 binding"
url="https://github.com/Neopallium/lua-zmq"
arch="all"
license="MIT"
-depends="lua-llthreads"
-makedepends="zeromq-dev cmake lua-dev"
+depends="lua-llthreads lua5.1-zmq"
+makedepends="zeromq-dev cmake"
+for _i in $_luaversions; do
+ makedepends="$makedepends lua$_i-dev"
+ subpackages="$subpackages lua$_i-zmq:split_${_i/./_}"
+done
install=""
-subpackages=
source="$pkgname-$_ver.tar.gz::https://github.com/Neopallium/lua-zmq/archive/v$_ver.tar.gz
git-${pkgver##*_git}.patch"
-_builddir="$srcdir"/lua-zmq-$_ver
+_sdir="$srcdir"/lua-zmq-$_ver
prepare() {
local i
- cd "$_builddir"
+ cd "$_sdir"
for i in $source; do
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
esac
done
+ for _i in $_luaversions; do
+ mkdir -p "$srcdir"/build-$_i || return 1
+ done
}
build() {
- cd "$_builddir"
- cmake \
- -DCMAKE_INSTALL_PREFIX=/usr \
- . || return 1
- make || return 1
+ for _i in $_luaversions; do
+ cd "$srcdir"/build-$_i
+ msg "build for Lua $_i"
+ CFLAGS="$CFLAGS $(pkg-config --cflags lua$_i)" cmake \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DINSTALL_CMOD=/usr/lib/lua/$_i \
+ -DINSTALL_LMOD=/usr/share/lua/$_i \
+ "$_sdir" || return 1
+ make || return 1
+ done
}
package() {
- cd "$_builddir"
- make install DESTDIR="$pkgdir" || return 1
+ for _i in $_luaversions; do
+ cd "$srcdir"/build-$_i
+ make install DESTDIR="$pkgdir" || return 1
+ done
}
+_split() {
+ local d= _ver=$1
+ pkgdesc="Filesystem functions for Lua $_ver"
+ replaces="$pkgname"
+ for d in usr/lib/lua usr/share/lua; do
+ if [ -d "$pkgdir"/$d/$_ver ]; then
+ mkdir -p "$subpkgdir"/$d
+ mv "$pkgdir"/$d/$_ver "$subpkgdir"/$d/ || return 1
+ fi
+ done
+}
+
+for _i in $_luaversions; do
+ eval "split_${_i/./_}() { _split $_i; }"
+done
+
md5sums="cb4df81b4c884bf97bf6add88fcfa58d lua-zmq-1.1.tar.gz
-e568cb33eef6230454a70dddfd5d3978 git-20121231.patch"
+e68a07c32d77fbea78165d6ae49027cb git-20130709.patch"
sha256sums="f2bdf3142b744971da4eb8bdb12020a34b62f8ba384be44d8448b4ef05ec3dcc lua-zmq-1.1.tar.gz
-9f3b2ddd87c0fd7064a317e5ed63c16c4d1999b020f3d98970f1c5962ed34354 git-20121231.patch"
+f0266865ac2ebc10e74877686e8536caec88db286408170b22543243235fa608 git-20130709.patch"
sha512sums="35d7da6215a96b80ea59b52591082473d2c54bcb9577ae95ead1235de894d5ef226b6c4e3030c327b2b146e07af6b3998d91c5b520dfb35e87c85e958069362d lua-zmq-1.1.tar.gz
-12ff90d9b01ca03f8c9f8e02e1392de839c19242570acb77d5078e4358a89dabe3df6f6b701a30b95121b35ed09a72eedd0259c34b2663e5193a963c588be64c git-20121231.patch"
+c9080a53b3f6f63a03bc105fc2d49bdf664fccfdcd35414f21972cee30db466744024727418491dbff6ac845186e1b77f684832ccbbf0c209759303ede8150bb git-20130709.patch"
diff --git a/main/lua-zmq/git-20121231.patch b/main/lua-zmq/git-20130709.patch
index cfeaaebc35..fce538bc48 100644
--- a/main/lua-zmq/git-20121231.patch
+++ b/main/lua-zmq/git-20130709.patch
@@ -1,3 +1,77 @@
+diff --git a/.travis.yml b/.travis.yml
+new file mode 100644
+index 0000000..9a579b2
+--- /dev/null
++++ b/.travis.yml
+@@ -0,0 +1,68 @@
++language: c
++
++env:
++ matrix:
++ - LUA=lua5.1 LIBLUA=liblua5.1-dev LUA_INCDIR=/usr/include/lua5.1 LUA_LIB=lua5.1
++ - LUA=lua5.2 LIBLUA=liblua5.2-dev LUA_INCDIR=/usr/include/lua5.2 LUA_LIB=lua5.2
++ - LUA=luajit LIBLUA=libluajit-5.1-dev LUA_INCDIR=/usr/include/luajit-2.0 LUA_LIB=luajit-5.1
++
++branches:
++ only:
++ - master
++
++compiler:
++ - gcc
++
++before_install:
++ - if [ $LUA = "luajit" ]; then
++ sudo add-apt-repository ppa:mwild1/ppa -y && sudo apt-get update -y;
++ fi
++
++install:
++ - sudo apt-get install libzmq3-dev -y
++ - sudo apt-get install $LUA -y
++ - sudo apt-get install $LIBLUA -y
++ - LUA_LIBDIR=`pkg-config $LUA --variable=libdir`
++ - INSTALL_LMOD=`pkg-config $LUA --variable=INSTALL_LMOD`
++ - INSTALL_CMOD=`pkg-config $LUA --variable=INSTALL_CMOD`
++ ## make sure there is a 'lua' command.
++ - if [ ! -x /usr/bin/lua ]; then
++ sudo ln -s `which $LUA` /usr/bin/lua;
++ fi
++ ## install lua-llthreads
++ - git clone git://github.com/Neopallium/lua-llthreads.git
++ - cd lua-llthreads ; mkdir build ; cd build
++ - cmake .. -DLUA_LIBRARIES=$LUA_LIBDIR -DLUA_INCLUDE_DIR=$LUA_INCDIR
++ -DINSTALL_LMOD=$INSTALL_LMOD -DINSTALL_CMOD=$INSTALL_CMOD
++ - make
++ - sudo make install
++ - cd ../..
++
++script:
++ #### build using pre-generated bindings.
++ - mkdir build; cd build
++ - cmake .. -DLUA_LIBRARIES=$LUA_LIBDIR -DLUA_INCLUDE_DIR=$LUA_INCDIR
++ -DINSTALL_LMOD=$INSTALL_LMOD -DINSTALL_CMOD=$INSTALL_CMOD
++ - make
++ - sudo make install
++ # Run tests.
++ - $LUA ../tests/test_inproc.lua
++ - $LUA ../perf/thread_lat.lua 1 1000
++ - cd .. ; rm -rf build
++ #### Re-Generate bindings.
++ - git clone git://github.com/Neopallium/LuaNativeObjects.git;
++ - mkdir build; cd build
++ - cmake .. -DLUA_LIBRARIES=$LUA_LIBDIR -DLUA_INCLUDE_DIR=$LUA_INCDIR
++ -DLUA_NATIVE_OBJECTS_PATH=$TRAVIS_BUILD_DIR/LuaNativeObjects
++ -DUSE_PRE_GENERATED_BINDINGS=OFF -DGENERATE_LUADOCS=OFF
++ -DINSTALL_LMOD=$INSTALL_LMOD -DINSTALL_CMOD=$INSTALL_CMOD
++ - make
++ - sudo make install
++ # Run tests.
++ - $LUA ../tests/test_inproc.lua
++ - $LUA ../perf/thread_lat.lua 1 1000
++
++notifications:
++ email:
++ on_failure: always
++ on_success: change
diff --git a/API.md b/API.md
index f15da79..9cdcb8e 100644
--- a/API.md
@@ -133,11 +207,15 @@ index 0000000..9840d93
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README.md b/README.md
-index eac5f5f..830e350 100644
+index eac5f5f..0b3b15d 100644
--- a/README.md
+++ b/README.md
-@@ -3,6 +3,11 @@ About
+@@ -1,8 +1,15 @@
+ About
+ =====
++[![travis-ci status](https://secure.travis-ci.org/Neopallium/lua-zmq.png?branch=master)](http://travis-ci.org/Neopallium/lua-zmq/builds)
++
Lua bindings to zeromq2. Check out the [ZeroMQ Guide with Lua examples](http://zguide.zeromq.org/lua:all).
+Windows
@@ -148,7 +226,7 @@ index eac5f5f..830e350 100644
API
===
-@@ -12,7 +17,7 @@ See [API.md](https://github.com/Neopallium/lua-zmq/blob/master/API.md) and
+@@ -12,7 +19,7 @@ See [API.md](https://github.com/Neopallium/lua-zmq/blob/master/API.md) and
Requirements
============
@@ -157,7 +235,7 @@ index eac5f5f..830e350 100644
* Might work with some 2.0.x versions (2.0.6 and lower are not supported).
For Ubuntu 10.10 users:
-@@ -22,7 +27,7 @@ For Ubuntu 10.10 users:
+@@ -22,7 +29,7 @@ For Ubuntu 10.10 users:
Installation
============
@@ -166,7 +244,7 @@ index eac5f5f..830e350 100644
$ LD_PRELOAD=/lib/libpthread.so lua
-@@ -45,12 +50,12 @@ Latest Git revision
+@@ -45,12 +52,12 @@ Latest Git revision
With LuaRocks 2.0.4.1:
@@ -182,6 +260,25 @@ index eac5f5f..830e350 100644
With CMake:
+diff --git a/README.regenerate.md b/README.regenerate.md
+new file mode 100644
+index 0000000..e3b288e
+--- /dev/null
++++ b/README.regenerate.md
+@@ -0,0 +1,13 @@
++To re-generating the bindings
++-----------------------------
++
++You will need to install LuaNativeObjects and set the CMake variable `USE_PRE_GENERATED_BINDINGS` to FALSE.
++By default CMake will use the pre-generated bindings that are include in the project.
++
++Build Dependencies
++------------------
++
++Optional dependency for re-generating Lua bindings from `*.nobj.lua` files:
++
++* [LuaNativeObjects](https://github.com/Neopallium/LuaNativeObjects), this is the bindings generator used to convert the `*.nobj.lua` files into a native Lua module.
++
diff --git a/cmake/CustomMacros.cmake b/cmake/CustomMacros.cmake
new file mode 100644
index 0000000..312eeff
@@ -1693,10 +1790,17 @@ index 0000000..1be24b2
+ctx:term()
+
diff --git a/perf/local_lat.lua b/perf/local_lat.lua
-index d6a4ec1..027c583 100644
+index d6a4ec1..4417c46 100644
--- a/perf/local_lat.lua
+++ b/perf/local_lat.lua
-@@ -35,11 +35,26 @@ s:bind(bind_to)
+@@ -30,16 +30,31 @@ local roundtrip_count = tonumber(arg[3])
+ local zmq = require"zmq"
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.REP)
+-s:bind(bind_to)
++local s = assert(ctx:socket(zmq.REP))
++assert(s:bind(bind_to))
local msg = zmq.zmq_msg_t()
@@ -1723,9 +1827,57 @@ index d6a4ec1..027c583 100644
+print(string.format("elapsed = %f", secs))
+print(string.format("msg/sec = %f", roundtrip_count / secs))
+
+diff --git a/perf/local_multipart.lua b/perf/local_multipart.lua
+index 7d3ab99..69955dd 100644
+--- a/perf/local_multipart.lua
++++ b/perf/local_multipart.lua
+@@ -30,9 +30,9 @@ local message_count = tonumber(arg[3])
+ local zmq = require"zmq"
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.PULL)
++local s = assert(ctx:socket(zmq.PULL))
+ --s:setopt(zmq.SUBSCRIBE, "");
+-s:bind(bind_to)
++assert(s:bind(bind_to))
+
+ local function recv_msg(s,msg)
+ assert(s:recv_msg(msg))
+diff --git a/perf/local_pull.lua b/perf/local_pull.lua
+index a515f60..2d52b1e 100644
+--- a/perf/local_pull.lua
++++ b/perf/local_pull.lua
+@@ -30,8 +30,8 @@ local message_count = tonumber(arg[3])
+ local zmq = require"zmq"
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.PULL)
+-s:bind(bind_to)
++local s = assert(ctx:socket(zmq.PULL))
++assert(s:bind(bind_to))
+
+ print(string.format("message size: %i [B]", message_size))
+ print(string.format("message count: %i", message_count))
+diff --git a/perf/local_thr.lua b/perf/local_thr.lua
+index 572c4e0..c7ede4c 100644
+--- a/perf/local_thr.lua
++++ b/perf/local_thr.lua
+@@ -30,9 +30,9 @@ local message_count = tonumber(arg[3])
+ local zmq = require"zmq"
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.SUB)
+-s:setopt(zmq.SUBSCRIBE, "");
+-s:bind(bind_to)
++local s = assert(ctx:socket(zmq.SUB))
++assert(s:setopt(zmq.SUBSCRIBE, ""))
++assert(s:bind(bind_to))
+
+ print(string.format("message size: %i [B]", message_size))
+ print(string.format("message count: %i", message_count))
diff --git a/perf/local_thr_poll.lua b/perf/local_thr_poll.lua
new file mode 100644
-index 0000000..bfe0d33
+index 0000000..2c3b7a4
--- /dev/null
+++ b/perf/local_thr_poll.lua
@@ -0,0 +1,77 @@
@@ -1765,9 +1917,9 @@ index 0000000..bfe0d33
+local poller = z_poller(64)
+
+local ctx = zmq.init(1)
-+local s = ctx:socket(zmq.SUB)
-+s:setopt(zmq.SUBSCRIBE, "");
-+s:bind(bind_to)
++local s = assert(ctx:socket(zmq.SUB))
++assert(s:setopt(zmq.SUBSCRIBE, ""))
++assert(s:bind(bind_to))
+
+print(string.format("message size: %i [B]", message_size))
+print(string.format("message count: %i", message_count))
@@ -1808,7 +1960,7 @@ index 0000000..bfe0d33
+
diff --git a/perf/local_thr_push_pull.lua b/perf/local_thr_push_pull.lua
new file mode 100644
-index 0000000..9b2dee2
+index 0000000..727c94c
--- /dev/null
+++ b/perf/local_thr_push_pull.lua
@@ -0,0 +1,62 @@
@@ -1844,8 +1996,8 @@ index 0000000..9b2dee2
+local zmq = require"zmq"
+
+local ctx = zmq.init(1)
-+local s = ctx:socket(zmq.PULL)
-+s:bind(bind_to)
++local s = assert(ctx:socket(zmq.PULL))
++assert(s:bind(bind_to))
+
+print(string.format("message size: %i [B]", message_size))
+print(string.format("message count: %i", message_count))
@@ -1875,31 +2027,74 @@ index 0000000..9b2dee2
+print(string.format("mean throughput: %.3f [Mb/s]", megabits))
+
diff --git a/perf/remote_lat.lua b/perf/remote_lat.lua
-index 4376f60..ebcc680 100644
+index 4376f60..c426279 100644
--- a/perf/remote_lat.lua
+++ b/perf/remote_lat.lua
+@@ -30,8 +30,8 @@ local roundtrip_count = tonumber(arg[3])
+ local zmq = require"zmq"
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.REQ)
+-s:connect(connect_to)
++local s = assert(ctx:socket(zmq.REQ))
++assert(s:connect(connect_to))
+
+ local data = ("0"):rep(message_size)
+ local msg = zmq.zmq_msg_t.init_size(message_size)
@@ -54,3 +54,4 @@ local latency = elapsed / roundtrip_count / 2
print(string.format("message size: %i [B]", message_size))
print(string.format("roundtrip count: %i", roundtrip_count))
print(string.format("mean latency: %.3f [us]", latency))
+
+diff --git a/perf/remote_multipart.lua b/perf/remote_multipart.lua
+index f071555..004120e 100644
+--- a/perf/remote_multipart.lua
++++ b/perf/remote_multipart.lua
+@@ -31,8 +31,8 @@ local zmq = require"zmq"
+ local z_SNDMORE = zmq.SNDMORE
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.PUSH)
+-s:connect(connect_to)
++local s = assert(ctx:socket(zmq.PUSH))
++assert(s:connect(connect_to))
+
+ local data = ("0"):rep(message_size/2)
+ local msg = zmq.zmq_msg_t.init_size(message_size/2)
+diff --git a/perf/remote_push.lua b/perf/remote_push.lua
+index a37a189..ff26903 100644
+--- a/perf/remote_push.lua
++++ b/perf/remote_push.lua
+@@ -30,8 +30,8 @@ local message_count = tonumber(arg[3])
+ local zmq = require"zmq"
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.PUSH)
+-s:connect(connect_to)
++local s = assert(ctx:socket(zmq.PUSH))
++assert(s:connect(connect_to))
+
+ local data = ("0"):rep(message_size)
+ local msg = zmq.zmq_msg_t.init_size(message_size)
diff --git a/perf/remote_thr.lua b/perf/remote_thr.lua
-index 967e08b..5890508 100644
+index 967e08b..74cccb4 100644
--- a/perf/remote_thr.lua
+++ b/perf/remote_thr.lua
-@@ -31,8 +31,12 @@ local zmq = require"zmq"
+@@ -30,8 +30,12 @@ local message_count = tonumber(arg[3])
+ local zmq = require"zmq"
local ctx = zmq.init(1)
- local s = ctx:socket(zmq.PUB)
+-local s = ctx:socket(zmq.PUB)
+-s:connect(connect_to)
++local s = assert(ctx:socket(zmq.PUB))
+-- for ZeroMQ 3.x need to change HWM option.
-+s:set_hwm(0)
- s:connect(connect_to)
-
-+zmq.sleep(1)
++assert(s:set_hwm(0))
++assert(s:connect(connect_to))
+
++zmq.sleep(1)
+
local data = ("0"):rep(message_size)
local msg_data = zmq.zmq_msg_t.init_data(data)
- local msg = zmq.zmq_msg_t.init()
@@ -42,7 +46,6 @@ for i = 1, message_count do
assert(s:send_msg(msg))
end
@@ -1911,7 +2106,7 @@ index 967e08b..5890508 100644
+
diff --git a/perf/remote_thr_push_pull.lua b/perf/remote_thr_push_pull.lua
new file mode 100644
-index 0000000..11be905
+index 0000000..3604d6e
--- /dev/null
+++ b/perf/remote_thr_push_pull.lua
@@ -0,0 +1,49 @@
@@ -1947,8 +2142,8 @@ index 0000000..11be905
+local zmq = require"zmq"
+
+local ctx = zmq.init(1)
-+local s = ctx:socket(zmq.PUSH)
-+s:connect(connect_to)
++local s = assert(ctx:socket(zmq.PUSH))
++assert(s:connect(connect_to))
+
+zmq.sleep(1)
+
@@ -1965,9 +2160,20 @@ index 0000000..11be905
+ctx:term()
+
diff --git a/perf/thread_lat.lua b/perf/thread_lat.lua
-index 93ed691..f781e55 100644
+index 93ed691..3f04689 100644
--- a/perf/thread_lat.lua
+++ b/perf/thread_lat.lua
+@@ -52,8 +52,8 @@ local child_code = [[
+ ]]
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.REQ)
+-s:bind(bind_to)
++local s = assert(ctx:socket(zmq.REQ))
++assert(s:bind(bind_to))
+
+ local child_thread = zthreads.runstring(ctx, child_code, connect_to, message_size, roundtrip_count)
+ child_thread:start()
@@ -64,6 +64,8 @@ local msg = zmq.zmq_msg_t.init_size(message_size)
print(string.format("message size: %i [B]", message_size))
print(string.format("roundtrip count: %i", roundtrip_count))
@@ -1986,11 +2192,19 @@ index 93ed691..f781e55 100644
+print(string.format("msg/sec = %f", roundtrip_count / secs))
diff --git a/perf/thread_push_pull.lua b/perf/thread_push_pull.lua
-index f69ff48..b3d96cb 100644
+index f69ff48..5030172 100644
--- a/perf/thread_push_pull.lua
+++ b/perf/thread_push_pull.lua
-@@ -42,12 +42,13 @@ local child_code = [[
- s:connect(connect_to)
+@@ -37,17 +37,18 @@ local child_code = [[
+ local zthreads = require"zmq.threads"
+
+ local ctx = zthreads.get_parent_ctx()
+- local s = ctx:socket(zmq.PUSH)
+- s:setopt(zmq.HWM, message_count/4)
+- s:connect(connect_to)
++ local s = assert(ctx:socket(zmq.PUSH))
++ assert(s:setopt(zmq.HWM, message_count/4))
++ assert(s:connect(connect_to))
local data = ("0"):rep(message_size)
- local msg = zmq.zmq_msg_t.init_size(message_size)
@@ -2005,19 +2219,58 @@ index f69ff48..b3d96cb 100644
assert(s:send_msg(msg))
end
+@@ -67,8 +68,8 @@ local child_code = [[
+ ]]
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.PULL)
+-s:bind(bind_to)
++local s = assert(ctx:socket(zmq.PULL))
++assert(s:bind(bind_to))
+
+ print(string.format("message size: %i [B]", message_size))
+ print(string.format("message count: %i", message_count))
diff --git a/perf/thread_thr.lua b/perf/thread_thr.lua
-index 7b9183a..d3958e8 100644
+index 7b9183a..a7a5d11 100644
--- a/perf/thread_thr.lua
+++ b/perf/thread_thr.lua
-@@ -38,6 +38,8 @@ local child_code = [[
+@@ -24,8 +24,8 @@ end
+
+ local message_size = tonumber(arg[1] or 1)
+ local message_count = tonumber(arg[2] or 100000)
+-local bind_to = arg[3] or 'inproc://thread_lat_test'
+-local connect_to = arg[4] or 'inproc://thread_lat_test'
++local bind_to = arg[3] or 'inproc://thread_thr_test'
++local connect_to = arg[4] or 'inproc://thread_thr_test'
+
+ local zmq = require"zmq"
+ local zthreads = require"zmq.threads"
+@@ -37,8 +37,10 @@ local child_code = [[
+ local zthreads = require"zmq.threads"
local ctx = zthreads.get_parent_ctx()
- local s = ctx:socket(zmq.PUB)
+- local s = ctx:socket(zmq.PUB)
+- s:connect(connect_to)
++ local s = assert(ctx:socket(zmq.PUB))
+ -- for ZeroMQ 3.x need to change HWM option.
-+ s:set_hwm(0)
- s:connect(connect_to)
++ assert(s:set_hwm(0))
++ assert(s:connect(connect_to))
local data = ("0"):rep(message_size)
+ local msg_data = zmq.zmq_msg_t.init_data(data)
+@@ -67,9 +69,9 @@ local child_code = [[
+ ]]
+
+ local ctx = zmq.init(1)
+-local s = ctx:socket(zmq.SUB)
+-s:setopt(zmq.SUBSCRIBE, "");
+-s:bind(bind_to)
++local s = assert(ctx:socket(zmq.SUB))
++assert(s:setopt(zmq.SUBSCRIBE, ""))
++assert(s:bind(bind_to))
+
+ print(string.format("message size: %i [B]", message_size))
+ print(string.format("message count: %i", message_count))
diff --git a/rockspecs/lua-zmq-scm-1.rockspec b/rockspecs/lua-zmq-scm-1.rockspec
index 10737b7..b3cd3c6 100644
--- a/rockspecs/lua-zmq-scm-1.rockspec
@@ -2080,7 +2333,7 @@ index 0000000..5e3e0e1
+ },
+}
diff --git a/src/ctx.nobj.lua b/src/ctx.nobj.lua
-index adc0c42..246b653 100644
+index adc0c42..694520f 100644
--- a/src/ctx.nobj.lua
+++ b/src/ctx.nobj.lua
@@ -19,6 +19,7 @@
@@ -2091,6 +2344,20 @@ index adc0c42..246b653 100644
error_on_null = "get_zmq_strerror()",
c_source [[
typedef struct ZMQ_Ctx ZMQ_Ctx;
+@@ -35,5 +36,13 @@ typedef struct ZMQ_Ctx ZMQ_Ctx;
+ method "socket" {
+ c_method_call "!ZMQ_Socket *" "zmq_socket" { "int", "type"}
+ },
++ method "set" {
++ if_defs = { "VERSION_3_2" },
++ c_method_call "int" "zmq_ctx_set" { "int", "flag", "int", "value" }
++ },
++ method "get" {
++ if_defs = { "VERSION_3_2" },
++ c_method_call "int" "zmq_ctx_get" { "int", "flag" }
++ },
+ }
+
diff --git a/src/error.nobj.lua b/src/error.nobj.lua
index 4e353f3..b5559c7 100644
--- a/src/error.nobj.lua
@@ -2576,7 +2843,7 @@ index 8c77337..2ca40ea 100644
+return setmetatable(M, {__call = function(tab, ...) return M.new(...) end})
diff --git a/src/poller.nobj.lua b/src/poller.nobj.lua
-index 66594d2..39b4938 100644
+index 66594d2..fc51ac9 100644
--- a/src/poller.nobj.lua
+++ b/src/poller.nobj.lua
@@ -58,7 +58,24 @@ static int poller_resize_items(ZMQ_Poller *poller, int len) {
@@ -2726,13 +2993,14 @@ index 66594d2..39b4938 100644
},
method "add" {
var_in{ "<any>", "sock" },
-@@ -266,6 +300,22 @@ int zmq_poll(zmq_pollitem_t *items, int nitems, long timeout);
+@@ -266,6 +300,23 @@ int zmq_poll(zmq_pollitem_t *items, int nitems, long timeout);
item->fd = fd;
item->events = ${events};
]],
+ ffi_source[[
+ local fd = 0
+ local sock_type = type(${sock})
++ local sock
+ if sock_type == 'cdata' then
+ sock = obj_type_ZMQ_Socket_check(${sock})
+ elseif sock_type == 'number' then
@@ -2749,13 +3017,14 @@ index 66594d2..39b4938 100644
},
method "modify" {
var_in{ "<any>", "sock" },
-@@ -302,123 +352,99 @@ int zmq_poll(zmq_pollitem_t *items, int nitems, long timeout);
+@@ -302,123 +353,101 @@ int zmq_poll(zmq_pollitem_t *items, int nitems, long timeout);
poller_remove_item(${this}, ${idx});
}
]],
+ ffi_source[[
+ local fd = 0
+ local sock_type = type(${sock})
++ local sock
+ if sock_type == 'cdata' then
+ sock = obj_type_ZMQ_Socket_check(${sock})
+ -- find sock in items list.
@@ -2810,6 +3079,7 @@ index 66594d2..39b4938 100644
+ ffi_source[[
+ local fd = 0
+ local sock_type = type(${sock})
++ local sock
+ if sock_type == 'cdata' then
+ sock = obj_type_ZMQ_Socket_check(${sock})
+ -- find sock in items list.
@@ -2929,7 +3199,7 @@ index 66594d2..39b4938 100644
method "count" {
var_out{ "int", "count" },
diff --git a/src/pre_generated-zmq.nobj.c b/src/pre_generated-zmq.nobj.c
-index a6d739d..7442736 100644
+index a6d739d..081807f 100644
--- a/src/pre_generated-zmq.nobj.c
+++ b/src/pre_generated-zmq.nobj.c
@@ -10,16 +10,65 @@
@@ -3093,7 +3363,7 @@ index a6d739d..7442736 100644
} reg_sub_module;
#define OBJ_UDATA_FLAG_OWN (1<<0)
-@@ -188,15 +259,78 @@ typedef struct obj_udata {
+@@ -188,15 +259,95 @@ typedef struct obj_udata {
} obj_udata;
/* use static pointer as key to weak userdata table. */
@@ -3120,6 +3390,7 @@ index a6d739d..7442736 100644
+#define VERSION_2_1 0
+#define VERSION_2_2 0
+#define VERSION_3_0 0
++#define VERSION_3_2 0
+#if defined(ZMQ_VERSION_MAJOR)
+# if (ZMQ_VERSION_MAJOR == 2) && (ZMQ_VERSION_MINOR == 2)
+# undef VERSION_2_2
@@ -3131,6 +3402,22 @@ index a6d739d..7442736 100644
+# undef VERSION_2_1
+# define VERSION_2_1 1
+# endif
++# if (ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR == 3)
++# undef VERSION_2_0
++# define VERSION_2_0 0
++# undef VERSION_3_2
++# define VERSION_3_2 1
++# undef VERSION_3_0
++# define VERSION_3_0 1
++# endif
++# if (ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR == 2)
++# undef VERSION_2_0
++# define VERSION_2_0 0
++# undef VERSION_3_2
++# define VERSION_3_2 1
++# undef VERSION_3_0
++# define VERSION_3_0 1
++# endif
+# if (ZMQ_VERSION_MAJOR == 3)
+# undef VERSION_2_0
+# define VERSION_2_0 0
@@ -3174,7 +3461,7 @@ index a6d739d..7442736 100644
typedef int ZMQ_Error;
-@@ -204,29 +338,329 @@ static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err);
+@@ -204,29 +355,329 @@ static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err);
static obj_type obj_types[] = {
@@ -3514,7 +3801,7 @@ index a6d739d..7442736 100644
#ifndef REG_OBJECTS_AS_GLOBALS
#define REG_OBJECTS_AS_GLOBALS 0
#endif
-@@ -235,6 +669,48 @@ static obj_type obj_types[] = {
+@@ -235,6 +686,48 @@ static obj_type obj_types[] = {
#define OBJ_DATA_HIDDEN_METATABLE 1
#endif
@@ -3563,7 +3850,7 @@ index a6d739d..7442736 100644
static FUNC_UNUSED obj_udata *obj_udata_toobj(lua_State *L, int _index) {
obj_udata *ud;
size_t len;
-@@ -245,7 +721,7 @@ static FUNC_UNUSED obj_udata *obj_udata_toobj(lua_State *L, int _index) {
+@@ -245,7 +738,7 @@ static FUNC_UNUSED obj_udata *obj_udata_toobj(lua_State *L, int _index) {
luaL_typerror(L, _index, "userdata"); /* is not a userdata value. */
}
/* verify userdata size. */
@@ -3572,7 +3859,7 @@ index a6d739d..7442736 100644
if(len != sizeof(obj_udata)) {
/* This shouldn't be possible */
luaL_error(L, "invalid userdata size: size=%d, expected=%d", len, sizeof(obj_udata));
-@@ -258,10 +734,23 @@ static FUNC_UNUSED int obj_udata_is_compatible(lua_State *L, obj_udata *ud, void
+@@ -258,10 +751,23 @@ static FUNC_UNUSED int obj_udata_is_compatible(lua_State *L, obj_udata *ud, void
obj_type *ud_type;
lua_pushlightuserdata(L, type);
lua_rawget(L, LUA_REGISTRYINDEX); /* type's metatable. */
@@ -3596,7 +3883,7 @@ index a6d739d..7442736 100644
} else {
/* Different types see if we can cast to the required type. */
lua_rawgeti(L, -2, type->id);
-@@ -314,6 +803,39 @@ static FUNC_UNUSED obj_udata *obj_udata_luacheck_internal(lua_State *L, int _ind
+@@ -314,6 +820,39 @@ static FUNC_UNUSED obj_udata *obj_udata_luacheck_internal(lua_State *L, int _ind
return ud;
}
}
@@ -3636,7 +3923,7 @@ index a6d739d..7442736 100644
}
if(not_delete) {
luaL_typerror(L, _index, type->name); /* is not a userdata value. */
-@@ -327,6 +849,15 @@ static FUNC_UNUSED void *obj_udata_luacheck(lua_State *L, int _index, obj_type *
+@@ -327,6 +866,15 @@ static FUNC_UNUSED void *obj_udata_luacheck(lua_State *L, int _index, obj_type *
return obj;
}
@@ -3652,7 +3939,7 @@ index a6d739d..7442736 100644
static FUNC_UNUSED void *obj_udata_luadelete(lua_State *L, int _index, obj_type *type, int *flags) {
void *obj;
obj_udata *ud = obj_udata_luacheck_internal(L, _index, &(obj), type, 0);
-@@ -335,6 +866,9 @@ static FUNC_UNUSED void *obj_udata_luadelete(lua_State *L, int _index, obj_type
+@@ -335,6 +883,9 @@ static FUNC_UNUSED void *obj_udata_luadelete(lua_State *L, int _index, obj_type
/* null userdata. */
ud->obj = NULL;
ud->flags = 0;
@@ -3662,7 +3949,7 @@ index a6d739d..7442736 100644
return obj;
}
-@@ -345,6 +879,17 @@ static FUNC_UNUSED void obj_udata_luapush(lua_State *L, void *obj, obj_type *typ
+@@ -345,6 +896,17 @@ static FUNC_UNUSED void obj_udata_luapush(lua_State *L, void *obj, obj_type *typ
lua_pushnil(L);
return;
}
@@ -3680,7 +3967,7 @@ index a6d739d..7442736 100644
/* check for type caster. */
if(type->dcaster) {
(type->dcaster)(&obj, &type);
-@@ -354,8 +899,12 @@ static FUNC_UNUSED void obj_udata_luapush(lua_State *L, void *obj, obj_type *typ
+@@ -354,8 +916,12 @@ static FUNC_UNUSED void obj_udata_luapush(lua_State *L, void *obj, obj_type *typ
ud->obj = obj;
ud->flags = flags;
/* get obj_type metatable. */
@@ -3693,7 +3980,7 @@ index a6d739d..7442736 100644
lua_setmetatable(L, -2);
}
-@@ -367,6 +916,9 @@ static FUNC_UNUSED void *obj_udata_luadelete_weak(lua_State *L, int _index, obj_
+@@ -367,6 +933,9 @@ static FUNC_UNUSED void *obj_udata_luadelete_weak(lua_State *L, int _index, obj_
/* null userdata. */
ud->obj = NULL;
ud->flags = 0;
@@ -3703,7 +3990,7 @@ index a6d739d..7442736 100644
/* get objects weak table. */
lua_pushlightuserdata(L, obj_udata_weak_ref_key);
lua_rawget(L, LUA_REGISTRYINDEX); /* weak ref table. */
-@@ -401,6 +953,18 @@ static FUNC_UNUSED void obj_udata_luapush_weak(lua_State *L, void *obj, obj_type
+@@ -401,6 +970,18 @@ static FUNC_UNUSED void obj_udata_luapush_weak(lua_State *L, void *obj, obj_type
}
lua_pop(L, 1); /* pop nil. */
@@ -3722,7 +4009,7 @@ index a6d739d..7442736 100644
/* create new userdata. */
ud = (obj_udata *)lua_newuserdata(L, sizeof(obj_udata));
-@@ -408,8 +972,12 @@ static FUNC_UNUSED void obj_udata_luapush_weak(lua_State *L, void *obj, obj_type
+@@ -408,8 +989,12 @@ static FUNC_UNUSED void obj_udata_luapush_weak(lua_State *L, void *obj, obj_type
ud->obj = obj;
ud->flags = flags;
/* get obj_type metatable. */
@@ -3735,7 +4022,7 @@ index a6d739d..7442736 100644
lua_setmetatable(L, -2);
/* add weak reference to object. */
-@@ -468,9 +1036,53 @@ static FUNC_UNUSED void * obj_simple_udata_luacheck(lua_State *L, int _index, ob
+@@ -468,9 +1053,53 @@ static FUNC_UNUSED void * obj_simple_udata_luacheck(lua_State *L, int _index, ob
if(lua_getmetatable(L, _index)) {
lua_pushlightuserdata(L, type);
lua_rawget(L, LUA_REGISTRYINDEX); /* type's metatable. */
@@ -3789,7 +4076,7 @@ index a6d739d..7442736 100644
}
}
}
-@@ -478,10 +1090,16 @@ static FUNC_UNUSED void * obj_simple_udata_luacheck(lua_State *L, int _index, ob
+@@ -478,10 +1107,16 @@ static FUNC_UNUSED void * obj_simple_udata_luacheck(lua_State *L, int _index, ob
return NULL;
}
@@ -3808,7 +4095,7 @@ index a6d739d..7442736 100644
/* clear the metatable to invalidate userdata. */
lua_pushnil(L);
lua_setmetatable(L, _index);
-@@ -490,12 +1108,27 @@ static FUNC_UNUSED void * obj_simple_udata_luadelete(lua_State *L, int _index, o
+@@ -490,12 +1125,27 @@ static FUNC_UNUSED void * obj_simple_udata_luadelete(lua_State *L, int _index, o
static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int size, obj_type *type)
{
@@ -3837,7 +4124,7 @@ index a6d739d..7442736 100644
lua_setmetatable(L, -2);
return ud;
-@@ -504,9 +1137,9 @@ static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int s
+@@ -504,9 +1154,9 @@ static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int s
/* default simple object equal method. */
static FUNC_UNUSED int obj_simple_udata_default_equal(lua_State *L) {
void *ud1 = obj_simple_udata_toobj(L, 1);
@@ -3849,7 +4136,7 @@ index a6d739d..7442736 100644
if(len1 == len2) {
lua_pushboolean(L, (memcmp(ud1, ud2, len1) == 0));
-@@ -544,7 +1177,8 @@ static int obj_constructor_call_wrapper(lua_State *L) {
+@@ -544,7 +1194,8 @@ static int obj_constructor_call_wrapper(lua_State *L) {
return lua_gettop(L);
}
@@ -3859,7 +4146,7 @@ index a6d739d..7442736 100644
/* register constants. */
while(constants->name != NULL) {
lua_pushstring(L, constants->name);
-@@ -562,40 +1196,84 @@ static void obj_type_register_constants(lua_State *L, const obj_const *constants
+@@ -562,40 +1213,84 @@ static void obj_type_register_constants(lua_State *L, const obj_const *constants
lua_pushnil(L);
break;
}
@@ -3950,7 +4237,7 @@ index a6d739d..7442736 100644
/* make public API table callable as the default constructor. */
lua_newtable(L); /* create metatable */
-@@ -625,7 +1303,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
+@@ -625,7 +1320,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
#endif
}
@@ -3959,7 +4246,7 @@ index a6d739d..7442736 100644
luaL_newmetatable(L, type->name); /* create metatable */
lua_pushliteral(L, ".name");
-@@ -638,16 +1316,12 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
+@@ -638,16 +1333,12 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
lua_pushvalue(L, -2); /* dup metatable. */
lua_rawset(L, LUA_REGISTRYINDEX); /* REGISTRY[type] = metatable */
@@ -3977,7 +4264,7 @@ index a6d739d..7442736 100644
/* add obj_bases to metatable. */
while(base->id >= 0) {
-@@ -656,7 +1330,9 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
+@@ -656,7 +1347,9 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
base++;
}
@@ -3988,7 +4275,7 @@ index a6d739d..7442736 100644
lua_pushliteral(L, "__index");
lua_pushvalue(L, -3); /* dup methods table */
-@@ -676,62 +1352,193 @@ static FUNC_UNUSED int lua_checktype_ref(lua_State *L, int _index, int _type) {
+@@ -676,62 +1369,193 @@ static FUNC_UNUSED int lua_checktype_ref(lua_State *L, int _index, int _type) {
return luaL_ref(L, LUA_REGISTRYINDEX);
}
@@ -4103,57 +4390,57 @@ index a6d739d..7442736 100644
+
+
+
-+typedef struct MutableBuffer_if {
-+ uint8_t * (* const data)(void *this_v);
++typedef struct Buffer_if {
++ const uint8_t * (* const const_data)(void *this_v);
+ size_t (* const get_size)(void *this_v);
-+} MutableBufferIF;
++} BufferIF;
+
+/* a per-module unique pointer for fast lookup of an interface's implementation table. */
-+static char obj_interface_MutableBufferIF[] = "MutableBufferIF";
++static char obj_interface_BufferIF[] = "BufferIF";
+
-+#define MutableBufferIF_VAR(var_name) \
-+ MutableBufferIF *var_name ## _if; \
++#define BufferIF_VAR(var_name) \
++ BufferIF *var_name ## _if; \
+ void *var_name;
+
-+#define MutableBufferIF_LUA_OPTIONAL(L, _index, var_name) \
++#define BufferIF_LUA_OPTIONAL(L, _index, var_name) \
+ var_name = obj_implement_luaoptional(L, _index, (void **)&(var_name ## _if), \
-+ obj_interface_MutableBufferIF)
++ obj_interface_BufferIF)
+
-+#define MutableBufferIF_LUA_CHECK(L, _index, var_name) \
++#define BufferIF_LUA_CHECK(L, _index, var_name) \
+ var_name = obj_implement_luacheck(L, _index, (void **)&(var_name ## _if), \
-+ obj_interface_MutableBufferIF)
++ obj_interface_BufferIF)
+
+
+
+
+
+
-+typedef struct Buffer_if {
-+ const uint8_t * (* const const_data)(void *this_v);
++typedef struct MutableBuffer_if {
++ uint8_t * (* const data)(void *this_v);
+ size_t (* const get_size)(void *this_v);
-+} BufferIF;
++} MutableBufferIF;
+
+/* a per-module unique pointer for fast lookup of an interface's implementation table. */
-+static char obj_interface_BufferIF[] = "BufferIF";
++static char obj_interface_MutableBufferIF[] = "MutableBufferIF";
+
-+#define BufferIF_VAR(var_name) \
-+ BufferIF *var_name ## _if; \
++#define MutableBufferIF_VAR(var_name) \
++ MutableBufferIF *var_name ## _if; \
+ void *var_name;
+
-+#define BufferIF_LUA_OPTIONAL(L, _index, var_name) \
++#define MutableBufferIF_LUA_OPTIONAL(L, _index, var_name) \
+ var_name = obj_implement_luaoptional(L, _index, (void **)&(var_name ## _if), \
-+ obj_interface_BufferIF)
++ obj_interface_MutableBufferIF)
+
-+#define BufferIF_LUA_CHECK(L, _index, var_name) \
++#define MutableBufferIF_LUA_CHECK(L, _index, var_name) \
+ var_name = obj_implement_luacheck(L, _index, (void **)&(var_name ## _if), \
-+ obj_interface_BufferIF)
++ obj_interface_MutableBufferIF)
+
+
+
+
+static char *obj_interfaces[] = {
-+ obj_interface_MutableBufferIF,
+ obj_interface_BufferIF,
++ obj_interface_MutableBufferIF,
+ NULL,
+};
+
@@ -4224,7 +4511,7 @@ index a6d739d..7442736 100644
#define obj_type_ZMQ_Socket_delete(L, _index, flags) \
obj_udata_luadelete_weak(L, _index, &(obj_type_ZMQ_Socket), flags)
#define obj_type_ZMQ_Socket_push(L, obj, flags) \
-@@ -739,13 +1546,17 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
+@@ -739,13 +1563,17 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
#define obj_type_ZMQ_Poller_check(L, _index) \
(ZMQ_Poller *)obj_simple_udata_luacheck(L, _index, &(obj_type_ZMQ_Poller))
@@ -4245,7 +4532,7 @@ index a6d739d..7442736 100644
#define obj_type_ZMQ_Ctx_delete(L, _index, flags) \
obj_udata_luadelete_weak(L, _index, &(obj_type_ZMQ_Ctx), flags)
#define obj_type_ZMQ_Ctx_push(L, obj, flags) \
-@@ -753,6 +1564,8 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
+@@ -753,6 +1581,8 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
#define obj_type_ZMQ_StopWatch_check(L, _index) \
obj_udata_luacheck(L, _index, &(obj_type_ZMQ_StopWatch))
@@ -4254,7 +4541,7 @@ index a6d739d..7442736 100644
#define obj_type_ZMQ_StopWatch_delete(L, _index, flags) \
obj_udata_luadelete_weak(L, _index, &(obj_type_ZMQ_StopWatch), flags)
#define obj_type_ZMQ_StopWatch_push(L, obj, flags) \
-@@ -761,30 +1574,83 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
+@@ -761,30 +1591,71 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
@@ -4270,19 +4557,7 @@ index a6d739d..7442736 100644
+" return assert(ffi_safe_load(name, global))\n"
+"end\n"
+"\n"
-+"local function ffi_string(ptr)\n"
-+" if ptr ~= nil then\n"
-+" return ffi.string(ptr)\n"
-+" end\n"
-+" return nil\n"
-+"end\n"
-+"\n"
-+"local function ffi_string_len(ptr, len)\n"
-+" if ptr ~= nil then\n"
-+" return ffi.string(ptr, len)\n"
-+" end\n"
-+" return nil\n"
-+"end\n"
++"local ffi_string = ffi.string\n"
+"\n"
+"local f_cast = ffi.cast\n"
+"local pcall = pcall\n"
@@ -4354,7 +4629,7 @@ index a6d739d..7442736 100644
"\n"
"local function ffi_safe_cdef(block_name, cdefs)\n"
" local fake_type = \"struct sentinel_\" .. block_name .. \"_ty\"\n"
-@@ -822,151 +1688,94 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
+@@ -822,151 +1693,101 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
" uint32_t flags; /**< lua_own:1bit */\n"
"} obj_udata;\n"
"\n"
@@ -4476,7 +4751,8 @@ index a6d739d..7442736 100644
+" if REG_OBJECTS_AS_GLOBALS then\n"
+" _G[obj_name] = obj_pub\n"
" end\n"
--"\n"
++"end\n"
+ "\n"
-" -- lookup object in weak ref. table.\n"
-" local obj_key = tonumber(ffi.cast('uintptr_t', obj))\n"
-" local ud_obj = weak_objects[obj_key]\n"
@@ -4491,25 +4767,8 @@ index a6d739d..7442736 100644
-"\n"
-" -- cache weak reference to object.\n"
-" weak_objects[obj_key] = ud_obj\n"
--"\n"
--" return ud_obj\n"
- "end\n"
- "\n"
--"local function obj_simple_udata_luacheck(ud_obj, type_mt)\n"
--" local obj_mt = d_getmetatable(ud_obj)\n"
--" if obj_mt == type_mt then\n"
--" -- convert userdata to cdata.\n"
--" return ffi.cast(\"void *\", ud_obj)\n"
--" end\n"
--" error(\"(expected `\" .. type_mt['.name'] .. \"`, got \" .. type(ud_obj) .. \")\", 3)\n"
--"end\n"
"\n"
--"local function obj_simple_udata_to_cdata(objects, ud_obj, c_type, ud_mt)\n"
--" -- convert userdata to cdata.\n"
--" local c_obj = ffi.cast(c_type, obj_simple_udata_luacheck(ud_obj, ud_mt))\n"
--" -- cache converted cdata\n"
--" rawset(objects, ud_obj, c_obj)\n"
--" return c_obj\n"
+-" return ud_obj\n"
+"-- detect zmq version\n"
+"local VERSION_2_0 = true\n"
+"local VERSION_2_1 = false\n"
@@ -4526,29 +4785,51 @@ index a6d739d..7442736 100644
+" VERSION_2_1 = true\n"
"end\n"
"\n"
--"local function obj_simple_udata_luadelete(ud_obj, type_mt)\n"
--" local c_obj = obj_simple_udata_luacheck(ud_obj, type_mt)\n"
--" -- invalid userdata, by setting the metatable to nil.\n"
--" d_setmetatable(ud_obj, nil)\n"
--" return c_obj, OBJ_UDATA_FLAG_OWN\n"
+-"local function obj_simple_udata_luacheck(ud_obj, type_mt)\n"
+-" local obj_mt = d_getmetatable(ud_obj)\n"
+-" if obj_mt == type_mt then\n"
+-" -- convert userdata to cdata.\n"
+-" return ffi.cast(\"void *\", ud_obj)\n"
+-" end\n"
+-" error(\"(expected `\" .. type_mt['.name'] .. \"`, got \" .. type(ud_obj) .. \")\", 3)\n"
+-"end\n"
+"if VERSION_2_0 then\n"
+" ffi.cdef[==[\n"
+"typedef int ZMQ_Error;\n"
+"typedef struct ZMQ_Socket ZMQ_Socket;\n"
+"typedef struct zmq_msg_t zmq_msg_t;\n"
-+"\n"
+ "\n"
+-"local function obj_simple_udata_to_cdata(objects, ud_obj, c_type, ud_mt)\n"
+-" -- convert userdata to cdata.\n"
+-" local c_obj = ffi.cast(c_type, obj_simple_udata_luacheck(ud_obj, ud_mt))\n"
+-" -- cache converted cdata\n"
+-" rawset(objects, ud_obj, c_obj)\n"
+-" return c_obj\n"
+"ZMQ_Error zmq_sendmsg(ZMQ_Socket *sock, zmq_msg_t *msg, int flags) __asm__(\"zmq_send\");\n"
+"ZMQ_Error zmq_recvmsg(ZMQ_Socket *sock, zmq_msg_t *msg, int flags) __asm__(\"zmq_recv\");\n"
+"]==]\n"
"end\n"
"\n"
+-"local function obj_simple_udata_luadelete(ud_obj, type_mt)\n"
+-" local c_obj = obj_simple_udata_luacheck(ud_obj, type_mt)\n"
+-" -- invalid userdata, by setting the metatable to nil.\n"
+-" d_setmetatable(ud_obj, nil)\n"
+-" return c_obj, OBJ_UDATA_FLAG_OWN\n"
+-"end\n"
++"ffi_safe_cdef(\"BufferIF\", [[\n"
++"typedef struct Buffer_if {\n"
++" const uint8_t * (* const const_data)(void *this_v);\n"
++" size_t (* const get_size)(void *this_v);\n"
++"} BufferIF;\n"
++"]])\n"
+ "\n"
-"local function obj_simple_udata_luapush(c_obj, size, type_mt)\n"
-" if c_obj == nil then return end\n"
-+"ffi_safe_cdef(\"MutableBufferIF\", [[\n"
-+"typedef struct MutableBuffer_if {\n"
-+" uint8_t * (* const data)(void *this_v);\n"
-+" size_t (* const get_size)(void *this_v);\n"
-+"} MutableBufferIF;\n"
++"ffi_safe_cdef(\"FDIF\", [[\n"
++"typedef struct FD_if {\n"
++" int (* const get_fd)(void *this_v);\n"
++" int (* const get_type)(void *this_v);\n"
++"} FDIF;\n"
+"]])\n"
"\n"
-" -- create new userdata\n"
@@ -4556,11 +4837,11 @@ index a6d739d..7442736 100644
-" local cdata = ffi.cast(\"void *\", ud_obj)\n"
-" -- init. object\n"
-" ffi.copy(cdata, c_obj, size)\n"
-+"ffi_safe_cdef(\"BufferIF\", [[\n"
-+"typedef struct Buffer_if {\n"
-+" const uint8_t * (* const const_data)(void *this_v);\n"
++"ffi_safe_cdef(\"MutableBufferIF\", [[\n"
++"typedef struct MutableBuffer_if {\n"
++" uint8_t * (* const data)(void *this_v);\n"
+" size_t (* const get_size)(void *this_v);\n"
-+"} BufferIF;\n"
++"} MutableBufferIF;\n"
+"]])\n"
"\n"
-" return ud_obj, cdata\n"
@@ -4574,7 +4855,7 @@ index a6d739d..7442736 100644
"typedef struct zmq_msg_t zmq_msg_t;\n"
"typedef struct ZMQ_Socket ZMQ_Socket;\n"
"typedef struct ZMQ_Poller ZMQ_Poller;\n"
-@@ -976,9 +1785,7 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
+@@ -976,9 +1797,7 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
"]]\n"
"\n"
"ffi.cdef[[\n"
@@ -4585,7 +4866,7 @@ index a6d739d..7442736 100644
"\n"
"\n"
"struct zmq_msg_t\n"
-@@ -989,39 +1796,134 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
+@@ -989,39 +1808,138 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
" unsigned char vsm_data [30]; /* that '30' is from 'MAX_VSM_SIZE' */\n"
"};\n"
"\n"
@@ -4598,32 +4879,36 @@ index a6d739d..7442736 100644
"\n"
-"ZMQ_Error zmq_msg_close(zmq_msg_t * this1);\n"
+"ZMQ_Error zmq_msg_init(zmq_msg_t *);\n"
++"\n"
++"ZMQ_Error zmq_msg_init_size(zmq_msg_t *, size_t);\n"
++"\n"
++"ZMQ_Error zmq_msg_close(zmq_msg_t *);\n"
++"\n"
++"ZMQ_Error zmq_msg_move(zmq_msg_t *, zmq_msg_t *);\n"
"\n"
-"ZMQ_Error zmq_msg_close(zmq_msg_t * this1);\n"
-+"ZMQ_Error zmq_msg_init_size(zmq_msg_t *, size_t);\n"
++"ZMQ_Error zmq_msg_copy(zmq_msg_t *, zmq_msg_t *);\n"
"\n"
-"ZMQ_Error zmq_msg_move(zmq_msg_t * this1, zmq_msg_t * src2);\n"
-+"ZMQ_Error zmq_msg_close(zmq_msg_t *);\n"
++"void * zmq_msg_data(zmq_msg_t *);\n"
"\n"
-"ZMQ_Error zmq_msg_copy(zmq_msg_t * this1, zmq_msg_t * src2);\n"
-+"ZMQ_Error zmq_msg_move(zmq_msg_t *, zmq_msg_t *);\n"
++"size_t zmq_msg_size(zmq_msg_t *);\n"
"\n"
-"void * zmq_msg_data(zmq_msg_t * this1);\n"
-+"ZMQ_Error zmq_msg_copy(zmq_msg_t *, zmq_msg_t *);\n"
++"ZMQ_Error zmq_close(ZMQ_Socket *);\n"
"\n"
-"size_t zmq_msg_size(zmq_msg_t * this1);\n"
-+"void * zmq_msg_data(zmq_msg_t *);\n"
++"ZMQ_Error zmq_bind(ZMQ_Socket *, const char *);\n"
"\n"
-"ZMQ_Error zmq_close(ZMQ_Socket * this1);\n"
-+"size_t zmq_msg_size(zmq_msg_t *);\n"
++"ZMQ_Error zmq_unbind(ZMQ_Socket *, const char *);\n"
"\n"
-"ZMQ_Error zmq_bind(ZMQ_Socket * this1, const char * addr2);\n"
-+"ZMQ_Error zmq_close(ZMQ_Socket *);\n"
++"ZMQ_Error zmq_connect(ZMQ_Socket *, const char *);\n"
"\n"
-"ZMQ_Error zmq_connect(ZMQ_Socket * this1, const char * addr2);\n"
-+"ZMQ_Error zmq_bind(ZMQ_Socket *, const char *);\n"
-+"\n"
-+"ZMQ_Error zmq_connect(ZMQ_Socket *, const char *);\n"
++"ZMQ_Error zmq_disconnect(ZMQ_Socket *, const char *);\n"
"\n"
"int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);\n"
"int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);\n"
@@ -4680,17 +4965,17 @@ index a6d739d..7442736 100644
+"ZMQ_Error lzmq_socket_fd(ZMQ_Socket *, int*);\n"
+"\n"
+"ZMQ_Error lzmq_socket_events(ZMQ_Socket *, int*);\n"
- "\n"
--"typedef ZMQ_Error (*simple_zmq_send_func)(ZMQ_Socket *sock, const char *data, size_t data_len, int flags);\n"
++"\n"
+"ZMQ_Error lzmq_socket_type(ZMQ_Socket *, int*);\n"
- "\n"
--"ZMQ_Error zmq_recv(ZMQ_Socket * this1, zmq_msg_t * msg2, int flags3);\n"
++"\n"
+"ZMQ_Error lzmq_socket_linger(ZMQ_Socket *, int*);\n"
+"\n"
+"ZMQ_Error lzmq_socket_set_linger(ZMQ_Socket *, int);\n"
-+"\n"
+ "\n"
+-"typedef ZMQ_Error (*simple_zmq_send_func)(ZMQ_Socket *sock, const char *data, size_t data_len, int flags);\n"
+"ZMQ_Error lzmq_socket_reconnect_ivl(ZMQ_Socket *, int*);\n"
-+"\n"
+ "\n"
+-"ZMQ_Error zmq_recv(ZMQ_Socket * this1, zmq_msg_t * msg2, int flags3);\n"
+"ZMQ_Error lzmq_socket_set_reconnect_ivl(ZMQ_Socket *, int);\n"
+"\n"
+"ZMQ_Error lzmq_socket_backlog(ZMQ_Socket *, int*);\n"
@@ -4735,7 +5020,7 @@ index a6d739d..7442736 100644
"\n"
"typedef int socket_t;\n"
"typedef struct zmq_pollitem_t {\n"
-@@ -1031,7 +1933,12 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
+@@ -1031,7 +1949,12 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
" short revents;\n"
"} zmq_pollitem_t;\n"
"\n"
@@ -4749,43 +5034,47 @@ index a6d739d..7442736 100644
"\n"
"struct ZMQ_Poller {\n"
" zmq_pollitem_t *items;\n"
-@@ -1041,616 +1948,823 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
+@@ -1041,616 +1964,862 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
" int len;\n"
"};\n"
"\n"
-"typedef int (*poller_find_sock_item_func)(ZMQ_Poller *poller, ZMQ_Socket *sock);\n"
+"void poller_init(ZMQ_Poller *, unsigned int);\n"
++"\n"
++"void poller_cleanup(ZMQ_Poller *);\n"
"\n"
-"typedef int (*poller_find_fd_item_func)(ZMQ_Poller *poller, socket_t fd);\n"
-+"void poller_cleanup(ZMQ_Poller *);\n"
++"ZMQ_Error poller_poll(ZMQ_Poller *, long);\n"
"\n"
-"typedef int (*poller_get_free_item_func)(ZMQ_Poller *poller);\n"
-+"ZMQ_Error poller_poll(ZMQ_Poller *, long);\n"
++"int poller_next_revents(ZMQ_Poller *, int*);\n"
"\n"
-"typedef int (*poller_poll_func)(ZMQ_Poller *poller, long timeout);\n"
-+"int poller_next_revents(ZMQ_Poller *, int*);\n"
++"ZMQ_Error zmq_term(ZMQ_Ctx *);\n"
"\n"
-"typedef void (*poller_remove_item_func)(ZMQ_Poller *poller, int idx);\n"
-+"ZMQ_Error zmq_term(ZMQ_Ctx *);\n"
++"ZMQ_Socket * zmq_socket(ZMQ_Ctx *, int);\n"
"\n"
-"ZMQ_Error zmq_term(ZMQ_Ctx * this1);\n"
--"\n"
++"int zmq_ctx_set(ZMQ_Ctx *, int, int);\n"
+ "\n"
-"ZMQ_Socket * zmq_socket(ZMQ_Ctx * this1, int type2);\n"
-+"ZMQ_Socket * zmq_socket(ZMQ_Ctx *, int);\n"
++"int zmq_ctx_get(ZMQ_Ctx *, int);\n"
"\n"
"ZMQ_StopWatch * zmq_stopwatch_start();\n"
"\n"
-"unsigned long zmq_stopwatch_stop(ZMQ_StopWatch * this1);\n"
--"\n"
--"ZMQ_Ctx * zmq_init(int io_threads1);\n"
+"unsigned long zmq_stopwatch_stop(ZMQ_StopWatch *);\n"
"\n"
--"ZMQ_Error zmq_device(int device1, ZMQ_Socket * insock2, ZMQ_Socket * outsock3);\n"
+-"ZMQ_Ctx * zmq_init(int io_threads1);\n"
+"ZMQ_Ctx * zmq_init(int);\n"
"\n"
--"ZMQ_StopWatch * zmq_stopwatch_start();\n"
+-"ZMQ_Error zmq_device(int device1, ZMQ_Socket * insock2, ZMQ_Socket * outsock3);\n"
+"ZMQ_Error zmq_device(int, ZMQ_Socket *, ZMQ_Socket *);\n"
"\n"
+-"ZMQ_StopWatch * zmq_stopwatch_start();\n"
++"ZMQ_Error zmq_proxy(ZMQ_Socket *, ZMQ_Socket *, ZMQ_Socket *);\n"
+ "\n"
-"void zmq_sleep(int seconds_1);\n"
+"void zmq_sleep(int);\n"
"\n"
@@ -4864,21 +5153,7 @@ index a6d739d..7442736 100644
+" return obj_mt, obj_type, obj_ctype\n"
"end\n"
-"end)()\n"
--"\n"
--"\n"
--"local obj_type_ZMQ_Socket_check\n"
--"local obj_type_ZMQ_Socket_delete\n"
--"local obj_type_ZMQ_Socket_push\n"
"\n"
--"(function()\n"
--"local ZMQ_Socket_mt = _priv.ZMQ_Socket\n"
--"local ZMQ_Socket_objects = setmetatable({}, { __mode = \"k\",\n"
--"__index = function(objects, ud_obj)\n"
--" return obj_udata_to_cdata(objects, ud_obj, \"ZMQ_Socket *\", ZMQ_Socket_mt)\n"
--"end,\n"
--"})\n"
--"function obj_type_ZMQ_Socket_check(ud_obj)\n"
--" return ZMQ_Socket_objects[ud_obj]\n"
+"--\n"
+"-- Interfaces helper code.\n"
+"--\n"
@@ -4890,11 +5165,21 @@ index a6d739d..7442736 100644
+" -- create missing interfaces table for FFI bindings.\n"
+" _obj_interfaces_ffi = {}\n"
+" reg_table[_obj_interfaces_key_ffi] = _obj_interfaces_ffi\n"
- "end\n"
++"end\n"
"\n"
--"function obj_type_ZMQ_Socket_delete(ud_obj)\n"
--" ZMQ_Socket_objects[ud_obj] = nil\n"
--" return obj_udata_luadelete_weak(ud_obj, ZMQ_Socket_mt)\n"
+-"local obj_type_ZMQ_Socket_check\n"
+-"local obj_type_ZMQ_Socket_delete\n"
+-"local obj_type_ZMQ_Socket_push\n"
+-"\n"
+-"(function()\n"
+-"local ZMQ_Socket_mt = _priv.ZMQ_Socket\n"
+-"local ZMQ_Socket_objects = setmetatable({}, { __mode = \"k\",\n"
+-"__index = function(objects, ud_obj)\n"
+-" return obj_udata_to_cdata(objects, ud_obj, \"ZMQ_Socket *\", ZMQ_Socket_mt)\n"
+-"end,\n"
+-"})\n"
+-"function obj_type_ZMQ_Socket_check(ud_obj)\n"
+-" return ZMQ_Socket_objects[ud_obj]\n"
+"local function obj_get_userdata_interface(if_name, expected_err)\n"
+" local impls_ud = _obj_interfaces_ud[if_name]\n"
+" if not impls_ud then\n"
@@ -4910,11 +5195,9 @@ index a6d739d..7442736 100644
+" return impls_ud\n"
"end\n"
"\n"
--"local ZMQ_Socket_type = ffi.cast(\"obj_type *\", ZMQ_Socket_mt[\".type\"])\n"
--"function obj_type_ZMQ_Socket_push(c_obj, flags)\n"
--" local ud_obj = obj_udata_luapush_weak(c_obj, ZMQ_Socket_mt, ZMQ_Socket_type, flags)\n"
--" ZMQ_Socket_objects[ud_obj] = c_obj\n"
--" return ud_obj\n"
+-"function obj_type_ZMQ_Socket_delete(ud_obj)\n"
+-" ZMQ_Socket_objects[ud_obj] = nil\n"
+-" return obj_udata_luadelete_weak(ud_obj, ZMQ_Socket_mt)\n"
+"local function obj_get_interface_check(if_name, expected_err)\n"
+" local impls_ffi = _obj_interfaces_ffi[if_name]\n"
+" if not impls_ffi then\n"
@@ -4946,12 +5229,31 @@ index a6d739d..7442736 100644
+" end\n"
+" return impls_ffi.check\n"
"end\n"
+ "\n"
+-"local ZMQ_Socket_type = ffi.cast(\"obj_type *\", ZMQ_Socket_mt[\".type\"])\n"
+-"function obj_type_ZMQ_Socket_push(c_obj, flags)\n"
+-" local ud_obj = obj_udata_luapush_weak(c_obj, ZMQ_Socket_mt, ZMQ_Socket_type, flags)\n"
+-" ZMQ_Socket_objects[ud_obj] = c_obj\n"
+-" return ud_obj\n"
++"local function obj_register_interface(if_name, obj_name)\n"
++" -- loopkup cdata id\n"
++" local obj_mt = _priv[obj_name]\n"
++" local obj_type_id = _ctype_meta_map[obj_mt]\n"
++" local impl_meths = {}\n"
++" local ffi_impls = _obj_interfaces_ffi[if_name]\n"
++" ffi_impls[obj_type_id] = impl_meths\n"
++" _meth[obj_name]['NOBJ_get_' .. if_name] = impl_meths\n"
++" return impl_meths\n"
+ "end\n"
-"end)()\n"
--"\n"
--"\n"
+ "\n"
+ "\n"
-"local obj_type_ZMQ_Poller_check\n"
-"local obj_type_ZMQ_Poller_delete\n"
-"local obj_type_ZMQ_Poller_push\n"
++"local obj_type_zmq_msg_t_check\n"
++"local obj_type_zmq_msg_t_delete\n"
++"local obj_type_zmq_msg_t_push\n"
"\n"
-"(function()\n"
-"local ZMQ_Poller_mt = _priv.ZMQ_Poller\n"
@@ -4962,21 +5264,18 @@ index a6d739d..7442736 100644
-"})\n"
-"function obj_type_ZMQ_Poller_check(ud_obj)\n"
-" return ZMQ_Poller_objects[ud_obj]\n"
-+"local function obj_register_interface(if_name, obj_name)\n"
-+" -- loopkup cdata id\n"
-+" local obj_mt = _priv[obj_name]\n"
-+" local obj_type_id = _ctype_meta_map[obj_mt]\n"
-+" local impl_meths = {}\n"
-+" local ffi_impls = _obj_interfaces_ffi[if_name]\n"
-+" ffi_impls[obj_type_id] = impl_meths\n"
-+" _meth[obj_name]['NOBJ_get_' .. if_name] = impl_meths\n"
-+" return impl_meths\n"
- "end\n"
+-"end\n"
++"do\n"
++" local obj_mt, obj_type, obj_ctype = obj_register_ctype(\"zmq_msg_t\", \"zmq_msg_t\")\n"
++" local zmq_msg_t_sizeof = ffi.sizeof\"zmq_msg_t\"\n"
"\n"
-"function obj_type_ZMQ_Poller_delete(ud_obj)\n"
-" ZMQ_Poller_objects[ud_obj] = nil\n"
-" return obj_simple_udata_luadelete(ud_obj, ZMQ_Poller_mt)\n"
-"end\n"
++" function obj_type_zmq_msg_t_check(obj)\n"
++" return obj\n"
++" end\n"
"\n"
-"local ZMQ_Poller_sizeof = ffi.sizeof\"ZMQ_Poller\"\n"
-"function obj_type_ZMQ_Poller_push(c_obj)\n"
@@ -4985,19 +5284,19 @@ index a6d739d..7442736 100644
-" return ud_obj\n"
-"end\n"
-"end)()\n"
-+"local obj_type_zmq_msg_t_check\n"
-+"local obj_type_zmq_msg_t_delete\n"
-+"local obj_type_zmq_msg_t_push\n"
++" function obj_type_zmq_msg_t_delete(obj)\n"
++" return obj\n"
++" end\n"
"\n"
-+"do\n"
-+" local obj_mt, obj_type, obj_ctype = obj_register_ctype(\"zmq_msg_t\", \"zmq_msg_t\")\n"
-+" local zmq_msg_t_sizeof = ffi.sizeof\"zmq_msg_t\"\n"
++" function obj_type_zmq_msg_t_push(obj)\n"
++" return obj\n"
++" end\n"
"\n"
-"local obj_type_ZMQ_Ctx_check\n"
-"local obj_type_ZMQ_Ctx_delete\n"
-"local obj_type_ZMQ_Ctx_push\n"
-+" function obj_type_zmq_msg_t_check(obj)\n"
-+" return obj\n"
++" function obj_mt:__tostring()\n"
++" return sformat(\"zmq_msg_t: %p\", self)\n"
+" end\n"
"\n"
-"(function()\n"
@@ -5010,15 +5309,26 @@ index a6d739d..7442736 100644
-"function obj_type_ZMQ_Ctx_check(ud_obj)\n"
-" return ZMQ_Ctx_objects[ud_obj]\n"
-"end\n"
-+" function obj_type_zmq_msg_t_delete(obj)\n"
-+" return obj\n"
++" function obj_mt.__eq(val1, val2)\n"
++" if not ffi.istype(obj_ctype, val2) then return false end\n"
++" assert(ffi.istype(obj_ctype, val1), \"expected zmq_msg_t\")\n"
++" return (C.memcmp(val1, val2, zmq_msg_t_sizeof) == 0)\n"
+" end\n"
"\n"
-"function obj_type_ZMQ_Ctx_delete(ud_obj)\n"
-" ZMQ_Ctx_objects[ud_obj] = nil\n"
-" return obj_udata_luadelete_weak(ud_obj, ZMQ_Ctx_mt)\n"
-"end\n"
-+" function obj_type_zmq_msg_t_push(obj)\n"
++" -- type checking function for C API.\n"
++" local function c_check(obj)\n"
++" if ffi.istype(obj_ctype, obj) then return obj end\n"
++" return nil\n"
++" end\n"
++" _priv[obj_type] = c_check\n"
++" -- push function for C API.\n"
++" reg_table[obj_type] = function(ptr)\n"
++" local obj = obj_ctype()\n", /* ----- CUT ----- */
++" ffi.copy(obj, ptr, zmq_msg_t_sizeof);\n"
+" return obj\n"
+" end\n"
"\n"
@@ -5027,33 +5337,16 @@ index a6d739d..7442736 100644
-" local ud_obj = obj_udata_luapush_weak(c_obj, ZMQ_Ctx_mt, ZMQ_Ctx_type, flags)\n"
-" ZMQ_Ctx_objects[ud_obj] = c_obj\n"
-" return ud_obj\n"
--"end\n"
++" -- export check functions for use in other modules.\n"
++" obj_mt.c_check = c_check\n"
++" obj_mt.ffi_check = obj_type_zmq_msg_t_check\n"
+ "end\n"
-"end)()\n"
-+" function obj_mt:__tostring()\n"
-+" return sformat(\"zmq_msg_t: %p\", self)\n"
-+" end\n"
- "\n"
-+" function obj_mt.__eq(val1, val2)\n"
-+" if not ffi.istype(obj_type, val2) then return false end\n"
-+" assert(ffi.istype(obj_type, val1), \"expected zmq_msg_t\")\n"
-+" return (C.memcmp(val1, val2, zmq_msg_t_sizeof) == 0)\n"
-+" end\n"
+-"\n"
"\n"
-"local obj_type_ZMQ_StopWatch_check\n"
-"local obj_type_ZMQ_StopWatch_delete\n"
-"local obj_type_ZMQ_StopWatch_push\n"
-+" -- type checking function for C API.\n"
-+" local function c_check(obj)\n"
-+" if ffi.istype(obj_type, obj) then return obj end\n"
-+" return nil\n"
-+" end\n"
-+" _priv[obj_type] = c_check\n"
-+" -- push function for C API.\n"
-+" reg_table[obj_type] = function(ptr)\n"
-+" local obj = obj_ctype()\n"
-+" ffi.copy(obj, ptr, zmq_msg_t_sizeof);\n"
-+" return obj\n"
-+" end\n"
"\n"
-"(function()\n"
-"local ZMQ_StopWatch_mt = _priv.ZMQ_StopWatch\n"
@@ -5064,27 +5357,15 @@ index a6d739d..7442736 100644
-"})\n"
-"function obj_type_ZMQ_StopWatch_check(ud_obj)\n"
-" return ZMQ_StopWatch_objects[ud_obj]\n"
-+" -- export check functions for use in other modules.\n"
-+" obj_mt.c_check = c_check\n"
-+" obj_mt.ffi_check = obj_type_zmq_msg_t_check\n"
- "end\n"
- "\n"
--"function obj_type_ZMQ_StopWatch_delete(ud_obj)\n"
--" ZMQ_StopWatch_objects[ud_obj] = nil\n"
--" return obj_udata_luadelete_weak(ud_obj, ZMQ_StopWatch_mt)\n"
-"end\n"
-+"\n", /* ----- CUT ----- */
+"local obj_type_ZMQ_Socket_check\n"
+"local obj_type_ZMQ_Socket_delete\n"
+"local obj_type_ZMQ_Socket_push\n"
"\n"
--"local ZMQ_StopWatch_type = ffi.cast(\"obj_type *\", ZMQ_StopWatch_mt[\".type\"])\n"
--"function obj_type_ZMQ_StopWatch_push(c_obj, flags)\n"
--" local ud_obj = obj_udata_luapush_weak(c_obj, ZMQ_StopWatch_mt, ZMQ_StopWatch_type, flags)\n"
--" ZMQ_StopWatch_objects[ud_obj] = c_obj\n"
--" return ud_obj\n"
+-"function obj_type_ZMQ_StopWatch_delete(ud_obj)\n"
+-" ZMQ_StopWatch_objects[ud_obj] = nil\n"
+-" return obj_udata_luadelete_weak(ud_obj, ZMQ_StopWatch_mt)\n"
-"end\n"
--"end)()\n"
+"do\n"
+" local obj_mt, obj_type, obj_ctype = obj_register_ctype(\"ZMQ_Socket\", \"ZMQ_Socket *\")\n"
+"\n"
@@ -5100,6 +5381,13 @@ index a6d739d..7442736 100644
+" return error(\"Expected 'ZMQ_Socket *'\", 2)\n"
+" end\n"
"\n"
+-"local ZMQ_StopWatch_type = ffi.cast(\"obj_type *\", ZMQ_StopWatch_mt[\".type\"])\n"
+-"function obj_type_ZMQ_StopWatch_push(c_obj, flags)\n"
+-" local ud_obj = obj_udata_luapush_weak(c_obj, ZMQ_StopWatch_mt, ZMQ_StopWatch_type, flags)\n"
+-" ZMQ_StopWatch_objects[ud_obj] = c_obj\n"
+-" return ud_obj\n"
+-"end\n"
+-"end)()\n"
+" function obj_type_ZMQ_Socket_delete(ptr)\n"
+" local id = obj_ptr_to_id(ptr)\n"
+" local flags = nobj_obj_flags[id]\n"
@@ -5109,13 +5397,12 @@ index a6d739d..7442736 100644
+" return ptr, flags\n"
+" end\n"
"\n"
--"local get_zmq_strerror = ffi.new(\"get_zmq_strerror_func\", _priv[\"get_zmq_strerror\"])\n"
+" function obj_type_ZMQ_Socket_push(ptr, flags)\n"
+" local id = obj_ptr_to_id(ptr)\n"
+" -- check weak refs\n"
+" if nobj_obj_flags[id] then return nobj_weak_objects[id] end\n"
"\n"
--"local simple_zmq_send = ffi.new(\"simple_zmq_send_func\", _priv[\"simple_zmq_send\"])\n"
+-"local get_zmq_strerror = ffi.new(\"get_zmq_strerror_func\", _priv[\"get_zmq_strerror\"])\n"
+" if flags ~= 0 then\n"
+" nobj_obj_flags[id] = flags\n"
+" ffi.gc(ptr, obj_mt.__gc)\n"
@@ -5124,12 +5411,12 @@ index a6d739d..7442736 100644
+" return ptr\n"
+" end\n"
"\n"
--"local poller_find_sock_item = ffi.new(\"poller_find_sock_item_func\", _priv[\"poller_find_sock_item\"])\n"
+-"local simple_zmq_send = ffi.new(\"simple_zmq_send_func\", _priv[\"simple_zmq_send\"])\n"
+" function obj_mt:__tostring()\n"
+" return sformat(\"ZMQ_Socket: %p, flags=%d\", self, nobj_obj_flags[obj_ptr_to_id(self)] or 0)\n"
+" end\n"
"\n"
--"local poller_find_fd_item = ffi.new(\"poller_find_fd_item_func\", _priv[\"poller_find_fd_item\"])\n"
+-"local poller_find_sock_item = ffi.new(\"poller_find_sock_item_func\", _priv[\"poller_find_sock_item\"])\n"
+" -- type checking function for C API.\n"
+" _priv[obj_type] = obj_type_ZMQ_Socket_check\n"
+" -- push function for C API.\n"
@@ -5137,33 +5424,38 @@ index a6d739d..7442736 100644
+" return obj_type_ZMQ_Socket_push(ffi.cast(obj_ctype,ptr), flags)\n"
+" end\n"
"\n"
--"local poller_get_free_item = ffi.new(\"poller_get_free_item_func\", _priv[\"poller_get_free_item\"])\n"
+-"local poller_find_fd_item = ffi.new(\"poller_find_fd_item_func\", _priv[\"poller_find_fd_item\"])\n"
+" -- export check functions for use in other modules.\n"
+" obj_mt.c_check = obj_type_ZMQ_Socket_check\n"
+" obj_mt.ffi_check = obj_type_ZMQ_Socket_check\n"
+"end\n"
"\n"
--"local poller_poll = ffi.new(\"poller_poll_func\", _priv[\"poller_poll\"])\n"
+-"local poller_get_free_item = ffi.new(\"poller_get_free_item_func\", _priv[\"poller_get_free_item\"])\n"
"\n"
--"local poller_remove_item = ffi.new(\"poller_remove_item_func\", _priv[\"poller_remove_item\"])\n"
+-"local poller_poll = ffi.new(\"poller_poll_func\", _priv[\"poller_poll\"])\n"
+"local obj_type_ZMQ_Poller_check\n"
+"local obj_type_ZMQ_Poller_delete\n"
+"local obj_type_ZMQ_Poller_push\n"
"\n"
+-"local poller_remove_item = ffi.new(\"poller_remove_item_func\", _priv[\"poller_remove_item\"])\n"
++"do\n"
++" local obj_mt, obj_type, obj_ctype = obj_register_ctype(\"ZMQ_Poller\", \"ZMQ_Poller\")\n"
++" local ZMQ_Poller_sizeof = ffi.sizeof\"ZMQ_Poller\"\n"
+ "\n"
-"local os_lib_table = {\n"
-" [\"Windows\"] = \"libzmq\",\n"
-"}\n"
-"local C = ffi.load(os_lib_table[ffi.os] or \"zmq\")\n"
-+"do\n"
-+" local obj_mt, obj_type, obj_ctype = obj_register_ctype(\"ZMQ_Poller\", \"ZMQ_Poller\")\n"
-+" local ZMQ_Poller_sizeof = ffi.sizeof\"ZMQ_Poller\"\n"
++" function obj_type_ZMQ_Poller_check(obj)\n"
++" return obj\n"
++" end\n"
"\n"
-"local C_get_zmq_strerror = get_zmq_strerror\n"
-"-- make nicer wrapper for exported error function.\n"
-"local function get_zmq_strerror()\n"
-" return ffi.string(C_get_zmq_strerror())\n"
-"end\n"
-+" function obj_type_ZMQ_Poller_check(obj)\n"
++" function obj_type_ZMQ_Poller_delete(obj)\n"
+" return obj\n"
+" end\n"
"\n"
@@ -5171,28 +5463,25 @@ index a6d739d..7442736 100644
-" local err_str\n"
-" if(-1 == err) then\n"
-" err_str = get_zmq_strerror();\n"
-+" function obj_type_ZMQ_Poller_delete(obj)\n"
++" function obj_type_ZMQ_Poller_push(obj)\n"
+" return obj\n"
" end\n"
"\n"
-" return err_str\n"
-+" function obj_type_ZMQ_Poller_push(obj)\n"
-+" return obj\n"
-+" end\n"
-+"\n"
+-"end\n"
+" function obj_mt:__tostring()\n"
+" return sformat(\"ZMQ_Poller: %p\", self)\n"
+" end\n"
+"\n"
+" function obj_mt.__eq(val1, val2)\n"
-+" if not ffi.istype(obj_type, val2) then return false end\n"
-+" assert(ffi.istype(obj_type, val1), \"expected ZMQ_Poller\")\n"
++" if not ffi.istype(obj_ctype, val2) then return false end\n"
++" assert(ffi.istype(obj_ctype, val1), \"expected ZMQ_Poller\")\n"
+" return (C.memcmp(val1, val2, ZMQ_Poller_sizeof) == 0)\n"
+" end\n"
+"\n"
+" -- type checking function for C API.\n"
+" local function c_check(obj)\n"
-+" if ffi.istype(obj_type, obj) then return obj end\n"
++" if ffi.istype(obj_ctype, obj) then return obj end\n"
+" return nil\n"
+" end\n"
+" _priv[obj_type] = c_check\n"
@@ -5325,12 +5614,15 @@ index a6d739d..7442736 100644
+"end\n"
+"\n"
+"\n"
-+"local obj_type_MutableBuffer_check =\n"
-+" obj_get_interface_check(\"MutableBufferIF\", \"Expected object with MutableBuffer interface\")\n"
-+"\n"
+"local obj_type_Buffer_check =\n"
+" obj_get_interface_check(\"BufferIF\", \"Expected object with Buffer interface\")\n"
+"\n"
++"local obj_type_FD_check =\n"
++" obj_get_interface_check(\"FDIF\", \"Expected object with FD interface\")\n"
++"\n"
++"local obj_type_MutableBuffer_check =\n"
++" obj_get_interface_check(\"MutableBufferIF\", \"Expected object with MutableBuffer interface\")\n"
++"\n"
+"local os_lib_table = {\n"
+" [\"Windows\"] = \"libzmq\",\n"
+"}\n"
@@ -5354,7 +5646,7 @@ index a6d739d..7442736 100644
+" end\n"
+"\n"
+" return err_str\n"
- "end\n"
++"end\n"
"\n"
"\n"
"-- Start \"zmq_msg_t\" FFI interface\n"
@@ -5593,7 +5885,7 @@ index a6d739d..7442736 100644
+" data1 = C.zmq_msg_data(self);\n"
+" data_len1 = C.zmq_msg_size(self);\n"
+"\n"
-+" return ffi_string_len(data1,data_len1)\n"
++" return data1 ~= nil and ffi_string(data1,data_len1) or nil\n"
+"end\n"
+"\n"
+"-- zmq_msg_t implements Buffer interface\n"
@@ -5666,6 +5958,21 @@ index a6d739d..7442736 100644
" end\n"
-" return rc_zmq_bind1, rc_zmq_bind1_err\n"
+" return true\n"
++"end\n"
++"\n"
++"-- method: unbind\n"
++"if (_meth.ZMQ_Socket.unbind) then\n"
++"function _meth.ZMQ_Socket.unbind(self, addr2)\n"
++" \n"
++" local addr_len2 = #addr2\n"
++" local rc_zmq_unbind1 = 0\n"
++" rc_zmq_unbind1 = C.zmq_unbind(self, addr2)\n"
++" -- check for error.\n"
++" if (-1 == rc_zmq_unbind1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_zmq_unbind1)\n"
++" end\n"
++" return true\n"
++"end\n"
"end\n"
"\n"
"-- method: connect\n"
@@ -5715,9 +6022,24 @@ index a6d739d..7442736 100644
-" option_len[k] = ffi.sizeof(v)\n"
-" option_tmps[k] = ffi.new(v, 0)\n"
+" return nil, error_code__ZMQ_Error__push(rc_zmq_connect1)\n"
++" end\n"
++" return true\n"
++"end\n"
++"\n"
++"-- method: disconnect\n"
++"if (_meth.ZMQ_Socket.disconnect) then\n"
++"function _meth.ZMQ_Socket.disconnect(self, addr2)\n"
++" \n"
++" local addr_len2 = #addr2\n"
++" local rc_zmq_disconnect1 = 0\n"
++" rc_zmq_disconnect1 = C.zmq_disconnect(self, addr2)\n"
++" -- check for error.\n"
++" if (-1 == rc_zmq_disconnect1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_zmq_disconnect1)\n"
" end\n"
+" return true\n"
+"end\n"
++"end\n"
+"\n"
+"local option_gets = {}\n"
+"local option_sets = {}\n"
@@ -5745,7 +6067,7 @@ index a6d739d..7442736 100644
+" [4] = 'affinity',\n"
+" [5] = 'identity',\n"
+" [6] = 'subscribe',\n"
-+" [7] = 'unsubscribe',\n"
++" [7] = 'unsubscribe',\n", /* ----- CUT ----- */
+" [8] = 'rate',\n"
+" [9] = 'recovery_ivl',\n"
+" [10] = 'mcast_loop',\n"
@@ -5827,7 +6149,7 @@ index a6d739d..7442736 100644
-" ffi.fill(val, val_len[0])\n"
+" local err2 = 0\n"
+" local get = option_gets[opt2]\n"
-+" if get then\n", /* ----- CUT ----- */
++" if get then\n"
+" return get(self)\n"
" else\n"
-" val = option_tmps[opt2]\n"
@@ -5967,7 +6289,7 @@ index a6d739d..7442736 100644
" local msg = tmp_msg\n"
" -- initialize blank message.\n"
" if C.zmq_msg_init(msg) < 0 then\n"
-@@ -1658,1106 +2772,3462 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
+@@ -1658,1106 +2827,3603 @@ static const char zmq_ffi_lua_code[] = "local error = error\n"
" end\n"
"\n"
" -- receive message\n"
@@ -5993,18 +6315,18 @@ index a6d739d..7442736 100644
" C.zmq_msg_close(msg)\n"
"\n"
-" return data1, err2\n"
-+" return ffi_string_len(data1,data_len1)\n"
++" return data1 ~= nil and ffi_string(data1,data_len1) or nil\n"
"end\n"
"\n"
-"-- End \"ZMQ_Socket\" FFI interface\n"
-"\n"
--"\n"
++"do\n"
++" local hwm_value_tmp = ffi.new(\"int[1]\")\n"
+ "\n"
-"-- Start \"ZMQ_Poller\" FFI interface\n"
-"-- method: poll\n"
-"function _meth.ZMQ_Poller.poll(self, timeout2)\n"
-" local this1 = obj_type_ZMQ_Poller_check(self)\n"
-+"do\n"
-+" local hwm_value_tmp = ffi.new(\"int[1]\")\n"
+"-- method: hwm\n"
+"if (_meth.ZMQ_Socket.hwm) then\n"
+"function _meth.ZMQ_Socket.hwm(self)\n"
@@ -6017,13 +6339,14 @@ index a6d739d..7442736 100644
-" else\n"
-" this1.next = -1\n"
-" end\n"
-+" local value1 = hwm_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_hwm2 = 0\n"
-+" rc_lzmq_socket_hwm2 = Cmod.lzmq_socket_hwm(self, value1)\n"
++" rc_lzmq_socket_hwm2 = Cmod.lzmq_socket_hwm(self, hwm_value_tmp)\n"
++" value1 = hwm_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_hwm2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_hwm2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6042,10 +6365,14 @@ index a6d739d..7442736 100644
-" err1 = nil\n"
-" else\n"
-" err1 = true\n"
--" end\n"
++" if (-1 == rc_lzmq_socket_set_hwm1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_hwm1)\n"
+ " end\n"
-" return err1, err1_err\n"
--"end\n"
--"\n"
++" return true\n"
++"end\n"
+ "end\n"
+ "\n"
-"-- method: next_revents\n"
-"function _meth.ZMQ_Poller.next_revents(self)\n"
-" local this1 = obj_type_ZMQ_Poller_check(self)\n"
@@ -6081,42 +6408,35 @@ index a6d739d..7442736 100644
-" return sock, revents2\n"
-" end\n"
-" this1.next = idx\n"
--"\n"
--" revents2 = revents2\n"
--" return sock1, revents2\n"
-+" if (-1 == rc_lzmq_socket_set_hwm1) then\n"
-+" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_hwm1)\n"
-+" end\n"
-+" return true\n"
-+"end\n"
- "end\n"
- "\n"
--"-- method: count\n"
--"function _meth.ZMQ_Poller.count(self)\n"
--" local this1 = obj_type_ZMQ_Poller_check(self)\n"
--" local count1\n"
--" count1 = this1.count;\n"
--"\n"
--" count1 = count1\n"
--" return count1\n"
+"do\n"
+" local swap_value_tmp = ffi.new(\"int[1]\")\n"
+ "\n"
+-" revents2 = revents2\n"
+-" return sock1, revents2\n"
+"-- method: swap\n"
+"if (_meth.ZMQ_Socket.swap) then\n"
+"function _meth.ZMQ_Socket.swap(self)\n"
+" \n"
-+" local value1 = swap_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_swap2 = 0\n"
-+" rc_lzmq_socket_swap2 = Cmod.lzmq_socket_swap(self, value1)\n"
++" rc_lzmq_socket_swap2 = Cmod.lzmq_socket_swap(self, swap_value_tmp)\n"
++" value1 = swap_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_swap2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_swap2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
"end\n"
"\n"
--"-- End \"ZMQ_Poller\" FFI interface\n"
+-"-- method: count\n"
+-"function _meth.ZMQ_Poller.count(self)\n"
+-" local this1 = obj_type_ZMQ_Poller_check(self)\n"
+-" local count1\n"
+-" count1 = this1.count;\n"
+-"\n"
+-" count1 = count1\n"
+-" return count1\n"
+"-- method: set_swap\n"
+"if (_meth.ZMQ_Socket.set_swap) then\n"
+"function _meth.ZMQ_Socket.set_swap(self, value2)\n"
@@ -6130,21 +6450,24 @@ index a6d739d..7442736 100644
+" end\n"
+" return true\n"
+"end\n"
-+"end\n"
+ "end\n"
"\n"
+-"-- End \"ZMQ_Poller\" FFI interface\n"
+"do\n"
+" local affinity_value_tmp = ffi.new(\"uint64_t[1]\")\n"
+ "\n"
+"-- method: affinity\n"
+"if (_meth.ZMQ_Socket.affinity) then\n"
+"function _meth.ZMQ_Socket.affinity(self)\n"
+" \n"
-+" local value1 = affinity_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_affinity2 = 0\n"
-+" rc_lzmq_socket_affinity2 = Cmod.lzmq_socket_affinity(self, value1)\n"
++" rc_lzmq_socket_affinity2 = Cmod.lzmq_socket_affinity(self, affinity_value_tmp)\n"
++" value1 = affinity_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_affinity2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_affinity2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6181,6 +6504,9 @@ index a6d739d..7442736 100644
-"-- method: socket\n"
-"function _meth.ZMQ_Ctx.socket(self, type2)\n"
-" local this1 = obj_type_ZMQ_Ctx_check(self)\n"
++"do\n"
++" local identity_value_len_tmp = ffi.new(\"size_t[1]\")\n"
++"\n"
+"-- method: identity\n"
+"if (_meth.ZMQ_Socket.identity) then\n"
+"function _meth.ZMQ_Socket.identity(self)\n"
@@ -6196,16 +6522,19 @@ index a6d739d..7442736 100644
+" local value_len1 = 0\n"
+" local value1\n"
+" local rc_lzmq_socket_identity2 = 0\n"
-+" rc_lzmq_socket_identity2 = Cmod.lzmq_socket_identity(self, value1, value_len1)\n"
++" rc_lzmq_socket_identity2 = Cmod.lzmq_socket_identity(self, value1, identity_value_len_tmp)\n"
++" value_len1 = identity_value_len_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_identity2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_identity2)\n"
" end\n"
-" return rc_zmq_socket1, rc_zmq_socket1_err\n"
-+" return ffi_string_len(value1,value_len1)\n"
++" return value1 ~= nil and ffi_string(value1,value_len1) or nil\n"
++"end\n"
+"end\n"
"end\n"
"\n"
-"-- End \"ZMQ_Ctx\" FFI interface\n"
+-"\n"
+"-- method: set_identity\n"
+"if (_meth.ZMQ_Socket.set_identity) then\n"
+"function _meth.ZMQ_Socket.set_identity(self, value2)\n"
@@ -6221,6 +6550,14 @@ index a6d739d..7442736 100644
+"end\n"
+"end\n"
"\n"
+-"-- Start \"ZMQ_StopWatch\" FFI interface\n"
+-"-- method: start\n"
+-"function _pub.ZMQ_StopWatch.start()\n"
+-" local this_flags1 = OBJ_UDATA_FLAG_OWN\n"
+-" local this1\n"
+-" this1 = C.zmq_stopwatch_start()\n"
+-" this1 = obj_type_ZMQ_StopWatch_push(this1, this_flags1)\n"
+-" return this1\n"
+"-- method: subscribe\n"
+"if (_meth.ZMQ_Socket.subscribe) then\n"
+"function _meth.ZMQ_Socket.subscribe(self, value2)\n"
@@ -6234,16 +6571,16 @@ index a6d739d..7442736 100644
+" end\n"
+" return true\n"
+"end\n"
-+"end\n"
+ "end\n"
"\n"
--"-- Start \"ZMQ_StopWatch\" FFI interface\n"
--"-- method: start\n"
--"function _pub.ZMQ_StopWatch.start()\n"
--" local this_flags1 = OBJ_UDATA_FLAG_OWN\n"
--" local this1\n"
--" this1 = C.zmq_stopwatch_start()\n"
--" this1 = obj_type_ZMQ_StopWatch_push(this1, this_flags1)\n"
--" return this1\n"
+-"-- method: stop\n"
+-"function _meth.ZMQ_StopWatch.stop(self)\n"
+-" local this1,this_flags1 = obj_type_ZMQ_StopWatch_delete(self)\n"
+-" if(band(this_flags1,OBJ_UDATA_FLAG_OWN) == 0) then return end\n"
+-" local usecs1\n"
+-" usecs1 = C.zmq_stopwatch_stop(this1)\n"
+-" usecs1 = tonumber(usecs1)\n"
+-" return usecs1\n"
+"-- method: unsubscribe\n"
+"if (_meth.ZMQ_Socket.unsubscribe) then\n"
+"function _meth.ZMQ_Socket.unsubscribe(self, value2)\n"
@@ -6259,54 +6596,15 @@ index a6d739d..7442736 100644
+"end\n"
"end\n"
"\n"
--"-- method: stop\n"
--"function _meth.ZMQ_StopWatch.stop(self)\n"
--" local this1,this_flags1 = obj_type_ZMQ_StopWatch_delete(self)\n"
--" if(band(this_flags1,OBJ_UDATA_FLAG_OWN) == 0) then return end\n"
--" local usecs1\n"
--" usecs1 = C.zmq_stopwatch_stop(this1)\n"
--" usecs1 = tonumber(usecs1)\n"
--" return usecs1\n"
+-"-- End \"ZMQ_StopWatch\" FFI interface\n"
+"do\n"
+" local rate_value_tmp = ffi.new(\"int[1]\")\n"
-+"-- method: rate\n"
-+"if (_meth.ZMQ_Socket.rate) then\n"
-+"function _meth.ZMQ_Socket.rate(self)\n"
-+" \n"
-+" local value1 = rate_value_tmp\n"
-+" local rc_lzmq_socket_rate2 = 0\n"
-+" rc_lzmq_socket_rate2 = Cmod.lzmq_socket_rate(self, value1)\n"
-+" if (-1 == rc_lzmq_socket_rate2) then\n"
-+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_rate2)\n"
-+" end\n"
-+" return value1[0]\n"
-+"end\n"
-+"end\n"
- "end\n"
- "\n"
--"-- End \"ZMQ_StopWatch\" FFI interface\n"
-+"-- method: set_rate\n"
-+"if (_meth.ZMQ_Socket.set_rate) then\n"
-+"function _meth.ZMQ_Socket.set_rate(self, value2)\n"
-+" \n"
-+" \n"
-+" local rc_lzmq_socket_set_rate1 = 0\n"
-+" rc_lzmq_socket_set_rate1 = Cmod.lzmq_socket_set_rate(self, value2)\n"
-+" -- check for error.\n"
-+" if (-1 == rc_lzmq_socket_set_rate1) then\n"
-+" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_rate1)\n"
-+" end\n"
-+" return true\n"
-+"end\n"
-+"end\n"
"\n"
-"-- method: init\n"
-"function _pub.zmq.init(io_threads1)\n"
-+"do\n"
-+" local recovery_ivl_value_tmp = ffi.new(\"int[1]\")\n"
-+"-- method: recovery_ivl\n"
-+"if (_meth.ZMQ_Socket.recovery_ivl) then\n"
-+"function _meth.ZMQ_Socket.recovery_ivl(self)\n"
++"-- method: rate\n"
++"if (_meth.ZMQ_Socket.rate) then\n"
++"function _meth.ZMQ_Socket.rate(self)\n"
" \n"
-" local rc_zmq_init_flags1 = OBJ_UDATA_FLAG_OWN\n"
-" local rc_zmq_init1\n"
@@ -6316,14 +6614,15 @@ index a6d739d..7442736 100644
-" rc_zmq_init1_err = get_zmq_strerror()\n"
-" else\n"
-" rc_zmq_init1 = obj_type_ZMQ_Ctx_push(rc_zmq_init1, rc_zmq_init_flags1)\n"
-+" local value1 = recovery_ivl_value_tmp\n"
-+" local rc_lzmq_socket_recovery_ivl2 = 0\n"
-+" rc_lzmq_socket_recovery_ivl2 = Cmod.lzmq_socket_recovery_ivl(self, value1)\n"
-+" if (-1 == rc_lzmq_socket_recovery_ivl2) then\n"
-+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_recovery_ivl2)\n"
++" local value1\n"
++" local rc_lzmq_socket_rate2 = 0\n"
++" rc_lzmq_socket_rate2 = Cmod.lzmq_socket_rate(self, rate_value_tmp)\n"
++" value1 = rate_value_tmp[0]\n"
++" if (-1 == rc_lzmq_socket_rate2) then\n"
++" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_rate2)\n"
" end\n"
-" return rc_zmq_init1, rc_zmq_init1_err\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
"end\n"
@@ -6339,16 +6638,16 @@ index a6d739d..7442736 100644
-" else\n"
-" return error(\"expected lightuserdata/cdata<void *>\");\n"
-" end\n"
-+"-- method: set_recovery_ivl\n"
-+"if (_meth.ZMQ_Socket.set_recovery_ivl) then\n"
-+"function _meth.ZMQ_Socket.set_recovery_ivl(self, value2)\n"
++"-- method: set_rate\n"
++"if (_meth.ZMQ_Socket.set_rate) then\n"
++"function _meth.ZMQ_Socket.set_rate(self, value2)\n"
+" \n"
+" \n"
-+" local rc_lzmq_socket_set_recovery_ivl1 = 0\n"
-+" rc_lzmq_socket_set_recovery_ivl1 = Cmod.lzmq_socket_set_recovery_ivl(self, value2)\n"
++" local rc_lzmq_socket_set_rate1 = 0\n"
++" rc_lzmq_socket_set_rate1 = Cmod.lzmq_socket_set_rate(self, value2)\n"
+" -- check for error.\n"
-+" if (-1 == rc_lzmq_socket_set_recovery_ivl1) then\n"
-+" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_recovery_ivl1)\n"
++" if (-1 == rc_lzmq_socket_set_rate1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_rate1)\n"
+" end\n"
+" return true\n"
+"end\n"
@@ -6360,36 +6659,38 @@ index a6d739d..7442736 100644
-" else\n"
-" ctx1 = obj_type_ZMQ_Ctx_push(ctx1, 0)\n"
+"do\n"
-+" local mcast_loop_value_tmp = ffi.new(\"int[1]\")\n"
-+"-- method: mcast_loop\n"
-+"if (_meth.ZMQ_Socket.mcast_loop) then\n"
-+"function _meth.ZMQ_Socket.mcast_loop(self)\n"
++" local recovery_ivl_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
++"-- method: recovery_ivl\n"
++"if (_meth.ZMQ_Socket.recovery_ivl) then\n"
++"function _meth.ZMQ_Socket.recovery_ivl(self)\n"
+" \n"
-+" local value1 = mcast_loop_value_tmp\n"
-+" local rc_lzmq_socket_mcast_loop2 = 0\n"
-+" rc_lzmq_socket_mcast_loop2 = Cmod.lzmq_socket_mcast_loop(self, value1)\n"
-+" if (-1 == rc_lzmq_socket_mcast_loop2) then\n"
-+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_mcast_loop2)\n"
++" local value1\n"
++" local rc_lzmq_socket_recovery_ivl2 = 0\n"
++" rc_lzmq_socket_recovery_ivl2 = Cmod.lzmq_socket_recovery_ivl(self, recovery_ivl_value_tmp)\n"
++" value1 = recovery_ivl_value_tmp[0]\n"
++" if (-1 == rc_lzmq_socket_recovery_ivl2) then\n"
++" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_recovery_ivl2)\n"
" end\n"
-" return ctx1, ctx1_err\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
"end\n"
"\n"
-"-- method: device\n"
-"function _pub.zmq.device(device1, insock2, outsock3)\n"
-+"-- method: set_mcast_loop\n"
-+"if (_meth.ZMQ_Socket.set_mcast_loop) then\n"
-+"function _meth.ZMQ_Socket.set_mcast_loop(self, value2)\n"
++"-- method: set_recovery_ivl\n"
++"if (_meth.ZMQ_Socket.set_recovery_ivl) then\n"
++"function _meth.ZMQ_Socket.set_recovery_ivl(self, value2)\n"
" \n"
-" insock2 = obj_type_ZMQ_Socket_check(insock2)\n"
-" outsock3 = obj_type_ZMQ_Socket_check(outsock3)\n"
-" local rc_zmq_device1\n"
-" rc_zmq_device1 = C.zmq_device(device1, insock2, outsock3)\n"
+" \n"
-+" local rc_lzmq_socket_set_mcast_loop1 = 0\n"
-+" rc_lzmq_socket_set_mcast_loop1 = Cmod.lzmq_socket_set_mcast_loop(self, value2)\n"
++" local rc_lzmq_socket_set_recovery_ivl1 = 0\n"
++" rc_lzmq_socket_set_recovery_ivl1 = Cmod.lzmq_socket_set_recovery_ivl(self, value2)\n"
" -- check for error.\n"
-" local rc_zmq_device1_err\n"
-" if (-1 == rc_zmq_device1) then\n"
@@ -6397,14 +6698,13 @@ index a6d739d..7442736 100644
-" rc_zmq_device1 = nil\n"
-" else\n"
-" rc_zmq_device1 = true\n"
-+" if (-1 == rc_lzmq_socket_set_mcast_loop1) then\n"
-+" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_mcast_loop1)\n"
++" if (-1 == rc_lzmq_socket_set_recovery_ivl1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_recovery_ivl1)\n"
" end\n"
-" return rc_zmq_device1, rc_zmq_device1_err\n"
+" return true\n"
-+"end\n"
"end\n"
- "\n"
+-"\n"
-"-- method: stopwatch_start\n"
-"function _pub.zmq.stopwatch_start()\n"
-" local rc_zmq_stopwatch_start_flags1 = OBJ_UDATA_FLAG_OWN\n"
@@ -6412,31 +6712,77 @@ index a6d739d..7442736 100644
-" rc_zmq_stopwatch_start1 = C.zmq_stopwatch_start()\n"
-" rc_zmq_stopwatch_start1 = obj_type_ZMQ_StopWatch_push(rc_zmq_stopwatch_start1, rc_zmq_stopwatch_start_flags1)\n"
-" return rc_zmq_stopwatch_start1\n"
+ "end\n"
+ "\n"
+-"-- method: sleep\n"
+-"function _pub.zmq.sleep(seconds_1)\n"
++"do\n"
++" local mcast_loop_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
++"-- method: mcast_loop\n"
++"if (_meth.ZMQ_Socket.mcast_loop) then\n"
++"function _meth.ZMQ_Socket.mcast_loop(self)\n"
+ " \n"
+-" C.zmq_sleep(seconds_1)\n"
+-" return \n"
++" local value1\n"
++" local rc_lzmq_socket_mcast_loop2 = 0\n"
++" rc_lzmq_socket_mcast_loop2 = Cmod.lzmq_socket_mcast_loop(self, mcast_loop_value_tmp)\n"
++" value1 = mcast_loop_value_tmp[0]\n"
++" if (-1 == rc_lzmq_socket_mcast_loop2) then\n"
++" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_mcast_loop2)\n"
++" end\n"
++" return value1\n"
++"end\n"
++"end\n"
+ "end\n"
+ "\n"
+-"";
+-
+-/* detect zmq version >= 2.1.0 */
+-#define VERSION_2_1 0
+-#if defined(ZMQ_VERSION)
+-#if (ZMQ_VERSION >= ZMQ_MAKE_VERSION(2,1,0))
+-#undef VERSION_2_1
+-#define VERSION_2_1 1
++"-- method: set_mcast_loop\n"
++"if (_meth.ZMQ_Socket.set_mcast_loop) then\n"
++"function _meth.ZMQ_Socket.set_mcast_loop(self, value2)\n"
++" \n"
++" \n"
++" local rc_lzmq_socket_set_mcast_loop1 = 0\n"
++" rc_lzmq_socket_set_mcast_loop1 = Cmod.lzmq_socket_set_mcast_loop(self, value2)\n"
++" -- check for error.\n"
++" if (-1 == rc_lzmq_socket_set_mcast_loop1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_mcast_loop1)\n"
++" end\n"
++" return true\n"
++"end\n"
++"end\n"
++"\n"
+"do\n"
+" local sndbuf_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: sndbuf\n"
+"if (_meth.ZMQ_Socket.sndbuf) then\n"
+"function _meth.ZMQ_Socket.sndbuf(self)\n"
+" \n"
-+" local value1 = sndbuf_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_sndbuf2 = 0\n"
-+" rc_lzmq_socket_sndbuf2 = Cmod.lzmq_socket_sndbuf(self, value1)\n"
++" rc_lzmq_socket_sndbuf2 = Cmod.lzmq_socket_sndbuf(self, sndbuf_value_tmp)\n"
++" value1 = sndbuf_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_sndbuf2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_sndbuf2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
- "end\n"
- "\n"
--"-- method: sleep\n"
--"function _pub.zmq.sleep(seconds_1)\n"
++"end\n"
++"\n"
+"-- method: set_sndbuf\n"
+"if (_meth.ZMQ_Socket.set_sndbuf) then\n"
+"function _meth.ZMQ_Socket.set_sndbuf(self, value2)\n"
- " \n"
--" C.zmq_sleep(seconds_1)\n"
--" return \n"
++" \n"
+" \n"
+" local rc_lzmq_socket_set_sndbuf1 = 0\n"
+" rc_lzmq_socket_set_sndbuf1 = Cmod.lzmq_socket_set_sndbuf(self, value2)\n"
@@ -6446,29 +6792,23 @@ index a6d739d..7442736 100644
+" end\n"
+" return true\n"
+"end\n"
- "end\n"
- "\n"
--"";
--
--/* detect zmq version >= 2.1.0 */
--#define VERSION_2_1 0
--#if defined(ZMQ_VERSION)
--#if (ZMQ_VERSION >= ZMQ_MAKE_VERSION(2,1,0))
--#undef VERSION_2_1
--#define VERSION_2_1 1
++"end\n"
++"\n"
+"do\n"
+" local rcvbuf_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: rcvbuf\n"
+"if (_meth.ZMQ_Socket.rcvbuf) then\n"
+"function _meth.ZMQ_Socket.rcvbuf(self)\n"
+" \n"
-+" local value1 = rcvbuf_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_rcvbuf2 = 0\n"
-+" rc_lzmq_socket_rcvbuf2 = Cmod.lzmq_socket_rcvbuf(self, value1)\n"
++" rc_lzmq_socket_rcvbuf2 = Cmod.lzmq_socket_rcvbuf(self, rcvbuf_value_tmp)\n"
++" value1 = rcvbuf_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_rcvbuf2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_rcvbuf2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6490,85 +6830,95 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local rcvmore_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: rcvmore\n"
+"if (_meth.ZMQ_Socket.rcvmore) then\n"
+"function _meth.ZMQ_Socket.rcvmore(self)\n"
+" \n"
-+" local value1 = rcvmore_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_rcvmore2 = 0\n"
-+" rc_lzmq_socket_rcvmore2 = Cmod.lzmq_socket_rcvmore(self, value1)\n"
++" rc_lzmq_socket_rcvmore2 = Cmod.lzmq_socket_rcvmore(self, rcvmore_value_tmp)\n"
++" value1 = rcvmore_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_rcvmore2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_rcvmore2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
+"\n"
+"do\n"
+" local fd_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: fd\n"
+"if (_meth.ZMQ_Socket.fd) then\n"
+"function _meth.ZMQ_Socket.fd(self)\n"
+" \n"
-+" local value1 = fd_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_fd2 = 0\n"
-+" rc_lzmq_socket_fd2 = Cmod.lzmq_socket_fd(self, value1)\n"
++" rc_lzmq_socket_fd2 = Cmod.lzmq_socket_fd(self, fd_value_tmp)\n"
++" value1 = fd_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_fd2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_fd2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
+"\n"
+"do\n"
+" local events_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: events\n"
+"if (_meth.ZMQ_Socket.events) then\n"
+"function _meth.ZMQ_Socket.events(self)\n"
+" \n"
-+" local value1 = events_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_events2 = 0\n"
-+" rc_lzmq_socket_events2 = Cmod.lzmq_socket_events(self, value1)\n"
++" rc_lzmq_socket_events2 = Cmod.lzmq_socket_events(self, events_value_tmp)\n"
++" value1 = events_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_events2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_events2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
+"\n"
+"do\n"
+" local type_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: type\n"
+"if (_meth.ZMQ_Socket.type) then\n"
+"function _meth.ZMQ_Socket.type(self)\n"
+" \n"
-+" local value1 = type_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_type2 = 0\n"
-+" rc_lzmq_socket_type2 = Cmod.lzmq_socket_type(self, value1)\n"
++" rc_lzmq_socket_type2 = Cmod.lzmq_socket_type(self, type_value_tmp)\n"
++" value1 = type_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_type2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_type2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
+"\n"
+"do\n"
+" local linger_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: linger\n"
+"if (_meth.ZMQ_Socket.linger) then\n"
+"function _meth.ZMQ_Socket.linger(self)\n"
+" \n"
-+" local value1 = linger_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_linger2 = 0\n"
-+" rc_lzmq_socket_linger2 = Cmod.lzmq_socket_linger(self, value1)\n"
++" rc_lzmq_socket_linger2 = Cmod.lzmq_socket_linger(self, linger_value_tmp)\n"
++" value1 = linger_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_linger2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_linger2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6587,20 +6937,22 @@ index a6d739d..7442736 100644
+" return true\n"
+"end\n"
+"end\n"
-+"\n"
++"\n", /* ----- CUT ----- */
+"do\n"
+" local reconnect_ivl_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: reconnect_ivl\n"
+"if (_meth.ZMQ_Socket.reconnect_ivl) then\n"
+"function _meth.ZMQ_Socket.reconnect_ivl(self)\n"
+" \n"
-+" local value1 = reconnect_ivl_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_reconnect_ivl2 = 0\n"
-+" rc_lzmq_socket_reconnect_ivl2 = Cmod.lzmq_socket_reconnect_ivl(self, value1)\n"
++" rc_lzmq_socket_reconnect_ivl2 = Cmod.lzmq_socket_reconnect_ivl(self, reconnect_ivl_value_tmp)\n"
++" value1 = reconnect_ivl_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_reconnect_ivl2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_reconnect_ivl2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6622,17 +6974,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local backlog_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: backlog\n"
+"if (_meth.ZMQ_Socket.backlog) then\n"
+"function _meth.ZMQ_Socket.backlog(self)\n"
+" \n"
-+" local value1 = backlog_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_backlog2 = 0\n"
-+" rc_lzmq_socket_backlog2 = Cmod.lzmq_socket_backlog(self, value1)\n"
++" rc_lzmq_socket_backlog2 = Cmod.lzmq_socket_backlog(self, backlog_value_tmp)\n"
++" value1 = backlog_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_backlog2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_backlog2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6641,7 +6995,7 @@ index a6d739d..7442736 100644
+"if (_meth.ZMQ_Socket.set_backlog) then\n"
+"function _meth.ZMQ_Socket.set_backlog(self, value2)\n"
+" \n"
-+" \n", /* ----- CUT ----- */
++" \n"
+" local rc_lzmq_socket_set_backlog1 = 0\n"
+" rc_lzmq_socket_set_backlog1 = Cmod.lzmq_socket_set_backlog(self, value2)\n"
+" -- check for error.\n"
@@ -6654,17 +7008,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local recovery_ivl_msec_value_tmp = ffi.new(\"int64_t[1]\")\n"
++"\n"
+"-- method: recovery_ivl_msec\n"
+"if (_meth.ZMQ_Socket.recovery_ivl_msec) then\n"
+"function _meth.ZMQ_Socket.recovery_ivl_msec(self)\n"
+" \n"
-+" local value1 = recovery_ivl_msec_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_recovery_ivl_msec2 = 0\n"
-+" rc_lzmq_socket_recovery_ivl_msec2 = Cmod.lzmq_socket_recovery_ivl_msec(self, value1)\n"
++" rc_lzmq_socket_recovery_ivl_msec2 = Cmod.lzmq_socket_recovery_ivl_msec(self, recovery_ivl_msec_value_tmp)\n"
++" value1 = recovery_ivl_msec_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_recovery_ivl_msec2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_recovery_ivl_msec2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6686,17 +7042,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local reconnect_ivl_max_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: reconnect_ivl_max\n"
+"if (_meth.ZMQ_Socket.reconnect_ivl_max) then\n"
+"function _meth.ZMQ_Socket.reconnect_ivl_max(self)\n"
+" \n"
-+" local value1 = reconnect_ivl_max_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_reconnect_ivl_max2 = 0\n"
-+" rc_lzmq_socket_reconnect_ivl_max2 = Cmod.lzmq_socket_reconnect_ivl_max(self, value1)\n"
++" rc_lzmq_socket_reconnect_ivl_max2 = Cmod.lzmq_socket_reconnect_ivl_max(self, reconnect_ivl_max_value_tmp)\n"
++" value1 = reconnect_ivl_max_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_reconnect_ivl_max2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_reconnect_ivl_max2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6718,17 +7076,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local maxmsgsize_value_tmp = ffi.new(\"int64_t[1]\")\n"
++"\n"
+"-- method: maxmsgsize\n"
+"if (_meth.ZMQ_Socket.maxmsgsize) then\n"
+"function _meth.ZMQ_Socket.maxmsgsize(self)\n"
+" \n"
-+" local value1 = maxmsgsize_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_maxmsgsize2 = 0\n"
-+" rc_lzmq_socket_maxmsgsize2 = Cmod.lzmq_socket_maxmsgsize(self, value1)\n"
++" rc_lzmq_socket_maxmsgsize2 = Cmod.lzmq_socket_maxmsgsize(self, maxmsgsize_value_tmp)\n"
++" value1 = maxmsgsize_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_maxmsgsize2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_maxmsgsize2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6750,17 +7110,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local sndhwm_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: sndhwm\n"
+"if (_meth.ZMQ_Socket.sndhwm) then\n"
+"function _meth.ZMQ_Socket.sndhwm(self)\n"
+" \n"
-+" local value1 = sndhwm_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_sndhwm2 = 0\n"
-+" rc_lzmq_socket_sndhwm2 = Cmod.lzmq_socket_sndhwm(self, value1)\n"
++" rc_lzmq_socket_sndhwm2 = Cmod.lzmq_socket_sndhwm(self, sndhwm_value_tmp)\n"
++" value1 = sndhwm_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_sndhwm2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_sndhwm2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6782,17 +7144,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local rcvhwm_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: rcvhwm\n"
+"if (_meth.ZMQ_Socket.rcvhwm) then\n"
+"function _meth.ZMQ_Socket.rcvhwm(self)\n"
+" \n"
-+" local value1 = rcvhwm_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_rcvhwm2 = 0\n"
-+" rc_lzmq_socket_rcvhwm2 = Cmod.lzmq_socket_rcvhwm(self, value1)\n"
++" rc_lzmq_socket_rcvhwm2 = Cmod.lzmq_socket_rcvhwm(self, rcvhwm_value_tmp)\n"
++" value1 = rcvhwm_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_rcvhwm2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_rcvhwm2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6814,17 +7178,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local multicast_hops_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: multicast_hops\n"
+"if (_meth.ZMQ_Socket.multicast_hops) then\n"
+"function _meth.ZMQ_Socket.multicast_hops(self)\n"
+" \n"
-+" local value1 = multicast_hops_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_multicast_hops2 = 0\n"
-+" rc_lzmq_socket_multicast_hops2 = Cmod.lzmq_socket_multicast_hops(self, value1)\n"
++" rc_lzmq_socket_multicast_hops2 = Cmod.lzmq_socket_multicast_hops(self, multicast_hops_value_tmp)\n"
++" value1 = multicast_hops_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_multicast_hops2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_multicast_hops2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6846,17 +7212,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local rcvtimeo_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: rcvtimeo\n"
+"if (_meth.ZMQ_Socket.rcvtimeo) then\n"
+"function _meth.ZMQ_Socket.rcvtimeo(self)\n"
+" \n"
-+" local value1 = rcvtimeo_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_rcvtimeo2 = 0\n"
-+" rc_lzmq_socket_rcvtimeo2 = Cmod.lzmq_socket_rcvtimeo(self, value1)\n"
++" rc_lzmq_socket_rcvtimeo2 = Cmod.lzmq_socket_rcvtimeo(self, rcvtimeo_value_tmp)\n"
++" value1 = rcvtimeo_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_rcvtimeo2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_rcvtimeo2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6878,17 +7246,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local sndtimeo_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: sndtimeo\n"
+"if (_meth.ZMQ_Socket.sndtimeo) then\n"
+"function _meth.ZMQ_Socket.sndtimeo(self)\n"
+" \n"
-+" local value1 = sndtimeo_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_sndtimeo2 = 0\n"
-+" rc_lzmq_socket_sndtimeo2 = Cmod.lzmq_socket_sndtimeo(self, value1)\n"
++" rc_lzmq_socket_sndtimeo2 = Cmod.lzmq_socket_sndtimeo(self, sndtimeo_value_tmp)\n"
++" value1 = sndtimeo_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_sndtimeo2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_sndtimeo2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6910,17 +7280,19 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local ipv4only_value_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: ipv4only\n"
+"if (_meth.ZMQ_Socket.ipv4only) then\n"
+"function _meth.ZMQ_Socket.ipv4only(self)\n"
+" \n"
-+" local value1 = ipv4only_value_tmp\n"
++" local value1\n"
+" local rc_lzmq_socket_ipv4only2 = 0\n"
-+" rc_lzmq_socket_ipv4only2 = Cmod.lzmq_socket_ipv4only(self, value1)\n"
++" rc_lzmq_socket_ipv4only2 = Cmod.lzmq_socket_ipv4only(self, ipv4only_value_tmp)\n"
++" value1 = ipv4only_value_tmp[0]\n"
+" if (-1 == rc_lzmq_socket_ipv4only2) then\n"
+" return nil,error_code__ZMQ_Error__push(rc_lzmq_socket_ipv4only2)\n"
+" end\n"
-+" return value1[0]\n"
++" return value1\n"
+"end\n"
+"end\n"
+"end\n"
@@ -6971,6 +7343,7 @@ index a6d739d..7442736 100644
+" local idx1 = 0\n"
+" local fd = 0\n"
+" local sock_type = type(sock2)\n"
++" local sock\n"
+" if sock_type == 'cdata' then\n"
+" sock = obj_type_ZMQ_Socket_check(sock2)\n"
+" elseif sock_type == 'number' then\n"
@@ -6994,6 +7367,7 @@ index a6d739d..7442736 100644
+" local idx1 = 0\n"
+" local fd = 0\n"
+" local sock_type = type(sock2)\n"
++" local sock\n"
+" if sock_type == 'cdata' then\n"
+" sock = obj_type_ZMQ_Socket_check(sock2)\n"
+" -- find sock in items list.\n"
@@ -7023,6 +7397,7 @@ index a6d739d..7442736 100644
+" local idx1 = 0\n"
+" local fd = 0\n"
+" local sock_type = type(sock2)\n"
++" local sock\n"
+" if sock_type == 'cdata' then\n"
+" sock = obj_type_ZMQ_Socket_check(sock2)\n"
+" -- find sock in items list.\n"
@@ -7064,13 +7439,15 @@ index a6d739d..7442736 100644
+"\n"
+"do\n"
+" local next_revents_idx_revents_tmp = ffi.new(\"int[1]\")\n"
++"\n"
+"-- method: next_revents_idx\n"
+"function _meth.ZMQ_Poller.next_revents_idx(self)\n"
+" \n"
+" local idx1 = 0\n"
-+" local revents2 = next_revents_idx_revents_tmp\n"
-+" idx1 = Cmod.poller_next_revents(self, revents2)\n"
-+" return idx1, revents2[0]\n"
++" local revents2\n"
++" idx1 = Cmod.poller_next_revents(self, next_revents_idx_revents_tmp)\n"
++" revents2 = next_revents_idx_revents_tmp[0]\n"
++" return idx1, revents2\n"
+"end\n"
+"end\n"
+"\n"
@@ -7115,6 +7492,29 @@ index a6d739d..7442736 100644
+" end\n"
+" return obj_type_ZMQ_Socket_push(rc_zmq_socket1, rc_zmq_socket_flags1)\n"
+"end\n"
++"\n", /* ----- CUT ----- */
++"-- method: set\n"
++"if (_meth.ZMQ_Ctx.set) then\n"
++"function _meth.ZMQ_Ctx.set(self, flag2, value3)\n"
++" \n"
++" \n"
++" \n"
++" local rc_zmq_ctx_set1 = 0\n"
++" rc_zmq_ctx_set1 = C.zmq_ctx_set(self, flag2, value3)\n"
++" return rc_zmq_ctx_set1\n"
++"end\n"
++"end\n"
++"\n"
++"-- method: get\n"
++"if (_meth.ZMQ_Ctx.get) then\n"
++"function _meth.ZMQ_Ctx.get(self, flag2)\n"
++" \n"
++" \n"
++" local rc_zmq_ctx_get1 = 0\n"
++" rc_zmq_ctx_get1 = C.zmq_ctx_get(self, flag2)\n"
++" return rc_zmq_ctx_get1\n"
++"end\n"
++"end\n"
+"\n"
+"_push.ZMQ_Ctx = obj_type_ZMQ_Ctx_push\n"
+"ffi.metatype(\"ZMQ_Ctx\", _priv.ZMQ_Ctx)\n"
@@ -7184,13 +7584,29 @@ index a6d739d..7442736 100644
+" local rc_zmq_device1 = 0\n"
+" rc_zmq_device1 = C.zmq_device(device1, insock2, outsock3)\n"
+" -- check for error.\n"
-+" if (-1 == rc_zmq_device1) then\n", /* ----- CUT ----- */
++" if (-1 == rc_zmq_device1) then\n"
+" return nil, error_code__ZMQ_Error__push(rc_zmq_device1)\n"
+" end\n"
+" return true\n"
+"end\n"
+"end\n"
+"\n"
++"-- method: proxy\n"
++"if (_M.proxy) then\n"
++"function _M.proxy(frontend1, backend2, capture3)\n"
++" \n"
++" \n"
++" capture3 = capture3 and obj_type_ZMQ_Socket_check(capture3) or nil\n"
++" local rc_zmq_proxy1 = 0\n"
++" rc_zmq_proxy1 = C.zmq_proxy(frontend1, backend2, capture3)\n"
++" -- check for error.\n"
++" if (-1 == rc_zmq_proxy1) then\n"
++" return nil, error_code__ZMQ_Error__push(rc_zmq_proxy1)\n"
++" end\n"
++" return true\n"
++"end\n"
++"end\n"
++"\n"
+"-- method: stopwatch_start\n"
+"function _M.stopwatch_start()\n"
+" local rc_zmq_stopwatch_start_flags1 = OBJ_UDATA_FLAG_OWN\n"
@@ -7224,7 +7640,7 @@ index a6d739d..7442736 100644
+ case ETERM:
+ return "closed";
+ break;
- #endif
++#endif
+ default:
+ break;
+ }
@@ -7236,12 +7652,8 @@ index a6d739d..7442736 100644
+/* detect really old ZeroMQ 2.0.x series. */
+#if !defined(ZMQ_RCVMORE)
+# error "Your version of ZeroMQ is too old. Please upgrade to version 2.1 or to the latest 2.0.x"
- #endif
-
--/* detect really old ZeroMQ 2.0.x series. */
--#if !defined(ZMQ_RCVMORE)
--#error "Your version of ZeroMQ is too old. Please upgrade to version 2.1 or to the latest 2.0.x"
--#endif
++#endif
++
+typedef struct ZMQ_Socket ZMQ_Socket;
+
+#ifdef _WIN32
@@ -7254,7 +7666,7 @@ index a6d739d..7442736 100644
+#if VERSION_2_0
+# define zmq_sendmsg zmq_send
+# define zmq_recvmsg zmq_recv
-+#endif
+ #endif
+
+/* socket option types. */
+#define OPT_TYPE_NONE 0
@@ -7348,7 +7760,7 @@ index a6d739d..7442736 100644
+# else
+# define MAX_OPTS VERSION_2_0_MAX_OPT
+# endif
-+#endif
+ #endif
+};
+
+#if VERSION_2_0
@@ -7702,7 +8114,10 @@ index a6d739d..7442736 100644
+LUA_NOBJ_API ZMQ_Error lzmq_socket_set_maxmsgsize(ZMQ_Socket *sock, int64_t value) {
+ return zmq_setsockopt(sock, ZMQ_MAXMSGSIZE, &value, sizeof(value));
+}
-+
+
+-/* detect really old ZeroMQ 2.0.x series. */
+-#if !defined(ZMQ_RCVMORE)
+-#error "Your version of ZeroMQ is too old. Please upgrade to version 2.1 or to the latest 2.0.x"
+LUA_NOBJ_API ZMQ_Error lzmq_socket_maxmsgsize(ZMQ_Socket *sock, int64_t *value) {
+ size_t val_len = sizeof(int64_t);
+ return zmq_getsockopt(sock, ZMQ_MAXMSGSIZE, value, &val_len);
@@ -7958,18 +8373,11 @@ index a6d739d..7442736 100644
+ memset(&(items[count]), 0, ((old_count - count) * sizeof(zmq_pollitem_t)));
+ poller->count = count;
+ poller->free_list = -1; /* free list is now empty. */
-
--typedef struct ZMQ_Socket ZMQ_Socket;
++
+ assert(count <= poller->len);
+ return count;
+}
-
--#ifdef _WIN32
--#include <winsock2.h>
--typedef SOCKET socket_t;
--#else
--typedef int socket_t;
--#endif
++
+int poller_poll(ZMQ_Poller *poller, long timeout) {
+ int count;
+ /* remove free slots from items list. */
@@ -7981,36 +8389,13 @@ index a6d739d..7442736 100644
+ /* poll for events. */
+ return zmq_poll(poller->items, count, timeout);
+}
-
--/* socket option types. */
--#define OPT_TYPE_NONE 0
--#define OPT_TYPE_INT 1
--#define OPT_TYPE_UINT32 2
--#define OPT_TYPE_UINT64 3
--#define OPT_TYPE_INT64 4
--#define OPT_TYPE_STR 5
--#define OPT_TYPE_FD 6
++
+int poller_next_revents(ZMQ_Poller *poller, int *revents) {
+ zmq_pollitem_t *items;
+ int count;
+ int idx;
+ int next;
-
--static const int opt_types[] = {
-- OPT_TYPE_NONE, /* 0 unused */
-- OPT_TYPE_UINT64, /* 1 ZMQ_HWM */
-- OPT_TYPE_NONE, /* 2 unused */
-- OPT_TYPE_INT64, /* 3 ZMQ_SWAP */
-- OPT_TYPE_UINT64, /* 4 ZMQ_AFFINITY */
-- OPT_TYPE_STR, /* 5 ZMQ_IDENTITY */
-- OPT_TYPE_STR, /* 6 ZMQ_SUBSCRIBE */
-- OPT_TYPE_STR, /* 7 ZMQ_UNSUBSCRIBE */
-- OPT_TYPE_INT64, /* 8 ZMQ_RATE */
-- OPT_TYPE_INT64, /* 9 ZMQ_RECOVERY_IVL */
-- OPT_TYPE_INT64, /* 10 ZMQ_MCAST_LOOP */
-- OPT_TYPE_UINT64, /* 11 ZMQ_SNDBUF */
-- OPT_TYPE_UINT64, /* 12 ZMQ_RCVBUF */
-- OPT_TYPE_INT64, /* 13 ZMQ_RCVMORE */
++
+ idx = poller->next;
+ /* do we need to poll for more events? */
+ if(idx < 0) {
@@ -8032,20 +8417,7 @@ index a6d739d..7442736 100644
+ *revents = 0;
+ return -1;
+}
-
--#if VERSION_2_1
-- OPT_TYPE_FD, /* 14 ZMQ_FD */
-- OPT_TYPE_UINT32, /* 15 ZMQ_EVENTS */
-- OPT_TYPE_INT, /* 16 ZMQ_TYPE */
-- OPT_TYPE_INT, /* 17 ZMQ_LINGER */
-- OPT_TYPE_INT, /* 18 ZMQ_RECONNECT_IVL */
-- OPT_TYPE_INT, /* 19 ZMQ_BACKLOG */
--#endif
--};
--#if VERSION_2_1
--#define MAX_OPTS ZMQ_BACKLOG
--#else
--#define MAX_OPTS ZMQ_RCVMORE
++
+
+typedef struct ZMQ_Ctx ZMQ_Ctx;
+
@@ -8108,16 +8480,26 @@ index a6d739d..7442736 100644
+ lua_pushstring(L, msg1);
+ lua_rawset(L, 1);
+-typedef struct ZMQ_Socket ZMQ_Socket;
+-
+-#ifdef _WIN32
+-#include <winsock2.h>
+-typedef SOCKET socket_t;
+-#else
+-typedef int socket_t;
+-#endif
+ lua_pushstring(L, msg1);
+ return 1;
+}
--static ZMQ_Error simple_zmq_send(ZMQ_Socket *sock, const char *data, size_t data_len, int flags) {
-- ZMQ_Error err;
-- zmq_msg_t msg;
-- /* initialize message */
-- err = zmq_msg_init_size(&msg, data_len);
-- if(0 == err) {
+-/* socket option types. */
+-#define OPT_TYPE_NONE 0
+-#define OPT_TYPE_INT 1
+-#define OPT_TYPE_UINT32 2
+-#define OPT_TYPE_UINT64 3
+-#define OPT_TYPE_INT64 4
+-#define OPT_TYPE_STR 5
+-#define OPT_TYPE_FD 6
+static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err) {
+ const char *err_str = NULL;
+ int num;
@@ -8140,14 +8522,43 @@ index a6d739d..7442736 100644
+ lua_pushfstring(L, "UNKNOWN ERROR(%d)", num);
+ return;
+ }
-+
+
+-static const int opt_types[] = {
+- OPT_TYPE_NONE, /* 0 unused */
+- OPT_TYPE_UINT64, /* 1 ZMQ_HWM */
+- OPT_TYPE_NONE, /* 2 unused */
+- OPT_TYPE_INT64, /* 3 ZMQ_SWAP */
+- OPT_TYPE_UINT64, /* 4 ZMQ_AFFINITY */
+- OPT_TYPE_STR, /* 5 ZMQ_IDENTITY */
+- OPT_TYPE_STR, /* 6 ZMQ_SUBSCRIBE */
+- OPT_TYPE_STR, /* 7 ZMQ_UNSUBSCRIBE */
+- OPT_TYPE_INT64, /* 8 ZMQ_RATE */
+- OPT_TYPE_INT64, /* 9 ZMQ_RECOVERY_IVL */
+- OPT_TYPE_INT64, /* 10 ZMQ_MCAST_LOOP */
+- OPT_TYPE_UINT64, /* 11 ZMQ_SNDBUF */
+- OPT_TYPE_UINT64, /* 12 ZMQ_RCVBUF */
+- OPT_TYPE_INT64, /* 13 ZMQ_RCVMORE */
+ if(err_str) {
+ lua_pushstring(L, err_str);
+ } else {
+ lua_pushnil(L);
+ }
+}
-+
+
+-#if VERSION_2_1
+- OPT_TYPE_FD, /* 14 ZMQ_FD */
+- OPT_TYPE_UINT32, /* 15 ZMQ_EVENTS */
+- OPT_TYPE_INT, /* 16 ZMQ_TYPE */
+- OPT_TYPE_INT, /* 17 ZMQ_LINGER */
+- OPT_TYPE_INT, /* 18 ZMQ_RECONNECT_IVL */
+- OPT_TYPE_INT, /* 19 ZMQ_BACKLOG */
+-#endif
+-};
+-#if VERSION_2_1
+-#define MAX_OPTS ZMQ_BACKLOG
+-#else
+-#define MAX_OPTS ZMQ_RCVMORE
+-#endif
+/* method: init */
+static int zmq_msg_t__init__meth(lua_State *L) {
+ zmq_msg_t this1_store;
@@ -8162,7 +8573,7 @@ index a6d739d..7442736 100644
+ error_code__ZMQ_Error__push(L, rc_zmq_msg_init2);
+ return 2;
+}
-+
+
+/* method: init_size */
+static int zmq_msg_t__init_size__meth(lua_State *L) {
+ size_t size1;
@@ -8179,7 +8590,13 @@ index a6d739d..7442736 100644
+ error_code__ZMQ_Error__push(L, rc_zmq_msg_init_size2);
+ return 2;
+}
-+
+
+-static ZMQ_Error simple_zmq_send(ZMQ_Socket *sock, const char *data, size_t data_len, int flags) {
+- ZMQ_Error err;
+- zmq_msg_t msg;
+- /* initialize message */
+- err = zmq_msg_init_size(&msg, data_len);
+- if(0 == err) {
+/* method: init_data */
+static int zmq_msg_t__init_data__meth(lua_State *L) {
+ size_t data_len1;
@@ -8207,8 +8624,15 @@ index a6d739d..7442736 100644
+ }
+ error_code__ZMQ_Error__push(L, err2);
+ return 2;
-+}
-+
+ }
+
+-struct ZMQ_Poller {
+- zmq_pollitem_t *items;
+- int next;
+- int count;
+- int free_list;
+- int len;
+-};
+/* method: _priv */
+static int zmq_msg_t__delete__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8225,7 +8649,7 @@ index a6d739d..7442736 100644
+ }
+ return 2;
+}
-+
+
+/* method: close */
+static int zmq_msg_t__close__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8242,7 +8666,8 @@ index a6d739d..7442736 100644
+ }
+ return 2;
+}
-+
+
+-typedef struct ZMQ_Poller ZMQ_Poller;
+/* method: move */
+static int zmq_msg_t__move__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8261,7 +8686,8 @@ index a6d739d..7442736 100644
+ }
+ return 2;
+}
-+
+
+-#define FREE_ITEM_EVENTS_TAG ((short)0xFFFF)
+/* method: copy */
+static int zmq_msg_t__copy__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8280,7 +8706,8 @@ index a6d739d..7442736 100644
+ }
+ return 2;
+}
-+
+
+-#define ITEM_TO_INDEX(items, item) (item - (items))
+/* method: set_data */
+static int zmq_msg_t__set_data__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8300,7 +8727,9 @@ index a6d739d..7442736 100644
+ }
+ /* copy data into message */
+ memcpy(zmq_msg_data(this1), data2, data_len2);
-+
+
+-static int poller_resize_items(ZMQ_Poller *poller, int len) {
+- int old_len = poller->len;
+ /* check for error. */
+ if((-1 == err1)) {
+ lua_pushnil(L);
@@ -8348,15 +8777,8 @@ index a6d739d..7442736 100644
+ lua_pushnil(L);
+ }
+ return 2;
- }
-
--struct ZMQ_Poller {
-- zmq_pollitem_t *items;
-- int next;
-- int count;
-- int free_list;
-- int len;
--};
++}
++
+/* method: size */
+static int zmq_msg_t__size__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8366,7 +8788,7 @@ index a6d739d..7442736 100644
+ lua_pushinteger(L, size1);
+ return 1;
+}
-
++
+/* method: __tostring */
+static int zmq_msg_t____tostring__meth(lua_State *L) {
+ zmq_msg_t * this1;
@@ -8375,13 +8797,11 @@ index a6d739d..7442736 100644
+ this1 = obj_type_zmq_msg_t_check(L,1);
+ data1 = zmq_msg_data(this1);
+ data_len1 = zmq_msg_size(this1);
-
--typedef struct ZMQ_Poller ZMQ_Poller;
++
+ if(data1 == NULL) lua_pushnil(L); else lua_pushlstring(L, data1,data_len1);
+ return 1;
+}
-
--#define FREE_ITEM_EVENTS_TAG ((short)0xFFFF)
++
+/* method: close */
+static int ZMQ_Socket__close__meth(lua_State *L) {
+ int this_flags1 = 0;
@@ -8400,8 +8820,7 @@ index a6d739d..7442736 100644
+ }
+ return 2;
+}
-
--#define ITEM_TO_INDEX(items, item) (item - (items))
++
+/* method: bind */
+static int ZMQ_Socket__bind__meth(lua_State *L) {
+ ZMQ_Socket * this1;
@@ -8422,8 +8841,32 @@ index a6d739d..7442736 100644
+ return 2;
+}
--static int poller_resize_items(ZMQ_Poller *poller, int len) {
-- int old_len = poller->len;
+- /* make sure new length is atleast as large as items count. */
+- len = (poller->count <= len) ? len : poller->count;
++/* method: unbind */
++#if (VERSION_3_2)
++static int ZMQ_Socket__unbind__meth(lua_State *L) {
++ ZMQ_Socket * this1;
++ size_t addr_len2;
++ const char * addr2;
++ ZMQ_Error rc_zmq_unbind1 = 0;
++ this1 = obj_type_ZMQ_Socket_check(L,1);
++ addr2 = luaL_checklstring(L,2,&(addr_len2));
++ rc_zmq_unbind1 = zmq_unbind(this1, addr2);
++ /* check for error. */
++ if((-1 == rc_zmq_unbind1)) {
++ lua_pushnil(L);
++ error_code__ZMQ_Error__push(L, rc_zmq_unbind1);
++ } else {
++ lua_pushboolean(L, 1);
++ lua_pushnil(L);
++ }
++ return 2;
++}
++#endif
+
+- /* if the new length is the same as the old length, then don't try to resize. */
+- if(old_len == len) return len;
+/* method: connect */
+static int ZMQ_Socket__connect__meth(lua_State *L) {
+ ZMQ_Socket * this1;
@@ -8444,8 +8887,39 @@ index a6d739d..7442736 100644
+ return 2;
+}
-- /* make sure new length is atleast as large as items count. */
-- len = (poller->count <= len) ? len : poller->count;
+- poller->items = (zmq_pollitem_t *)realloc(poller->items, len * sizeof(zmq_pollitem_t));
+- poller->len = len;
+- if(len > old_len) {
+- /* clear new space. */
+- memset(&(poller->items[old_len]), 0, (len - old_len) * sizeof(zmq_pollitem_t));
+- }
+- return len;
++/* method: disconnect */
++#if (VERSION_3_2)
++static int ZMQ_Socket__disconnect__meth(lua_State *L) {
++ ZMQ_Socket * this1;
++ size_t addr_len2;
++ const char * addr2;
++ ZMQ_Error rc_zmq_disconnect1 = 0;
++ this1 = obj_type_ZMQ_Socket_check(L,1);
++ addr2 = luaL_checklstring(L,2,&(addr_len2));
++ rc_zmq_disconnect1 = zmq_disconnect(this1, addr2);
++ /* check for error. */
++ if((-1 == rc_zmq_disconnect1)) {
++ lua_pushnil(L);
++ error_code__ZMQ_Error__push(L, rc_zmq_disconnect1);
++ } else {
++ lua_pushboolean(L, 1);
++ lua_pushnil(L);
++ }
++ return 2;
+ }
++#endif
+
+-static int poller_find_sock_item(ZMQ_Poller *poller, ZMQ_Socket *sock) {
+- zmq_pollitem_t *items;
+- int count;
+- int n;
+/* method: setopt */
+static int ZMQ_Socket__setopt__meth(lua_State *L) {
+ ZMQ_Socket * this1;
@@ -8456,8 +8930,11 @@ index a6d739d..7442736 100644
+ size_t val_len;
+ const void *val;
-- /* if the new length is the same as the old length, then don't try to resize. */
-- if(old_len == len) return len;
+- /* find ZMQ_Socket */
+- items = poller->items;
+- count = poller->count;
+- for(n=0; n < count; n++) {
+- if(items[n].socket == sock) return n;
+#if defined(VERSION_2_1) || defined(VERSION_3_0)
+ socket_t fd_val;
+#endif
@@ -8465,12 +8942,7 @@ index a6d739d..7442736 100644
+ uint32_t uint32_val;
+ uint64_t uint64_val;
+ int64_t int64_val;
-
-- poller->items = (zmq_pollitem_t *)realloc(poller->items, len * sizeof(zmq_pollitem_t));
-- poller->len = len;
-- if(len > old_len) {
-- /* clear new space. */
-- memset(&(poller->items[old_len]), 0, (len - old_len) * sizeof(zmq_pollitem_t));
++
+#if VERSION_3_0
+ /* 3.0 backwards compatibility support for HWM. */
+ if(opt2 == ZMQ_HWM) {
@@ -8483,31 +8955,18 @@ index a6d739d..7442736 100644
+ }
+ goto finished;
}
-- return len;
--}
--
--static int poller_find_sock_item(ZMQ_Poller *poller, ZMQ_Socket *sock) {
-- zmq_pollitem_t *items;
-- int count;
-- int n;
-+#endif
-
-- /* find ZMQ_Socket */
-- items = poller->items;
-- count = poller->count;
-- for(n=0; n < count; n++) {
-- if(items[n].socket == sock) return n;
-+ if(opt2 > MAX_OPTS) {
-+ return luaL_argerror(L, 2, "Invalid socket option.");
- }
- /* not found. */
- return -1;
-}
--
++#endif
+
-static int poller_find_fd_item(ZMQ_Poller *poller, socket_t fd) {
- zmq_pollitem_t *items;
- int count;
- int n;
++ if(opt2 > MAX_OPTS) {
++ return luaL_argerror(L, 2, "Invalid socket option.");
++ }
- /* find fd */
- items = poller->items;
@@ -8613,13 +9072,13 @@ index a6d739d..7442736 100644
- /* clear old revents. */
- items[idx].revents = 0;
-}
-
+-
-static int poller_get_free_item(ZMQ_Poller *poller) {
- zmq_pollitem_t *curr;
- zmq_pollitem_t *next;
- int count;
- int idx;
--
+
- count = poller->count;
- idx = poller->free_list;
- /* check for a free slot in the free list. */
@@ -8644,7 +9103,10 @@ index a6d739d..7442736 100644
+ if(0 == err2) {
+ lua_pushinteger(L, (lua_Integer)fd_val);
+ return 1;
-+ }
+ }
+- /* clear slot */
+- memset(curr, 0, sizeof(zmq_pollitem_t));
+- return idx;
+ break;
+#endif
+ case OPT_TYPE_INT:
@@ -8669,10 +9131,7 @@ index a6d739d..7442736 100644
+ if(0 == err2) {
+ lua_pushinteger(L, (lua_Integer)uint64_val);
+ return 1;
- }
-- /* clear slot */
-- memset(curr, 0, sizeof(zmq_pollitem_t));
-- return idx;
++ }
+ break;
+ case OPT_TYPE_INT64:
+ val_len = sizeof(int64_val);
@@ -8976,9 +9435,9 @@ index a6d739d..7442736 100644
+ lua_pushnil(L);
+ }
+ return 2;
-+}
+ }
+#endif
-+
+
+/* method: identity */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__identity__meth(lua_State *L) {
@@ -8995,7 +9454,7 @@ index a6d739d..7442736 100644
+ }
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_identity2);
+ return 2;
- }
++}
+#endif
+/* method: set_identity */
@@ -9042,6 +9501,11 @@ index a6d739d..7442736 100644
+}
+#endif
+-static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err) {
+- const char *err_str = NULL;
+- if(-1 == err) {
+- err_str = get_zmq_strerror();
+- }
+/* method: unsubscribe */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__unsubscribe__meth(lua_State *L) {
@@ -9064,10 +9528,10 @@ index a6d739d..7442736 100644
+}
+#endif
--static void error_code__ZMQ_Error__push(lua_State *L, ZMQ_Error err) {
-- const char *err_str = NULL;
-- if(-1 == err) {
-- err_str = get_zmq_strerror();
+- if(err_str) {
+- lua_pushstring(L, err_str);
+- } else {
+- lua_pushnil(L);
- }
+/* method: rate */
+#if (VERSION_2_0|VERSION_3_0)
@@ -9084,14 +9548,17 @@ index a6d739d..7442736 100644
+ }
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rate2);
+ return 2;
-+}
+ }
+#endif
-- if(err_str) {
-- lua_pushstring(L, err_str);
-- } else {
-- lua_pushnil(L);
-- }
+-/* method: init */
+-static int zmq_msg_t__init__meth(lua_State *L) {
+- int this_flags1 = OBJ_UDATA_FLAG_OWN;
+- zmq_msg_t * this1;
+- ZMQ_Error err2 = 0;
+- zmq_msg_t tmp;
+- this1 = &tmp;
+- err2 = zmq_msg_init(this1);
+/* method: set_rate */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__set_rate__meth(lua_State *L) {
@@ -9110,17 +9577,11 @@ index a6d739d..7442736 100644
+ lua_pushnil(L);
+ }
+ return 2;
- }
++}
+#endif
--/* method: init */
--static int zmq_msg_t__init__meth(lua_State *L) {
-- int this_flags1 = OBJ_UDATA_FLAG_OWN;
-- zmq_msg_t * this1;
-- ZMQ_Error err2 = 0;
-- zmq_msg_t tmp;
-- this1 = &tmp;
-- err2 = zmq_msg_init(this1);
+- if(!(-1 == err2)) {
+- obj_type_zmq_msg_t_push(L, this1, this_flags1);
+/* method: recovery_ivl */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__recovery_ivl__meth(lua_State *L) {
@@ -9131,16 +9592,24 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_recovery_ivl2 = lzmq_socket_recovery_ivl(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_recovery_ivl2)) {
+ lua_pushinteger(L, value1);
-+ } else {
-+ lua_pushnil(L);
-+ }
+ } else {
+ lua_pushnil(L);
+ }
+- error_code__ZMQ_Error__push(L, err2);
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_recovery_ivl2);
-+ return 2;
-+}
+ return 2;
+ }
+#endif
-- if(!(-1 == err2)) {
-- obj_type_zmq_msg_t_push(L, this1, this_flags1);
+-/* method: init_size */
+-static int zmq_msg_t__init_size__meth(lua_State *L) {
+- size_t size1 = luaL_checkinteger(L,1);
+- int this_flags1 = OBJ_UDATA_FLAG_OWN;
+- zmq_msg_t * this1;
+- ZMQ_Error err2 = 0;
+- zmq_msg_t tmp;
+- this1 = &tmp;
+- err2 = zmq_msg_init_size(this1, size1);
+/* method: set_recovery_ivl */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__set_recovery_ivl__meth(lua_State *L) {
@@ -9154,25 +9623,14 @@ index a6d739d..7442736 100644
+ if((-1 == rc_lzmq_socket_set_recovery_ivl1)) {
+ lua_pushnil(L);
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_recovery_ivl1);
- } else {
++ } else {
+ lua_pushboolean(L, 1);
- lua_pushnil(L);
- }
-- error_code__ZMQ_Error__push(L, err2);
- return 2;
- }
++ lua_pushnil(L);
++ }
++ return 2;
++}
+#endif
--/* method: init_size */
--static int zmq_msg_t__init_size__meth(lua_State *L) {
-- size_t size1 = luaL_checkinteger(L,1);
-- int this_flags1 = OBJ_UDATA_FLAG_OWN;
-- zmq_msg_t * this1;
-- ZMQ_Error err2 = 0;
-- zmq_msg_t tmp;
-- this1 = &tmp;
-- err2 = zmq_msg_init_size(this1, size1);
--
- if(!(-1 == err2)) {
- obj_type_zmq_msg_t_push(L, this1, this_flags1);
+/* method: mcast_loop */
@@ -9185,29 +9643,14 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_mcast_loop2 = lzmq_socket_mcast_loop(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_mcast_loop2)) {
+ lua_pushinteger(L, value1);
- } else {
- lua_pushnil(L);
- }
-- error_code__ZMQ_Error__push(L, err2);
++ } else {
++ lua_pushnil(L);
++ }
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_mcast_loop2);
- return 2;
- }
++ return 2;
++}
+#endif
-
--/* method: init_data */
--static int zmq_msg_t__init_data__meth(lua_State *L) {
-- size_t data_len1;
-- const char * data1 = luaL_checklstring(L,1,&(data_len1));
-- int this_flags1 = OBJ_UDATA_FLAG_OWN;
-- zmq_msg_t * this1;
-- ZMQ_Error err2 = 0;
-- zmq_msg_t tmp;
-- this1 = &tmp;
-- err2 = zmq_msg_init_size(this1, data_len1);
-- if(0 == err2) {
-- /* fill message */
-- memcpy(zmq_msg_data(this1), data1, data_len1);
-- }
++
+/* method: set_mcast_loop */
+#if (VERSION_2_0)
+static int ZMQ_Socket__set_mcast_loop__meth(lua_State *L) {
@@ -9228,9 +9671,7 @@ index a6d739d..7442736 100644
+ return 2;
+}
+#endif
-
-- if(!(-1 == err2)) {
-- obj_type_zmq_msg_t_push(L, this1, this_flags1);
++
+/* method: sndbuf */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__sndbuf__meth(lua_State *L) {
@@ -9241,22 +9682,14 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_sndbuf2 = lzmq_socket_sndbuf(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_sndbuf2)) {
+ lua_pushinteger(L, value1);
- } else {
- lua_pushnil(L);
- }
-- error_code__ZMQ_Error__push(L, err2);
++ } else {
++ lua_pushnil(L);
++ }
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_sndbuf2);
- return 2;
- }
++ return 2;
++}
+#endif
-
--/* method: delete */
--static int zmq_msg_t__delete__meth(lua_State *L) {
-- int this_flags1 = 0;
-- zmq_msg_t * this1 = obj_type_zmq_msg_t_delete(L,1,&(this_flags1));
-- ZMQ_Error rc_zmq_msg_close1 = 0;
-- if(!(this_flags1 & OBJ_UDATA_FLAG_OWN)) { return 0; }
-- rc_zmq_msg_close1 = zmq_msg_close(this1);
++
+/* method: set_sndbuf */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__set_sndbuf__meth(lua_State *L) {
@@ -9266,25 +9699,36 @@ index a6d739d..7442736 100644
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
+ rc_lzmq_socket_set_sndbuf1 = lzmq_socket_set_sndbuf(this1, value2);
- /* check for error. */
-- if((-1 == rc_zmq_msg_close1)) {
++ /* check for error. */
+ if((-1 == rc_lzmq_socket_set_sndbuf1)) {
- lua_pushnil(L);
-- error_code__ZMQ_Error__push(L, rc_zmq_msg_close1);
++ lua_pushnil(L);
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_sndbuf1);
} else {
- lua_pushboolean(L, 1);
++ lua_pushboolean(L, 1);
lua_pushnil(L);
}
+- error_code__ZMQ_Error__push(L, err2);
return 2;
}
+#endif
--/* method: close */
--static int zmq_msg_t__close__meth(lua_State *L) {
-- zmq_msg_t * this1 = obj_type_zmq_msg_t_check(L,1);
-- ZMQ_Error rc_zmq_msg_close1 = 0;
-- rc_zmq_msg_close1 = zmq_msg_close(this1);
+-/* method: init_data */
+-static int zmq_msg_t__init_data__meth(lua_State *L) {
+- size_t data_len1;
+- const char * data1 = luaL_checklstring(L,1,&(data_len1));
+- int this_flags1 = OBJ_UDATA_FLAG_OWN;
+- zmq_msg_t * this1;
+- ZMQ_Error err2 = 0;
+- zmq_msg_t tmp;
+- this1 = &tmp;
+- err2 = zmq_msg_init_size(this1, data_len1);
+- if(0 == err2) {
+- /* fill message */
+- memcpy(zmq_msg_data(this1), data1, data_len1);
+- }
+-
+- if(!(-1 == err2)) {
+- obj_type_zmq_msg_t_push(L, this1, this_flags1);
+/* method: rcvbuf */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__rcvbuf__meth(lua_State *L) {
@@ -9295,14 +9739,22 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_rcvbuf2 = lzmq_socket_rcvbuf(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_rcvbuf2)) {
+ lua_pushinteger(L, value1);
-+ } else {
-+ lua_pushnil(L);
-+ }
+ } else {
+ lua_pushnil(L);
+ }
+- error_code__ZMQ_Error__push(L, err2);
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rcvbuf2);
-+ return 2;
-+}
+ return 2;
+ }
+#endif
-+
+
+-/* method: delete */
+-static int zmq_msg_t__delete__meth(lua_State *L) {
+- int this_flags1 = 0;
+- zmq_msg_t * this1 = obj_type_zmq_msg_t_delete(L,1,&(this_flags1));
+- ZMQ_Error rc_zmq_msg_close1 = 0;
+- if(!(this_flags1 & OBJ_UDATA_FLAG_OWN)) { return 0; }
+- rc_zmq_msg_close1 = zmq_msg_close(this1);
+/* method: set_rcvbuf */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__set_rcvbuf__meth(lua_State *L) {
@@ -9326,14 +9778,15 @@ index a6d739d..7442736 100644
}
+#endif
--/* method: move */
--static int zmq_msg_t__move__meth(lua_State *L) {
+-/* method: close */
+-static int zmq_msg_t__close__meth(lua_State *L) {
- zmq_msg_t * this1 = obj_type_zmq_msg_t_check(L,1);
-- zmq_msg_t * src2 = obj_type_zmq_msg_t_check(L,2);
-- ZMQ_Error rc_zmq_msg_move1 = 0;
-- rc_zmq_msg_move1 = zmq_msg_move(this1, src2);
+- ZMQ_Error rc_zmq_msg_close1 = 0;
+- rc_zmq_msg_close1 = zmq_msg_close(this1);
- /* check for error. */
-- if((-1 == rc_zmq_msg_move1)) {
+- if((-1 == rc_zmq_msg_close1)) {
+- lua_pushnil(L);
+- error_code__ZMQ_Error__push(L, rc_zmq_msg_close1);
+/* method: rcvmore */
+#if (VERSION_2_0|VERSION_3_0)
+static int ZMQ_Socket__rcvmore__meth(lua_State *L) {
@@ -9344,15 +9797,25 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_rcvmore2 = lzmq_socket_rcvmore(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_rcvmore2)) {
+ lua_pushinteger(L, value1);
-+ } else {
+ } else {
+- lua_pushboolean(L, 1);
lua_pushnil(L);
-- error_code__ZMQ_Error__push(L, rc_zmq_msg_move1);
-+ }
+ }
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rcvmore2);
-+ return 2;
-+}
+ return 2;
+ }
+#endif
-+
+
+-/* method: move */
+-static int zmq_msg_t__move__meth(lua_State *L) {
+- zmq_msg_t * this1 = obj_type_zmq_msg_t_check(L,1);
+- zmq_msg_t * src2 = obj_type_zmq_msg_t_check(L,2);
+- ZMQ_Error rc_zmq_msg_move1 = 0;
+- rc_zmq_msg_move1 = zmq_msg_move(this1, src2);
+- /* check for error. */
+- if((-1 == rc_zmq_msg_move1)) {
+- lua_pushnil(L);
+- error_code__ZMQ_Error__push(L, rc_zmq_msg_move1);
+/* method: fd */
+#if (VERSION_2_1|VERSION_3_0)
+static int ZMQ_Socket__fd__meth(lua_State *L) {
@@ -9613,6 +10076,10 @@ index a6d739d..7442736 100644
- const char * addr2 = luaL_checklstring(L,2,&(addr_len2));
- ZMQ_Error rc_zmq_bind1 = 0;
- rc_zmq_bind1 = zmq_bind(this1, addr2);
+- /* check for error. */
+- if((-1 == rc_zmq_bind1)) {
+- lua_pushnil(L);
+- error_code__ZMQ_Error__push(L, rc_zmq_bind1);
+/* method: recovery_ivl_msec */
+#if (VERSION_2_1)
+static int ZMQ_Socket__recovery_ivl_msec__meth(lua_State *L) {
@@ -9623,33 +10090,11 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_recovery_ivl_msec2 = lzmq_socket_recovery_ivl_msec(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_recovery_ivl_msec2)) {
+ lua_pushinteger(L, value1);
-+ } else {
-+ lua_pushnil(L);
-+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_recovery_ivl_msec2);
-+ return 2;
-+}
-+#endif
-+
-+/* method: set_recovery_ivl_msec */
-+#if (VERSION_2_1)
-+static int ZMQ_Socket__set_recovery_ivl_msec__meth(lua_State *L) {
-+ ZMQ_Socket * this1;
-+ int64_t value2;
-+ ZMQ_Error rc_lzmq_socket_set_recovery_ivl_msec1 = 0;
-+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_recovery_ivl_msec1 = lzmq_socket_set_recovery_ivl_msec(this1, value2);
- /* check for error. */
-- if((-1 == rc_zmq_bind1)) {
-+ if((-1 == rc_lzmq_socket_set_recovery_ivl_msec1)) {
- lua_pushnil(L);
-- error_code__ZMQ_Error__push(L, rc_zmq_bind1);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_recovery_ivl_msec1);
} else {
- lua_pushboolean(L, 1);
+- lua_pushboolean(L, 1);
lua_pushnil(L);
}
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_recovery_ivl_msec2);
return 2;
}
+#endif
@@ -9661,39 +10106,21 @@ index a6d739d..7442736 100644
- const char * addr2 = luaL_checklstring(L,2,&(addr_len2));
- ZMQ_Error rc_zmq_connect1 = 0;
- rc_zmq_connect1 = zmq_connect(this1, addr2);
-+/* method: reconnect_ivl_max */
-+#if (VERSION_2_1|VERSION_3_0)
-+static int ZMQ_Socket__reconnect_ivl_max__meth(lua_State *L) {
-+ ZMQ_Socket * this1;
-+ int value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_reconnect_ivl_max2 = 0;
-+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_reconnect_ivl_max2 = lzmq_socket_reconnect_ivl_max(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_reconnect_ivl_max2)) {
-+ lua_pushinteger(L, value1);
-+ } else {
-+ lua_pushnil(L);
-+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_reconnect_ivl_max2);
-+ return 2;
-+}
-+#endif
-+
-+/* method: set_reconnect_ivl_max */
-+#if (VERSION_2_1|VERSION_3_0)
-+static int ZMQ_Socket__set_reconnect_ivl_max__meth(lua_State *L) {
++/* method: set_recovery_ivl_msec */
++#if (VERSION_2_1)
++static int ZMQ_Socket__set_recovery_ivl_msec__meth(lua_State *L) {
+ ZMQ_Socket * this1;
-+ int value2;
-+ ZMQ_Error rc_lzmq_socket_set_reconnect_ivl_max1 = 0;
++ int64_t value2;
++ ZMQ_Error rc_lzmq_socket_set_recovery_ivl_msec1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_reconnect_ivl_max1 = lzmq_socket_set_reconnect_ivl_max(this1, value2);
++ rc_lzmq_socket_set_recovery_ivl_msec1 = lzmq_socket_set_recovery_ivl_msec(this1, value2);
/* check for error. */
- if((-1 == rc_zmq_connect1)) {
-+ if((-1 == rc_lzmq_socket_set_reconnect_ivl_max1)) {
++ if((-1 == rc_lzmq_socket_set_recovery_ivl_msec1)) {
lua_pushnil(L);
- error_code__ZMQ_Error__push(L, rc_zmq_connect1);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_reconnect_ivl_max1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_recovery_ivl_msec1);
} else {
lua_pushboolean(L, 1);
lua_pushnil(L);
@@ -9728,20 +10155,20 @@ index a6d739d..7442736 100644
- val = &fd_val;
- val_len = sizeof(fd_val);
- break;
-+/* method: maxmsgsize */
-+#if (VERSION_3_0)
-+static int ZMQ_Socket__maxmsgsize__meth(lua_State *L) {
++/* method: reconnect_ivl_max */
++#if (VERSION_2_1|VERSION_3_0)
++static int ZMQ_Socket__reconnect_ivl_max__meth(lua_State *L) {
+ ZMQ_Socket * this1;
-+ int64_t value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_maxmsgsize2 = 0;
++ int value1 = 0;
++ ZMQ_Error rc_lzmq_socket_reconnect_ivl_max2 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_maxmsgsize2 = lzmq_socket_maxmsgsize(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_maxmsgsize2)) {
++ rc_lzmq_socket_reconnect_ivl_max2 = lzmq_socket_reconnect_ivl_max(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_reconnect_ivl_max2)) {
+ lua_pushinteger(L, value1);
+ } else {
+ lua_pushnil(L);
+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_maxmsgsize2);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_reconnect_ivl_max2);
+ return 2;
+}
#endif
@@ -9775,21 +10202,21 @@ index a6d739d..7442736 100644
- }
- err1 = zmq_setsockopt(this1, opt2, val, val_len);
-+/* method: set_maxmsgsize */
-+#if (VERSION_3_0)
-+static int ZMQ_Socket__set_maxmsgsize__meth(lua_State *L) {
++/* method: set_reconnect_ivl_max */
++#if (VERSION_2_1|VERSION_3_0)
++static int ZMQ_Socket__set_reconnect_ivl_max__meth(lua_State *L) {
+ ZMQ_Socket * this1;
-+ int64_t value2;
-+ ZMQ_Error rc_lzmq_socket_set_maxmsgsize1 = 0;
++ int value2;
++ ZMQ_Error rc_lzmq_socket_set_reconnect_ivl_max1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_maxmsgsize1 = lzmq_socket_set_maxmsgsize(this1, value2);
++ rc_lzmq_socket_set_reconnect_ivl_max1 = lzmq_socket_set_reconnect_ivl_max(this1, value2);
/* check for error. */
- if((-1 == err1)) {
-+ if((-1 == rc_lzmq_socket_set_maxmsgsize1)) {
++ if((-1 == rc_lzmq_socket_set_reconnect_ivl_max1)) {
lua_pushnil(L);
- error_code__ZMQ_Error__push(L, err1);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_maxmsgsize1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_reconnect_ivl_max1);
} else {
lua_pushboolean(L, 1);
lua_pushnil(L);
@@ -9819,20 +10246,20 @@ index a6d739d..7442736 100644
- lua_pushliteral(L, "Invalid socket option.");
- return 2;
- }
-+/* method: sndhwm */
++/* method: maxmsgsize */
+#if (VERSION_3_0)
-+static int ZMQ_Socket__sndhwm__meth(lua_State *L) {
++static int ZMQ_Socket__maxmsgsize__meth(lua_State *L) {
+ ZMQ_Socket * this1;
-+ int value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_sndhwm2 = 0;
++ int64_t value1 = 0;
++ ZMQ_Error rc_lzmq_socket_maxmsgsize2 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_sndhwm2 = lzmq_socket_sndhwm(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_sndhwm2)) {
++ rc_lzmq_socket_maxmsgsize2 = lzmq_socket_maxmsgsize(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_maxmsgsize2)) {
+ lua_pushinteger(L, value1);
+ } else {
+ lua_pushnil(L);
+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_sndhwm2);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_maxmsgsize2);
+ return 2;
+}
+#endif
@@ -9847,19 +10274,19 @@ index a6d739d..7442736 100644
- return 1;
- }
- break;
-+/* method: set_sndhwm */
++/* method: set_maxmsgsize */
+#if (VERSION_3_0)
-+static int ZMQ_Socket__set_sndhwm__meth(lua_State *L) {
++static int ZMQ_Socket__set_maxmsgsize__meth(lua_State *L) {
+ ZMQ_Socket * this1;
-+ int value2;
-+ ZMQ_Error rc_lzmq_socket_set_sndhwm1 = 0;
++ int64_t value2;
++ ZMQ_Error rc_lzmq_socket_set_maxmsgsize1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_sndhwm1 = lzmq_socket_set_sndhwm(this1, value2);
++ rc_lzmq_socket_set_maxmsgsize1 = lzmq_socket_set_maxmsgsize(this1, value2);
+ /* check for error. */
-+ if((-1 == rc_lzmq_socket_set_sndhwm1)) {
++ if((-1 == rc_lzmq_socket_set_maxmsgsize1)) {
+ lua_pushnil(L);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_sndhwm1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_maxmsgsize1);
+ } else {
+ lua_pushboolean(L, 1);
+ lua_pushnil(L);
@@ -9916,20 +10343,20 @@ index a6d739d..7442736 100644
- lua_pushnil(L);
- error_code__ZMQ_Error__push(L, err2);
-+/* method: rcvhwm */
++/* method: sndhwm */
+#if (VERSION_3_0)
-+static int ZMQ_Socket__rcvhwm__meth(lua_State *L) {
++static int ZMQ_Socket__sndhwm__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_rcvhwm2 = 0;
++ ZMQ_Error rc_lzmq_socket_sndhwm2 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_rcvhwm2 = lzmq_socket_rcvhwm(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_rcvhwm2)) {
++ rc_lzmq_socket_sndhwm2 = lzmq_socket_sndhwm(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_sndhwm2)) {
+ lua_pushinteger(L, value1);
+ } else {
+ lua_pushnil(L);
+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rcvhwm2);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_sndhwm2);
return 2;
}
+#endif
@@ -9944,19 +10371,19 @@ index a6d739d..7442736 100644
- err2 = zmq_getsockopt(this1, ZMQ_EVENTS, &(events1), &val_len);
-#else
- luaL_error(L, "'events' method only supported in 0MQ version >= 2.1");
-+/* method: set_rcvhwm */
++/* method: set_sndhwm */
+#if (VERSION_3_0)
-+static int ZMQ_Socket__set_rcvhwm__meth(lua_State *L) {
++static int ZMQ_Socket__set_sndhwm__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value2;
-+ ZMQ_Error rc_lzmq_socket_set_rcvhwm1 = 0;
++ ZMQ_Error rc_lzmq_socket_set_sndhwm1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_rcvhwm1 = lzmq_socket_set_rcvhwm(this1, value2);
++ rc_lzmq_socket_set_sndhwm1 = lzmq_socket_set_sndhwm(this1, value2);
+ /* check for error. */
-+ if((-1 == rc_lzmq_socket_set_rcvhwm1)) {
++ if((-1 == rc_lzmq_socket_set_sndhwm1)) {
+ lua_pushnil(L);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_rcvhwm1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_sndhwm1);
+ } else {
+ lua_pushboolean(L, 1);
+ lua_pushnil(L);
@@ -9967,21 +10394,21 @@ index a6d739d..7442736 100644
- if(!(-1 == err2)) {
- lua_pushinteger(L, events1);
-+/* method: multicast_hops */
++/* method: rcvhwm */
+#if (VERSION_3_0)
-+static int ZMQ_Socket__multicast_hops__meth(lua_State *L) {
++static int ZMQ_Socket__rcvhwm__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_multicast_hops2 = 0;
++ ZMQ_Error rc_lzmq_socket_rcvhwm2 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_multicast_hops2 = lzmq_socket_multicast_hops(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_multicast_hops2)) {
++ rc_lzmq_socket_rcvhwm2 = lzmq_socket_rcvhwm(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_rcvhwm2)) {
+ lua_pushinteger(L, value1);
} else {
lua_pushnil(L);
}
- error_code__ZMQ_Error__push(L, err2);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_multicast_hops2);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rcvhwm2);
return 2;
}
+#endif
@@ -9993,21 +10420,21 @@ index a6d739d..7442736 100644
- int flags3 = luaL_optinteger(L,3,0);
- ZMQ_Error rc_zmq_send1 = 0;
- rc_zmq_send1 = zmq_send(this1, msg2, flags3);
-+/* method: set_multicast_hops */
++/* method: set_rcvhwm */
+#if (VERSION_3_0)
-+static int ZMQ_Socket__set_multicast_hops__meth(lua_State *L) {
++static int ZMQ_Socket__set_rcvhwm__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value2;
-+ ZMQ_Error rc_lzmq_socket_set_multicast_hops1 = 0;
++ ZMQ_Error rc_lzmq_socket_set_rcvhwm1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_multicast_hops1 = lzmq_socket_set_multicast_hops(this1, value2);
++ rc_lzmq_socket_set_rcvhwm1 = lzmq_socket_set_rcvhwm(this1, value2);
/* check for error. */
- if((-1 == rc_zmq_send1)) {
-+ if((-1 == rc_lzmq_socket_set_multicast_hops1)) {
++ if((-1 == rc_lzmq_socket_set_rcvhwm1)) {
lua_pushnil(L);
- error_code__ZMQ_Error__push(L, rc_zmq_send1);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_multicast_hops1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_rcvhwm1);
} else {
lua_pushboolean(L, 1);
lua_pushnil(L);
@@ -10024,39 +10451,39 @@ index a6d739d..7442736 100644
- int flags3 = luaL_optinteger(L,3,0);
- ZMQ_Error err1 = 0;
- err1 = simple_zmq_send(this1, data2, data_len2, flags3);
-+/* method: rcvtimeo */
-+#if (VERSION_2_2|VERSION_3_0)
-+static int ZMQ_Socket__rcvtimeo__meth(lua_State *L) {
++/* method: multicast_hops */
++#if (VERSION_3_0)
++static int ZMQ_Socket__multicast_hops__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_rcvtimeo2 = 0;
++ ZMQ_Error rc_lzmq_socket_multicast_hops2 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_rcvtimeo2 = lzmq_socket_rcvtimeo(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_rcvtimeo2)) {
++ rc_lzmq_socket_multicast_hops2 = lzmq_socket_multicast_hops(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_multicast_hops2)) {
+ lua_pushinteger(L, value1);
+ } else {
+ lua_pushnil(L);
+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rcvtimeo2);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_multicast_hops2);
+ return 2;
+}
+#endif
-+/* method: set_rcvtimeo */
-+#if (VERSION_2_2|VERSION_3_0)
-+static int ZMQ_Socket__set_rcvtimeo__meth(lua_State *L) {
++/* method: set_multicast_hops */
++#if (VERSION_3_0)
++static int ZMQ_Socket__set_multicast_hops__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value2;
-+ ZMQ_Error rc_lzmq_socket_set_rcvtimeo1 = 0;
++ ZMQ_Error rc_lzmq_socket_set_multicast_hops1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_rcvtimeo1 = lzmq_socket_set_rcvtimeo(this1, value2);
++ rc_lzmq_socket_set_multicast_hops1 = lzmq_socket_set_multicast_hops(this1, value2);
/* check for error. */
- if((-1 == err1)) {
-+ if((-1 == rc_lzmq_socket_set_rcvtimeo1)) {
++ if((-1 == rc_lzmq_socket_set_multicast_hops1)) {
lua_pushnil(L);
- error_code__ZMQ_Error__push(L, err1);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_rcvtimeo1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_multicast_hops1);
} else {
lua_pushboolean(L, 1);
lua_pushnil(L);
@@ -10064,47 +10491,47 @@ index a6d739d..7442736 100644
return 2;
}
+#endif
-+
-+/* method: sndtimeo */
+
+-/* method: recv_msg */
+-static int ZMQ_Socket__recv_msg__meth(lua_State *L) {
+- ZMQ_Socket * this1 = obj_type_ZMQ_Socket_check(L,1);
+- zmq_msg_t * msg2 = obj_type_zmq_msg_t_check(L,2);
+- int flags3 = luaL_optinteger(L,3,0);
+- ZMQ_Error rc_zmq_recv1 = 0;
+- rc_zmq_recv1 = zmq_recv(this1, msg2, flags3);
++/* method: rcvtimeo */
+#if (VERSION_2_2|VERSION_3_0)
-+static int ZMQ_Socket__sndtimeo__meth(lua_State *L) {
++static int ZMQ_Socket__rcvtimeo__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value1 = 0;
-+ ZMQ_Error rc_lzmq_socket_sndtimeo2 = 0;
++ ZMQ_Error rc_lzmq_socket_rcvtimeo2 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
-+ rc_lzmq_socket_sndtimeo2 = lzmq_socket_sndtimeo(this1, &(value1));
-+ if(!(-1 == rc_lzmq_socket_sndtimeo2)) {
++ rc_lzmq_socket_rcvtimeo2 = lzmq_socket_rcvtimeo(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_rcvtimeo2)) {
+ lua_pushinteger(L, value1);
+ } else {
+ lua_pushnil(L);
+ }
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_sndtimeo2);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_rcvtimeo2);
+ return 2;
+}
+#endif
-
--/* method: recv_msg */
--static int ZMQ_Socket__recv_msg__meth(lua_State *L) {
-- ZMQ_Socket * this1 = obj_type_ZMQ_Socket_check(L,1);
-- zmq_msg_t * msg2 = obj_type_zmq_msg_t_check(L,2);
-- int flags3 = luaL_optinteger(L,3,0);
-- ZMQ_Error rc_zmq_recv1 = 0;
-- rc_zmq_recv1 = zmq_recv(this1, msg2, flags3);
-+/* method: set_sndtimeo */
++
++/* method: set_rcvtimeo */
+#if (VERSION_2_2|VERSION_3_0)
-+static int ZMQ_Socket__set_sndtimeo__meth(lua_State *L) {
++static int ZMQ_Socket__set_rcvtimeo__meth(lua_State *L) {
+ ZMQ_Socket * this1;
+ int value2;
-+ ZMQ_Error rc_lzmq_socket_set_sndtimeo1 = 0;
++ ZMQ_Error rc_lzmq_socket_set_rcvtimeo1 = 0;
+ this1 = obj_type_ZMQ_Socket_check(L,1);
+ value2 = luaL_checkinteger(L,2);
-+ rc_lzmq_socket_set_sndtimeo1 = lzmq_socket_set_sndtimeo(this1, value2);
++ rc_lzmq_socket_set_rcvtimeo1 = lzmq_socket_set_rcvtimeo(this1, value2);
/* check for error. */
- if((-1 == rc_zmq_recv1)) {
-+ if((-1 == rc_lzmq_socket_set_sndtimeo1)) {
++ if((-1 == rc_lzmq_socket_set_rcvtimeo1)) {
lua_pushnil(L);
- error_code__ZMQ_Error__push(L, rc_zmq_recv1);
-+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_sndtimeo1);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_rcvtimeo1);
} else {
lua_pushboolean(L, 1);
lua_pushnil(L);
@@ -10131,9 +10558,50 @@ index a6d739d..7442736 100644
- data_len1 = zmq_msg_size(&msg);
- }
- }
--
++/* method: sndtimeo */
++#if (VERSION_2_2|VERSION_3_0)
++static int ZMQ_Socket__sndtimeo__meth(lua_State *L) {
++ ZMQ_Socket * this1;
++ int value1 = 0;
++ ZMQ_Error rc_lzmq_socket_sndtimeo2 = 0;
++ this1 = obj_type_ZMQ_Socket_check(L,1);
++ rc_lzmq_socket_sndtimeo2 = lzmq_socket_sndtimeo(this1, &(value1));
++ if(!(-1 == rc_lzmq_socket_sndtimeo2)) {
++ lua_pushinteger(L, value1);
++ } else {
++ lua_pushnil(L);
++ }
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_sndtimeo2);
++ return 2;
++}
++#endif
+
- if(!(-1 == err2)) {
- if(data1 == NULL) lua_pushnil(L); else lua_pushlstring(L, data1,data_len1);
++/* method: set_sndtimeo */
++#if (VERSION_2_2|VERSION_3_0)
++static int ZMQ_Socket__set_sndtimeo__meth(lua_State *L) {
++ ZMQ_Socket * this1;
++ int value2;
++ ZMQ_Error rc_lzmq_socket_set_sndtimeo1 = 0;
++ this1 = obj_type_ZMQ_Socket_check(L,1);
++ value2 = luaL_checkinteger(L,2);
++ rc_lzmq_socket_set_sndtimeo1 = lzmq_socket_set_sndtimeo(this1, value2);
++ /* check for error. */
++ if((-1 == rc_lzmq_socket_set_sndtimeo1)) {
++ lua_pushnil(L);
++ error_code__ZMQ_Error__push(L, rc_lzmq_socket_set_sndtimeo1);
+ } else {
++ lua_pushboolean(L, 1);
+ lua_pushnil(L);
+ }
+- error_code__ZMQ_Error__push(L, err2);
+- /* close message */
+- zmq_msg_close(&msg);
++ return 2;
++}
++#endif
++
+/* method: ipv4only */
+#if (VERSION_3_0)
+static int ZMQ_Socket__ipv4only__meth(lua_State *L) {
@@ -10144,12 +10612,9 @@ index a6d739d..7442736 100644
+ rc_lzmq_socket_ipv4only2 = lzmq_socket_ipv4only(this1, &(value1));
+ if(!(-1 == rc_lzmq_socket_ipv4only2)) {
+ lua_pushinteger(L, value1);
- } else {
- lua_pushnil(L);
- }
-- error_code__ZMQ_Error__push(L, err2);
-- /* close message */
-- zmq_msg_close(&msg);
++ } else {
++ lua_pushnil(L);
++ }
+ error_code__ZMQ_Error__push(L, rc_lzmq_socket_ipv4only2);
+ return 2;
+}
@@ -10233,7 +10698,7 @@ index a6d739d..7442736 100644
if(lua_isuserdata(L, 2)) {
sock = obj_type_ZMQ_Socket_check(L, 2);
} else if(lua_isnumber(L, 2)) {
-@@ -2777,13 +6247,15 @@ static int ZMQ_Poller__add__meth(lua_State *L) {
+@@ -2777,13 +6443,15 @@ static int ZMQ_Poller__add__meth(lua_State *L) {
/* method: modify */
static int ZMQ_Poller__modify__meth(lua_State *L) {
@@ -10251,7 +10716,7 @@ index a6d739d..7442736 100644
if(lua_isuserdata(L, 2)) {
sock = obj_type_ZMQ_Socket_check(L, 2);
/* find sock in items list. */
-@@ -2815,98 +6287,76 @@ static int ZMQ_Poller__modify__meth(lua_State *L) {
+@@ -2815,98 +6483,76 @@ static int ZMQ_Poller__modify__meth(lua_State *L) {
/* method: remove */
static int ZMQ_Poller__remove__meth(lua_State *L) {
@@ -10382,7 +10847,7 @@ index a6d739d..7442736 100644
count1 = this1->count;
lua_pushinteger(L, count1);
-@@ -2916,8 +6366,9 @@ static int ZMQ_Poller__count__meth(lua_State *L) {
+@@ -2916,8 +6562,9 @@ static int ZMQ_Poller__count__meth(lua_State *L) {
/* method: term */
static int ZMQ_Ctx__term__meth(lua_State *L) {
int this_flags1 = 0;
@@ -10393,7 +10858,7 @@ index a6d739d..7442736 100644
if(!(this_flags1 & OBJ_UDATA_FLAG_OWN)) { return 0; }
rc_zmq_term1 = zmq_term(this1);
/* check for error. */
-@@ -2933,8 +6384,9 @@ static int ZMQ_Ctx__term__meth(lua_State *L) {
+@@ -2933,8 +6580,9 @@ static int ZMQ_Ctx__term__meth(lua_State *L) {
/* method: lightuserdata */
static int ZMQ_Ctx__lightuserdata__meth(lua_State *L) {
@@ -10404,7 +10869,7 @@ index a6d739d..7442736 100644
ptr1 = this1;
lua_pushlightuserdata(L, ptr1);
-@@ -2943,10 +6395,12 @@ static int ZMQ_Ctx__lightuserdata__meth(lua_State *L) {
+@@ -2943,20 +6591,53 @@ static int ZMQ_Ctx__lightuserdata__meth(lua_State *L) {
/* method: socket */
static int ZMQ_Ctx__socket__meth(lua_State *L) {
@@ -10419,7 +10884,48 @@ index a6d739d..7442736 100644
rc_zmq_socket1 = zmq_socket(this1, type2);
if((NULL == rc_zmq_socket1)) {
lua_pushnil(L);
-@@ -2969,8 +6423,9 @@ static int ZMQ_StopWatch__start__meth(lua_State *L) {
+ lua_pushstring(L, get_zmq_strerror());
++ return 2;
+ } else {
+ obj_type_ZMQ_Socket_push(L, rc_zmq_socket1, rc_zmq_socket_flags1);
+ }
+ return 1;
+ }
+
++/* method: set */
++#if (VERSION_3_2)
++static int ZMQ_Ctx__set__meth(lua_State *L) {
++ ZMQ_Ctx * this1;
++ int flag2;
++ int value3;
++ int rc_zmq_ctx_set1 = 0;
++ this1 = obj_type_ZMQ_Ctx_check(L,1);
++ flag2 = luaL_checkinteger(L,2);
++ value3 = luaL_checkinteger(L,3);
++ rc_zmq_ctx_set1 = zmq_ctx_set(this1, flag2, value3);
++ lua_pushinteger(L, rc_zmq_ctx_set1);
++ return 1;
++}
++#endif
++
++/* method: get */
++#if (VERSION_3_2)
++static int ZMQ_Ctx__get__meth(lua_State *L) {
++ ZMQ_Ctx * this1;
++ int flag2;
++ int rc_zmq_ctx_get1 = 0;
++ this1 = obj_type_ZMQ_Ctx_check(L,1);
++ flag2 = luaL_checkinteger(L,2);
++ rc_zmq_ctx_get1 = zmq_ctx_get(this1, flag2);
++ lua_pushinteger(L, rc_zmq_ctx_get1);
++ return 1;
++}
++#endif
++
+ /* method: start */
+ static int ZMQ_StopWatch__start__meth(lua_State *L) {
+ int this_flags1 = OBJ_UDATA_FLAG_OWN;
+@@ -2969,8 +6650,9 @@ static int ZMQ_StopWatch__start__meth(lua_State *L) {
/* method: stop */
static int ZMQ_StopWatch__stop__meth(lua_State *L) {
int this_flags1 = 0;
@@ -10430,7 +10936,7 @@ index a6d739d..7442736 100644
if(!(this_flags1 & OBJ_UDATA_FLAG_OWN)) { return 0; }
usecs1 = zmq_stopwatch_stop(this1);
lua_pushinteger(L, usecs1);
-@@ -2996,9 +6451,10 @@ static int zmq__version__func(lua_State *L) {
+@@ -2996,13 +6678,15 @@ static int zmq__version__func(lua_State *L) {
/* method: init */
static int zmq__init__func(lua_State *L) {
@@ -10442,11 +10948,24 @@ index a6d739d..7442736 100644
rc_zmq_init1 = zmq_init(io_threads1);
if((NULL == rc_zmq_init1)) {
lua_pushnil(L);
-@@ -3028,11 +6484,15 @@ static int zmq__init_ctx__func(lua_State *L) {
+ lua_pushstring(L, get_zmq_strerror());
++ return 2;
+ } else {
+ obj_type_ZMQ_Ctx_push(L, rc_zmq_init1, rc_zmq_init_flags1);
+ }
+@@ -3021,6 +6705,7 @@ static int zmq__init_ctx__func(lua_State *L) {
+ if((NULL == ctx1)) {
+ lua_pushnil(L);
+ lua_pushstring(L, get_zmq_strerror());
++ return 2;
+ } else {
+ obj_type_ZMQ_Ctx_push(L, ctx1, 0);
+ }
+@@ -3028,11 +6713,15 @@ static int zmq__init_ctx__func(lua_State *L) {
}
/* method: device */
-+#if (VERSION_2_0)
++#if (VERSION_2_0|VERSION_3_2)
static int zmq__device__func(lua_State *L) {
- int device1 = luaL_checkinteger(L,1);
- ZMQ_Socket * insock2 = obj_type_ZMQ_Socket_check(L,2);
@@ -10461,15 +10980,38 @@ index a6d739d..7442736 100644
rc_zmq_device1 = zmq_device(device1, insock2, outsock3);
/* check for error. */
if((-1 == rc_zmq_device1)) {
-@@ -3044,6 +6504,7 @@ static int zmq__device__func(lua_State *L) {
+@@ -3044,6 +6733,30 @@ static int zmq__device__func(lua_State *L) {
}
return 2;
}
+#endif
++
++/* method: proxy */
++#if (VERSION_3_2)
++static int zmq__proxy__func(lua_State *L) {
++ ZMQ_Socket * frontend1;
++ ZMQ_Socket * backend2;
++ ZMQ_Socket * capture3;
++ ZMQ_Error rc_zmq_proxy1 = 0;
++ frontend1 = obj_type_ZMQ_Socket_check(L,1);
++ backend2 = obj_type_ZMQ_Socket_check(L,2);
++ capture3 = obj_type_ZMQ_Socket_optional(L,3);
++ rc_zmq_proxy1 = zmq_proxy(frontend1, backend2, capture3);
++ /* check for error. */
++ if((-1 == rc_zmq_proxy1)) {
++ lua_pushnil(L);
++ error_code__ZMQ_Error__push(L, rc_zmq_proxy1);
++ } else {
++ lua_pushboolean(L, 1);
++ lua_pushnil(L);
++ }
++ return 2;
++}
++#endif
/* method: stopwatch_start */
static int zmq__stopwatch_start__func(lua_State *L) {
-@@ -3056,32 +6517,452 @@ static int zmq__stopwatch_start__func(lua_State *L) {
+@@ -3056,32 +6769,452 @@ static int zmq__stopwatch_start__func(lua_State *L) {
/* method: sleep */
static int zmq__sleep__func(lua_State *L) {
@@ -10934,7 +11476,7 @@ index a6d739d..7442736 100644
{"close", zmq_msg_t__close__meth},
{"move", zmq_msg_t__move__meth},
{"copy", zmq_msg_t__copy__meth},
-@@ -3092,7 +6973,7 @@ static const luaL_reg obj_zmq_msg_t_methods[] = {
+@@ -3092,7 +7225,7 @@ static const luaL_reg obj_zmq_msg_t_methods[] = {
{NULL, NULL}
};
@@ -10943,7 +11485,7 @@ index a6d739d..7442736 100644
{"__gc", zmq_msg_t__delete__meth},
{"__tostring", zmq_msg_t____tostring__meth},
{"__eq", obj_simple_udata_default_equal},
-@@ -3111,25 +6992,176 @@ static const obj_const obj_zmq_msg_t_constants[] = {
+@@ -3111,25 +7244,182 @@ static const obj_const obj_zmq_msg_t_constants[] = {
{NULL, NULL, 0.0 , 0}
};
@@ -10964,7 +11506,13 @@ index a6d739d..7442736 100644
+static const luaL_Reg obj_ZMQ_Socket_methods[] = {
{"close", ZMQ_Socket__close__meth},
{"bind", ZMQ_Socket__bind__meth},
++#if (VERSION_3_2)
++ {"unbind", ZMQ_Socket__unbind__meth},
++#endif
{"connect", ZMQ_Socket__connect__meth},
++#if (VERSION_3_2)
++ {"disconnect", ZMQ_Socket__disconnect__meth},
++#endif
{"setopt", ZMQ_Socket__setopt__meth},
{"getopt", ZMQ_Socket__getopt__meth},
- {"events", ZMQ_Socket__events__meth},
@@ -11124,7 +11672,7 @@ index a6d739d..7442736 100644
{"__gc", ZMQ_Socket__close__meth},
{"__tostring", obj_udata_default_tostring},
{"__eq", obj_udata_default_equal},
-@@ -3148,23 +7180,27 @@ static const obj_const obj_ZMQ_Socket_constants[] = {
+@@ -3148,23 +7438,27 @@ static const obj_const obj_ZMQ_Socket_constants[] = {
{NULL, NULL, 0.0 , 0}
};
@@ -11156,24 +11704,30 @@ index a6d739d..7442736 100644
{"__gc", ZMQ_Poller__close__meth},
{"__tostring", obj_simple_udata_default_tostring},
{"__eq", obj_simple_udata_default_equal},
-@@ -3183,18 +7219,22 @@ static const obj_const obj_ZMQ_Poller_constants[] = {
+@@ -3183,18 +7477,28 @@ static const obj_const obj_ZMQ_Poller_constants[] = {
{NULL, NULL, 0.0 , 0}
};
-static const luaL_reg obj_ZMQ_Ctx_pub_funcs[] = {
+static const reg_impl obj_ZMQ_Poller_implements[] = {
-+ {NULL, NULL}
-+};
-+
-+static const luaL_Reg obj_ZMQ_Ctx_pub_funcs[] = {
{NULL, NULL}
};
-static const luaL_reg obj_ZMQ_Ctx_methods[] = {
++static const luaL_Reg obj_ZMQ_Ctx_pub_funcs[] = {
++ {NULL, NULL}
++};
++
+static const luaL_Reg obj_ZMQ_Ctx_methods[] = {
{"term", ZMQ_Ctx__term__meth},
{"lightuserdata", ZMQ_Ctx__lightuserdata__meth},
{"socket", ZMQ_Ctx__socket__meth},
++#if (VERSION_3_2)
++ {"set", ZMQ_Ctx__set__meth},
++#endif
++#if (VERSION_3_2)
++ {"get", ZMQ_Ctx__get__meth},
++#endif
{NULL, NULL}
};
@@ -11182,7 +11736,7 @@ index a6d739d..7442736 100644
{"__gc", ZMQ_Ctx__term__meth},
{"__tostring", obj_udata_default_tostring},
{"__eq", obj_udata_default_equal},
-@@ -3213,17 +7253,21 @@ static const obj_const obj_ZMQ_Ctx_constants[] = {
+@@ -3213,17 +7517,21 @@ static const obj_const obj_ZMQ_Ctx_constants[] = {
{NULL, NULL, 0.0 , 0}
};
@@ -11207,7 +11761,7 @@ index a6d739d..7442736 100644
{"__gc", ZMQ_StopWatch__stop__meth},
{"__tostring", obj_udata_default_tostring},
{"__eq", obj_udata_default_equal},
-@@ -3242,87 +7286,217 @@ static const obj_const obj_ZMQ_StopWatch_constants[] = {
+@@ -3242,87 +7550,226 @@ static const obj_const obj_ZMQ_StopWatch_constants[] = {
{NULL, NULL, 0.0 , 0}
};
@@ -11220,9 +11774,12 @@ index a6d739d..7442736 100644
{"version", zmq__version__func},
{"init", zmq__init__func},
{"init_ctx", zmq__init_ctx__func},
-+#if (VERSION_2_0)
++#if (VERSION_2_0|VERSION_3_2)
{"device", zmq__device__func},
+#endif
++#if (VERSION_3_2)
++ {"proxy", zmq__proxy__func},
++#endif
{"stopwatch_start", zmq__stopwatch_start__func},
{"sleep", zmq__sleep__func},
- {"dump_ffi", zmq__dump_ffi__func},
@@ -11282,23 +11839,29 @@ index a6d739d..7442736 100644
+#ifdef ZMQ_REP
+ {"REP", NULL, ZMQ_REP, CONST_NUMBER},
+#endif
++#ifdef ZMQ_MAX_VSM_SIZE
++ {"MAX_VSM_SIZE", NULL, ZMQ_MAX_VSM_SIZE, CONST_NUMBER},
++#endif
+#ifdef ZMQ_MSG_SHARED
+ {"MSG_SHARED", NULL, ZMQ_MSG_SHARED, CONST_NUMBER},
+#endif
++#ifdef ZMQ_MULTICAST_HOPS
++ {"MULTICAST_HOPS", NULL, ZMQ_MULTICAST_HOPS, CONST_NUMBER},
++#endif
+#ifdef ZMQ_XSUB
+ {"XSUB", NULL, ZMQ_XSUB, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_STREAMER
-+ {"STREAMER", NULL, ZMQ_STREAMER, CONST_NUMBER},
++#ifdef ZMQ_PAIR
++ {"PAIR", NULL, ZMQ_PAIR, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_RECONNECT_IVL_MSEC
-+ {"RECONNECT_IVL_MSEC", NULL, ZMQ_RECONNECT_IVL_MSEC, CONST_NUMBER},
++#ifdef ZMQ_MSG_MORE
++ {"MSG_MORE", NULL, ZMQ_MSG_MORE, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_MAX_VSM_SIZE
-+ {"MAX_VSM_SIZE", NULL, ZMQ_MAX_VSM_SIZE, CONST_NUMBER},
++#ifdef ZMQ_STREAMER
++ {"STREAMER", NULL, ZMQ_STREAMER, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_PAIR
-+ {"PAIR", NULL, ZMQ_PAIR, CONST_NUMBER},
++#ifdef ZMQ_MAXMSGSIZE
++ {"MAXMSGSIZE", NULL, ZMQ_MAXMSGSIZE, CONST_NUMBER},
+#endif
+#ifdef ZMQ_DEALER
+ {"DEALER", NULL, ZMQ_DEALER, CONST_NUMBER},
@@ -11321,35 +11884,35 @@ index a6d739d..7442736 100644
+#ifdef ZMQ_IDENTITY
+ {"IDENTITY", NULL, ZMQ_IDENTITY, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_MSG_MORE
-+ {"MSG_MORE", NULL, ZMQ_MSG_MORE, CONST_NUMBER},
-+#endif
-+#ifdef ZMQ_MAXMSGSIZE
-+ {"MAXMSGSIZE", NULL, ZMQ_MAXMSGSIZE, CONST_NUMBER},
-+#endif
+#ifdef ZMQ_PULL
+ {"PULL", NULL, ZMQ_PULL, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_MULTICAST_HOPS
-+ {"MULTICAST_HOPS", NULL, ZMQ_MULTICAST_HOPS, CONST_NUMBER},
++#ifdef ZMQ_IO_THREADS
++ {"IO_THREADS", NULL, ZMQ_IO_THREADS, CONST_NUMBER},
+#endif
+#ifdef ZMQ_RCVHWM
+ {"RCVHWM", NULL, ZMQ_RCVHWM, CONST_NUMBER},
+#endif
++#ifdef ZMQ_SNDHWM
++ {"SNDHWM", NULL, ZMQ_SNDHWM, CONST_NUMBER},
++#endif
++#ifdef ZMQ_AFFINITY
++ {"AFFINITY", NULL, ZMQ_AFFINITY, CONST_NUMBER},
++#endif
+#ifdef ZMQ_SUB
+ {"SUB", NULL, ZMQ_SUB, CONST_NUMBER},
+#endif
+#ifdef ZMQ_UNSUBSCRIBE
+ {"UNSUBSCRIBE", NULL, ZMQ_UNSUBSCRIBE, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_BACKLOG
-+ {"BACKLOG", NULL, ZMQ_BACKLOG, CONST_NUMBER},
++#ifdef ZMQ_PUSH
++ {"PUSH", NULL, ZMQ_PUSH, CONST_NUMBER},
+#endif
+#ifdef ZMQ_XREQ
+ {"XREQ", NULL, ZMQ_XREQ, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_PUSH
-+ {"PUSH", NULL, ZMQ_PUSH, CONST_NUMBER},
++#ifdef ZMQ_RCVLABEL
++ {"RCVLABEL", NULL, ZMQ_RCVLABEL, CONST_NUMBER},
+#endif
+#ifdef ZMQ_PUB
+ {"PUB", NULL, ZMQ_PUB, CONST_NUMBER},
@@ -11357,26 +11920,26 @@ index a6d739d..7442736 100644
+#ifdef ZMQ_DELIMITER
+ {"DELIMITER", NULL, ZMQ_DELIMITER, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_EVENTS
-+ {"EVENTS", NULL, ZMQ_EVENTS, CONST_NUMBER},
++#ifdef ZMQ_BACKLOG
++ {"BACKLOG", NULL, ZMQ_BACKLOG, CONST_NUMBER},
+#endif
+#ifdef ZMQ_SNDMORE
+ {"SNDMORE", NULL, ZMQ_SNDMORE, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_RCVLABEL
-+ {"RCVLABEL", NULL, ZMQ_RCVLABEL, CONST_NUMBER},
++#ifdef ZMQ_EVENTS
++ {"EVENTS", NULL, ZMQ_EVENTS, CONST_NUMBER},
+#endif
+#ifdef ZMQ_SNDBUF
+ {"SNDBUF", NULL, ZMQ_SNDBUF, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_FD
-+ {"FD", NULL, ZMQ_FD, CONST_NUMBER},
++#ifdef ZMQ_MAX_SOCKETS
++ {"MAX_SOCKETS", NULL, ZMQ_MAX_SOCKETS, CONST_NUMBER},
+#endif
+#ifdef ZMQ_POLLIN
+ {"POLLIN", NULL, ZMQ_POLLIN, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_XPUB
-+ {"XPUB", NULL, ZMQ_XPUB, CONST_NUMBER},
++#ifdef ZMQ_FD
++ {"FD", NULL, ZMQ_FD, CONST_NUMBER},
+#endif
+#ifdef ZMQ_POLLERR
+ {"POLLERR", NULL, ZMQ_POLLERR, CONST_NUMBER},
@@ -11390,8 +11953,8 @@ index a6d739d..7442736 100644
+#ifdef ZMQ_HWM
+ {"HWM", NULL, ZMQ_HWM, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_SWAP
-+ {"SWAP", NULL, ZMQ_SWAP, CONST_NUMBER},
++#ifdef ZMQ_XPUB
++ {"XPUB", NULL, ZMQ_XPUB, CONST_NUMBER},
+#endif
+#ifdef ZMQ_REQ
+ {"REQ", NULL, ZMQ_REQ, CONST_NUMBER},
@@ -11399,8 +11962,8 @@ index a6d739d..7442736 100644
+#ifdef ZMQ_RECONNECT_IVL_MAX
+ {"RECONNECT_IVL_MAX", NULL, ZMQ_RECONNECT_IVL_MAX, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_AFFINITY
-+ {"AFFINITY", NULL, ZMQ_AFFINITY, CONST_NUMBER},
++#ifdef ZMQ_RECONNECT_IVL_MSEC
++ {"RECONNECT_IVL_MSEC", NULL, ZMQ_RECONNECT_IVL_MSEC, CONST_NUMBER},
+#endif
+#ifdef ZMQ_SNDLABEL
+ {"SNDLABEL", NULL, ZMQ_SNDLABEL, CONST_NUMBER},
@@ -11411,8 +11974,8 @@ index a6d739d..7442736 100644
+#ifdef ZMQ_VSM
+ {"VSM", NULL, ZMQ_VSM, CONST_NUMBER},
+#endif
-+#ifdef ZMQ_SNDHWM
-+ {"SNDHWM", NULL, ZMQ_SNDHWM, CONST_NUMBER},
++#ifdef ZMQ_SWAP
++ {"SWAP", NULL, ZMQ_SWAP, CONST_NUMBER},
+#endif
+#ifdef ZMQ_XREP
+ {"XREP", NULL, ZMQ_XREP, CONST_NUMBER},
@@ -11484,7 +12047,7 @@ index a6d739d..7442736 100644
static const luaL_Reg submodule_libs[] = {
-@@ -3355,20 +7529,29 @@ LUA_NOBJ_API int luaopen_zmq(lua_State *L) {
+@@ -3355,20 +7802,29 @@ LUA_NOBJ_API int luaopen_zmq(lua_State *L) {
const luaL_Reg *submodules = submodule_libs;
int priv_table = -1;
@@ -11517,7 +12080,7 @@ index a6d739d..7442736 100644
for(; submodules->func != NULL ; submodules++) {
lua_pushcfunction(L, submodules->func);
-@@ -3389,9 +7572,19 @@ LUA_NOBJ_API int luaopen_zmq(lua_State *L) {
+@@ -3389,9 +7845,19 @@ LUA_NOBJ_API int luaopen_zmq(lua_State *L) {
}
#if LUAJIT_FFI
@@ -11540,7 +12103,7 @@ index a6d739d..7442736 100644
}
diff --git a/src/socket.nobj.lua b/src/socket.nobj.lua
-index 207f52b..ef7a0db 100644
+index 207f52b..9c9b067 100644
--- a/src/socket.nobj.lua
+++ b/src/socket.nobj.lua
@@ -18,21 +18,416 @@
@@ -12026,7 +12589,22 @@ index 207f52b..ef7a0db 100644
destructor "close" {
c_method_call "ZMQ_Error" "zmq_close" {}
-@@ -99,37 +470,32 @@ static const int opt_types[] = {
+@@ -92,44 +463,47 @@ static const int opt_types[] = {
+ method "bind" {
+ c_method_call "ZMQ_Error" "zmq_bind" { "const char *", "addr" }
+ },
++ method "unbind" {
++ if_defs = { "VERSION_3_2" },
++ c_method_call "ZMQ_Error" "zmq_unbind" { "const char *", "addr" }
++ },
+ method "connect" {
+ c_method_call "ZMQ_Error" "zmq_connect" { "const char *", "addr" }
+ },
++ method "disconnect" {
++ if_defs = { "VERSION_3_2" },
++ c_method_call "ZMQ_Error" "zmq_disconnect" { "const char *", "addr" }
++ },
+ ffi_cdef[[
int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
]],
@@ -12088,7 +12666,7 @@ index 207f52b..ef7a0db 100644
method "setopt" {
var_in{ "uint32_t", "opt" },
var_in{ "<any>", "val" },
-@@ -138,7 +504,7 @@ end
+@@ -138,7 +512,7 @@ end
size_t val_len;
const void *val;
@@ -12097,7 +12675,7 @@ index 207f52b..ef7a0db 100644
socket_t fd_val;
#endif
int int_val;
-@@ -146,12 +512,26 @@ end
+@@ -146,12 +520,26 @@ end
uint64_t uint64_val;
int64_t int64_val;
@@ -12125,7 +12703,7 @@ index 207f52b..ef7a0db 100644
case OPT_TYPE_FD:
fd_val = luaL_checklong(L, ${val::idx});
val = &fd_val;
-@@ -178,7 +558,7 @@ end
+@@ -178,7 +566,7 @@ end
val = &int64_val;
val_len = sizeof(int64_val);
break;
@@ -12134,7 +12712,7 @@ index 207f52b..ef7a0db 100644
val = luaL_checklstring(L, ${val::idx}, &(val_len));
break;
default:
-@@ -187,20 +567,15 @@ end
+@@ -187,20 +575,15 @@ end
break;
}
${err} = zmq_setsockopt(${this}, ${opt}, val, val_len);
@@ -12160,7 +12738,7 @@ index 207f52b..ef7a0db 100644
]],
},
ffi_source[[
-@@ -213,7 +588,7 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
+@@ -213,7 +596,7 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
c_source[[
size_t val_len;
@@ -12169,7 +12747,7 @@ index 207f52b..ef7a0db 100644
socket_t fd_val;
#endif
int int_val;
-@@ -230,7 +605,7 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
+@@ -230,7 +613,7 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
}
switch(opt_types[${opt}]) {
@@ -12178,7 +12756,7 @@ index 207f52b..ef7a0db 100644
case OPT_TYPE_FD:
val_len = sizeof(fd_val);
${err} = zmq_getsockopt(${this}, ${opt}, &fd_val, &val_len);
-@@ -272,7 +647,7 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
+@@ -272,7 +655,7 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
return 1;
}
break;
@@ -12187,7 +12765,7 @@ index 207f52b..ef7a0db 100644
val_len = STR_MAX;
${err} = zmq_getsockopt(${this}, ${opt}, str_val, &val_len);
if(0 == ${err}) {
-@@ -289,62 +664,23 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
+@@ -289,62 +672,23 @@ local tmp_val_len = ffi.new('size_t[1]', 4)
lua_pushnil(L);
]],
ffi_source[[
@@ -12256,7 +12834,7 @@ index 207f52b..ef7a0db 100644
ZMQ_Error err;
zmq_msg_t msg;
/* initialize message */
-@@ -353,32 +689,22 @@ static ZMQ_Error simple_zmq_send(ZMQ_Socket *sock, const char *data, size_t data
+@@ -353,32 +697,22 @@ static ZMQ_Error simple_zmq_send(ZMQ_Socket *sock, const char *data, size_t data
/* fill message */
memcpy(zmq_msg_data(&msg), data, data_len);
/* send message */
@@ -12293,7 +12871,7 @@ index 207f52b..ef7a0db 100644
},
ffi_source[[
local tmp_msg = ffi.new('zmq_msg_t')
-@@ -393,8 +719,8 @@ local tmp_msg = ffi.new('zmq_msg_t')
+@@ -393,8 +727,8 @@ local tmp_msg = ffi.new('zmq_msg_t')
${err} = zmq_msg_init(&msg);
if(0 == ${err}) {
/* receive message */
@@ -12304,7 +12882,7 @@ index 207f52b..ef7a0db 100644
${data} = zmq_msg_data(&msg);
${data_len} = zmq_msg_size(&msg);
}
-@@ -412,8 +738,8 @@ local tmp_msg = ffi.new('zmq_msg_t')
+@@ -412,8 +746,8 @@ local tmp_msg = ffi.new('zmq_msg_t')
end
-- receive message
@@ -12315,7 +12893,7 @@ index 207f52b..ef7a0db 100644
local data = ffi.string(C.zmq_msg_data(msg), C.zmq_msg_size(msg))
-- close message
C.zmq_msg_close(msg)
-@@ -425,5 +751,8 @@ local tmp_msg = ffi.new('zmq_msg_t')
+@@ -425,5 +759,8 @@ local tmp_msg = ffi.new('zmq_msg_t')
C.zmq_msg_close(msg)
]],
},
@@ -12325,11 +12903,40 @@ index 207f52b..ef7a0db 100644
}
diff --git a/src/threads.lua b/src/threads.lua
-index 99257ea..e37838a 100644
+index 99257ea..dbdd3e7 100644
--- a/src/threads.lua
+++ b/src/threads.lua
-@@ -85,26 +85,28 @@ local function new_thread(ctx, action, action_arg, ...)
- }, thread_mt)
+@@ -25,21 +25,6 @@
+ local zmq = require"zmq"
+ local llthreads = require"llthreads"
+
+-local setmetatable = setmetatable
+-local tonumber = tonumber
+-local assert = assert
+-
+-local thread_mt = {}
+-thread_mt.__index = thread_mt
+-
+-function thread_mt:start(detached)
+- return self.thread:start(detached)
+-end
+-
+-function thread_mt:join()
+- return self.thread:join()
+-end
+-
+ local bootstrap_pre = [[
+ local action, action_arg, parent_ctx = ...
+ local func
+@@ -79,32 +64,31 @@ local function new_thread(ctx, action, action_arg, ...)
+ if ctx then
+ ctx = ctx:lightuserdata()
+ end
+- local thread = llthreads.new(bootstrap_code, action, action_arg, ctx, ...)
+- return setmetatable({
+- thread = thread,
+- }, thread_mt)
++ return llthreads.new(bootstrap_code, action, action_arg, ctx, ...)
end
-module(...)
@@ -12363,6 +12970,87 @@ index 99257ea..e37838a 100644
+zmq.threads = M
+return M
+diff --git a/tests/test_inproc.lua b/tests/test_inproc.lua
+new file mode 100644
+index 0000000..a3c2d70
+--- /dev/null
++++ b/tests/test_inproc.lua
+@@ -0,0 +1,75 @@
++-- Copyright (c) 2011 Robert G. Jakabosky <bobby@sharedrealm.com>
++--
++-- 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.
++
++if #arg < 1 then
++ print("usage: lua " .. arg[0] .. " [message-size] [roundtrip-count] [bind-to] [connect-to]")
++end
++
++local message_size = tonumber(arg[1] or 1)
++local roundtrip_count = tonumber(arg[2] or 100)
++local bind_to = arg[3] or 'inproc://thread_lat_test'
++local connect_to = arg[4] or 'inproc://thread_lat_test'
++
++local zmq = require"zmq"
++
++local ctx = zmq.init(1)
++local server = assert(ctx:socket(zmq.REQ))
++assert(server:bind(bind_to))
++
++local client = ctx:socket(zmq.REP)
++client:connect(connect_to)
++
++local data = ("0"):rep(message_size)
++local msg = zmq.zmq_msg_t.init_size(message_size)
++local client_msg = zmq.zmq_msg_t()
++
++print(string.format("message size: %i [B]", message_size))
++print(string.format("roundtrip count: %i", roundtrip_count))
++
++local timer = zmq.stopwatch_start()
++
++for i = 1, roundtrip_count do
++ -- server send
++ assert(server:send_msg(msg))
++
++ -- client recv
++ assert(client:recv_msg(client_msg))
++ assert(client_msg:size() == message_size, "Invalid message size")
++ -- client send
++ assert(client:send_msg(client_msg))
++
++ -- server recv
++ assert(server:recv_msg(msg))
++ assert(msg:size() == message_size, "Invalid message size")
++end
++
++local elapsed = timer:stop()
++
++server:close()
++client:close()
++ctx:term()
++
++local latency = elapsed / roundtrip_count / 2
++
++print(string.format("mean latency: %.3f [us]", latency))
++local secs = elapsed / (1000 * 1000)
++print(string.format("elapsed = %f", secs))
++print(string.format("msg/sec = %f", roundtrip_count / secs))
++
diff --git a/ws/LICENSE_GPL.txt b/ws/LICENSE_GPL.txt
new file mode 100644
index 0000000..94a9ed0
@@ -13045,7 +13733,7 @@ index 0000000..94a9ed0
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/ws/dissector.lua b/ws/dissector.lua
new file mode 100644
-index 0000000..0431c67
+index 0000000..58fd043
--- /dev/null
+++ b/ws/dissector.lua
@@ -0,0 +1,306 @@
@@ -13085,13 +13773,13 @@ index 0000000..0431c67
+-- setup protocol fields.
+zmq_proto.fields = {}
+local fds = zmq_proto.fields
-+fds.frame = ProtoField.new("Frame", "zmq.frame", "FT_BYTES", nil, "BASE_NONE")
-+fds.length = ProtoField.new("Frame Length", "zmq.frame.len", "FT_UINT64", nil, "BASE_DEC")
-+fds.length8 = ProtoField.new("Frame 8bit Length", "zmq.frame.len8", "FT_UINT8", nil, "BASE_DEC")
-+fds.length64 = ProtoField.new("Frame 64bit Length", "zmq.frame.len64", "FT_UINT64", nil, "BASE_DEC")
-+fds.flags = ProtoField.new("Frame Flags", "zmq.frame.flags", "FT_UINT8", nil, "BASE_HEX", "0xFF")
-+fds.flags_more = ProtoField.new("More", "zmq.frame.flags.more", "FT_UINT8", nil, "BASE_HEX", "0x01")
-+fds.body = ProtoField.new("Frame body", "zmq.frame.body", "FT_BYTES", nil, "BASE_NONE")
++fds.frame = ProtoField.new("Frame", "zmq.frame", "ftypes.BYTES", nil, "base.NONE")
++fds.length = ProtoField.new("Frame Length", "zmq.frame.len", "ftypes.UINT64", nil, "base.DEC")
++fds.length8 = ProtoField.new("Frame 8bit Length", "zmq.frame.len8", "ftypes.UINT8", nil, "base.DEC")
++fds.length64 = ProtoField.new("Frame 64bit Length", "zmq.frame.len64", "ftypes.UINT64", nil, "base.DEC")
++fds.flags = ProtoField.new("Frame Flags", "zmq.frame.flags", "ftypes.UINT8", nil, "base.HEX", "0xFF")
++fds.flags_more = ProtoField.new("More", "zmq.frame.flags.more", "ftypes.UINT8", nil, "base.HEX", "0x01")
++fds.body = ProtoField.new("Frame body", "zmq.frame.body", "ftypes.BYTES", nil, "base.NONE")
+
+-- un-register zmq to handle tcp port range
+local function unregister_tcp_port_range(start_port, end_port)
@@ -13532,10 +14220,10 @@ index 0000000..096332d
+end
+
diff --git a/zmq.nobj.lua b/zmq.nobj.lua
-index 83c0aa5..3be6e76 100644
+index 83c0aa5..e46193c 100644
--- a/zmq.nobj.lua
+++ b/zmq.nobj.lua
-@@ -23,110 +23,157 @@ set_variable_format "%s%d"
+@@ -23,110 +23,178 @@ set_variable_format "%s%d"
c_module "zmq" {
-- module settings.
@@ -13578,6 +14266,7 @@ index 83c0aa5..3be6e76 100644
+#define VERSION_2_1 0
+#define VERSION_2_2 0
+#define VERSION_3_0 0
++#define VERSION_3_2 0
+#if defined(ZMQ_VERSION_MAJOR)
+# if (ZMQ_VERSION_MAJOR == 2) && (ZMQ_VERSION_MINOR == 2)
+# undef VERSION_2_2
@@ -13589,6 +14278,22 @@ index 83c0aa5..3be6e76 100644
+# undef VERSION_2_1
+# define VERSION_2_1 1
+# endif
++# if (ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR == 3)
++# undef VERSION_2_0
++# define VERSION_2_0 0
++# undef VERSION_3_2
++# define VERSION_3_2 1
++# undef VERSION_3_0
++# define VERSION_3_0 1
++# endif
++# if (ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR == 2)
++# undef VERSION_2_0
++# define VERSION_2_0 0
++# undef VERSION_3_2
++# define VERSION_3_2 1
++# undef VERSION_3_0
++# define VERSION_3_0 1
++# endif
+# if (ZMQ_VERSION_MAJOR == 3)
+# undef VERSION_2_0
+# define VERSION_2_0 0
@@ -13650,6 +14355,10 @@ index 83c0aa5..3be6e76 100644
-MAX_VSM_SIZE = 30,
+export_definitions {
+MAX_VSM_SIZE = "ZMQ_MAX_VSM_SIZE",
++
++-- context settings
++MAX_SOCKETS = "ZMQ_MAX_SOCKETS",
++IO_THREADS = "ZMQ_IO_THREADS",
-- message types
-DELIMITER = 31,
@@ -13766,7 +14475,7 @@ index 83c0aa5..3be6e76 100644
},
-@@ -159,6 +206,7 @@ c_function "version" {
+@@ -159,6 +227,7 @@ c_function "version" {
]],
},
c_function "init" {
@@ -13774,7 +14483,7 @@ index 83c0aa5..3be6e76 100644
c_call "!ZMQ_Ctx *" "zmq_init" { "int", "io_threads" },
},
c_function "init_ctx" {
-@@ -174,15 +222,15 @@ c_function "init_ctx" {
+@@ -174,18 +243,22 @@ c_function "init_ctx" {
ffi_source[[
local p_type = type(${ptr})
if p_type == 'userdata' then
@@ -13790,11 +14499,18 @@ index 83c0aa5..3be6e76 100644
]],
},
-c_function "device" {
-+c_function "device" { if_defs = "VERSION_2_0",
++c_function "device" { if_defs = { "VERSION_2_0", "VERSION_3_2" },
c_call "ZMQ_Error" "zmq_device"
{ "int", "device", "ZMQ_Socket *", "insock", "ZMQ_Socket *", "outsock" },
},
-@@ -197,16 +245,5 @@ c_function "stopwatch_start" {
++c_function "proxy" { if_defs = "VERSION_3_2",
++ c_call "ZMQ_Error" "zmq_proxy"
++ { "ZMQ_Socket *", "frontend", "ZMQ_Socket *", "backend", "ZMQ_Socket *", "capture?" },
++},
+
+ --
+ -- zmq_utils.h
+@@ -197,16 +270,5 @@ c_function "stopwatch_start" {
c_function "sleep" {
c_call "void" "zmq_sleep" { "int", "seconds_" },
},