@@ -6,21 +6,20 @@ VALUE rb_cTree;
6
6
7
7
void init_tree (){
8
8
rb_cTree = rb_define_class_under (rb_mRr3 , "Tree" , rb_cObject );
9
- rb_define_attr (rb_cTree , "root" , 1 , 0 );
10
- rb_define_method (rb_cTree , "initialize" , rb_initialize , 1 );
11
- rb_define_method (rb_cTree , "insert_path" , rb_insert_path , -1 );
12
- rb_define_method (rb_cTree , "compile!" , rb_compile , 0 );
13
- rb_define_method (rb_cTree , "match" , rb_match , 1 );
14
- rb_define_method (rb_cTree , "dump" , rb_dump , 1 );
9
+ rb_define_method (rb_cTree , "initialize" , rb_tree_initialize , 1 );
10
+ rb_define_method (rb_cTree , "insert_path" , rb_tree_insert_path , -1 );
11
+ rb_define_method (rb_cTree , "compile!" , rb_tree_compile , 0 );
12
+ rb_define_method (rb_cTree , "match" , rb_tree_match , 1 );
13
+ rb_define_method (rb_cTree , "dump" , rb_tree_dump , 1 );
15
14
}
16
15
17
- static VALUE rb_initialize (VALUE self , VALUE size ){
16
+ static VALUE rb_tree_initialize (VALUE self , VALUE size ){
18
17
node * n = r3_tree_create (FIX2INT (size ));
19
18
rb_ivar_set (self , rb_intern ("@root" ), Data_Wrap_Struct (rb_cObject , NULL , release , n ));
20
19
return self ;
21
20
}
22
21
23
- static VALUE rb_insert_path (int argc , VALUE * argv , VALUE self ){
22
+ static VALUE rb_tree_insert_path (int argc , VALUE * argv , VALUE self ){
24
23
VALUE path , * data ;
25
24
Data_Make_Struct (rb_cObject , VALUE , NULL , -1 , data );
26
25
rb_scan_args (argc , argv , "11" , & path , data );
@@ -33,7 +32,7 @@ static VALUE rb_insert_path(int argc, VALUE *argv, VALUE self){
33
32
return Qnil ;
34
33
}
35
34
36
- static VALUE rb_compile (VALUE self ){
35
+ static VALUE rb_tree_compile (VALUE self ){
37
36
char * errstr = NULL ;
38
37
if (r3_tree_compile (root (self ), & errstr ) != 0 ){
39
38
rb_raise (rb_eRuntimeError , "%s" , errstr );
@@ -42,12 +41,13 @@ static VALUE rb_compile(VALUE self){
42
41
return Qnil ;
43
42
}
44
43
45
- static VALUE rb_match (VALUE self , VALUE path ){
44
+ static VALUE rb_tree_match (VALUE self , VALUE path ){
45
+ // match_entry *entry = match_entry_createl(RSTRING_PTR(path), RSTRING_LEN(path));
46
46
node * matched_node = r3_tree_matchl (root (self ), RSTRING_PTR (path ), RSTRING_LEN (path ), NULL ); // TODO: support entry
47
47
return matched_node ? * ((VALUE * ) matched_node -> data ) : Qfalse ;
48
48
}
49
49
50
- static VALUE rb_dump (VALUE self , VALUE level ){
50
+ static VALUE rb_tree_dump (VALUE self , VALUE level ){
51
51
r3_tree_dump (root (self ), FIX2INT (level ));
52
52
return Qnil ;
53
53
}
0 commit comments