Skip to content

Commit

Permalink
Convert return value of msg:size() to a Lua number from 'size_t' in F…
Browse files Browse the repository at this point in the history
…FI bindings.
  • Loading branch information
Neopallium committed Apr 6, 2012
1 parent df6157e commit 78ac082
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
10 changes: 9 additions & 1 deletion API.md
Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/msg.nobj.lua
Expand Up @@ -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 },
Expand Down
20 changes: 10 additions & 10 deletions src/pre_generated-zmq.nobj.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 78ac082

Please sign in to comment.