Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert return value of msg:size() to a Lua number from 'size_t' in F…

…FI bindings.
  • Loading branch information...
commit 78ac082f628971bf69b04289a735a958286e06ec 1 parent df6157e
@Neopallium authored
Showing with 20 additions and 12 deletions.
  1. +9 −1 API.md
  2. +1 −1  src/msg.nobj.lua
  3. +10 −10 src/pre_generated-zmq.nobj.c
View
10 API.md
@@ -147,6 +147,14 @@ See [zmq_msg_copy(3)](http://api.zeromq.org/zmq_msg_copy.html).
msg1:copy(msg2) -- copy contents from msg2 -> msg1
+## set_size(size)
+
+Re-initialize the message with a new size. The current contents will be lost.
+See [zmq_msg_init_size(3)](http://api.zeromq.org/zmq_msg_init_size.html).
+
+ msg:set_size(size) -- re-initialize message if size is different from current size.
+ local buf = msg:data() -- get buffer to fill message with new contents.
+
## set_data(data)
Change the message contents.
@@ -156,7 +164,7 @@ See [zmq_msg_data(3)](http://api.zeromq.org/zmq_msg_data.html).
## data()
-Get the message contents.
+Get a lightuserdata pointer to the message contents.
See [zmq_msg_data(3)](http://api.zeromq.org/zmq_msg_data.html).
local data = msg:data() -- get the message contents
View
2  src/msg.nobj.lua
@@ -132,7 +132,7 @@ int zmq_msg_init_size (zmq_msg_t *msg, size_t size);
]],
},
method "size" {
- c_method_call "size_t" "zmq_msg_size" {}
+ c_method_call { "size_t", "size", ffi_wrap = "tonumber"} "zmq_msg_size" {}
},
method "__tostring" {
var_out{ "const char *", "data", has_length = true },
View
20 src/pre_generated-zmq.nobj.c
@@ -1914,9 +1914,9 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n"
"-- method: size\n"
"function _meth.zmq_msg_t.size(self)\n"
" \n"
-" local rc_zmq_msg_size1 = 0\n"
-" rc_zmq_msg_size1 = C.zmq_msg_size(self)\n"
-" return rc_zmq_msg_size1\n"
+" local size1 = 0\n"
+" size1 = C.zmq_msg_size(self)\n"
+" return tonumber(size1)\n"
"end\n"
"\n"
"-- method: __tostring\n"
@@ -2221,8 +2221,8 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n"
"end\n"
"end\n"
"\n"
-"-- method: set_affinity\n", /* ----- CUT ----- */
-"if (_meth.ZMQ_Socket.set_affinity) then\n"
+"-- method: set_affinity\n"
+"if (_meth.ZMQ_Socket.set_affinity) then\n", /* ----- CUT ----- */
"function _meth.ZMQ_Socket.set_affinity(self, value2)\n"
" \n"
" \n"
@@ -2741,10 +2741,10 @@ static const char *zmq_ffi_lua_code[] = { "local ffi=require\"ffi\"\n"
" local rc_lzmq_socket_set_sndhwm1 = 0\n"
" rc_lzmq_socket_set_sndhwm1 = Cmod.lzmq_socket_set_sndhwm(self, value2)\n"
" -- check for error.\n"
-" if (-1 == rc_lzmq_socket_set_sndhwm1) then\n", /* ----- CUT ----- */
+" if (-1 == rc_lzmq_socket_set_sndhwm1) then\n"
" return nil, error_code__ZMQ_Error__push(rc_lzmq_socket_set_sndhwm1)\n"
" end\n"
-" return true\n"
+" return true\n", /* ----- CUT ----- */
"end\n"
"end\n"
"\n"
@@ -4216,9 +4216,9 @@ static int zmq_msg_t__set_size__meth(lua_State *L) {
/* method: size */
static int zmq_msg_t__size__meth(lua_State *L) {
zmq_msg_t * this1 = obj_type_zmq_msg_t_check(L,1);
- size_t rc_zmq_msg_size1 = 0;
- rc_zmq_msg_size1 = zmq_msg_size(this1);
- lua_pushinteger(L, rc_zmq_msg_size1);
+ size_t size1 = 0;
+ size1 = zmq_msg_size(this1);
+ lua_pushinteger(L, size1);
return 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.