mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 04:52:59 +01:00
Merge pull request #103 from dbussink/rubinius_support
Improve Rubinius support for msgpack Ruby gem
This commit is contained in:
commit
92975bb21d
@ -1,5 +1,6 @@
|
|||||||
require 'mkmf'
|
require 'mkmf'
|
||||||
require './version.rb'
|
require './version.rb'
|
||||||
$CFLAGS << %[ -I.. -Wall -O3 -DMESSAGEPACK_VERSION=\\"#{MessagePack::VERSION}\\" -g]
|
$CFLAGS << %[ -I.. -Wall -O3 -DMESSAGEPACK_VERSION=\\"#{MessagePack::VERSION}\\" -g]
|
||||||
|
have_header("ruby/st.h")
|
||||||
create_makefile('msgpack')
|
create_makefile('msgpack')
|
||||||
|
|
||||||
|
16
ruby/pack.c
16
ruby/pack.c
@ -15,6 +15,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#define RSTRING_NOT_MODIFIED
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
@ -39,8 +40,8 @@ static ID s_append;
|
|||||||
#include "msgpack/pack_template.h"
|
#include "msgpack/pack_template.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef RUBY_VM
|
#ifdef HAVE_RUBY_ST_H
|
||||||
#include "st.h" // ruby hash
|
#include "ruby/st.h" // ruby hash
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARG_BUFFER(name, argc, argv) \
|
#define ARG_BUFFER(name, argc, argv) \
|
||||||
@ -219,11 +220,12 @@ static VALUE MessagePack_Array_to_msgpack(int argc, VALUE *argv, VALUE self)
|
|||||||
{
|
{
|
||||||
ARG_BUFFER(out, argc, argv);
|
ARG_BUFFER(out, argc, argv);
|
||||||
// FIXME check sizeof(long) > sizeof(unsigned int) && RARRAY_LEN(self) > UINT_MAX
|
// FIXME check sizeof(long) > sizeof(unsigned int) && RARRAY_LEN(self) > UINT_MAX
|
||||||
msgpack_pack_array(out, (unsigned int)RARRAY_LEN(self));
|
unsigned int ary_length = (unsigned int)RARRAY_LEN(self);
|
||||||
VALUE* p = RARRAY_PTR(self);
|
unsigned int i = 0;
|
||||||
VALUE* const pend = p + RARRAY_LEN(self);
|
msgpack_pack_array(out, ary_length);
|
||||||
for(;p != pend; ++p) {
|
for(; i < ary_length; ++i) {
|
||||||
rb_funcall(*p, s_to_msgpack, 1, out);
|
VALUE p = rb_ary_entry(self, i);
|
||||||
|
rb_funcall(p, s_to_msgpack, 1, out);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, VALUE*
|
|||||||
{ *o = rb_ary_new2(n); return 0; }
|
{ *o = rb_ary_new2(n); return 0; }
|
||||||
|
|
||||||
static inline int template_callback_array_item(unpack_user* u, VALUE* c, VALUE o)
|
static inline int template_callback_array_item(unpack_user* u, VALUE* c, VALUE o)
|
||||||
{ rb_ary_push(*c, o); return 0; } // FIXME set value directry RARRAY_PTR(obj)[RARRAY_LEN(obj)++]
|
{ rb_ary_push(*c, o); return 0; }
|
||||||
|
|
||||||
static inline int template_callback_map(unpack_user* u, unsigned int n, VALUE* o)
|
static inline int template_callback_map(unpack_user* u, unsigned int n, VALUE* o)
|
||||||
{ *o = rb_hash_new(); return 0; }
|
{ *o = rb_hash_new(); return 0; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user