Lucy
view release on metacpan or search on metacpan
buildlib/Lucy/Build/Binding/Analysis.pm view on Meta::CPAN
$token->set_text($text);
Set the token's text.
END_SET_TEXT_POD
$pod_spec->set_synopsis($synopsis);
$pod_spec->add_constructor( alias => 'new', pod => $constructor_pod );
$pod_spec->add_method( alias => 'Get_Text', pod => $get_text_pod);
$pod_spec->add_method( alias => 'Set_Text', pod => $set_text_pod);
my $xs = <<'END_XS';
MODULE = Lucy PACKAGE = Lucy::Analysis::Token
SV*
new(either_sv, ...)
SV *either_sv;
CODE:
{
static const XSBind_ParamSpec param_specs[5] = {
XSBIND_PARAM("text", true),
XSBIND_PARAM("start_offset", true),
XSBIND_PARAM("end_offset", true),
XSBIND_PARAM("pos_inc", false),
XSBIND_PARAM("boost", false)
};
int32_t locations[5];
uint32_t start_off = 0;
uint32_t end_off = 0;
int32_t pos_inc = 1;
float boost = 1.0f;
STRLEN len = 0;
char *text = NULL;
lucy_Token *self = NULL;
XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 5);
text = SvPVutf8(ST(locations[0]), len);
start_off = (uint32_t)SvUV(ST(locations[1]));
end_off = (uint32_t)SvUV(ST(locations[2]));
pos_inc = locations[3] < items ? (int32_t)SvIV(ST(locations[3])) : 1;
boost = locations[4] < items ? (float)SvNV(ST(locations[4])) : 1.0f;
self = (lucy_Token*)XSBind_new_blank_obj(aTHX_ either_sv);
lucy_Token_init(self, text, len, start_off, end_off, boost,
pos_inc);
RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
}
OUTPUT: RETVAL
SV*
get_text(self)
lucy_Token *self;
CODE:
RETVAL = newSVpvn(LUCY_Token_Get_Text(self), LUCY_Token_Get_Len(self));
SvUTF8_on(RETVAL);
OUTPUT: RETVAL
void
set_text(self, sv)
lucy_Token *self;
SV *sv;
PPCODE:
{
STRLEN len;
char *ptr = SvPVutf8(sv, len);
LUCY_Token_Set_Text(self, ptr, len);
}
END_XS
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
parcel => "Lucy",
class_name => "Lucy::Analysis::Token",
);
$binding->set_pod_spec($pod_spec);
$binding->append_xs($xs);
$binding->exclude_method($_) for @hand_rolled;
$binding->exclude_constructor;
Clownfish::CFC::Binding::Perl::Class->register($binding);
}
1;
( run in 1.127 second using v1.01-cache-2.11-cpan-5511b514fd6 )