From f9b280980ac10830dd479608bac3ad9e4cc69986 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Tue, 2 Jun 2015 13:36:59 +0200 Subject: [PATCH] Problem: zmsg_sendm not defined in API model Causes loss of prototype when regenerating project.xml. Solution: add it to right place. Incidental fix, the Makefile also reflects zproject PR #192. --- Makefile.am | 6 +++--- api/zmsg.xml | 12 ++++++++++++ bindings/python/czmq.py | 12 ++++++++++++ bindings/qml/src/QmlZmsg.cpp | 11 +++++++++++ bindings/qml/src/QmlZmsg.h | 8 ++++++++ bindings/ruby/lib/czmq/ffi.rb | 1 + bindings/ruby/lib/czmq/ffi/zmsg.rb | 12 ++++++++++++ include/zmsg.h | 10 ++++++---- 8 files changed, 65 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index fb228694c..1b7651e8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,9 +24,9 @@ noinst_LTLIBRARIES = TESTS = EXTRA_DIST = \ - zgossip_engine.inc \ - zhash_primes.inc \ - zclass_example.xml \ + src/zgossip_engine.inc \ + src/zhash_primes.inc \ + src/zclass_example.xml \ version.sh include $(srcdir)/src/Makemodule.am diff --git a/api/zmsg.xml b/api/zmsg.xml index 6dcd50659..7c113c246 100644 --- a/api/zmsg.xml +++ b/api/zmsg.xml @@ -30,6 +30,18 @@ + + Send message to destination socket as part of a multipart sequence, and + destroy the message after sending it successfully. Note that after a + zmsg_sendm, you must call zmsg_send or another method that sends a final + message part. If the message has no frames, sends nothing but destroys + the message anyhow. Nullifies the caller's reference to the message (as + it is a destructor). + + + + + Return size of message, i.e. number of frames (0 or more). diff --git a/bindings/python/czmq.py b/bindings/python/czmq.py index 4919d2a02..ffe089c64 100644 --- a/bindings/python/czmq.py +++ b/bindings/python/czmq.py @@ -1388,6 +1388,8 @@ def test(verbose): lib.zmsg_recv.argtypes = [c_void_p] lib.zmsg_send.restype = c_int lib.zmsg_send.argtypes = [POINTER(zmsg_p), c_void_p] +lib.zmsg_sendm.restype = c_int +lib.zmsg_sendm.argtypes = [POINTER(zmsg_p), c_void_p] lib.zmsg_size.restype = c_size_t lib.zmsg_size.argtypes = [zmsg_p] lib.zmsg_content_size.restype = c_size_t @@ -1492,6 +1494,16 @@ def send(self_p, dest): it is a destructor).""" return lib.zmsg_send(byref(zmsg_p.from_param(self_p)), dest) + @staticmethod + def sendm(self_p, dest): + """Send message to destination socket as part of a multipart sequence, and +destroy the message after sending it successfully. Note that after a +zmsg_sendm, you must call zmsg_send or another method that sends a final +message part. If the message has no frames, sends nothing but destroys +the message anyhow. Nullifies the caller's reference to the message (as +it is a destructor).""" + return lib.zmsg_sendm(byref(zmsg_p.from_param(self_p)), dest) + def size(self): """Return size of message, i.e. number of frames (0 or more).""" return lib.zmsg_size(self._as_parameter_) diff --git a/bindings/qml/src/QmlZmsg.cpp b/bindings/qml/src/QmlZmsg.cpp index 0ac528540..6b2f4b749 100644 --- a/bindings/qml/src/QmlZmsg.cpp +++ b/bindings/qml/src/QmlZmsg.cpp @@ -222,6 +222,17 @@ int QmlZmsgAttached::send (QmlZmsg *selfP, void *dest) { return zmsg_send (&selfP->self, dest); }; +/// +// Send message to destination socket as part of a multipart sequence, and +// destroy the message after sending it successfully. Note that after a +// zmsg_sendm, you must call zmsg_send or another method that sends a final +// message part. If the message has no frames, sends nothing but destroys +// the message anyhow. Nullifies the caller's reference to the message (as +// it is a destructor). +int QmlZmsgAttached::sendm (QmlZmsg *selfP, void *dest) { + return zmsg_sendm (&selfP->self, dest); +}; + /// // Load/append an open file into message, create new message if // null message provided. Returns NULL if the message could not diff --git a/bindings/qml/src/QmlZmsg.h b/bindings/qml/src/QmlZmsg.h index f3ad15755..c67caa915 100644 --- a/bindings/qml/src/QmlZmsg.h +++ b/bindings/qml/src/QmlZmsg.h @@ -153,6 +153,14 @@ public slots: // it is a destructor). int send (QmlZmsg *selfP, void *dest); + // Send message to destination socket as part of a multipart sequence, and + // destroy the message after sending it successfully. Note that after a + // zmsg_sendm, you must call zmsg_send or another method that sends a final + // message part. If the message has no frames, sends nothing but destroys + // the message anyhow. Nullifies the caller's reference to the message (as + // it is a destructor). + int sendm (QmlZmsg *selfP, void *dest); + // Load/append an open file into message, create new message if // null message provided. Returns NULL if the message could not // be loaded. diff --git a/bindings/ruby/lib/czmq/ffi.rb b/bindings/ruby/lib/czmq/ffi.rb index 4e6735fc3..f8873d958 100644 --- a/bindings/ruby/lib/czmq/ffi.rb +++ b/bindings/ruby/lib/czmq/ffi.rb @@ -200,6 +200,7 @@ def self.available? attach_function :zmsg_destroy, [:pointer], :void, **opts attach_function :zmsg_recv, [:pointer], :pointer, **opts attach_function :zmsg_send, [:pointer, :pointer], :int, **opts + attach_function :zmsg_sendm, [:pointer, :pointer], :int, **opts attach_function :zmsg_size, [:pointer], :size_t, **opts attach_function :zmsg_content_size, [:pointer], :size_t, **opts attach_function :zmsg_prepend, [:pointer, :pointer], :int, **opts diff --git a/bindings/ruby/lib/czmq/ffi/zmsg.rb b/bindings/ruby/lib/czmq/ffi/zmsg.rb index bf3ace677..31344ccc2 100644 --- a/bindings/ruby/lib/czmq/ffi/zmsg.rb +++ b/bindings/ruby/lib/czmq/ffi/zmsg.rb @@ -84,6 +84,18 @@ def self.send self_p, dest result end + # Send message to destination socket as part of a multipart sequence, and + # destroy the message after sending it successfully. Note that after a + # zmsg_sendm, you must call zmsg_send or another method that sends a final + # message part. If the message has no frames, sends nothing but destroys + # the message anyhow. Nullifies the caller's reference to the message (as + # it is a destructor). + def self.sendm self_p, dest + self_p = self_p.__ptr_give_ref + result = ::CZMQ::FFI.zmsg_sendm self_p, dest + result + end + # Return size of message, i.e. number of frames (0 or more). def size raise DestroyedError unless @ptr diff --git a/include/zmsg.h b/include/zmsg.h index f55aa6650..1667fbfa8 100644 --- a/include/zmsg.h +++ b/include/zmsg.h @@ -44,10 +44,12 @@ CZMQ_EXPORT zmsg_t * CZMQ_EXPORT int zmsg_send (zmsg_t **self_p, void *dest); -// Send (More) message to destination socket, and destroy the message after sending -// it successfully. If the message has no frames, sends nothing but destroys -// the message anyhow. Nullifies the caller's reference to the message (as -// it is a destructor). +// Send message to destination socket as part of a multipart sequence, and +// destroy the message after sending it successfully. Note that after a +// zmsg_sendm, you must call zmsg_send or another method that sends a final +// message part. If the message has no frames, sends nothing but destroys +// the message anyhow. Nullifies the caller's reference to the message (as +// it is a destructor). CZMQ_EXPORT int zmsg_sendm (zmsg_t **self_p, void *dest);