Sha256: 39ea39c3e6ce0fa64045ef18df4432ab11671b1cef87d9500117abb11ee2056f

Contents?: true

Size: 907 Bytes

Versions: 2

Compression:

Stored size: 907 Bytes

Contents

/*
 * wxStream.cpp
 *
 *  Created on: 22.02.2012
 *      Author: hanmac
 */
#include "wxStream.hpp"
#if wxUSE_STREAMS
wxFileOffset RubyInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
{
	return NUM2INT(rb_funcall(mRuby,rb_intern("seek"),2,INT2NUM(seek),INT2NUM(mode)));
}

wxFileOffset RubyInputStream::OnSysTell() const
{
	return NUM2INT(rb_funcall(mRuby,rb_intern("tell"),0));
}

bool RubyInputStream::IsSeekable() const
{
	return rb_respond_to(mRuby,rb_intern("seek"));
}

bool RubyInputStream::Eof() const
{
	return RTEST(rb_funcall(mRuby,rb_intern("eof?"),0));
}

bool RubyInputStream::CanRead() const
{
	return !Eof() && !RTEST(rb_funcall(mRuby,rb_intern("closed?"),0));
}

size_t RubyInputStream::OnSysRead(void *buffer, size_t size)
{
	VALUE str = rb_funcall(mRuby,rb_intern("read"),1,INT2NUM(size));
	size_t s = RSTRING_LEN(str);
	memcpy(buffer, RSTRING_PTR(str), s);
	return s;
}
#endif

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rwx-0.0.1.1.dev ext/wxStream.cpp
rwx-0.0.1.dev ext/wxStream.cpp