Skip to content
Browse files

removing stree string

  • Loading branch information...
1 parent cd3e395 commit caaf350872a4599643966adcde50371866a25cf5 @tenderlove committed Dec 17, 2009
Showing with 0 additions and 108 deletions.
  1. +0 −1 ext/stree/stree.c
  2. +0 −1 ext/stree/stree.h
  3. +0 −67 ext/stree/stree_string.c
  4. +0 −10 ext/stree/stree_string.h
  5. +0 −29 test/test_string.rb
View
1 ext/stree/stree.c
@@ -51,6 +51,5 @@ void Init_stree()
rb_define_method(cStree, "push", push, 1);
rb_define_method(cStree, "longest_common_substr", longest_common_substr, 2);
- Init_stree_string();
Init_stree_stringset();
}
View
1 ext/stree/stree.h
@@ -6,7 +6,6 @@
#include <stree/lst_stree.h>
#include <stree/lst_algorithms.h>
-#include <stree_string.h>
#include <stree_stringset.h>
extern VALUE cStree;
View
67 ext/stree/stree_string.c
@@ -1,67 +0,0 @@
-#include <stree_string.h>
-
-VALUE cStreeString;
-
-static void dealloc(void * ptr)
-{
- lst_string_free((LST_String *)ptr);
-}
-
-static VALUE allocate(VALUE klass)
-{
- LST_String * ptr;
- return Data_Make_Struct(klass, LST_String, NULL, dealloc, ptr);
-}
-
-static VALUE initialize(VALUE self, VALUE string)
-{
- LST_String * ptr;
-
- Data_Get_Struct(self, LST_String, ptr);
- lst_string_init(ptr, StringValuePtr(string), sizeof(char), RSTRING_LEN(string));
-
- return self;
-}
-
-static VALUE bytesize(VALUE self)
-{
- LST_String * ptr;
-
- Data_Get_Struct(self, LST_String, ptr);
- return INT2NUM(lst_string_get_length(ptr));
-}
-
-static VALUE get(VALUE self, VALUE index)
-{
- LST_String * ptr;
-
- Data_Get_Struct(self, LST_String, ptr);
-
- void * item = lst_string_get_item(ptr, NUM2INT(index));
-
- if(NULL == item) return Qnil;
-
- char * c = ((char *)item)[0];
-
- if(c) return INT2NUM(((char *)item)[0]);
- return Qnil;
-}
-
-static VALUE to_s(VALUE self)
-{
- LST_String * ptr;
-
- Data_Get_Struct(self, LST_String, ptr);
- return rb_str_new2(lst_string_print(ptr));
-}
-
-void Init_stree_string()
-{
- cStreeString = rb_define_class_under(cStree, "String", rb_cObject);
- rb_define_alloc_func(cStreeString, allocate);
-
- rb_define_method(cStreeString, "initialize", initialize, 1);
- rb_define_method(cStreeString, "bytesize", bytesize, 0);
- rb_define_method(cStreeString, "[]", get, 1);
- rb_define_method(cStreeString, "to_s", to_s, 0);
-}
View
10 ext/stree/stree_string.h
@@ -1,10 +0,0 @@
-#ifndef RUBY_STREE_STRING
-#define RUBY_STREE_STRING
-
-#include <stree.h>
-
-void Init_stree_string();
-
-extern VALUE cStreeString;
-
-#endif
View
29 test/test_string.rb
@@ -1,29 +0,0 @@
-require "test/unit"
-require "stree"
-
-class Stree
- class TestString < Test::Unit::TestCase
- def test_bytesize
- str = "foo"
- assert_equal str.bytesize, Stree::String.new(str).bytesize
- end
-
- def test_square
- str = "foo"
- sstr = Stree::String.new(str)
-
- 0.upto(str.bytesize) do |i|
- if str.respond_to?(:getbyte)
- assert_equal str.getbyte(i), sstr[i], "failed on #{i}"
- else
- assert_equal str[i], sstr[i], "failed on #{i}"
- end
- end
- end
-
- def test_to_s
- sstr = Stree::String.new("foo")
- assert_equal 'foo', sstr.to_s
- end
- end
-end

0 comments on commit caaf350

Please sign in to comment.
Something went wrong with that request. Please try again.