From b0413d4e75184af7a60c3271b83bcb8e18b990ea Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Mon, 17 Jun 2013 15:06:40 -0700 Subject: [PATCH] Add zmq_proxy() function for ZeroMQ 3.2.x zmq_device() is also available in 3.2.x as a deprecated method. --- src/pre_generated-zmq.nobj.c | 384 ++++++++++++++++++++++------------- zmq.nobj.lua | 15 +- 2 files changed, 259 insertions(+), 140 deletions(-) diff --git a/src/pre_generated-zmq.nobj.c b/src/pre_generated-zmq.nobj.c index 6b949ff..1fa9ae4 100644 --- a/src/pre_generated-zmq.nobj.c +++ b/src/pre_generated-zmq.nobj.c @@ -280,6 +280,7 @@ typedef struct ffi_export_symbol { #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 @@ -291,6 +292,14 @@ typedef struct ffi_export_symbol { # undef VERSION_2_1 # define VERSION_2_1 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 @@ -1424,57 +1433,57 @@ static FUNC_UNUSED void *nobj_delete_callback_state(lua_State *L, int owner_idx) -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, }; @@ -1585,19 +1594,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " 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" @@ -1756,13 +1753,6 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "]==]\n" "end\n" "\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" -"]])\n" -"\n" "ffi_safe_cdef(\"BufferIF\", [[\n" "typedef struct Buffer_if {\n" " const uint8_t * (* const const_data)(void *this_v);\n" @@ -1770,6 +1760,20 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "} BufferIF;\n" "]])\n" "\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" +"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" +"]])\n" +"\n" "local Cmod = ffi_load_cmodule(\"zmq\", false)\n" "local C = Cmod\n" "\n" @@ -1968,6 +1972,8 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\n" "ZMQ_Error zmq_device(int, ZMQ_Socket *, ZMQ_Socket *);\n" "\n" +"ZMQ_Error zmq_proxy(ZMQ_Socket *, ZMQ_Socket *, ZMQ_Socket *);\n" +"\n" "void zmq_sleep(int);\n" "\n" "\n" @@ -2116,14 +2122,14 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\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" +" 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" " -- 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" @@ -2136,10 +2142,10 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" +" obj_mt.ffi_check = obj_type_zmq_msg_t_check\n", /* ----- CUT ----- */ "end\n" "\n" -"\n", /* ----- CUT ----- */ +"\n" "local obj_type_ZMQ_Socket_check\n" "local obj_type_ZMQ_Socket_delete\n" "local obj_type_ZMQ_Socket_push\n" @@ -2223,14 +2229,14 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\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" @@ -2363,12 +2369,15 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "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" @@ -2558,7 +2567,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " 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" @@ -2697,7 +2706,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "end\n" "\n" "local tmp_val_len = ffi.new('size_t[1]', 4)\n" -"\n" +"\n", /* ----- CUT ----- */ "-- method: getopt\n" "function _meth.ZMQ_Socket.getopt(self, opt2)\n" " \n" @@ -2705,7 +2714,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " local val1\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" " error(\"Invalid socket option.\")\n" @@ -2786,22 +2795,24 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " -- close message\n" " C.zmq_msg_close(msg)\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" "do\n" " local hwm_value_tmp = ffi.new(\"int[1]\")\n" +"\n" "-- method: hwm\n" "if (_meth.ZMQ_Socket.hwm) then\n" "function _meth.ZMQ_Socket.hwm(self)\n" " \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" @@ -2823,17 +2834,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\n" "do\n" " local swap_value_tmp = ffi.new(\"int[1]\")\n" +"\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" @@ -2855,17 +2868,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -2885,6 +2900,9 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "end\n" "end\n" "\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" @@ -2892,11 +2910,13 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " 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 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" @@ -2947,17 +2967,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\n" "do\n" " local rate_value_tmp = ffi.new(\"int[1]\")\n" +"\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 value1\n" " local rc_lzmq_socket_rate2 = 0\n" -" rc_lzmq_socket_rate2 = Cmod.lzmq_socket_rate(self, value1)\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 value1[0]\n" +" return value1\n" "end\n" "end\n" "end\n" @@ -2979,17 +3001,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\n" "do\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 = recovery_ivl_value_tmp\n" +" local value1\n" " local rc_lzmq_socket_recovery_ivl2 = 0\n" -" rc_lzmq_socket_recovery_ivl2 = Cmod.lzmq_socket_recovery_ivl(self, value1)\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 value1[0]\n" +" return value1\n" "end\n" "end\n" "end\n" @@ -3011,17 +3035,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" -" local value1 = mcast_loop_value_tmp\n" +" local value1\n" " local rc_lzmq_socket_mcast_loop2 = 0\n" -" rc_lzmq_socket_mcast_loop2 = Cmod.lzmq_socket_mcast_loop(self, value1)\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[0]\n" +" return value1\n" "end\n" "end\n" "end\n" @@ -3043,17 +3069,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\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" @@ -3075,17 +3103,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\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" @@ -3107,85 +3137,95 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3207,17 +3247,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\n" "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" @@ -3230,7 +3272,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " local rc_lzmq_socket_set_reconnect_ivl1 = 0\n" " rc_lzmq_socket_set_reconnect_ivl1 = Cmod.lzmq_socket_set_reconnect_ivl(self, value2)\n" " -- check for error.\n" -" if (-1 == rc_lzmq_socket_set_reconnect_ivl1) then\n" +" if (-1 == rc_lzmq_socket_set_reconnect_ivl1) then\n", /* ----- CUT ----- */ " return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_reconnect_ivl1)\n" " end\n" " return true\n" @@ -3239,17 +3281,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3258,7 +3302,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "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" @@ -3271,17 +3315,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3303,17 +3349,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3335,17 +3383,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3367,17 +3417,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3399,17 +3451,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3431,17 +3485,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3463,17 +3519,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3495,17 +3553,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3527,17 +3587,19 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3684,13 +3746,15 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "\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" @@ -3766,7 +3830,7 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" "-- End \"ZMQ_StopWatch\" FFI interface\n" "\n" "-- method: init\n" -"function _M.init(io_threads1)\n" +"function _M.init(io_threads1)\n", /* ----- CUT ----- */ " io_threads1 = io_threads1 or 1\n" " local rc_zmq_init_flags1 = OBJ_UDATA_FLAG_OWN\n" " local rc_zmq_init1\n" @@ -3804,13 +3868,29 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n" " 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" @@ -6487,7 +6567,7 @@ 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; ZMQ_Socket * insock2; @@ -6509,6 +6589,29 @@ static int zmq__device__func(lua_State *L) { } #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) { int rc_zmq_stopwatch_start_flags1 = OBJ_UDATA_FLAG_OWN; @@ -7297,8 +7400,11 @@ static const luaL_Reg zmq_function[] = { {"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}, diff --git a/zmq.nobj.lua b/zmq.nobj.lua index 3be6e76..3d8860b 100644 --- a/zmq.nobj.lua +++ b/zmq.nobj.lua @@ -44,6 +44,7 @@ c_source "typedefs" [[ #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 @@ -55,6 +56,14 @@ c_source "typedefs" [[ # undef VERSION_2_1 # define VERSION_2_1 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 @@ -230,10 +239,14 @@ c_function "init_ctx" { end ]], }, -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" }, }, +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