diff --git a/java/CRFPP_wrap.cxx b/java/CRFPP_wrap.cxx index 309b2aa..7d71df1 100644 --- a/java/CRFPP_wrap.cxx +++ b/java/CRFPP_wrap.cxx @@ -1,14 +1,18 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 - * - * This file is not intended to be easily readable and contains a number of + * Version 3.0.8 + * + * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGJAVA #define SWIGJAVA +#endif + #ifdef __cplusplus @@ -65,28 +69,28 @@ template T SwigValueInit() { #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -129,7 +133,7 @@ template T SwigValueInit() { # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -142,6 +146,19 @@ template T SwigValueInit() { # define _SCL_SECURE_NO_DEPRECATE #endif +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif /* Fix for jlong on some versions of gcc on Windows */ @@ -211,18 +228,18 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC #define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 @@ -1617,7 +1634,7 @@ SWIGEXPORT jstring JNICALL Java_org_chasen_crfpp_CRFPPJNI_VERSION_1get(JNIEnv *j (void)jenv; (void)jcls; - result = (char *)("0.58"); + result = (char *)("0.59"); if (result) jresult = jenv->NewStringUTF((const char *)result); return jresult; } diff --git a/java/org/chasen/crfpp/CRFPP.java b/java/org/chasen/crfpp/CRFPP.java index c08b319..8008172 100644 --- a/java/org/chasen/crfpp/CRFPP.java +++ b/java/org/chasen/crfpp/CRFPP.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 + * Version 3.0.8 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/java/org/chasen/crfpp/CRFPPConstants.java b/java/org/chasen/crfpp/CRFPPConstants.java index d17e821..8b863e1 100644 --- a/java/org/chasen/crfpp/CRFPPConstants.java +++ b/java/org/chasen/crfpp/CRFPPConstants.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 + * Version 3.0.8 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/java/org/chasen/crfpp/CRFPPJNI.java b/java/org/chasen/crfpp/CRFPPJNI.java index 7089075..8f42036 100644 --- a/java/org/chasen/crfpp/CRFPPJNI.java +++ b/java/org/chasen/crfpp/CRFPPJNI.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 + * Version 3.0.8 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. diff --git a/java/org/chasen/crfpp/Model.java b/java/org/chasen/crfpp/Model.java index 7d63033..de6d833 100644 --- a/java/org/chasen/crfpp/Model.java +++ b/java/org/chasen/crfpp/Model.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 + * Version 3.0.8 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -9,15 +9,15 @@ package org.chasen.crfpp; public class Model { - private long swigCPtr; - protected boolean swigCMemOwn; + private transient long swigCPtr; + protected transient boolean swigCMemOwn; - public Model(long cPtr, boolean cMemoryOwn) { + protected Model(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } - public static long getCPtr(Model obj) { + protected static long getCPtr(Model obj) { return (obj == null) ? 0 : obj.swigCPtr; } diff --git a/java/org/chasen/crfpp/Tagger.java b/java/org/chasen/crfpp/Tagger.java index 3830ab3..041e87a 100644 --- a/java/org/chasen/crfpp/Tagger.java +++ b/java/org/chasen/crfpp/Tagger.java @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 + * Version 3.0.8 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. @@ -9,15 +9,15 @@ package org.chasen.crfpp; public class Tagger { - private long swigCPtr; - protected boolean swigCMemOwn; + private transient long swigCPtr; + protected transient boolean swigCMemOwn; - public Tagger(long cPtr, boolean cMemoryOwn) { + protected Tagger(long cPtr, boolean cMemoryOwn) { swigCMemOwn = cMemoryOwn; swigCPtr = cPtr; } - public static long getCPtr(Tagger obj) { + protected static long getCPtr(Tagger obj) { return (obj == null) ? 0 : obj.swigCPtr; } diff --git a/perl/CRFPP.pm b/perl/CRFPP.pm index 67afca5..3f667cb 100644 --- a/perl/CRFPP.pm +++ b/perl/CRFPP.pm @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 2.0.4 +# Version 3.0.8 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. diff --git a/perl/CRFPP_wrap.cxx b/perl/CRFPP_wrap.cxx index 59154c0..6b06f98 100644 --- a/perl/CRFPP_wrap.cxx +++ b/perl/CRFPP_wrap.cxx @@ -1,14 +1,18 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 - * - * This file is not intended to be easily readable and contains a number of + * Version 3.0.8 + * + * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGPERL #define SWIGPERL +#endif + #define SWIG_CASTRANK_MODE @@ -66,28 +70,28 @@ template T SwigValueInit() { #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -130,7 +134,7 @@ template T SwigValueInit() { # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -143,6 +147,19 @@ template T SwigValueInit() { # define _SCL_SECURE_NO_DEPRECATE #endif +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif /* ----------------------------------------------------------------------------- * swigrun.swg @@ -168,7 +185,7 @@ template T SwigValueInit() { You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -194,16 +211,16 @@ template T SwigValueInit() { #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -236,23 +253,23 @@ template T SwigValueInit() { } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -266,17 +283,17 @@ template T SwigValueInit() { int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -307,14 +324,14 @@ template T SwigValueInit() { # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif @@ -358,7 +375,7 @@ typedef struct swig_module_info { void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -378,18 +395,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1, /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -397,24 +414,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ @@ -442,7 +448,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -477,7 +483,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -521,7 +527,7 @@ SWIG_TypePrettyName(const swig_type_info *type) { return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -529,14 +535,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -545,31 +551,31 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; + size_t l = 0; + size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { + int compare = strcmp(name, iname); + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -594,14 +600,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -612,7 +618,7 @@ SWIG_TypeQueryModule(swig_module_info *start, of the str field (the human readable name) */ swig_module_info *iter = start; do { - register size_t i = 0; + size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; @@ -620,56 +626,56 @@ SWIG_TypeQueryModule(swig_module_info *start, iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register unsigned char uu = *u; + unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; + char d = *(c++); + unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); - else + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); - else + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * @@ -729,18 +735,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #endif /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 @@ -854,50 +860,35 @@ extern "C" { SWIGINTERN const char* SWIG_Perl_ErrorType(int code) { - const char* type = 0; switch(code) { case SWIG_MemoryError: - type = "MemoryError"; - break; + return "MemoryError"; case SWIG_IOError: - type = "IOError"; - break; + return "IOError"; case SWIG_RuntimeError: - type = "RuntimeError"; - break; + return "RuntimeError"; case SWIG_IndexError: - type = "IndexError"; - break; + return "IndexError"; case SWIG_TypeError: - type = "TypeError"; - break; + return "TypeError"; case SWIG_DivisionByZero: - type = "ZeroDivisionError"; - break; + return "ZeroDivisionError"; case SWIG_OverflowError: - type = "OverflowError"; - break; + return "OverflowError"; case SWIG_SyntaxError: - type = "SyntaxError"; - break; + return "SyntaxError"; case SWIG_ValueError: - type = "ValueError"; - break; + return "ValueError"; case SWIG_SystemError: - type = "SystemError"; - break; + return "SystemError"; case SWIG_AttributeError: - type = "AttributeError"; - break; + return "AttributeError"; default: - type = "RuntimeError"; + return "RuntimeError"; } - return type; } - - /* ----------------------------------------------------------------------------- * perlrun.swg * @@ -920,6 +911,7 @@ SWIG_Perl_ErrorType(int code) { #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) #define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own) #define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) +#define swig_owntype int /* for raw packed data */ #define SWIG_ConvertPacked(obj, p, s, type) SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type) @@ -940,14 +932,14 @@ SWIG_Perl_ErrorType(int code) { /* Runtime API */ -#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule() +#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer) /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Perl_ErrorType(code) -#define SWIG_Error(code, msg) sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg) +#define SWIG_Error(code, msg) sv_setpvf(get_sv("@", GV_ADD), "%s %s", SWIG_ErrorType(code), msg) #define SWIG_fail goto fail /* Perl-specific SWIG API */ @@ -1041,8 +1033,6 @@ typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *); #endif /* MULTIPLICITY */ #endif /* PERL_OBJECT */ -/* Workaround for bug in perl 5.6.x croak and earlier */ -#if (PERL_VERSION < 8) # ifdef PERL_OBJECT # define SWIG_croak_null() SWIG_Perl_croak_null(pPerl) static void SWIG_Perl_croak_null(CPerlObj *pPerl) @@ -1050,17 +1040,16 @@ static void SWIG_Perl_croak_null(CPerlObj *pPerl) static void SWIG_croak_null() # endif { - SV *err=ERRSV; + SV *err = get_sv("@", GV_ADD); # if (PERL_VERSION < 6) croak("%_", err); # else - if (SvOK(err) && !SvROK(err)) croak("%_", err); - croak(Nullch); + if (sv_isobject(err)) + croak(0); + else + croak("%s", SvPV_nolen(err)); # endif } -#else -# define SWIG_croak_null() croak(Nullch) -#endif /* @@ -1112,8 +1101,7 @@ SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { if (ty) { swig_cast_info *iter = ty->cast; while (iter) { - if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) || - (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) { + if (strcmp(SWIG_Perl_TypeProxyName(iter->type), c) == 0) { if (iter == ty->cast) return iter; /* Move iter to the top of the linked list */ @@ -1192,7 +1180,11 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_ /* Now see if the types match */ char *_c = HvNAME(SvSTASH(SvRV(sv))); tc = SWIG_TypeProxyCheck(_c,_t); +#ifdef SWIG_DIRECTORS + if (!tc && !sv_derived_from(sv,SWIG_Perl_TypeProxyName(_t))) { +#else if (!tc) { +#endif return SWIG_ERROR; } { @@ -1244,7 +1236,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i SV *obj=newSV(0); HV *hash=newHV(); HV *stash; - sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr); + sv_setref_pv(obj, SWIG_Perl_TypeProxyName(t), ptr); stash=SvSTASH(SvRV(obj)); if (flags & SWIG_POINTER_OWN) { HV *hv; @@ -1262,7 +1254,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i sv_bless(sv, stash); } else { - sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr); + sv_setref_pv(sv, SWIG_Perl_TypeProxyName(t), ptr); } } @@ -1353,19 +1345,23 @@ typedef struct { /* Magic variable code */ #ifndef PERL_OBJECT -#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c) - #ifndef MULTIPLICITY - SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) - #else - SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) - #endif +# ifdef __cplusplus +# define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast(a),b,c) +# else +# define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c) +# endif +# ifndef MULTIPLICITY +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) +# else +SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) +# endif #else # define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c) SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) #endif { MAGIC *mg; - sv_magic(sv,sv,'U',(char *) name,strlen(name)); + sv_magic(sv,sv,'U',name,strlen(name)); mg = mg_find(sv,'U'); mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL)); mg->mg_virtual->svt_get = (SwigMagicFunc) get; @@ -1377,7 +1373,7 @@ SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, i SWIGRUNTIME swig_module_info * -SWIG_Perl_GetModule(void) { +SWIG_Perl_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; SV *pointer; @@ -1471,9 +1467,6 @@ SWIG_Perl_SetModule(swig_module_info *module) { #ifdef eof #undef eof #endif -#ifdef bool - #undef bool -#endif #ifdef close #undef close #endif @@ -1513,6 +1506,17 @@ SWIG_Perl_SetModule(swig_module_info *module) { #ifdef stat #undef stat #endif +#ifdef seed + #undef seed +#endif + +#ifdef bool + /* Leave if macro is from C99 stdbool.h */ + #ifndef __bool_true_false_are_defined + #undef bool + #endif +#endif + @@ -1542,7 +1546,7 @@ static swig_module_info swig_module = {swig_types, 3, 0, 0, 0, 0}; #define SWIG_name "CRFPPc::boot_CRFPP" #define SWIG_prefix "CRFPPc::" -#define SWIGVERSION 0x020004 +#define SWIGVERSION 0x030008 #define SWIG_VERSION SWIGVERSION @@ -1673,14 +1677,8 @@ SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) SWIGINTERNINLINE SV * SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) -{ - SV *obj = sv_newmortal(); - if (value) { - sv_setsv(obj, &PL_sv_yes); - } else { - sv_setsv(obj, &PL_sv_no); - } - return obj; +{ + return boolSV(value); } @@ -1694,6 +1692,17 @@ SWIG_From_bool SWIG_PERL_DECL_ARGS_1(bool value) #endif +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + SWIGINTERN int SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val) { @@ -1766,20 +1775,18 @@ SWIG_AsVal_unsigned_SS_long SWIG_PERL_DECL_ARGS_2(SV *obj, unsigned long *val) { if (SvUOK(obj)) { UV v = SvUV(obj); - if (v >= 0 && v <= ULONG_MAX) { + if (UVSIZE <= sizeof(*val) || v <= ULONG_MAX) { if (val) *val = v; return SWIG_OK; - } else { - return SWIG_OverflowError; } - } else if (SvIOK(obj)) { + return SWIG_OverflowError; + } else if (SvIOK(obj)) { IV v = SvIV(obj); - if (v >= 0 && v <= ULONG_MAX) { + if (v >= 0 && (IVSIZE <= sizeof(*val) || v <= ULONG_MAX)) { if (val) *val = v; return SWIG_OK; - } else { - return SWIG_OverflowError; } + return SWIG_OverflowError; } else { int dispatch = 0; const char *nptr = SvPV_nolen(obj); @@ -1829,10 +1836,13 @@ SWIG_AsVal_unsigned_SS_int SWIG_PERL_DECL_ARGS_2(SV * obj, unsigned int *val) SWIGINTERNINLINE SV * SWIG_From_unsigned_SS_long SWIG_PERL_DECL_ARGS_1(unsigned long value) -{ - SV *obj = sv_newmortal(); - sv_setuv(obj, (UV) value); - return obj; +{ + SV *sv; + if (UVSIZE >= sizeof(value) || value <= UV_MAX) + sv = newSVuv(value); + else + sv = newSVpvf("%lu", value); + return sv_2mortal(sv); } @@ -1843,13 +1853,34 @@ SWIG_From_unsigned_SS_int SWIG_PERL_DECL_ARGS_1(unsigned int value) } +/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ +#ifndef SWIG_isfinite +# if defined(isfinite) +# define SWIG_isfinite(X) (isfinite(X)) +# elif defined(_MSC_VER) +# define SWIG_isfinite(X) (_finite(X)) +# elif defined(__sun) && defined(__SVR4) +# include +# define SWIG_isfinite(X) (finite(X)) +# endif +#endif + + +/* Accept infinite as a valid float value unless we are unable to check if a value is finite */ +#ifdef SWIG_isfinite +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) +#else +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) +#endif + + SWIGINTERN int SWIG_AsVal_float SWIG_PERL_DECL_ARGS_2(SV * obj, float *val) { double v; int res = SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj, &v); if (SWIG_IsOK(res)) { - if ((v < -FLT_MAX || v > FLT_MAX)) { + if (SWIG_Float_Overflow_Check(v)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< float >(v); @@ -1861,10 +1892,8 @@ SWIG_AsVal_float SWIG_PERL_DECL_ARGS_2(SV * obj, float *val) SWIGINTERNINLINE SV * SWIG_From_double SWIG_PERL_DECL_ARGS_1(double value) -{ - SV *obj = sv_newmortal(); - sv_setnv(obj, value); - return obj; +{ + return sv_2mortal(newSVnv(value)); } @@ -3161,11 +3190,11 @@ XS(_wrap_Tagger_prob) { dispatch: switch(_index) { case 1: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Tagger_prob__SWIG_2); return; + PUSHMARK(MARK); SWIG_CALLXS(_wrap_Tagger_prob__SWIG_2); return; case 2: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Tagger_prob__SWIG_1); return; + PUSHMARK(MARK); SWIG_CALLXS(_wrap_Tagger_prob__SWIG_1); return; case 3: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Tagger_prob__SWIG_0); return; + PUSHMARK(MARK); SWIG_CALLXS(_wrap_Tagger_prob__SWIG_0); return; } } @@ -3965,9 +3994,9 @@ XS(_wrap_Tagger_parse) { dispatch: switch(_index) { case 1: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Tagger_parse__SWIG_0); return; + PUSHMARK(MARK); SWIG_CALLXS(_wrap_Tagger_parse__SWIG_0); return; case 2: - ++PL_markstack_ptr; SWIG_CALLXS(_wrap_Tagger_parse__SWIG_1); return; + PUSHMARK(MARK); SWIG_CALLXS(_wrap_Tagger_parse__SWIG_1); return; } } @@ -4170,18 +4199,18 @@ static swig_command_info swig_commands[] = { }; /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -4191,17 +4220,17 @@ static swig_command_info swig_commands[] = { * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -4225,9 +4254,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found, init; - - clientdata = clientdata; + int init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { @@ -4246,27 +4273,23 @@ SWIG_InitializeModule(void *clientdata) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; iter=module_head; do { if (iter==&swig_module) { - found=1; - break; + /* Our module is already in the list, so there's nothing more to do. */ + return; } iter=iter->next; } while (iter!= module_head); - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ + /* otherwise we must add our module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ @@ -4407,7 +4430,7 @@ SWIG_PropagateClientData(void) { -#ifdef __cplusplus +#if defined(__cplusplus) && ! defined(XSPROTO) extern "C" #endif @@ -4419,25 +4442,30 @@ XS(SWIG_init) { /* Install commands */ for (i = 0; swig_commands[i].name; i++) { - newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); + /* Casts only needed for Perl < 5.10. */ +#ifdef __cplusplus + newXS(const_cast(swig_commands[i].name), swig_commands[i].wrapper, const_cast(__FILE__)); +#else + newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__); +#endif } /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; - sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); + sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { sv_setiv(sv,(IV) 0); } - swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); + swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); } /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; - sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); + sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); @@ -4446,7 +4474,7 @@ XS(SWIG_init) { sv_setnv(sv, (double) swig_constants[i].dvalue); break; case SWIG_STRING: - sv_setpv(sv, (char *) swig_constants[i].pvalue); + sv_setpv(sv, (const char *) swig_constants[i].pvalue); break; case SWIG_POINTER: SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); @@ -4462,9 +4490,9 @@ XS(SWIG_init) { SWIG_TypeClientData(SWIGTYPE_p_CRFPP__Model, (void*) "CRFPP::Model"); SWIG_TypeClientData(SWIGTYPE_p_CRFPP__Tagger, (void*) "CRFPP::Tagger"); - /*@SWIG:/usr/share/swig2.0/perl5/perltypemaps.swg,65,%set_constant@*/ do { + /*@SWIG:C:\dev\swigwin-3.0.8\Lib\perl5\perltypemaps.swg,65,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "VERSION", TRUE | 0x2 | GV_ADDMULTI); - sv_setsv(sv, SWIG_FromCharPtr("0.58")); + sv_setsv(sv, SWIG_FromCharPtr("0.59")); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; ST(0) = &PL_sv_yes; diff --git a/python/CRFPP.py b/python/CRFPP.py index 8041e6e..01879f4 100644 --- a/python/CRFPP.py +++ b/python/CRFPP.py @@ -1,13 +1,15 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 2.0.4 +# Version 3.0.8 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. + + from sys import version_info -if version_info >= (2,6,0): +if version_info >= (2, 6, 0): def swig_import_helper(): from os.path import dirname import imp @@ -31,39 +33,60 @@ def swig_import_helper(): try: _swig_property = property except NameError: - pass # Python < 2.2 doesn't have 'property'. -def _swig_setattr_nondynamic(self,class_type,name,value,static=1): - if (name == "thisown"): return self.this.own(value) + pass # Python < 2.2 doesn't have 'property'. + + +def _swig_setattr_nondynamic(self, class_type, name, value, static=1): + if (name == "thisown"): + return self.this.own(value) if (name == "this"): if type(value).__name__ == 'SwigPyObject': self.__dict__[name] = value return - method = class_type.__swig_setmethods__.get(name,None) - if method: return method(self,value) + method = class_type.__swig_setmethods__.get(name, None) + if method: + return method(self, value) if (not static): - self.__dict__[name] = value + if _newclass: + object.__setattr__(self, name, value) + else: + self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self) -def _swig_setattr(self,class_type,name,value): - return _swig_setattr_nondynamic(self,class_type,name,value,0) -def _swig_getattr(self,class_type,name): - if (name == "thisown"): return self.this.own() - method = class_type.__swig_getmethods__.get(name,None) - if method: return method(self) - raise AttributeError(name) +def _swig_setattr(self, class_type, name, value): + return _swig_setattr_nondynamic(self, class_type, name, value, 0) + + +def _swig_getattr_nondynamic(self, class_type, name, static=1): + if (name == "thisown"): + return self.this.own() + method = class_type.__swig_getmethods__.get(name, None) + if method: + return method(self) + if (not static): + return object.__getattr__(self, name) + else: + raise AttributeError(name) + +def _swig_getattr(self, class_type, name): + return _swig_getattr_nondynamic(self, class_type, name, 0) + def _swig_repr(self): - try: strthis = "proxy of " + self.this.__repr__() - except: strthis = "" + try: + strthis = "proxy of " + self.this.__repr__() + except Exception: + strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) try: _object = object _newclass = 1 except AttributeError: - class _object : pass + class _object: + pass _newclass = 0 @@ -73,15 +96,24 @@ class Model(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, Model, name) __repr__ = _swig_repr - def getTemplate(self): return _CRFPP.Model_getTemplate(self) - def createTagger(self): return _CRFPP.Model_createTagger(self) - def what(self): return _CRFPP.Model_what(self) + + def getTemplate(self): + return _CRFPP.Model_getTemplate(self) + + def createTagger(self): + return _CRFPP.Model_createTagger(self) + + def what(self): + return _CRFPP.Model_what(self) __swig_destroy__ = _CRFPP.delete_Model - __del__ = lambda self : None; - def __init__(self, *args): - this = _CRFPP.new_Model(*args) - try: self.this.append(this) - except: self.this = this + __del__ = lambda self: None + + def __init__(self, arg): + this = _CRFPP.new_Model(arg) + try: + self.this.append(this) + except Exception: + self.this = this Model_swigregister = _CRFPP.Model_swigregister Model_swigregister(Model) @@ -91,48 +123,119 @@ class Tagger(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, Tagger, name) __repr__ = _swig_repr - def set_model(self, *args): return _CRFPP.Tagger_set_model(self, *args) - def set_vlevel(self, *args): return _CRFPP.Tagger_set_vlevel(self, *args) - def vlevel(self): return _CRFPP.Tagger_vlevel(self) - def set_cost_factor(self, *args): return _CRFPP.Tagger_set_cost_factor(self, *args) - def cost_factor(self): return _CRFPP.Tagger_cost_factor(self) - def set_nbest(self, *args): return _CRFPP.Tagger_set_nbest(self, *args) - def nbest(self): return _CRFPP.Tagger_nbest(self) - def add(self, *args): return _CRFPP.Tagger_add(self, *args) - def size(self): return _CRFPP.Tagger_size(self) - def xsize(self): return _CRFPP.Tagger_xsize(self) - def dsize(self): return _CRFPP.Tagger_dsize(self) - def result(self, *args): return _CRFPP.Tagger_result(self, *args) - def answer(self, *args): return _CRFPP.Tagger_answer(self, *args) - def y(self, *args): return _CRFPP.Tagger_y(self, *args) - def y2(self, *args): return _CRFPP.Tagger_y2(self, *args) - def yname(self, *args): return _CRFPP.Tagger_yname(self, *args) - def x(self, *args): return _CRFPP.Tagger_x(self, *args) - def ysize(self): return _CRFPP.Tagger_ysize(self) - def prob(self, *args): return _CRFPP.Tagger_prob(self, *args) - def set_penalty(self, *args): return _CRFPP.Tagger_set_penalty(self, *args) - def penalty(self, *args): return _CRFPP.Tagger_penalty(self, *args) - def alpha(self, *args): return _CRFPP.Tagger_alpha(self, *args) - def beta(self, *args): return _CRFPP.Tagger_beta(self, *args) - def emission_cost(self, *args): return _CRFPP.Tagger_emission_cost(self, *args) - def next_transition_cost(self, *args): return _CRFPP.Tagger_next_transition_cost(self, *args) - def prev_transition_cost(self, *args): return _CRFPP.Tagger_prev_transition_cost(self, *args) - def best_cost(self, *args): return _CRFPP.Tagger_best_cost(self, *args) - def Z(self): return _CRFPP.Tagger_Z(self) - def empty(self): return _CRFPP.Tagger_empty(self) - def clear(self): return _CRFPP.Tagger_clear(self) - def next(self): return _CRFPP.Tagger_next(self) - def parse(self, *args): return _CRFPP.Tagger_parse(self, *args) - def what(self): return _CRFPP.Tagger_what(self) + + def set_model(self, model): + return _CRFPP.Tagger_set_model(self, model) + + def set_vlevel(self, vlevel): + return _CRFPP.Tagger_set_vlevel(self, vlevel) + + def vlevel(self): + return _CRFPP.Tagger_vlevel(self) + + def set_cost_factor(self, cost_factor): + return _CRFPP.Tagger_set_cost_factor(self, cost_factor) + + def cost_factor(self): + return _CRFPP.Tagger_cost_factor(self) + + def set_nbest(self, nbest): + return _CRFPP.Tagger_set_nbest(self, nbest) + + def nbest(self): + return _CRFPP.Tagger_nbest(self) + + def add(self, str): + return _CRFPP.Tagger_add(self, str) + + def size(self): + return _CRFPP.Tagger_size(self) + + def xsize(self): + return _CRFPP.Tagger_xsize(self) + + def dsize(self): + return _CRFPP.Tagger_dsize(self) + + def result(self, i): + return _CRFPP.Tagger_result(self, i) + + def answer(self, i): + return _CRFPP.Tagger_answer(self, i) + + def y(self, i): + return _CRFPP.Tagger_y(self, i) + + def y2(self, i): + return _CRFPP.Tagger_y2(self, i) + + def yname(self, i): + return _CRFPP.Tagger_yname(self, i) + + def x(self, i, j): + return _CRFPP.Tagger_x(self, i, j) + + def ysize(self): + return _CRFPP.Tagger_ysize(self) + + def prob(self, *args): + return _CRFPP.Tagger_prob(self, *args) + + def set_penalty(self, i, j, penalty): + return _CRFPP.Tagger_set_penalty(self, i, j, penalty) + + def penalty(self, i, j): + return _CRFPP.Tagger_penalty(self, i, j) + + def alpha(self, i, j): + return _CRFPP.Tagger_alpha(self, i, j) + + def beta(self, i, j): + return _CRFPP.Tagger_beta(self, i, j) + + def emission_cost(self, i, j): + return _CRFPP.Tagger_emission_cost(self, i, j) + + def next_transition_cost(self, i, j, k): + return _CRFPP.Tagger_next_transition_cost(self, i, j, k) + + def prev_transition_cost(self, i, j, k): + return _CRFPP.Tagger_prev_transition_cost(self, i, j, k) + + def best_cost(self, i, j): + return _CRFPP.Tagger_best_cost(self, i, j) + + def Z(self): + return _CRFPP.Tagger_Z(self) + + def empty(self): + return _CRFPP.Tagger_empty(self) + + def clear(self): + return _CRFPP.Tagger_clear(self) + + def next(self): + return _CRFPP.Tagger_next(self) + + def parse(self, *args): + return _CRFPP.Tagger_parse(self, *args) + + def what(self): + return _CRFPP.Tagger_what(self) __swig_destroy__ = _CRFPP.delete_Tagger - __del__ = lambda self : None; - def __init__(self, *args): - this = _CRFPP.new_Tagger(*args) - try: self.this.append(this) - except: self.this = this + __del__ = lambda self: None + + def __init__(self, arg): + this = _CRFPP.new_Tagger(arg) + try: + self.this.append(this) + except Exception: + self.this = this Tagger_swigregister = _CRFPP.Tagger_swigregister Tagger_swigregister(Tagger) + +_CRFPP.VERSION_swigconstant(_CRFPP) VERSION = _CRFPP.VERSION # This file is compatible with both classic and new-style classes. diff --git a/python/CRFPP_wrap.cxx b/python/CRFPP_wrap.cxx index 2f19bb0..6e2d3de 100644 --- a/python/CRFPP_wrap.cxx +++ b/python/CRFPP_wrap.cxx @@ -1,14 +1,18 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 - * - * This file is not intended to be easily readable and contains a number of + * Version 3.0.8 + * + * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGPYTHON #define SWIGPYTHON +#endif + #define SWIG_PYTHON_DIRECTOR_NO_VTABLE @@ -66,28 +70,28 @@ template T SwigValueInit() { #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -130,7 +134,7 @@ template T SwigValueInit() { # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -143,10 +147,29 @@ template T SwigValueInit() { # define _SCL_SECURE_NO_DEPRECATE #endif +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif -/* Python.h has to appear first */ -#include +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG +#else +# include +#endif /* ----------------------------------------------------------------------------- * swigrun.swg @@ -172,7 +195,7 @@ template T SwigValueInit() { You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -198,16 +221,16 @@ template T SwigValueInit() { #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -240,23 +263,23 @@ template T SwigValueInit() { } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -270,17 +293,17 @@ template T SwigValueInit() { int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -311,14 +334,14 @@ template T SwigValueInit() { # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif @@ -362,7 +385,7 @@ typedef struct swig_module_info { void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -382,18 +405,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1, /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -401,24 +424,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ @@ -446,7 +458,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -481,7 +493,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -525,7 +537,7 @@ SWIG_TypePrettyName(const swig_type_info *type) { return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -533,14 +545,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -549,31 +561,31 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; + size_t l = 0; + size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { + int compare = strcmp(name, iname); + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -598,14 +610,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -616,7 +628,7 @@ SWIG_TypeQueryModule(swig_module_info *start, of the str field (the human readable name) */ swig_module_info *iter = start; do { - register size_t i = 0; + size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; @@ -624,56 +636,56 @@ SWIG_TypeQueryModule(swig_module_info *start, iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register unsigned char uu = *u; + unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; + char d = *(c++); + unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); - else + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); - else + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * @@ -733,18 +745,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #endif /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 @@ -756,6 +768,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) #define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) #define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) @@ -925,6 +938,10 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) } #endif +#if PY_VERSION_HEX < 0x02050000 +#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) +#endif + #if PY_VERSION_HEX < 0x02040000 #define Py_VISIT(op) \ do { \ @@ -1196,7 +1213,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), /* Runtime API */ -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) @@ -1222,7 +1239,7 @@ SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { SWIGINTERN void SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); + PyErr_SetString(errtype, msg); SWIG_PYTHON_THREAD_END_BLOCK; } @@ -1241,7 +1258,11 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); @@ -1251,7 +1272,11 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { +#if PY_VERSION_HEX < 0x02030000 PyDict_SetItemString(d, (char *)name, obj); +#else + PyDict_SetItemString(d, name, obj); +#endif Py_DECREF(obj); } @@ -1304,7 +1329,7 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { /* Unpack the argument tuple */ -SWIGINTERN int +SWIGINTERN Py_ssize_t SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) { if (!args) { @@ -1318,7 +1343,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } if (!PyTuple_Check(args)) { if (min <= 1 && max >= 1) { - register int i; + Py_ssize_t i; objs[0] = args; for (i = 1; i < max; ++i) { objs[i] = 0; @@ -1328,7 +1353,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); return 0; } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); + Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", name, (min == max ? "" : "at least "), (int)min, (int)l); @@ -1338,7 +1363,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { - register int i; + Py_ssize_t i; for (i = 0; i < l; ++i) { objs[i] = PyTuple_GET_ITEM(args, i); } @@ -1524,6 +1549,23 @@ typedef struct { #endif } SwigPyObject; + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + SWIGRUNTIME PyObject * SwigPyObject_long(SwigPyObject *v) { @@ -1572,7 +1614,7 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", name, (void *)v); + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { # ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); @@ -1591,34 +1633,6 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) return repr; } -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char *str; -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; -} - SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { @@ -1690,16 +1704,32 @@ SwigPyObject_dealloc(PyObject *v) if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *val = NULL, *type = NULL, *tb = NULL; + PyErr_Fetch(&val, &type, &tb); + if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(val, type, tb); + Py_XDECREF(res); } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) @@ -1723,6 +1753,7 @@ SwigPyObject_append(PyObject* v, PyObject* next) next = tmp; #endif if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; } sobj->next = next; @@ -1776,8 +1807,10 @@ SwigPyObject_own(PyObject *v, PyObject *args) PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else +#elif (PY_VERSION_HEX < 0x02050000) if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#else + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) #endif { return NULL; @@ -1809,7 +1842,7 @@ SwigPyObject_own(PyObject *v, PyObject *args) static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, @@ -1820,7 +1853,7 @@ swigobject_methods[] = { static PyMethodDef swigobject_methods[] = { {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, @@ -1876,7 +1909,9 @@ SwigPyObject_TypeOnce(void) { (unaryfunc)SwigPyObject_oct, /*nb_oct*/ (unaryfunc)SwigPyObject_hex, /*nb_hex*/ #endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ @@ -1902,7 +1937,7 @@ SwigPyObject_TypeOnce(void) { sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - (printfunc)SwigPyObject_print, /* tp_print */ + 0, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ #else @@ -1920,7 +1955,7 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ + 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -1956,10 +1991,19 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ +#endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; swigpyobject_type = tmp; @@ -2135,10 +2179,19 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ +#endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; swigpypacked_type = tmp; @@ -2297,10 +2350,11 @@ SWIGRUNTIME int SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { int res; SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; if (!obj) return SWIG_ERROR; - if (obj == Py_None) { + if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; return SWIG_OK; @@ -2349,7 +2403,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } res = SWIG_OK; } else { - if (flags & SWIG_POINTER_IMPLICIT_CONV) { + if (implicit_conv) { SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; @@ -2384,6 +2438,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } return res; } @@ -2471,24 +2532,30 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } #else PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } #endif } return inst; #else #if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; + PyObject *inst = 0; PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } return (PyObject *) inst; #else PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); @@ -2539,7 +2606,7 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) SWIGINTERN PyObject * SWIG_Python_InitShadowInstance(PyObject *args) { PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { return NULL; } else { SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); @@ -2575,18 +2642,21 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif } } else { newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif } if (newobj) { newobj->ptr = ptr; newobj->ty = type; newobj->own = own; newobj->next = 0; -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif return (PyObject*) newobj; } return SWIG_Py_Void(); @@ -2595,12 +2665,10 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f assert(!(flags & SWIG_BUILTIN_TP_INIT)); robj = SwigPyObject_New(ptr, type, own); - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } + Py_DECREF(robj); + robj = inst; } return robj; } @@ -2621,7 +2689,7 @@ void *SWIG_ReturnGlobalTypeList(void *); #endif SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { static void *type_pointer = (void *)0; /* first check if module already created */ if (!type_pointer) { @@ -2651,13 +2719,11 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); + PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } @@ -2747,7 +2813,7 @@ SWIG_Python_TypeQuery(const char *type) descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); #endif } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); + swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { #ifdef SWIGPY_USE_CAPSULE @@ -2815,7 +2881,7 @@ SwigPyObject_GetDesc(PyObject *self) { SwigPyObject *v = (SwigPyObject *)self; swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; + return ty ? ty->str : ""; } SWIGRUNTIME void @@ -2872,23 +2938,24 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(arg return result; } +#ifdef SWIGPYTHON_BUILTIN SWIGRUNTIME int SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { PyTypeObject *tp = obj->ob_type; PyObject *descr; PyObject *encoded_name; descrsetfunc f; - int res; + int res = -1; -#ifdef Py_USING_UNICODE +# ifdef Py_USING_UNICODE if (PyString_Check(name)) { name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); if (!name) return -1; } else if (!PyUnicode_Check(name)) -#else +# else if (!PyString_Check(name)) -#endif +# endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); return -1; @@ -2901,7 +2968,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { goto done; } - res = -1; descr = _PyType_Lookup(tp, name); f = NULL; if (descr != NULL) @@ -2923,6 +2989,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_DECREF(name); return res; } +#endif #ifdef __cplusplus @@ -2970,7 +3037,7 @@ static swig_module_info swig_module = {swig_types, 3, 0, 0, 0, 0}; #endif #define SWIG_name "_CRFPP" -#define SWIGVERSION 0x020004 +#define SWIGVERSION 0x030008 #define SWIG_VERSION SWIGVERSION @@ -2993,27 +3060,35 @@ namespace swig { SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XINCREF(_obj); + SWIG_PYTHON_THREAD_END_BLOCK; } SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XINCREF(_obj); + SWIG_PYTHON_THREAD_END_BLOCK; } } SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XINCREF(item._obj); Py_XDECREF(_obj); _obj = item._obj; + SWIG_PYTHON_THREAD_END_BLOCK; return *this; } ~SwigPtr_PyObject() { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; Py_XDECREF(_obj); + SWIG_PYTHON_THREAD_END_BLOCK; } operator PyObject *() const @@ -3094,9 +3169,13 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { #if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); +#if PY_VERSION_HEX >= 0x03010000 + return PyUnicode_DecodeUTF8(carray, static_cast< Py_ssize_t >(size), "surrogateescape"); +#else + return PyUnicode_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); +#endif #else - return PyString_FromStringAndSize(carray, static_cast< int >(size)); + return PyString_FromStringAndSize(carray, static_cast< Py_ssize_t >(size)); #endif } } else { @@ -3152,18 +3231,17 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #else if (*alloc == SWIG_NEWOBJ) #endif - { - *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); - *alloc = SWIG_NEWOBJ; - } - else { + { + *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); + *alloc = SWIG_NEWOBJ; + } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } } else { - #if PY_VERSION_HEX>=0x03000000 - assert(0); /* Should never reach here in Python 3 */ - #endif + #if PY_VERSION_HEX>=0x03000000 + assert(0); /* Should never reach here in Python 3 */ + #endif *cptr = SWIG_Python_str_AsChar(obj); } } @@ -3173,6 +3251,30 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #endif return SWIG_OK; } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1))); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { void* vptr = 0; @@ -3215,9 +3317,11 @@ SWIG_AsVal_double (PyObject *obj, double *val) if (PyFloat_Check(obj)) { if (val) *val = PyFloat_AsDouble(obj); return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 } else if (PyInt_Check(obj)) { if (val) *val = PyInt_AsLong(obj); return SWIG_OK; +#endif } else if (PyLong_Check(obj)) { double v = PyLong_AsDouble(obj); if (!PyErr_Occurred()) { @@ -3291,6 +3395,7 @@ SWIG_CanCastAsInteger(double *d, double min, double max) { SWIGINTERN int SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) { +#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) { long v = PyInt_AsLong(obj); if (v >= 0) { @@ -3299,13 +3404,16 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) } else { return SWIG_OverflowError; } - } else if (PyLong_Check(obj)) { + } else +#endif + if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return SWIG_OK; } else { PyErr_Clear(); + return SWIG_OverflowError; } } #ifdef SWIG_PYTHON_CAST_MODE @@ -3348,22 +3456,32 @@ SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) } - #define SWIG_From_long PyInt_FromLong - - -SWIGINTERNINLINE PyObject* -SWIG_From_unsigned_SS_long (unsigned long value) +SWIGINTERNINLINE PyObject* + SWIG_From_unsigned_SS_int (unsigned int value) { - return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value)); + return PyInt_FromSize_t((size_t) value); } -SWIGINTERNINLINE PyObject * -SWIG_From_unsigned_SS_int (unsigned int value) -{ - return SWIG_From_unsigned_SS_long (value); -} +/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ +#ifndef SWIG_isfinite +# if defined(isfinite) +# define SWIG_isfinite(X) (isfinite(X)) +# elif defined(_MSC_VER) +# define SWIG_isfinite(X) (_finite(X)) +# elif defined(__sun) && defined(__SVR4) +# include +# define SWIG_isfinite(X) (finite(X)) +# endif +#endif + + +/* Accept infinite as a valid float value unless we are unable to check if a value is finite */ +#ifdef SWIG_isfinite +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) +#else +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) +#endif SWIGINTERN int @@ -3372,7 +3490,7 @@ SWIG_AsVal_float (PyObject * obj, float *val) double v; int res = SWIG_AsVal_double (obj, &v); if (SWIG_IsOK(res)) { - if ((v < -FLT_MAX || v > FLT_MAX)) { + if (SWIG_Float_Overflow_Check(v)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< float >(v); @@ -3402,6 +3520,17 @@ SWIG_AsVal_size_t (PyObject * obj, size_t *val) } + #define SWIG_From_long PyLong_FromLong + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyLong_FromLong(static_cast< long >(value)); +} + + SWIGINTERNINLINE PyObject * SWIG_From_size_t (size_t value) { @@ -4391,12 +4520,14 @@ SWIGINTERN PyObject *_wrap_Tagger_prob__SWIG_2(PyObject *SWIGUNUSEDPARM(self), P SWIGINTERN PyObject *_wrap_Tagger_prob(PyObject *self, PyObject *args) { - int argc; - PyObject *argv[4]; - int ii; + Py_ssize_t argc; + PyObject *argv[4] = { + 0 + }; + Py_ssize_t ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? (int)PyObject_Length(args) : 0; + argc = args ? PyObject_Length(args) : 0; for (ii = 0; (ii < 3) && (ii < argc); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -5087,12 +5218,14 @@ SWIGINTERN PyObject *_wrap_Tagger_parse__SWIG_1(PyObject *SWIGUNUSEDPARM(self), SWIGINTERN PyObject *_wrap_Tagger_parse(PyObject *self, PyObject *args) { - int argc; - PyObject *argv[3]; - int ii; + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + Py_ssize_t ii; if (!PyTuple_Check(args)) SWIG_fail; - argc = args ? (int)PyObject_Length(args) : 0; + argc = args ? PyObject_Length(args) : 0; for (ii = 0; (ii < 2) && (ii < argc); ii++) { argv[ii] = PyTuple_GET_ITEM(args,ii); } @@ -5233,6 +5366,17 @@ SWIGINTERN PyObject *Tagger_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObjec return SWIG_Py_Void(); } +SWIGINTERN PyObject *VERSION_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *module; + PyObject *d; + if (!PyArg_ParseTuple(args,(char*)"O:swigconstant", &module)) return NULL; + d = PyModule_GetDict(module); + if (!d) return NULL; + SWIG_Python_SetConstant(d, "VERSION",SWIG_FromCharPtr("0.59")); + return SWIG_Py_Void(); +} + + static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, { (char *)"Model_getTemplate", _wrap_Model_getTemplate, METH_VARARGS, NULL}, @@ -5277,6 +5421,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"delete_Tagger", _wrap_delete_Tagger, METH_VARARGS, NULL}, { (char *)"new_Tagger", _wrap_new_Tagger, METH_VARARGS, NULL}, { (char *)"Tagger_swigregister", Tagger_swigregister, METH_VARARGS, NULL}, + { (char *)"VERSION_swigconstant", VERSION_swigconstant, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; @@ -5314,18 +5459,18 @@ static swig_const_info swig_const_table[] = { #endif /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -5335,17 +5480,17 @@ static swig_const_info swig_const_table[] = { * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -5369,9 +5514,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found, init; - - clientdata = clientdata; + int init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { @@ -5390,27 +5533,23 @@ SWIG_InitializeModule(void *clientdata) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; iter=module_head; do { if (iter==&swig_module) { - found=1; - break; + /* Our module is already in the list, so there's nothing more to do. */ + return; } iter=iter->next; } while (iter!= module_head); - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ + /* otherwise we must add our module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ @@ -5657,7 +5796,7 @@ extern "C" { var = var->next; } if (res == NULL && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } @@ -5674,7 +5813,7 @@ extern "C" { var = var->next; } if (res == 1 && !PyErr_Occurred()) { - PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); } return res; } @@ -5724,10 +5863,19 @@ extern "C" { 0, /* tp_del */ #endif #if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version */ + 0, /* tp_version_tag */ +#endif +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ #endif #ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ +#if PY_VERSION_HEX >= 0x02050000 + 0, /* tp_prev */ +#endif + 0 /* tp_next */ #endif }; varlink_type = tmp; @@ -5816,7 +5964,9 @@ extern "C" { size_t i; for (i = 0; methods[i].ml_name; ++i) { const char *c = methods[i].ml_doc; - if (c && (c = strstr(c, "swig_ptr: "))) { + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { int j; swig_const_info *ci = 0; const char *name = c + 10; @@ -5918,6 +6068,7 @@ SWIG_init(void) { PyObject *public_interface, *public_symbol; PyObject *this_descr; PyObject *thisown_descr; + PyObject *self = 0; int i; (void)builtin_pytype; @@ -5925,6 +6076,7 @@ SWIG_init(void) { (void)builtin_basetype; (void)tuple; (void)static_getset; + (void)self; /* metatype is used to implement static member variables. */ metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); @@ -5944,7 +6096,9 @@ SWIG_init(void) { #else m = Py_InitModule((char *) SWIG_name, SwigMethods); #endif + md = d = PyModule_GetDict(m); + (void)md; SWIG_InitializeModule(0); @@ -5986,7 +6140,6 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "VERSION",SWIG_FromCharPtr("0.58")); #if PY_VERSION_HEX >= 0x03000000 return m; #else diff --git a/ruby/CRFPP_wrap.cpp b/ruby/CRFPP_wrap.cpp index 63b16a9..203aa8e 100644 --- a/ruby/CRFPP_wrap.cpp +++ b/ruby/CRFPP_wrap.cpp @@ -1,14 +1,18 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 - * - * This file is not intended to be easily readable and contains a number of + * Version 3.0.8 + * + * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. * ----------------------------------------------------------------------------- */ + +#ifndef SWIGRUBY #define SWIGRUBY +#endif + #ifdef __cplusplus @@ -65,28 +69,28 @@ template T SwigValueInit() { #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -129,7 +133,7 @@ template T SwigValueInit() { # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -142,6 +146,19 @@ template T SwigValueInit() { # define _SCL_SECURE_NO_DEPRECATE #endif +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif /* ----------------------------------------------------------------------------- * This section contains generic SWIG labels for method/variable @@ -174,28 +191,28 @@ template T SwigValueInit() { #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -238,7 +255,7 @@ template T SwigValueInit() { # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -251,6 +268,19 @@ template T SwigValueInit() { # define _SCL_SECURE_NO_DEPRECATE #endif +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif /* ----------------------------------------------------------------------------- * swigrun.swg @@ -276,7 +306,7 @@ template T SwigValueInit() { You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -302,16 +332,16 @@ template T SwigValueInit() { #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -344,23 +374,23 @@ template T SwigValueInit() { } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -374,17 +404,17 @@ template T SwigValueInit() { int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -415,14 +445,14 @@ template T SwigValueInit() { # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif @@ -466,7 +496,7 @@ typedef struct swig_module_info { void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -486,18 +516,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1, /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -505,24 +535,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) { /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ @@ -550,7 +569,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) { return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -585,7 +604,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -629,7 +648,7 @@ SWIG_TypePrettyName(const swig_type_info *type) { return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -637,14 +656,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -653,31 +672,31 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; + size_t l = 0; + size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { + int compare = strcmp(name, iname); + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -702,14 +721,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -720,7 +739,7 @@ SWIG_TypeQueryModule(swig_module_info *start, of the str field (the human readable name) */ swig_module_info *iter = start; do { - register size_t i = 0; + size_t i = 0; for (; i < iter->size; ++i) { if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) return iter->types[i]; @@ -728,56 +747,56 @@ SWIG_TypeQueryModule(swig_module_info *start, iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * SWIG_PackData(char *c, void *ptr, size_t sz) { static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register unsigned char uu = *u; + unsigned char uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; + char d = *(c++); + unsigned char uu; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); - else + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); - else + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * @@ -837,18 +856,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #endif /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 @@ -1179,6 +1198,11 @@ void Ruby_Format_OverloadedError( extern "C" { #endif +#if !defined(ST_DATA_T_DEFINED) +/* Needs to be explicitly included for Ruby 1.8 and earlier */ +#include +#endif + /* Ruby 1.8 actually assumes the first case. */ #if SIZEOF_VOIDP == SIZEOF_LONG # define SWIG2NUM(v) LONG2NUM((unsigned long)v) @@ -1190,19 +1214,19 @@ extern "C" { # error sizeof(void*) is not the same as long or long long #endif - -/* Global Ruby hash table to store Trackings from C/C++ +/* Global hash table to store Trackings from C/C++ structs to Ruby Objects. */ -static VALUE swig_ruby_trackings = Qnil; +static st_table* swig_ruby_trackings = NULL; + +static VALUE swig_ruby_trackings_count(ANYARGS) { + return SWIG2NUM(swig_ruby_trackings->num_entries); +} -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; -/* Setup a Ruby hash table to store Trackings */ +/* Setup a hash table to store Trackings */ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ + /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ /* Try to see if some other .so has already created a @@ -1211,88 +1235,46 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { This is done to allow multiple DSOs to share the same tracking table. */ - ID trackings_id = rb_intern( "@__trackings__" ); + VALUE trackings_value = Qnil; + /* change the variable name so that we can mix modules + compiled with older SWIG's - this used to be called "@__trackings__" */ + ID trackings_id = rb_intern( "@__safetrackings__" ); VALUE verbose = rb_gv_get("VERBOSE"); rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); + trackings_value = rb_ivar_get( _mSWIG, trackings_id ); rb_gv_set("VERBOSE", verbose); - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ + /* The trick here is that we have to store the hash table + pointer in a Ruby variable. We do not want Ruby's GC to + treat this pointer as a Ruby object, so we convert it to + a Ruby numeric value. */ + if (trackings_value == Qnil) { + /* No, it hasn't. Create one ourselves */ + swig_ruby_trackings = st_init_numtable(); + rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); + } else { + swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); + } - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL); } /* Add a Tracking from a C/C++ struct to a Ruby object */ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); + st_insert(swig_ruby_trackings, (st_data_t)ptr, object); } /* Get the Ruby object that owns the specified C/C++ struct */ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ + VALUE value; + + if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { + return value; + } else { return Qnil; } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } } /* Remove a Tracking from a C/C++ struct to a Ruby object. It @@ -1300,12 +1282,8 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { since the same memory address may be reused later to create a new object. */ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); + /* Delete the object from the hash table */ + st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); } /* This is a helper method that unlinks a Ruby object from its @@ -1315,10 +1293,25 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { + if (TYPE(object) != T_DATA) + abort(); DATA_PTR(object) = 0; } } +/* This is a helper method that iterates over all the trackings + passing the C++ object pointer and its related Ruby object + to the passed callback function. */ + +/* Proxy method to abstract the internal trackings datatype */ +static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { + (*meth)(ptr, obj); + return ST_CONTINUE; +} + +SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { + st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth); +} #ifdef __cplusplus } @@ -1377,7 +1370,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype +#define swig_owntype swig_ruby_owntype /* for raw packed data */ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) @@ -1398,7 +1391,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { /* Runtime API */ -#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() +#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) @@ -1514,14 +1507,13 @@ SWIG_Ruby_InitRuntime(void) SWIGRUNTIME void SWIG_Ruby_define_class(swig_type_info *type) { - VALUE klass; char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); sprintf(klass_name, "TYPE%s", type->name); if (NIL_P(_cSWIG_Pointer)) { _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); } - klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); + rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); free((void *) klass_name); } @@ -1552,7 +1544,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) downcast methods. */ if (obj != Qnil) { VALUE value = rb_iv_get(obj, "@__swigtype__"); - char* type_name = RSTRING_PTR(value); + const char* type_name = RSTRING_PTR(value); if (strcmp(type->name, type_name) == 0) { return obj; @@ -1602,22 +1594,24 @@ SWIG_Ruby_MangleStr(VALUE obj) } /* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); +typedef struct { + void (*datafree)(void *); + int own; +} swig_ruby_owntype; -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { +SWIGRUNTIME swig_ruby_owntype +SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { + swig_ruby_owntype oldown = {0, 0}; if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; + oldown.datafree = RDATA(obj)->dfree; + RDATA(obj)->dfree = own.datafree; } + return oldown; } /* Convert a pointer value */ SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) +SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own) { char *c; swig_cast_info *tc; @@ -1625,7 +1619,8 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Grab the pointer */ if (NIL_P(obj)) { - *ptr = 0; + if (ptr) + *ptr = 0; return SWIG_OK; } else { if (TYPE(obj) != T_DATA) { @@ -1634,7 +1629,10 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, Data_Get_Struct(obj, void, vptr); } - if (own) *own = RDATA(obj)->dfree; + if (own) { + own->datafree = RDATA(obj)->dfree; + own->own = 0; + } /* Check to see if the input object is giving up ownership of the underlying C struct or C++ object. If so then we @@ -1663,16 +1661,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, /* Do type-checking if type info was provided */ if (ty) { - if (ty->clientdata) { - if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { - if (vptr == 0) { - /* The object has already been deleted */ - return SWIG_ObjectPreviouslyDeletedError; - } - *ptr = vptr; - return SWIG_OK; - } - } if ((c = SWIG_MangleStr(obj)) == NULL) { return SWIG_ERROR; } @@ -1680,12 +1668,27 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (!tc) { return SWIG_ERROR; } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (vptr == 0) { + /* The object has already been deleted */ + return SWIG_ObjectPreviouslyDeletedError; + } + if (ptr) { + if (tc->type == ty) { + *ptr = vptr; + } else { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, vptr, &newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + own->own = own->own | SWIG_CAST_NEW_MEMORY; + } + } + } } } else { - *ptr = vptr; + if (ptr) + *ptr = vptr; } return SWIG_OK; @@ -1734,7 +1737,7 @@ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { } SWIGRUNTIME swig_module_info * -SWIG_Ruby_GetModule(void) +SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata)) { VALUE pointer; swig_module_info *ret = 0; @@ -1774,7 +1777,7 @@ SWIG_Ruby_SetModule(swig_module_info *pointer) SWIGINTERN int SWIG_Ruby_isCallable( VALUE proc ) { - if ( rb_respond_to( proc, swig_call_id ) == Qtrue ) + if ( rb_respond_to( proc, swig_call_id ) ) return 1; return 0; } @@ -1787,7 +1790,7 @@ int SWIG_Ruby_isCallable( VALUE proc ) SWIGINTERN int SWIG_Ruby_arity( VALUE proc, int minimal ) { - if ( rb_respond_to( proc, swig_arity_id ) == Qtrue ) + if ( rb_respond_to( proc, swig_arity_id ) ) { VALUE num = rb_funcall( proc, swig_arity_id, 0 ); int arity = NUM2INT(num); @@ -1835,7 +1838,7 @@ static VALUE mCRFPP; #define SWIG_RUBY_THREAD_END_BLOCK -#define SWIGVERSION 0x020004 +#define SWIGVERSION 0x030008 #define SWIG_VERSION SWIGVERSION @@ -1915,11 +1918,7 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) { if (TYPE(obj) == T_STRING) { - #if defined(StringValuePtr) char *cstr = StringValuePtr(obj); - #else - char *cstr = STR2CSTR(obj); - #endif size_t size = RSTRING_LEN(obj) + 1; if (cptr) { if (alloc) { @@ -1976,7 +1975,7 @@ SWIG_ruby_failed(void) } -/*@SWIG:/usr/share/swig2.0/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +/*@SWIG:C:\dev\swigwin-3.0.8\Lib\ruby\rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args) { VALUE obj = args[0]; @@ -2041,13 +2040,37 @@ SWIG_From_unsigned_SS_int (unsigned int value) #include -/*@SWIG:/usr/share/swig2.0/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/ +#include + + +/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ +#ifndef SWIG_isfinite +# if defined(isfinite) +# define SWIG_isfinite(X) (isfinite(X)) +# elif defined(_MSC_VER) +# define SWIG_isfinite(X) (_finite(X)) +# elif defined(__sun) && defined(__SVR4) +# include +# define SWIG_isfinite(X) (finite(X)) +# endif +#endif + + +/* Accept infinite as a valid float value unless we are unable to check if a value is finite */ +#ifdef SWIG_isfinite +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X)) +#else +# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX)) +#endif + + +/*@SWIG:C:\dev\swigwin-3.0.8\Lib\ruby\rubyprimtypes.swg,19,%ruby_aux_method@*/ SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) { VALUE obj = args[0]; VALUE type = TYPE(obj); double *res = (double *)(args[1]); - *res = NUM2DBL(obj); + *res = NUM2DBL(obj); (void)type; return obj; } /*@SWIG@*/ @@ -2076,7 +2099,7 @@ SWIG_AsVal_float (VALUE obj, float *val) double v; int res = SWIG_AsVal_double (obj, &v); if (SWIG_IsOK(res)) { - if ((v < -FLT_MAX || v > FLT_MAX)) { + if (SWIG_Float_Overflow_Check(v)) { return SWIG_OverflowError; } else { if (val) *val = static_cast< float >(v); @@ -2112,7 +2135,7 @@ SWIG_From_size_t (size_t value) return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value)); } -swig_class SwigClassModel; +static swig_class SwigClassModel; SWIGINTERN VALUE _wrap_Model_getTemplate(int argc, VALUE *argv, VALUE self) { @@ -2217,7 +2240,8 @@ _wrap_Model_what(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_CRFPP_Model(CRFPP::Model *arg1) { +free_CRFPP_Model(void *self) { + CRFPP::Model *arg1 = (CRFPP::Model *)self; delete arg1; } @@ -2251,7 +2275,7 @@ _wrap_new_Model(int argc, VALUE *argv, VALUE self) { } res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","CRFPP::Model", 1, argv[0] )); + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","Model", 1, argv[0] )); } arg1 = reinterpret_cast< char * >(buf1); { @@ -2274,7 +2298,7 @@ _wrap_new_Model(int argc, VALUE *argv, VALUE self) { } -swig_class SwigClassTagger; +static swig_class SwigClassTagger; SWIGINTERN VALUE _wrap_Tagger_set_model(int argc, VALUE *argv, VALUE self) { @@ -3906,7 +3930,8 @@ _wrap_Tagger_what(int argc, VALUE *argv, VALUE self) { SWIGINTERN void -free_CRFPP_Tagger(CRFPP::Tagger *arg1) { +free_CRFPP_Tagger(void *self) { + CRFPP::Tagger *arg1 = (CRFPP::Tagger *)self; delete arg1; } @@ -3940,7 +3965,7 @@ _wrap_new_Tagger(int argc, VALUE *argv, VALUE self) { } res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","CRFPP::Tagger", 1, argv[0] )); + SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","Tagger", 1, argv[0] )); } arg1 = reinterpret_cast< char * >(buf1); { @@ -3991,18 +4016,18 @@ static swig_cast_info *swig_cast_initial[] = { /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned statically to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -4012,17 +4037,17 @@ static swig_cast_info *swig_cast_initial[] = { * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -4046,9 +4071,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found, init; - - clientdata = clientdata; + int init; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { @@ -4067,27 +4090,23 @@ SWIG_InitializeModule(void *clientdata) { /* This is the first module loaded for this interpreter */ /* so set the swig module into the interpreter */ SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; } else { /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; iter=module_head; do { if (iter==&swig_module) { - found=1; - break; + /* Our module is already in the list, so there's nothing more to do. */ + return; } iter=iter->next; } while (iter!= module_head); - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ + /* otherwise we must add our module into the list */ swig_module.next = module_head->next; module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ @@ -4101,7 +4120,7 @@ SWIG_InitializeModule(void *clientdata) { swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; - + #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif @@ -4128,7 +4147,7 @@ SWIG_InitializeModule(void *clientdata) { /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { - + /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG @@ -4296,6 +4315,6 @@ SWIGEXPORT void Init_CRFPP(void) { SwigClassTagger.mark = 0; SwigClassTagger.destroy = (void (*)(void *)) free_CRFPP_Tagger; SwigClassTagger.trackObjects = 0; - rb_define_const(mCRFPP, "VERSION", SWIG_FromCharPtr("0.58")); + rb_define_const(mCRFPP, "VERSION", SWIG_FromCharPtr("0.59")); }