Module MessagePack
In: ext/unpack.c
ext/rbinit.c
ext/pack.c
ext/version.rb

static VALUE MessagePack_pack(int argc, VALUE* argv, VALUE self) {

        VALUE out;
        if(argc == 1) {
                out = rb_str_buf_new(0);
        } else if(argc == 2) {
                out = argv[1];
        } else {
                rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
        }
        return rb_funcall(argv[0], s_to_msgpack, 1, out);

}

void Init_msgpack_pack(VALUE mMessagePack) {

        s_to_msgpack = rb_intern("to_msgpack");
        s_append = rb_intern("<<");

        rb_define_method(rb_cNilClass,   "to_msgpack", MessagePack_NilClass_to_msgpack, -1);
        rb_define_method(rb_cTrueClass,  "to_msgpack", MessagePack_TrueClass_to_msgpack, -1);
        rb_define_method(rb_cFalseClass, "to_msgpack", MessagePack_FalseClass_to_msgpack, -1);
        rb_define_method(rb_cFixnum, "to_msgpack", MessagePack_Fixnum_to_msgpack, -1);
        rb_define_method(rb_cBignum, "to_msgpack", MessagePack_Bignum_to_msgpack, -1);
        rb_define_method(rb_cFloat,  "to_msgpack", MessagePack_Float_to_msgpack, -1);
        rb_define_method(rb_cString, "to_msgpack", MessagePack_String_to_msgpack, -1);
        rb_define_method(rb_cArray,  "to_msgpack", MessagePack_Array_to_msgpack, -1);
        rb_define_method(rb_cHash,   "to_msgpack", MessagePack_Hash_to_msgpack, -1);
        rb_define_method(rb_cSymbol, "to_msgpack", MessagePack_Symbol_to_msgpack, -1);

Methods

pack   unpack   unpack_limit  

Classes and Modules

Class MessagePack::UnpackError
Class MessagePack::Unpacker

Constants

VERSION = rb_str_new2(MESSAGEPACK_VERSION)
VERSION = "0.4.7"

Public Class methods

Document-method: MessagePack.pack

Serializes the object into raw bytes. The encoding of the string is ASCII-8BIT on Ruby 1.9. This method is same as object.to_msgpack(out = ’’).

out is an object that implements *<<* method like String or IO.

Document-method: MessagePack::Unpacker.unpack

Deserializes one object over the specified buffer.

UnpackError is throw when parse error is occured, the buffer is insufficient to deserialize one object or there are extra bytes.

Document-method: MessagePack::Unpacker.unpack_limit

Deserializes one object over the specified buffer upto limit bytes.

UnpackError is throw when parse error is occured, the buffer is insufficient to deserialize one object or there are extra bytes.

[Validate]