in scriptators/perl/Perltator.cpp [82:175]
TyErrorId initialize(AnnotatorContext &ac) {
swig_type_info *ac_type;
char srcfile[1000 + 256];
if (ac.isParameterDefined("DebugLevel")) {
ac.extractValue("DebugLevel", debug);
}
if (debug > 1) {
cerr<< MODULENAME ": Initialize - debug=" << debug <<endl;
}
if (!ac.isParameterDefined("SourceFile")) {
cerr<< MODULENAME ": Missing Perl SourceFile" <<endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
UnicodeString fn;
ac.extractValue(UnicodeString("SourceFile"), fn);
if (fn == "") {
cerr<< MODULENAME ": Empty Perl SourceFile" <<endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
UErrorCode err = U_ZERO_ERROR;
fn.extract(srcfile,sizeof(srcfile),0,err);
if (U_FAILURE(err)) {
cerr << MODULENAME ": Unable to extract parameter, got " << u_errorName(err) << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
if (my_perl == 0) {
my_perl = perl_alloc();
perl_construct(my_perl);
char * my_argv[] = { "", "-S", srcfile };
perl_parse(my_perl, xs_init, 3, my_argv, (char **) NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run(my_perl);
// convert cas and rs to python variables (parameters)
swig_module_info *module = SWIG_Perl_GetModule(NULL);
if (!module) {
cerr << MODULENAME ": could not get Perl swig module" << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
ts_type = SWIG_TypeQueryModule(module,module, "TypeSystem *");
if (!ts_type) {
cerr << MODULENAME ": could lookup TypeSystem type in swig" << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
ac_type = SWIG_TypeQueryModule(module,module, "AnnotatorContext *");
if (!ac_type) {
cerr << MODULENAME ": could lookup AnnotatorContext type in swig" << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
cas_type = SWIG_TypeQueryModule(module,module, "CAS *");
if (!cas_type) {
cerr << MODULENAME ": could lookup cas type in swig" << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
rs_type = SWIG_TypeQueryModule(module,module,
"ResultSpecification *");
if (!rs_type) {
cerr << MODULENAME ": could lookup rs type in swig" << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
}
dSP ;
ENTER ;
SAVETMPS ;
PUSHMARK(SP) ;
XPUSHs(SWIG_Perl_NewPointerObj(
reinterpret_cast<void *>( const_cast<AnnotatorContext *>(&ac)),
ac_type, 0));
PUTBACK ;
call_pv("initialize", G_DISCARD);
FREETMPS ;
LEAVE ;
if (SvTRUE(ERRSV)) {
cerr << MODULENAME " initialize error "
<< SvPV_nolen(ERRSV) << endl;
return UIMA_ERR_USER_ANNOTATOR_COULD_NOT_INIT;
}
return UIMA_ERR_NONE;
}