SWISH-3
view release on metacpan or search on metacpan
int ret;
CODE:
buf = SvPV(buffer, PL_na);
# need to swap return values to make it Perlish
ret = swish_parse_buffer( self, (xmlChar*)buf );
sp_Stash_set_int( self->stash, "error", ret );
RETVAL = ret ? 0 : 1;
OUTPUT:
RETVAL
# TODO
int
parse_fh(self, perl_fh)
swish_3* self;
PerlIO* perl_fh;
PREINIT:
FILE* c_fh;
CODE:
# RETVAL is number of parsed documents
c_fh = PerlIO_exportFILE(perl_fh, 0);
RETVAL = swish_parse_fh(self, c_fh);
OUTPUT:
RETVAL
# accessors/mutators
void
_set_or_get(self, ...)
swish_3* self;
ALIAS:
set_config = 1
get_config = 2
set_analyzer = 3
get_analyzer = 4
set_parser = 5
get_parser = 6
set_handler = 7
get_handler = 8
set_data_class = 9
get_data_class = 10
set_parser_class = 11
get_parser_class = 12
set_config_class = 13
get_config_class = 14
set_analyzer_class = 15
get_analyzer_class = 16
set_regex = 17
get_regex = 18
_x_placeholder = 19
get_stash = 20
PREINIT:
SV *RETVAL;
char *class;
PPCODE:
{
//warn("number of items %d for ix %d", items, ix);
START_SET_OR_GET_SWITCH
// set_config
case 1: if (!sv_derived_from(ST(1), CONFIG_CLASS)) {
croak("usage: must be a %s object", CONFIG_CLASS);
}
self->config->ref_cnt--;
//warn("set_config ref_cnt of old config = %d", self->config->ref_cnt);
if (self->config->ref_cnt < 1) {
if (SWISH_DEBUG) {
warn("freeing config on set_config");
}
sp_Stash_destroy(self->config->stash);
if (self->config->stash != NULL) {
//SWISH_WARN("set config stash to NULL");
self->config->stash = NULL;
}
swish_config_free(self->config);
}
self->config = (swish_Config*)sp_extract_ptr(ST(1));
self->config->ref_cnt++;
//warn("set_config ref_cnt of new config = %d", self->config->ref_cnt);
break;
// get_config
case 2: if (gimme != G_VOID)
self->config->ref_cnt++;
class = sp_Stash_get_char(self->stash, CONFIG_CLASS_KEY);
sp_Stash_set_char( self->config->stash, SELF_CLASS_KEY, class );
RETVAL = sp_bless_ptr(class, self->config);
break;
// set_analyzer
case 3: if (!sv_derived_from(ST(1), ANALYZER_CLASS)) {
croak("usage: must be a %s object", ANALYZER_CLASS);
}
self->analyzer->ref_cnt--;
//warn("set_analyzer ref_cnt of old analyzer: %d", self->analyzer->ref_cnt);
if (self->analyzer->ref_cnt < 1) {
if (SWISH_DEBUG) {
warn("freeing analyzer on set_analyzer");
}
sp_Stash_destroy(self->analyzer->stash);
swish_analyzer_free(self->analyzer);
}
self->analyzer = (swish_Analyzer*)sp_extract_ptr(ST(1));
self->analyzer->ref_cnt++;
//warn("set_analyzer ref_cnt of new analyzer: %d", self->analyzer->ref_cnt);
break;
// get_analyzer
case 4: if (gimme != G_VOID)
self->analyzer->ref_cnt++;
( run in 0.913 second using v1.01-cache-2.11-cpan-5511b514fd6 )