Sha256: 66f6813855879657c1c9c3c104356fc8d5689f43907c4e20783d0df6f4b2a95b

Contents?: true

Size: 1.78 KB

Versions: 10

Compression:

Stored size: 1.78 KB

Contents

#ifndef RBCZMQ_FRAME_H
#define RBCZMQ_FRAME_H

#include "message.h"

/* This flag indicates that the wrapped zframe_t is owned by ruby
   and can be freed when the ZMQ::Frame object is garbage collected */
#define ZMQ_FRAME_OWNED 0x01

typedef struct {
    /* The czmq frame object. This is only valid if the frame is owned
       by ruby, or the frame has been added to a message and the message
       is owned by ruby. */
    zframe_t *frame;

    /* The ruby ZMQ::Message object this frame is attached to, or NULL */
    zmq_message_wrapper* message;

    int flags;
} zmq_frame_wrapper;

#define ZmqAssertFrame(obj) ZmqAssertType(obj, rb_cZmqFrame, "ZMQ::Frame")
#define ZmqGetFrame(obj) \
    zmq_frame_wrapper *frame = NULL; \
    ZmqAssertFrame(obj); \
    Data_Get_Struct(obj, zmq_frame_wrapper, frame); \
    if (!frame) rb_raise(rb_eTypeError, "uninitialized ZMQ frame!");

#define ZmqAssertFrameOwned(wrapper) if (!(\
      (wrapper->flags & ZMQ_FRAME_OWNED) != 0 || \
      (wrapper->message != NULL && (wrapper->message->flags & ZMQ_MESSAGE_OWNED) != 0 ) \
    )) { \
        rb_raise(rb_eZmqError, "Cannot access frame that belongs to another message or is gone."); \
    }

#define ZmqAssertFrameOwnedNoMessage(wrapper) if (!(\
      (wrapper->flags & ZMQ_FRAME_OWNED) != 0 \
    )) { \
        rb_raise(rb_eZmqError, "Cannot access frame that belongs to another message or is gone."); \
    }

#define ZmqReturnNilUnlessFrameOwned(wrapper) if (!(\
      (wrapper->flags & ZMQ_FRAME_OWNED) != 0 || \
      (wrapper->message != NULL && (wrapper->message->flags & ZMQ_MESSAGE_OWNED) != 0 ) \
    )) { \
        return Qnil; \
    }

void rb_czmq_free_frame(zmq_frame_wrapper *frame);
void rb_czmq_free_frame_gc(void *ptr);

VALUE rb_czmq_alloc_frame(zframe_t *frame);

void _init_rb_czmq_frame();

#endif

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rbczmq-1.7.9 ext/rbczmq/frame.h
rbczmq-1.7.8 ext/rbczmq/frame.h
rbczmq-1.7.7 ext/rbczmq/frame.h
rbczmq-1.7.6 ext/rbczmq/frame.h
rbczmq-1.7.5 ext/rbczmq/frame.h
rbczmq-1.7.4 ext/rbczmq/frame.h
rbczmq-1.7.3 ext/rbczmq/frame.h
rbczmq-1.7.2 ext/rbczmq/frame.h
rbczmq-1.7.1 ext/rbczmq/frame.h
rbczmq-1.7.0 ext/rbczmq/frame.h