Skip to content

Commit

Permalink
Removed declaration of Base32#encode and #decode from ruby code and p…
Browse files Browse the repository at this point in the history
…ut them in the C code.
  • Loading branch information
stesla committed Jun 29, 2007
1 parent d87b1a0 commit c2b5bd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
32 changes: 4 additions & 28 deletions ext/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@
#include "encoder.h"

static VALUE
base32_decoder_initialize (VALUE self, VALUE value)
b32_decode (VALUE self, VALUE value)
{
rb_iv_set (self, "@value", rb_str_dup (value));
return self;
}

static VALUE
base32_decoder_decode (VALUE self)
{
VALUE value = rb_iv_get (self, "@value");
value = StringValue (value);
if (RSTRING (value)->len == 0)
return value;
Expand All @@ -49,16 +41,8 @@ base32_decoder_decode (VALUE self)
}

static VALUE
base32_encoder_initialize (VALUE self, VALUE value)
{
rb_iv_set (self, "@value", rb_str_dup (value));
return self;
}

static VALUE
base32_encoder_encode (VALUE self)
b32_encode (VALUE self, VALUE value)
{
VALUE value = rb_iv_get (self, "@value");
value = StringValue(value);

VALUE result = rb_str_new (0, base32_encoder_buffer_size (RSTRING (value)->len));
Expand All @@ -69,18 +53,10 @@ base32_encoder_encode (VALUE self)
}

VALUE mBase32;
VALUE cDecoder;
VALUE cEncoder;

void Init_base32_ext ()
{
mBase32 = rb_define_module ("Base32");

cDecoder = rb_define_class_under (mBase32, "Decoder", rb_cObject);
rb_define_method (cDecoder, "initialize", base32_decoder_initialize, 1);
rb_define_method (cDecoder, "decode", base32_decoder_decode, 0);

cEncoder = rb_define_class_under (mBase32, "Encoder", rb_cObject);
rb_define_method (cEncoder, "initialize", base32_encoder_initialize, 1);
rb_define_method (cEncoder, "encode", base32_encoder_encode, 0);
rb_define_module_function(mBase32, "decode", b32_decode, 1);
rb_define_module_function(mBase32, "encode", b32_encode, 1);
}
12 changes: 0 additions & 12 deletions lib/base32.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,3 @@
# THE SOFTWARE.

require 'base32/base32_ext'

module Base32
class << self
def decode(value)
Decoder.new(value).decode
end

def encode(value)
Encoder.new(value).encode
end
end
end

0 comments on commit c2b5bd4

Please sign in to comment.