Skip to content

Commit

Permalink
Merge pull request #1018 from hintjens/master
Browse files Browse the repository at this point in the history
Problem: zmsg_sendm not defined in API model
  • Loading branch information
hintjens committed Jun 2, 2015
2 parents 0dfe5f3 + f9b2809 commit b01b103
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions api/zmsg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
<return type = "integer" />
</method>

<method name = "sendm" singleton = "1">
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).
<argument name = "self_p" type = "zmsg" by_reference = "1" />
<argument name = "dest" type = "anything" />
<return type = "integer" />
</method>

<method name = "size">
Return size of message, i.e. number of frames (0 or more).
<return type = "size" />
Expand Down
12 changes: 12 additions & 0 deletions bindings/python/czmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_)
Expand Down
11 changes: 11 additions & 0 deletions bindings/qml/src/QmlZmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions bindings/qml/src/QmlZmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions bindings/ruby/lib/czmq/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions bindings/ruby/lib/czmq/ffi/zmsg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions include/zmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b01b103

Please sign in to comment.