Changeset 4001 for lang/perl/Senna/trunk
- Timestamp:
- 01/03/08 02:14:17 (5 years ago)
- Location:
- lang/perl/Senna/trunk
- Files:
-
- 4 added
- 7 modified
-
lib/Senna.xs (modified) (9 diffs)
-
senna-encoding.c (modified) (3 diffs)
-
senna-index.c (modified) (7 diffs)
-
senna-perl.h (modified) (4 diffs)
-
senna-query.c (added)
-
senna-records.c (modified) (6 diffs)
-
senna-sym.c (modified) (1 diff)
-
t/query (added)
-
t/query/01_load.t (added)
-
t/query/02_api.t (added)
-
typemap (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Senna/trunk/lib/Senna.xs
r3991 r4001 50 50 SV * 51 51 SennaPerl_Index__XS_info(self) 52 S V*self;52 SennaPerl_Index *self; 53 53 CODE: 54 54 RETVAL = SennaPerl_Index_info(self); … … 58 58 SV * 59 59 SennaPerl_Index_path(self) 60 S V*self;60 SennaPerl_Index *self; 61 61 62 62 SV * 63 63 SennaPerl_Index_remove(self) 64 S V*self;64 SennaPerl_Index *self; 65 65 66 66 SV * 67 67 SennaPerl_Index_close(self) 68 S V*self;68 SennaPerl_Index *self; 69 69 70 70 SV * 71 71 SennaPerl_Index_update(self, key, oldvalue, newvalue) 72 S V*self;72 SennaPerl_Index *self; 73 73 SV *key; 74 74 SV *oldvalue; … … 77 77 SV * 78 78 SennaPerl_Index__XS_insert(self, key, newvalue) 79 S V*self;79 SennaPerl_Index *self; 80 80 SV *key; 81 81 SV *newvalue; … … 96 96 void 97 97 SennaPerl_Index_DESTROY(self) 98 S V*self;98 SennaPerl_Index *self; 99 99 100 100 MODULE = Senna PACKAGE = Senna::Encoding PREFIX = SennaPerl_Encoding_ … … 105 105 SennaPerl_Encoding_enc2str(enc) 106 106 sen_encoding enc; 107 CODE:108 RETVAL = SennaPerl_Encoding_XS_enc2str(enc);109 OUTPUT:110 RETVAL111 107 112 108 MODULE = Senna PACKAGE = Senna::Records PREFIX = SennaPerl_Records_ … … 115 111 116 112 SV * 113 SennaPerl_Records_open(pkg, record_unit, subrec_unit, max_n_subrecs) 114 char *pkg; 115 sen_rec_unit record_unit; 116 sen_rec_unit subrec_unit; 117 unsigned int max_n_subrecs; 118 119 SV * 117 120 SennaPerl_Records__XS_next(self) 118 S V*self;121 SennaPerl_Records *self; 119 122 CODE: 120 123 RETVAL = SennaPerl_Records_next(self); … … 124 127 SV * 125 128 SennaPerl_Records_nhits(self) 126 S V*self;129 SennaPerl_Records *self; 127 130 128 131 SV * 129 132 SennaPerl_Records_curr_key(self) 130 S V*self;133 SennaPerl_Records *self; 131 134 132 135 SV * 133 136 SennaPerl_Records_sort(self, limit = 10, optarg = NULL) 134 S V*self;137 SennaPerl_Records *self; 135 138 int limit; 136 139 HV *optarg; … … 138 141 void 139 142 SennaPerl_Records_DESTROY(self) 140 SV *self; 143 SennaPerl_Records *self; 144 145 sen_rc 146 SennaPerl_Records_close(self) 147 SennaPerl_Records *self; 141 148 142 149 MODULE = Senna PACKAGE = Senna::Symbol PREFIX = SennaPerl_Symbol_ … … 180 187 SennaPerl_Symbol_DESTROY(obj) 181 188 SV *obj; 189 190 MODULE = Senna PACKAGE = Senna::Query PREFIX = SennaPerl_Query_ 191 192 PROTOTYPES: DISABLE 193 194 SV * 195 SennaPerl_Query_open(pkg, str, default_op, max_exprs, encoding) 196 char *pkg; 197 char *str; 198 sen_sel_operator default_op; 199 int max_exprs; 200 sen_encoding encoding; 201 202 sen_rc 203 SennaPerl_Query_close(obj) 204 SennaPerl_Query *obj; 205 206 void 207 SennaPerl_Query_DESTROY(obj) 208 SennaPerl_Query *obj; 209 210 sen_rc 211 SennaPerl_Query_exec(obj, index, records, op) 212 SennaPerl_Query *obj; 213 SennaPerl_Index *index; 214 SennaPerl_Records *records; 215 sen_sel_operator op 216 217 SV * 218 SennaPerl_Query_snip(query, flags, width, max_results, n_tags, opentags_av, closetags_av, mapping) 219 SennaPerl_Query *query; 220 int flags; 221 unsigned int width; 222 unsigned int max_results; 223 unsigned int n_tags; 224 AV *opentags_av; 225 AV *closetags_av; 226 sen_snip_mapping *mapping; 227 228 -
lang/perl/Senna/trunk/senna-encoding.c
r3767 r4001 1 /* $Id$ 2 * 3 * Copyright (c) 2005-2008 Daisuke Maki <daisuke@endeworks.jp> 4 * All rights reserved. 5 */ 1 6 #include "senna-perl.h" 7 #ifndef __SENNA_ENCODING_C__ 8 #define __SENNA_ENCODING_C__ 2 9 3 10 int … … 20 27 21 28 SV * 22 SennaPerl_Encoding_ XS_enc2str(enc)29 SennaPerl_Encoding_enc2str(enc) 23 30 sen_encoding enc; 24 31 { … … 41 48 return sv; 42 49 } 50 51 #endif /* ifndef __SENNA_ENCODING_C__ */ -
lang/perl/Senna/trunk/senna-index.c
r3991 r4001 90 90 91 91 SV * 92 SennaPerl_Index_info(self) 93 SV *self; 94 { 95 SennaPerl_Index *index; 92 SennaPerl_Index_info(index) 93 SennaPerl_Index *index; 94 { 96 95 int key_size = 0; 97 96 int flags = 0; … … 106 105 sen_rc rc; 107 106 108 index = XS_STATE(SennaPerl_Index *, self);109 107 rc = sen_index_info(index->index, 110 108 &key_size, &flags, &initial_n_segments, &encoding, … … 155 153 156 154 SV * 157 SennaPerl_Index_remove(self) 158 SV *self; 159 { 160 SennaPerl_Index *index; 155 SennaPerl_Index_remove(index) 156 SennaPerl_Index *index; 157 { 161 158 char path[ SEN_MAX_PATH_SIZE ]; 162 159 163 index = XS_STATE(SennaPerl_Index *, self);164 160 if (! sen_index_path( index->index, path, SEN_MAX_PATH_SIZE) ) { 165 161 croak("sen_index_path() did not return a proper path"); … … 170 166 171 167 SV * 172 SennaPerl_Index_close(obj) 173 SV *obj; 174 { 175 SennaPerl_Index *index; 176 index = XS_STATE(SennaPerl_Index *, obj); 168 SennaPerl_Index_close(index) 169 SennaPerl_Index *index; 170 { 177 171 if (index == NULL || ! index->open) { 178 172 return SennaPerl_Global_sen_rc2obj( sen_other_error ); … … 184 178 185 179 void 186 SennaPerl_Index_DESTROY(obj) 187 SV *obj; 188 { 189 SennaPerl_Index *index; 190 SP_DEBUG("Senna::Index::DESTROY"); 191 index = XS_STATE(SennaPerl_Index *, obj); 192 193 SP_DEBUG("Senna::Index::close"); 194 SennaPerl_Index_close(obj); 195 SP_DEBUG("Senna::Index Safefree"); 180 SennaPerl_Index_DESTROY(index) 181 SennaPerl_Index *index; 182 { 183 SennaPerl_Index_close(index); 196 184 Safefree(index); 197 SP_DEBUG("Senna::Index::DESTROY done"); 198 } 199 200 SV * 201 SennaPerl_Index_path(obj) 202 SV *obj; 203 { 204 SennaPerl_Index *index; 185 } 186 187 SV * 188 SennaPerl_Index_path(index) 189 SennaPerl_Index *index; 190 { 205 191 char *buf; 206 192 SV *sv; 207 193 208 index = XS_STATE(SennaPerl_Index *, obj);209 194 buf = malloc(sizeof(char) * SEN_MAX_PATH_SIZE); 210 195 … … 216 201 217 202 SV * 218 SennaPerl_Index_update( obj, key, oldvalue, newvalue)219 S V *obj;203 SennaPerl_Index_update(index, key, oldvalue, newvalue) 204 SennaPerl_Index *index; 220 205 SV *key; 221 206 SV *oldvalue; 222 207 SV *newvalue; 223 208 { 224 SennaPerl_Index *index = XS_STATE(SennaPerl_Index *, obj);225 209 void *pkey = SennaPerl_Global_sv2key(key); 226 210 char *oldc = NULL; … … 244 228 245 229 SV * 246 SennaPerl_Index_insert( obj, key, value)247 S V *obj;230 SennaPerl_Index_insert(index, key, value) 231 SennaPerl_Index *index; 248 232 SV *key; 249 233 SV *value; 250 234 { 251 return SennaPerl_Index_update( obj, key, NULL, value);235 return SennaPerl_Index_update(index, key, NULL, value); 252 236 } 253 237 -
lang/perl/Senna/trunk/senna-perl.h
r3991 r4001 64 64 } SennaPerl_Index ; 65 65 66 typedef struct { 67 sen_records *records; 68 } SennaPerl_Records; 66 #define XS_2SENINDEX(x) x->index 67 #define XS_2SENINDEX_OPEN(x) x->open 68 69 typedef sen_records SennaPerl_Records; 70 #define XS_2SENRECORDS(x) x 69 71 70 72 typedef struct { … … 72 74 char *path; 73 75 } SennaPerl_Symbol; 76 #define XS_2SENSYM(x) x->sym 77 #define XS_2SENSYM_PATH(x) x->path 78 79 typedef sen_query SennaPerl_Query; 80 #define XS_2SENQUERY(x) x 81 82 typedef sen_snip SennaPerl_Snip; 83 #define XS_2SENSNUP(x) x 74 84 75 85 /* SennaPerl_Global */ … … 81 91 82 92 /* SennaPerl_Encoding */ 83 SV *SennaPerl_Encoding_ XS_enc2str(sen_encoding enc);93 SV *SennaPerl_Encoding_enc2str(sen_encoding enc); 84 94 85 95 /* SennaPerl_Index */ 86 SV *SennaPerl_Index_ XS_create( char *pkg, char *path, int key_size, int flags, int initial_n_segments, sen_encoding encoding);96 SV *SennaPerl_Index_create( char *pkg, char *path, int key_size, int flags, int initial_n_segments, sen_encoding encoding); 87 97 SV *SennaPerl_Index_open( char *pkg, char *path ); 88 SV *SennaPerl_Index_remove(S V *self);89 SV *SennaPerl_Index_info(S V *self);90 SV *SennaPerl_Index_update(S V *self, SV *key, SV *oldvalue, SV *newvalue);91 SV *SennaPerl_Index_path(S V*self);92 SV *SennaPerl_Index_close(S V*self);98 SV *SennaPerl_Index_remove(SennaPerl_Index *index); 99 SV *SennaPerl_Index_info(SennaPerl_Index *index); 100 SV *SennaPerl_Index_update(SennaPerl_Index *index, SV *key, SV *oldvalue, SV *newvalue); 101 SV *SennaPerl_Index_path(SennaPerl_Index *self); 102 SV *SennaPerl_Index_close(SennaPerl_Index *self); 93 103 SV *SennaPerl_Index_rename(SV *self, char *from, char *to); 94 SV *SennaPerl_Index_insert(S V*self, SV *key, SV *value);104 SV *SennaPerl_Index_insert(SennaPerl_Index *self, SV *key, SV *value); 95 105 SV *SennaPerl_Index_select(SV *self, SV *query); 96 void SennaPerl_Index_DESTROY(S V*self);106 void SennaPerl_Index_DESTROY(SennaPerl_Index *self); 97 107 98 108 /* SennaPerl_Records */ 99 109 void SennaPerl_Records_bootstrap(); 100 110 SV *SennaPerl_Records_new(char *pkg, sen_records *records); 101 SV *SennaPerl_Records_next(SV *self); 102 SV *SennaPerl_Records_nhits(SV *self); 103 SV *SennaPerl_Records_curr_key(SV *self); 104 SV *SennaPerl_Records_sort(SV *self, int limit, HV *optarg); 105 void SennaPerl_Records_DESTROY(SV *self); 111 SV *SennaPerl_Records_open(char *pkg, sen_rec_unit record_unit, sen_rec_unit subrec_unit, unsigned int max_n_subrecs); 112 SV *SennaPerl_Records_next(SennaPerl_Records *self); 113 SV *SennaPerl_Records_nhits(SennaPerl_Records *self); 114 SV *SennaPerl_Records_curr_key(SennaPerl_Records *self); 115 SV *SennaPerl_Records_sort(SennaPerl_Records *self, int limit, HV *optarg); 116 sen_rc SennaPerl_Records_close(SennaPerl_Records *self); 117 void SennaPerl_Records_DESTROY(SennaPerl_Records *self); 106 118 107 119 /* SennaPerl_Symbol */ … … 114 126 SV *SennaPerl_Symbol_path(SV *obj); 115 127 128 /* SennaPerl_Query */ 129 SV *SennaPerl_Query_open(char *pkg, char *str, sen_sel_operator default_op, int max_exprs, sen_encoding encoding); 130 sen_rc SennaPerl_Query_close(SennaPerl_Query *obj); 131 void SennaPerl_Query_DESTROY(SennaPerl_Query *obj); 132 sen_rc SennaPerl_Query_exec(SennaPerl_Query *obj, SennaPerl_Index *index, SennaPerl_Records *records, sen_sel_operator op); 133 116 134 #endif /* ifndef __SENNA_PERL_H__ */ -
lang/perl/Senna/trunk/senna-records.c
r3962 r4001 4 4 * All rights reserved. 5 5 */ 6 #include "senna-perl.h" 6 7 #ifndef __SENNA_RECORDS_C__ 7 8 #define __SENNA_RECORDS_C__ 8 9 #include "senna-perl.h"10 9 11 10 void … … 25 24 sen_records *records; 26 25 { 27 SennaPerl_Records *xs;28 26 SV *sv; 29 30 Newz(1234, xs, 1, SennaPerl_Records); 31 32 xs->records = records; 33 34 XS_STRUCT2OBJ(sv, pkg, xs); 27 XS_STRUCT2OBJ(sv, pkg, records); 35 28 SvREADONLY_on(sv); 36 29 return sv; … … 38 31 39 32 SV * 40 SennaPerl_Records_next(obj) 41 SV *obj; 33 SennaPerl_Records_open(pkg, record_unit, subrec_unit, max_n_subrecs) 34 char *pkg; 35 sen_rec_unit record_unit; 36 sen_rec_unit subrec_unit; 37 unsigned int max_n_subrecs; 38 { 39 SV *sv; 40 sen_records *records; 41 42 records = sen_records_open(record_unit, subrec_unit, max_n_subrecs); 43 return SennaPerl_Records_new(pkg, records); 44 } 45 46 SV * 47 SennaPerl_Records_next(records) 48 SennaPerl_Records *records; 42 49 { 43 50 SV *sv; 44 51 char keybuf[SEN_MAX_KEY_SIZE]; 45 52 int score; 46 SennaPerl_Records *records = XS_STATE(SennaPerl_Records *, obj);47 53 48 if (sen_records_next( records->records, &keybuf, SEN_MAX_KEY_SIZE, &score)) {54 if (sen_records_next(XS_2SENRECORDS(records), &keybuf, SEN_MAX_KEY_SIZE, &score)) { 49 55 dSP; 50 56 ENTER; … … 78 84 79 85 SV * 80 SennaPerl_Records_nhits( obj)81 S V *obj;86 SennaPerl_Records_nhits(records) 87 SennaPerl_Records *records; 82 88 { 83 SennaPerl_Records *records = XS_STATE(SennaPerl_Records *, obj); 84 return newSViv( sen_records_nhits( records->records ) ); 89 return newSViv( sen_records_nhits( XS_2SENRECORDS(records)) ); 90 } 91 92 sen_rc 93 SennaPerl_Records_close(records) 94 SennaPerl_Records *records; 95 { 96 return sen_records_close(XS_2SENRECORDS(records)); 85 97 } 86 98 87 99 void 88 SennaPerl_Records_DESTROY( obj)89 S V *obj;100 SennaPerl_Records_DESTROY(records) 101 SennaPerl_Records *records; 90 102 { 91 SennaPerl_Records *records = XS_STATE(SennaPerl_Records *, obj);92 sen_records_close(records->records);93 Safefree(records);103 if (XS_2SENRECORDS(records)) { 104 sen_records_close(XS_2SENRECORDS(records)); 105 } 94 106 } 95 107 96 108 SV * 97 SennaPerl_Records_curr_key( obj)98 S V *obj;109 SennaPerl_Records_curr_key(records) 110 SennaPerl_Records *records; 99 111 { 100 112 char keybuf[SEN_MAX_KEY_SIZE]; 101 SennaPerl_Records *records = XS_STATE(SennaPerl_Records *, obj); 102 if (sen_records_curr_key(records->records, keybuf, SEN_MAX_KEY_SIZE)) { 113 if (sen_records_curr_key(XS_2SENRECORDS(records), keybuf, SEN_MAX_KEY_SIZE)) { 103 114 return newSVpvf("%s", keybuf); 104 115 } … … 107 118 108 119 SV * 109 SennaPerl_Records_sort( obj, limit, optarg)110 S V *obj;120 SennaPerl_Records_sort(records, limit, optarg) 121 SennaPerl_Records *records; 111 122 int limit; 112 123 HV *optarg; 113 124 { 114 125 SV *sv; 115 SennaPerl_Records *records = XS_STATE(SennaPerl_Records *, obj);116 126 sen_sort_optarg *o = NULL; 117 127 if (optarg != NULL) { … … 128 138 } 129 139 130 sv = sen_rc2obj(sen_records_sort( records->records, limit, o));140 sv = sen_rc2obj(sen_records_sort(XS_2SENRECORDS(records), limit, o)); 131 141 132 142 if (o) { -
lang/perl/Senna/trunk/senna-sym.c
r3993 r4001 92 92 { 93 93 SennaPerl_Symbol *symbol = XS_STATE(SennaPerl_Symbol *, obj); 94 S ennaPerl_Symbol_close(obj);94 SvREFCNT_dec(SennaPerl_Symbol_close(obj)); 95 95 Safefree(symbol->path); 96 96 Safefree(symbol); -
lang/perl/Senna/trunk/typemap
r3767 r4001 1 1 TYPEMAP 2 Senna::Index T_PTROBJ 2 SennaPerl_Index * T_PTROBJ_INDEX 3 SennaPerl_Query * T_PTROBJ_QUERY 4 SennaPerl_Records * T_PTROBJ_RECORDS 5 SennaPerl_Snip * T_PTROBJ_SNIP 3 6 sen_encoding T_ENUM 4 7 sen_sel_mode T_ENUM … … 8 11 sen_id T_U_INT 9 12 sen_sel_operator T_ENUM 10 sen_snip_mapping T_PRTOBJ 13 sen_snip_mapping * T_PTROBJ 14 15 INPUT 16 T_PTROBJ_INDEX 17 $var = XS_STATE(SennaPerl_Index *, $arg); 18 19 T_PTROBJ_QUERY 20 $var = XS_STATE(SennaPerl_Query *, $arg); 21 22 T_PTROBJ_RECORDS 23 $var = XS_STATE(SennaPerl_Records *, $arg); 24 25 T_PTROBJ_SNIP 26 $var = XS_STATE(SennaPerl_Snip *, $arg); 27
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)