/* ----------------------------------------------------------------------------
 * 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 
 * 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. 
 * ----------------------------------------------------------------------------- */

#define SWIGR


#ifdef __cplusplus
/* SwigValueWrapper is described in swig.swg */
template<typename T> class SwigValueWrapper {
  struct SwigMovePointer {
    T *ptr;
    SwigMovePointer(T *p) : ptr(p) { }
    ~SwigMovePointer() { delete ptr; }
    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
  } pointer;
  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
public:
  SwigValueWrapper() : pointer(0) { }
  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
  operator T&() const { return *pointer.ptr; }
  T *operator&() { return pointer.ptr; }
};

template <typename T> T SwigValueInit() {
  return T();
}
#endif

/* -----------------------------------------------------------------------------
 *  This section contains generic SWIG labels for method/variable
 *  declarations/attributes, and other compiler dependent labels.
 * ----------------------------------------------------------------------------- */

/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
#  define SWIGTEMPLATEDISAMBIGUATOR template
# elif defined(__HP_aCC)
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
#  define SWIGTEMPLATEDISAMBIGUATOR template
# else
#  define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif

/* inline attribute */
#ifndef SWIGINLINE
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
#   define SWIGINLINE inline
# else
#   define SWIGINLINE
# endif
#endif

/* attribute recognised by some compilers to avoid 'unused' warnings */
#ifndef SWIGUNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define SWIGUNUSED __attribute__ ((__unused__)) 
#   else
#     define SWIGUNUSED
#   endif
# elif defined(__ICC)
#   define SWIGUNUSED __attribute__ ((__unused__)) 
# else
#   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

#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
#   define SWIGUNUSEDPARM(p)
# else
#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
# endif
#endif

/* internal SWIG method */
#ifndef SWIGINTERN
# define SWIGINTERN static SWIGUNUSED
#endif

/* internal inline SWIG method */
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif

/* exporting methods */
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#  ifndef GCC_HASCLASSVISIBILITY
#    define GCC_HASCLASSVISIBILITY
#  endif
#endif

#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   if defined(STATIC_LINKED)
#     define SWIGEXPORT
#   else
#     define SWIGEXPORT __declspec(dllexport)
#   endif
# else
#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
#     define SWIGEXPORT __attribute__ ((visibility("default")))
#   else
#     define SWIGEXPORT
#   endif
# endif
#endif

/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   define SWIGSTDCALL __stdcall
# else
#   define SWIGSTDCALL
# endif 
#endif

/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif

/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif


/* -----------------------------------------------------------------------------
 * swigrun.swg
 *
 * This file contains generic C API SWIG runtime support for pointer
 * type checking.
 * ----------------------------------------------------------------------------- */

/* This should only be incremented when either the layout of swig_type_info changes,
   or for whatever reason, the runtime changes incompatibly */
#define SWIG_RUNTIME_VERSION "4"

/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
# define SWIG_QUOTE_STRING(x) #x
# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
#else
# define SWIG_TYPE_TABLE_NAME
#endif

/*
  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.
*/

#ifndef SWIGRUNTIME
# define SWIGRUNTIME SWIGINTERN
#endif

#ifndef SWIGRUNTIMEINLINE
# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
#endif

/*  Generic buffer size */
#ifndef SWIG_BUFFER_SIZE
# define SWIG_BUFFER_SIZE 1024
#endif

/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN        0x1
#define SWIG_CAST_NEW_MEMORY       0x2

/* Flags for new pointer objects */
#define SWIG_POINTER_OWN           0x1


/* 
   Flags/methods for returning states.
   
   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) {
       // success code
     } else {
       //fail code
     }

   Now you can be more explicit:

    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
    if (SWIG_IsOK(res)) {
      // success code
    } else {
      // fail code
    }

   which is the same really, but now you can also do

    Type *ptr;
    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
    if (SWIG_IsOK(res)) {
      // success code
      if (SWIG_IsNewObj(res) {
        ...
	delete *ptr;
      } else {
        ...
      }
    } 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 (<obj is ok>) {			       
          if (<need new object>) {		       
            *ptr = <ptr to new allocated object>; 
            return SWIG_NEWOBJ;		       
          } else {				       
            *ptr = <ptr to old object>;	       
            return SWIG_OLDOBJ;		       
          } 				       
        } else {				       
          return SWIG_BADOBJ;		       
        }					       
      }

   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
   SWIG errors code.

   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
   allows to return the 'cast rank', for example, if you have this

       int food(double)
       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_ERROR                 (-1)
#define SWIG_IsOK(r)               (r >= 0)
#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)
/* The NewMask denotes the object was created (using new/malloc) */
#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
/* The TmpMask is for in/out typemaps that use temporal objects */
#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
/* Simple returning values */
#define SWIG_BADOBJ                (SWIG_ERROR)
#define SWIG_OLDOBJ                (SWIG_OK)
#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
/* Check, add and del mask methods */
#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))

/* Cast-Rank Mode */
#if defined(SWIG_CASTRANK_MODE)
#  ifndef SWIG_TypeRank
#    define SWIG_TypeRank             unsigned long
#  endif
#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
#    define SWIG_MAXCASTRANK          (2)
#  endif
#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
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; 
}
#else /* no cast-rank mode */
#  define SWIG_AddCast
#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
#endif


#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);

/* Structure to store information on one type */
typedef struct swig_type_info {
  const char             *name;			/* mangled name of this type */
  const char             *str;			/* human readable name of this type */
  swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
  struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
  void                   *clientdata;		/* language specific type data */
  int                    owndata;		/* flag if the structure owns the clientdata */
} swig_type_info;

/* Structure to store a type and conversion function used for casting */
typedef struct swig_cast_info {
  swig_type_info         *type;			/* pointer to type that is equivalent to this type */
  swig_converter_func     converter;		/* function to cast the void pointers */
  struct swig_cast_info  *next;			/* pointer to next cast in linked list */
  struct swig_cast_info  *prev;			/* pointer to the previous cast */
} swig_cast_info;

/* Structure used to store module information
 * Each module generates one structure like this, and the runtime collects
 * all of these structures and stores them in a circularly linked list.*/
typedef struct swig_module_info {
  swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
  size_t                 size;		        /* Number of types in this module */
  struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
  swig_type_info         **type_initial;	/* Array of initially generated type structures */
  swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
  void                    *clientdata;		/* Language specific module data */
} swig_module_info;

/* 
  Compare two type names skipping the space characters, therefore
  "char*" == "char *" and "Class<int>" == "Class<int >", etc.

  Return 0 when the two name types are equivalent, as in
  strncmp, but skipping ' '.
*/
SWIGRUNTIME int
SWIG_TypeNameComp(const char *f1, const char *l1,
		  const char *f2, const char *l2) {
  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
    while ((*f1 == ' ') && (f1 != l1)) ++f1;
    while ((*f2 == ' ') && (f2 != l2)) ++f2;
    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
  }
  return (int)((l1 - f1) - (l2 - f2));
}

/*
  Check type equivalence in a name list like <name1>|<name2>|...
  Return 0 if not equal, 1 if equal
*/
SWIGRUNTIME int
SWIG_TypeEquiv(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;
}

/*
  Check type equivalence in a name list like <name1>|<name2>|...
  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
*/
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;
}


/*
  Check the typename
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
  if (ty) {
    swig_cast_info *iter = ty->cast;
    while (iter) {
      if (strcmp(iter->type->name, c) == 0) {
        if (iter == ty->cast)
          return iter;
        /* Move iter to the top of the linked list */
        iter->prev->next = iter->next;
        if (iter->next)
          iter->next->prev = iter->prev;
        iter->next = ty->cast;
        iter->prev = 0;
        if (ty->cast) ty->cast->prev = iter;
        ty->cast = iter;
        return iter;
      }
      iter = iter->next;
    }
  }
  return 0;
}

/* 
  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
  if (ty) {
    swig_cast_info *iter = ty->cast;
    while (iter) {
      if (iter->type == from) {
        if (iter == ty->cast)
          return iter;
        /* Move iter to the top of the linked list */
        iter->prev->next = iter->next;
        if (iter->next)
          iter->next->prev = iter->prev;
        iter->next = ty->cast;
        iter->prev = 0;
        if (ty->cast) ty->cast->prev = iter;
        ty->cast = iter;
        return iter;
      }
      iter = iter->next;
    }
  }
  return 0;
}

/*
  Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
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 *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
  swig_type_info *lastty = ty;
  if (!ty || !ty->dcast) return ty;
  while (ty && (ty->dcast)) {
    ty = (*ty->dcast)(ptr);
    if (ty) lastty = ty;
  }
  return lastty;
}

/*
  Return the name associated with this type
*/
SWIGRUNTIMEINLINE const char *
SWIG_TypeName(const swig_type_info *ty) {
  return ty->name;
}

/*
  Return the pretty name associated with this type,
  that is an unmangled type name in a form presentable to the user.
*/
SWIGRUNTIME const char *
SWIG_TypePrettyName(const swig_type_info *type) {
  /* The "str" field contains the equivalent pretty names of the
     type, separated by vertical-bar characters.  We choose
     to print the last name, as it is often (?) the most
     specific. */
  if (!type) return NULL;
  if (type->str != NULL) {
    const char *last_name = type->str;
    const char *s;
    for (s = type->str; *s; s++)
      if (*s == '|') last_name = s+1;
    return last_name;
  }
  else
    return type->name;
}

/* 
   Set the clientdata field for a type
*/
SWIGRUNTIME void
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;
  }
}
SWIGRUNTIME void
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.  
  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, 
		            const char *name) {
  swig_module_info *iter = start;
  do {
    if (iter->size) {
      register size_t l = 0;
      register size_t r = iter->size - 1;
      do {
	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
	register size_t i = (l + r) >> 1; 
	const char *iname = iter->types[i]->name;
	if (iname) {
	  register int compare = strcmp(name, iname);
	  if (compare == 0) {	    
	    return iter->types[i];
	  } else if (compare < 0) {
	    if (i) {
	      r = i - 1;
	    } else {
	      break;
	    }
	  } else if (compare > 0) {
	    l = i + 1;
	  }
	} else {
	  break; /* should never happen */
	}
      } while (l <= r);
    }
    iter = iter->next;
  } while (iter != end);
  return 0;
}

/*
  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.  
  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, 
		     const char *name) {
  /* STEP 1: Search the name field using binary search */
  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
  if (ret) {
    return ret;
  } else {
    /* STEP 2: If the type hasn't been found, do a complete search
       of the str field (the human readable name) */
    swig_module_info *iter = start;
    do {
      register 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];
      }
      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;
  for (; u != eu; ++u) {
    register 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;
  for (; u != eu; ++u) {
    register char d = *(c++);
    register unsigned char uu;
    if ((d >= '0') && (d <= '9'))
      uu = ((d - '0') << 4);
    else if ((d >= 'a') && (d <= 'f'))
      uu = ((d - ('a'-10)) << 4);
    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 
      return (char *) 0;
    *u = uu;
  }
  return c;
}

/* 
   Pack 'void *' into a string buffer.
*/
SWIGRUNTIME char *
SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
  char *r = buff;
  if ((2*sizeof(void *) + 2) > bsz) return 0;
  *(r++) = '_';
  r = SWIG_PackData(r,&ptr,sizeof(void *));
  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
  strcpy(r,name);
  return buff;
}

SWIGRUNTIME const char *
SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
  if (*c != '_') {
    if (strcmp(c,"NULL") == 0) {
      *ptr = (void *) 0;
      return name;
    } else {
      return 0;
    }
  }
  return SWIG_UnpackData(++c,ptr,sizeof(void *));
}

SWIGRUNTIME char *
SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
  char *r = buff;
  size_t lname = (name ? strlen(name) : 0);
  if ((2*sz + 2 + lname) > bsz) return 0;
  *(r++) = '_';
  r = SWIG_PackData(r,ptr,sz);
  if (lname) {
    strncpy(r,name,lname+1);
  } else {
    *r = 0;
  }
  return buff;
}

SWIGRUNTIME const char *
SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
  if (*c != '_') {
    if (strcmp(c,"NULL") == 0) {
      memset(ptr,0,sz);
      return name;
    } else {
      return 0;
    }
  }
  return SWIG_UnpackData(++c,ptr,sz);
}

#ifdef __cplusplus
}
#endif


#ifdef __cplusplus
extern "C" {
#endif

/* Remove global namespace pollution */
#if !defined(SWIG_NO_R_NO_REMAP)
# define R_NO_REMAP
#endif
#if !defined(SWIG_NO_STRICT_R_HEADERS)
# define STRICT_R_HEADERS
#endif

#include <Rdefines.h>
#include <Rversion.h>
#include <stdlib.h>
#include <assert.h>

#if R_VERSION >= R_Version(2,6,0)
#define VMAXTYPE void *
#else
#define VMAXTYPE char *
#endif

/*
  This is mainly a way to avoid having lots of local variables that may 
  conflict with those in the routine.

   Change name to R_SWIG_Callb....
*/
typedef struct RCallbackFunctionData {

  SEXP fun;
  SEXP userData;


  SEXP expr;
  SEXP retValue;
  int errorOccurred;

  SEXP el;  /* Temporary pointer used in the construction of the expression to call the R function. */

  struct RCallbackFunctionData *previous;   /* Stack */

} RCallbackFunctionData;

static RCallbackFunctionData  *callbackFunctionDataStack;


SWIGRUNTIME SEXP
R_SWIG_debug_getCallbackFunctionData()
{
  int n, i;
  SEXP ans;
  RCallbackFunctionData  *p = callbackFunctionDataStack;

  n = 0;
  while(p) { 
    n++;
    p = p->previous;
  }

  Rf_protect(ans = Rf_allocVector(VECSXP, n));
  for(p = callbackFunctionDataStack, i = 0; i < n; p = p->previous, i++) 
      SET_VECTOR_ELT(ans, i, p->fun);

  Rf_unprotect(1);

  return(ans);
}



SWIGRUNTIME RCallbackFunctionData *
R_SWIG_pushCallbackFunctionData(SEXP fun, SEXP userData)
{
   RCallbackFunctionData *el;
   el = (RCallbackFunctionData *) calloc(1, sizeof(RCallbackFunctionData));
   el->fun = fun;
   el->userData = userData;
   el->previous = callbackFunctionDataStack;

   callbackFunctionDataStack = el;

   return(el);
}


SWIGRUNTIME SEXP
R_SWIG_R_pushCallbackFunctionData(SEXP fun, SEXP userData)
{
    R_SWIG_pushCallbackFunctionData(fun, userData);
    return R_NilValue;
}

SWIGRUNTIME RCallbackFunctionData *
R_SWIG_getCallbackFunctionData()
{
  if(!callbackFunctionDataStack) {
    Rf_error("Supposedly impossible error occurred in the SWIG callback mechanism."
            "  No callback function data set.");
  }
  
  return callbackFunctionDataStack;
}

SWIGRUNTIME void
R_SWIG_popCallbackFunctionData(int doFree)
{
  RCallbackFunctionData  *el = NULL;
  if(!callbackFunctionDataStack)
    return ; /* Error !!! */

  el = callbackFunctionDataStack ;
  callbackFunctionDataStack = callbackFunctionDataStack->previous;

  if(doFree)
     free(el);
}


/*
  Interface to S function
      is(obj, type)
  which is to be used to determine if an 
  external pointer inherits from the right class.

  Ideally, we would like to be able to do this without an explicit call to the is() function.
  When the S4 class system uses its own SEXP types, then we will hopefully be able to do this
  in the C code.

  Should we make the expression static and preserve it to avoid the overhead of 
  allocating each time.
*/
SWIGRUNTIME int
R_SWIG_checkInherits(SEXP obj, SEXP tag, const char *type)
{
  SEXP e, val;
  int check_err = 0;

  Rf_protect(e = Rf_allocVector(LANGSXP, 3));
  SETCAR(e, Rf_install("extends"));

  SETCAR(CDR(e), Rf_mkString(CHAR(PRINTNAME(tag))));
  SETCAR(CDR(CDR(e)), Rf_mkString(type));

  val = R_tryEval(e, R_GlobalEnv, &check_err);
  Rf_unprotect(1);
  if(check_err) 
    return(0);


  return(LOGICAL(val)[0]);
}


SWIGRUNTIME void *
R_SWIG_resolveExternalRef(SEXP arg, const char * const type, const char * const argName, Rboolean nullOk)
{
  void *ptr;
  SEXP orig = arg;

  if(TYPEOF(arg) != EXTPTRSXP) 
    arg = GET_SLOT(arg, Rf_mkString("ref"));

  
  if(TYPEOF(arg) != EXTPTRSXP) {
    Rf_error("argument %s must be an external pointer (from an ExternalReference)", argName);
  }


  ptr = R_ExternalPtrAddr(arg);

  if(ptr == NULL && nullOk == (Rboolean) FALSE) {
    Rf_error("the external pointer (of type %s) for argument %s has value NULL", argName, type);
  }

  if(type[0] && R_ExternalPtrTag(arg) != Rf_install(type) && strcmp(type, "voidRef")
      && !R_SWIG_checkInherits(orig,  R_ExternalPtrTag(arg), type)) {
    Rf_error("the external pointer for argument %s has tag %s, not the expected value %s",
             argName, CHAR(PRINTNAME(R_ExternalPtrTag(arg))), type);
  }


  return(ptr);
}

SWIGRUNTIME void
R_SWIG_ReferenceFinalizer(SEXP el)
{
  void *ptr = R_SWIG_resolveExternalRef(el, "", "<finalizer>",  (Rboolean) 1);
  fprintf(stderr, "In R_SWIG_ReferenceFinalizer for %p\n", ptr);
  Rf_PrintValue(el);

  if(ptr) {
     if(TYPEOF(el) != EXTPTRSXP)
        el = GET_SLOT(el, Rf_mkString("ref"));

     if(TYPEOF(el) == EXTPTRSXP)
        R_ClearExternalPtr(el);

     free(ptr);
  }

  return;
}

typedef enum {R_SWIG_EXTERNAL, R_SWIG_OWNER } R_SWIG_Owner;

SWIGRUNTIME SEXP
SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner)
{
  SEXP external, r_obj;
  const char *p = typeName;

  if(typeName[0] == '_')
     p = typeName + 1;

  Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue));
  Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName)));

  if(owner)
    R_RegisterCFinalizer(external, R_SWIG_ReferenceFinalizer);

  r_obj = SET_SLOT(r_obj, Rf_mkString((char *) "ref"), external);
  SET_S4_OBJECT(r_obj);
  Rf_unprotect(2);

  return(r_obj);
}


SWIGRUNTIME SEXP
R_SWIG_create_SWIG_R_Array(const char *typeName, SEXP ref, int len)
{
   SEXP arr;

/*XXX remove the char * cast when we can. MAKE_CLASS should be declared appropriately. */
   Rf_protect(arr = NEW_OBJECT(MAKE_CLASS((char *) typeName)));
   Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("ref"), ref));
   Rf_protect(arr = R_do_slot_assign(arr, Rf_mkString("dims"), Rf_ScalarInteger(len)));

   Rf_unprotect(3); 			   
   SET_S4_OBJECT(arr);	
   return arr;
}

#define ADD_OUTPUT_ARG(result, pos, value, name)  r_ans = AddOutputArgToReturn(pos, value, name, OutputValues);

SWIGRUNTIME SEXP
AddOutputArgToReturn(int pos, SEXP value, const char *name, SEXP output)
{
  SET_VECTOR_ELT(output, pos, value);

  return(output);
}

/* Create a new pointer object */
SWIGRUNTIMEINLINE SEXP
SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
  SEXP rptr = R_MakeExternalPtr(ptr, 
  R_MakeExternalPtr(type, R_NilValue, R_NilValue), R_NilValue); 
  SET_S4_OBJECT(rptr);
//  rptr = Rf_setAttrib(rptr, R_ClassSymbol, mkChar(SWIG_TypeName(type)));
  return rptr;
}

/* Convert a pointer value */
SWIGRUNTIMEINLINE int
SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) {
  void *vptr;
  if (!obj) return SWIG_ERROR;
  if (obj == R_NilValue) {
    if (ptr) *ptr = NULL;
    return SWIG_OK;
  }

  vptr = R_ExternalPtrAddr(obj);
  if (ty) {
    swig_type_info *to = (swig_type_info*) 
      R_ExternalPtrAddr(R_ExternalPtrTag(obj));
    if (to == ty) {
      if (ptr) *ptr = vptr;
    } else {
      swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
      int newmemory = 0;
      if (ptr) *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
      assert(!newmemory); /* newmemory handling not yet implemented */
    }
  } else {
      if (ptr) *ptr = vptr;
 }
  return SWIG_OK;
}

SWIGRUNTIME swig_module_info *
SWIG_GetModule(void *v) {
  static void *type_pointer = (void *)0;
  return (swig_module_info *) type_pointer;
}

SWIGRUNTIME void
SWIG_SetModule(void *v, swig_module_info *swig_module) {
}

typedef struct {
  void *pack;
  swig_type_info *ty;
  size_t size;
} RSwigPacked;

/* Create a new packed object */

SWIGRUNTIMEINLINE SEXP RSwigPacked_New(void *ptr, size_t sz,
		  swig_type_info *ty) {
  SEXP rptr;
  RSwigPacked *sobj = 
  (RSwigPacked*) malloc(sizeof(RSwigPacked));
  if (sobj) {
    void *pack = malloc(sz);
    if (pack) {
      memcpy(pack, ptr, sz);
      sobj->pack = pack;
      sobj->ty   = ty;
      sobj->size = sz;
    } else {
      sobj = 0;
    }
  }
  rptr = R_MakeExternalPtr(sobj, R_NilValue, R_NilValue); 
  return rptr;
}

SWIGRUNTIME swig_type_info *
RSwigPacked_UnpackData(SEXP obj, void *ptr, size_t size)
{
    RSwigPacked *sobj = 
        (RSwigPacked *)R_ExternalPtrAddr(obj);
    if (sobj->size != size) return 0;
    memcpy(ptr, sobj->pack, size);
    return sobj->ty;
}

SWIGRUNTIMEINLINE SEXP
SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
  return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue;
}

/* Convert a packed value value */

SWIGRUNTIME int
SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) {
  swig_type_info *to = RSwigPacked_UnpackData(obj, ptr, sz);
  if (!to) return SWIG_ERROR;
  if (ty) {
    if (to != ty) {
      /* check type cast? */
      swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
      if (!tc) return SWIG_ERROR;
    }
  }
  return SWIG_OK;
}  

#ifdef __cplusplus
}
#endif



#define SWIG_exception_fail(code, msg) do { Rf_warning(msg); return Rf_ScalarLogical(NA_LOGICAL); return Rf_ScalarLogical(NA_LOGICAL); } while(0) 

#define SWIG_contract_assert(expr, msg) if (!(expr)) { Rf_warning(msg); return Rf_ScalarLogical(NA_LOGICAL); return Rf_ScalarLogical(NA_LOGICAL); } else 



/* -------- TYPES TABLE (BEGIN) -------- */

#define SWIGTYPE_p__THyPhy swig_types[0]
#define SWIGTYPE_p__THyPhyMatrix swig_types[1]
#define SWIGTYPE_p__THyPhyNumber swig_types[2]
#define SWIGTYPE_p__THyPhyReturnObject swig_types[3]
#define SWIGTYPE_p__THyPhyString swig_types[4]
#define SWIGTYPE_p_char swig_types[5]
#define SWIGTYPE_p_double swig_types[6]
#define SWIGTYPE_p_f_p_char_int_double__bool swig_types[7]
#define SWIGTYPE_p_void swig_types[8]
static swig_type_info *swig_types[10];
static swig_module_info swig_module = {swig_types, 9, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)

/* -------- TYPES TABLE (END) -------- */


/* -----------------------------------------------------------------------------
 *  This section contains generic SWIG labels for method/variable
 *  declarations/attributes, and other compiler dependent labels.
 * ----------------------------------------------------------------------------- */

/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
#  define SWIGTEMPLATEDISAMBIGUATOR template
# elif defined(__HP_aCC)
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
#  define SWIGTEMPLATEDISAMBIGUATOR template
# else
#  define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif

/* inline attribute */
#ifndef SWIGINLINE
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
#   define SWIGINLINE inline
# else
#   define SWIGINLINE
# endif
#endif

/* attribute recognised by some compilers to avoid 'unused' warnings */
#ifndef SWIGUNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define SWIGUNUSED __attribute__ ((__unused__)) 
#   else
#     define SWIGUNUSED
#   endif
# elif defined(__ICC)
#   define SWIGUNUSED __attribute__ ((__unused__)) 
# else
#   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

#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
#   define SWIGUNUSEDPARM(p)
# else
#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
# endif
#endif

/* internal SWIG method */
#ifndef SWIGINTERN
# define SWIGINTERN static SWIGUNUSED
#endif

/* internal inline SWIG method */
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif

/* exporting methods */
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#  ifndef GCC_HASCLASSVISIBILITY
#    define GCC_HASCLASSVISIBILITY
#  endif
#endif

#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   if defined(STATIC_LINKED)
#     define SWIGEXPORT
#   else
#     define SWIGEXPORT __declspec(dllexport)
#   endif
# else
#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
#     define SWIGEXPORT __attribute__ ((visibility("default")))
#   else
#     define SWIGEXPORT
#   endif
# endif
#endif

/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   define SWIGSTDCALL __stdcall
# else
#   define SWIGSTDCALL
# endif 
#endif

/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif

/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#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_SystemError    	   -10
#define  SWIG_AttributeError 	   -11
#define  SWIG_MemoryError    	   -12 
#define  SWIG_NullReferenceError   -13




#define SWIGVERSION 0x020004 
#define SWIG_VERSION SWIGVERSION


#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) 
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) 


#include <stdexcept>


#include "THyPhy.h"


SWIGINTERN int
SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc)
{
  if (cptr && Rf_isString(obj)) {
    char *cstr = const_cast< char * >(CHAR(STRING_ELT(obj, 0)));
    int len = strlen(cstr);

    if (alloc) {
      if (*alloc == SWIG_NEWOBJ) {
        *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1)));
        *alloc = SWIG_NEWOBJ;
      } else {
        *cptr = cstr;
      }
    } else {
      *cptr = reinterpret_cast< char * >(malloc(len + 1));
      *cptr = strcpy(*cptr, cstr);
    }
    if (psize) *psize = len + 1;
    return SWIG_OK;
  }
  return SWIG_TypeError;
}





SWIGINTERNINLINE  int
SWIG_AsVal_long (SEXP obj, long *val)
{
   if (val) *val = Rf_asInteger(obj);
   return SWIG_OK;
}


SWIGINTERN char *
SWIG_strdup(const char *str)
{
  char *newstr = reinterpret_cast< char * >(malloc(strlen(str) + 1));
  return strcpy(newstr, str);
}


SWIGINTERNINLINE  int
SWIG_AsVal_double (SEXP obj, double *val)
{
   if (val) *val = Rf_asReal(obj);
   return SWIG_OK;
}


SWIGINTERNINLINE SEXP
SWIG_From_double  (double value)
{
	return Rf_ScalarReal(value);
}


SWIGINTERN int
SWIG_AsVal_bool (SEXP obj, bool *val)
{
  long v;
  int res = SWIG_AsVal_long (obj, val ? &v : 0);
  if (SWIG_IsOK(res)) {    
    if (val) *val = v ? true : false;
    return res;
  }  
  return SWIG_TypeError;
}


#include <limits.h>
#if !defined(SWIG_NO_LLONG_MAX)
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
#   define LLONG_MAX __LONG_LONG_MAX__
#   define LLONG_MIN (-LLONG_MAX - 1LL)
#   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
# endif
#endif


SWIGINTERN int
SWIG_AsVal_int (SEXP obj, int *val)
{
  long v;
  int res = SWIG_AsVal_long (obj, &v);
  if (SWIG_IsOK(res)) {
    if ((v < INT_MIN || v > INT_MAX)) {
      return SWIG_OverflowError;
    } else {
      if (val) *val = static_cast< int >(v);
    }
  }  
  return res;
}


#ifdef __cplusplus
extern "C" {
#endif

SWIGEXPORT SEXP
R_swig__THyPhyReturnObject_myType ( SEXP self, SEXP s_swig_copy)
{
  int result;
  _THyPhyReturnObject *arg1 = (_THyPhyReturnObject *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyReturnObject, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyReturnObject_myType" "', argument " "1"" of type '" "_THyPhyReturnObject *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyReturnObject * >(argp1);
  result = (int)(arg1)->myType();
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_delete__THyPhyReturnObject ( SEXP self)
{
  _THyPhyReturnObject *arg1 = (_THyPhyReturnObject *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyReturnObject, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__THyPhyReturnObject" "', argument " "1"" of type '" "_THyPhyReturnObject *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyReturnObject * >(argp1);
  delete arg1;
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  R_ClearExternalPtr(self);
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyReturnObject_castToString ( SEXP self)
{
  _THyPhyString *result = 0 ;
  _THyPhyReturnObject *arg1 = (_THyPhyReturnObject *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyReturnObject, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyReturnObject_castToString" "', argument " "1"" of type '" "_THyPhyReturnObject *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyReturnObject * >(argp1);
  result = (_THyPhyString *)(arg1)->castToString();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyReturnObject_castToNumber ( SEXP self)
{
  _THyPhyNumber *result = 0 ;
  _THyPhyReturnObject *arg1 = (_THyPhyReturnObject *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyReturnObject, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyReturnObject_castToNumber" "', argument " "1"" of type '" "_THyPhyReturnObject *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyReturnObject * >(argp1);
  result = (_THyPhyNumber *)(arg1)->castToNumber();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyNumber, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyReturnObject_castToMatrix ( SEXP self)
{
  _THyPhyMatrix *result = 0 ;
  _THyPhyReturnObject *arg1 = (_THyPhyReturnObject *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyReturnObject, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyReturnObject_castToMatrix" "', argument " "1"" of type '" "_THyPhyReturnObject *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyReturnObject * >(argp1);
  result = (_THyPhyMatrix *)(arg1)->castToMatrix();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyMatrix, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyString__SWIG_0 ( SEXP s_arg1, SEXP s_arg2)
{
  _THyPhyString *result = 0 ;
  char *arg1 = (char *) 0 ;
  long arg2 ;
  int res1 ;
  char *buf1 = 0 ;
  int alloc1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_AsCharPtrAndSize(s_arg1, &buf1, NULL, &alloc1);
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new__THyPhyString" "', argument " "1"" of type '" "char const *""'");
  }
  arg1 = reinterpret_cast< char * >(buf1);
  arg2 = static_cast< long >(INTEGER(s_arg2)[0]);
  result = (_THyPhyString *)new _THyPhyString((char const *)arg1,arg2);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_OWNER |  0 );
  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyString__SWIG_1 ( SEXP s_arg1)
{
  _THyPhyString *result = 0 ;
  char *arg1 = (char *) 0 ;
  int res1 ;
  char *buf1 = 0 ;
  int alloc1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_AsCharPtrAndSize(s_arg1, &buf1, NULL, &alloc1);
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new__THyPhyString" "', argument " "1"" of type '" "char const *""'");
  }
  arg1 = reinterpret_cast< char * >(buf1);
  result = (_THyPhyString *)new _THyPhyString((char const *)arg1);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_OWNER |  0 );
  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyString__SWIG_2 ( )
{
  _THyPhyString *result = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (_THyPhyString *)new _THyPhyString();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_OWNER |  0 );
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyString_myType ( SEXP self, SEXP s_swig_copy)
{
  int result;
  _THyPhyString *arg1 = (_THyPhyString *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyString, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyString_myType" "', argument " "1"" of type '" "_THyPhyString *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyString * >(argp1);
  result = (int)(arg1)->myType();
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_delete__THyPhyString ( SEXP self)
{
  _THyPhyString *arg1 = (_THyPhyString *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyString, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__THyPhyString" "', argument " "1"" of type '" "_THyPhyString *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyString * >(argp1);
  delete arg1;
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  R_ClearExternalPtr(self);
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyString_sLength_set ( SEXP self, SEXP s_sLength)
{
  _THyPhyString *arg1 = (_THyPhyString *) 0 ;
  long arg2 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyString, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyString_sLength_set" "', argument " "1"" of type '" "_THyPhyString *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyString * >(argp1);
  arg2 = static_cast< long >(INTEGER(s_sLength)[0]);
  if (arg1) (arg1)->sLength = arg2;
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyString_sLength_get ( SEXP self, SEXP s_swig_copy)
{
  long result;
  _THyPhyString *arg1 = (_THyPhyString *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyString, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyString_sLength_get" "', argument " "1"" of type '" "_THyPhyString *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyString * >(argp1);
  result = (long) ((arg1)->sLength);
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyString_sData_set ( SEXP self, SEXP s_sData)
{
  _THyPhyString *arg1 = (_THyPhyString *) 0 ;
  char *arg2 = (char *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyString, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyString_sData_set" "', argument " "1"" of type '" "_THyPhyString *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyString * >(argp1);
  arg2 = reinterpret_cast< char * >(SWIG_strdup(CHAR(STRING_ELT(s_sData, 0))));
  if (arg1->sData) delete[] arg1->sData;
  if (arg2) {
    size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1;
    arg1->sData = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size)));
  } else {
    arg1->sData = 0;
  }
  r_ans = R_NilValue;
  
  free(arg2);
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyString_sData_get ( SEXP self)
{
  char *result = 0 ;
  _THyPhyString *arg1 = (_THyPhyString *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyString, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyString_sData_get" "', argument " "1"" of type '" "_THyPhyString *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyString * >(argp1);
  result = (char *) ((arg1)->sData);
  r_ans = result ? Rf_mkString(reinterpret_cast< char * >(result)) : R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyNumber__SWIG_0 ( SEXP s_arg1)
{
  _THyPhyNumber *result = 0 ;
  double arg1 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  arg1 = static_cast< double >(REAL(s_arg1)[0]);
  result = (_THyPhyNumber *)new _THyPhyNumber(arg1);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyNumber, R_SWIG_OWNER |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyNumber__SWIG_1 ( )
{
  _THyPhyNumber *result = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (_THyPhyNumber *)new _THyPhyNumber();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyNumber, R_SWIG_OWNER |  0 );
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyNumber_myType ( SEXP self, SEXP s_swig_copy)
{
  int result;
  _THyPhyNumber *arg1 = (_THyPhyNumber *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyNumber, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyNumber_myType" "', argument " "1"" of type '" "_THyPhyNumber *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyNumber * >(argp1);
  result = (int)(arg1)->myType();
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_delete__THyPhyNumber ( SEXP self)
{
  _THyPhyNumber *arg1 = (_THyPhyNumber *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyNumber, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__THyPhyNumber" "', argument " "1"" of type '" "_THyPhyNumber *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyNumber * >(argp1);
  delete arg1;
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  R_ClearExternalPtr(self);
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyNumber_nValue_set ( SEXP self, SEXP s_nValue)
{
  _THyPhyNumber *arg1 = (_THyPhyNumber *) 0 ;
  double arg2 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyNumber, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyNumber_nValue_set" "', argument " "1"" of type '" "_THyPhyNumber *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyNumber * >(argp1);
  arg2 = static_cast< double >(REAL(s_nValue)[0]);
  if (arg1) (arg1)->nValue = arg2;
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyNumber_nValue_get ( SEXP self, SEXP s_swig_copy)
{
  double result;
  _THyPhyNumber *arg1 = (_THyPhyNumber *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyNumber, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyNumber_nValue_get" "', argument " "1"" of type '" "_THyPhyNumber *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyNumber * >(argp1);
  result = (double) ((arg1)->nValue);
  r_ans = SWIG_From_double(static_cast< double >(result));
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyMatrix__SWIG_0 ( )
{
  _THyPhyMatrix *result = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (_THyPhyMatrix *)new _THyPhyMatrix();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyMatrix, R_SWIG_OWNER |  0 );
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhyMatrix__SWIG_1 ( SEXP s_arg1, SEXP s_arg2, SEXP s_arg3)
{
  _THyPhyMatrix *result = 0 ;
  long arg1 ;
  long arg2 ;
  double *arg3 = (double *) 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  arg1 = static_cast< long >(INTEGER(s_arg1)[0]);
  arg2 = static_cast< long >(INTEGER(s_arg2)[0]);
  {
    {
      int _rswigi;
      int _rswiglen = LENGTH(s_arg3);
      arg3 = static_cast< double * >(calloc(sizeof(double), _rswiglen));
      for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) {
        arg3[_rswigi] = REAL(s_arg3)[_rswigi];
      }
    }
  }
  result = (_THyPhyMatrix *)new _THyPhyMatrix(arg1,arg2,(double const *)arg3);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyMatrix, R_SWIG_OWNER |  0 );
  
  
  
  free(arg3);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_myType ( SEXP self, SEXP s_swig_copy)
{
  int result;
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_myType" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  result = (int)(arg1)->myType();
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_delete__THyPhyMatrix ( SEXP self)
{
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__THyPhyMatrix" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  delete arg1;
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  R_ClearExternalPtr(self);
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_MatrixCell ( SEXP self, SEXP s_arg2, SEXP s_arg3, SEXP s_swig_copy)
{
  double result;
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  long arg2 ;
  long arg3 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_MatrixCell" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  arg2 = static_cast< long >(INTEGER(s_arg2)[0]);
  arg3 = static_cast< long >(INTEGER(s_arg3)[0]);
  result = (double)(arg1)->MatrixCell(arg2,arg3);
  r_ans = SWIG_From_double(static_cast< double >(result));
  
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_mRows_set ( SEXP self, SEXP s_mRows)
{
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  long arg2 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_mRows_set" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  arg2 = static_cast< long >(INTEGER(s_mRows)[0]);
  if (arg1) (arg1)->mRows = arg2;
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_mRows_get ( SEXP self, SEXP s_swig_copy)
{
  long result;
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_mRows_get" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  result = (long) ((arg1)->mRows);
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_mCols_set ( SEXP self, SEXP s_mCols)
{
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  long arg2 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_mCols_set" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  arg2 = static_cast< long >(INTEGER(s_mCols)[0]);
  if (arg1) (arg1)->mCols = arg2;
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_mCols_get ( SEXP self, SEXP s_swig_copy)
{
  long result;
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_mCols_get" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  result = (long) ((arg1)->mCols);
  r_ans = Rf_ScalarInteger(result);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_mData_set ( SEXP self, SEXP s_mData)
{
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  double *arg2 = (double *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_mData_set" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  {
    {
      int _rswigi;
      int _rswiglen = LENGTH(s_mData);
      arg2 = static_cast< double * >(calloc(sizeof(double), _rswiglen));
      for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) {
        arg2[_rswigi] = REAL(s_mData)[_rswigi];
      }
    }
  }
  if (arg1) (arg1)->mData = arg2;
  r_ans = R_NilValue;
  
  
  free(arg2);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyMatrix_mData_get ( SEXP self)
{
  double *result = 0 ;
  _THyPhyMatrix *arg1 = (_THyPhyMatrix *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhyMatrix, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhyMatrix_mData_get" "', argument " "1"" of type '" "_THyPhyMatrix *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhyMatrix * >(argp1);
  result = (double *) ((arg1)->mData);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_double, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhy__SWIG_0 ( SEXP s_arg1, SEXP s_arg2, SEXP s_arg3)
{
  _THyPhy *result = 0 ;
  _ProgressCancelHandler *arg1 = (_ProgressCancelHandler *) 0 ;
  char *arg2 = (char *) 0 ;
  long arg3 ;
  int res2 ;
  char *buf2 = 0 ;
  int alloc2 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  {
    int res = SWIG_R_ConvertPtr(s_arg1, (void**)(&arg1), SWIGTYPE_p_f_p_char_int_double__bool, 0);
    if (!SWIG_IsOK(res)) {
      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "new__THyPhy" "', argument " "1"" of type '" "_ProgressCancelHandler *""'"); 
    }
  }
  res2 = SWIG_AsCharPtrAndSize(s_arg2, &buf2, NULL, &alloc2);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new__THyPhy" "', argument " "2"" of type '" "char const *""'");
  }
  arg2 = reinterpret_cast< char * >(buf2);
  arg3 = static_cast< long >(INTEGER(s_arg3)[0]);
  result = (_THyPhy *)new _THyPhy(arg1,(char const *)arg2,arg3);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhy, R_SWIG_OWNER |  0 );
  
  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhy__SWIG_1 ( SEXP s_arg1, SEXP s_arg2)
{
  _THyPhy *result = 0 ;
  _ProgressCancelHandler *arg1 = (_ProgressCancelHandler *) 0 ;
  char *arg2 = (char *) 0 ;
  int res2 ;
  char *buf2 = 0 ;
  int alloc2 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  {
    int res = SWIG_R_ConvertPtr(s_arg1, (void**)(&arg1), SWIGTYPE_p_f_p_char_int_double__bool, 0);
    if (!SWIG_IsOK(res)) {
      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "new__THyPhy" "', argument " "1"" of type '" "_ProgressCancelHandler *""'"); 
    }
  }
  res2 = SWIG_AsCharPtrAndSize(s_arg2, &buf2, NULL, &alloc2);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new__THyPhy" "', argument " "2"" of type '" "char const *""'");
  }
  arg2 = reinterpret_cast< char * >(buf2);
  result = (_THyPhy *)new _THyPhy(arg1,(char const *)arg2);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhy, R_SWIG_OWNER |  0 );
  
  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhy__SWIG_2 ( SEXP s_arg1, SEXP s_arg2)
{
  _THyPhy *result = 0 ;
  char *arg1 = (char *) 0 ;
  long arg2 ;
  int res1 ;
  char *buf1 = 0 ;
  int alloc1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_AsCharPtrAndSize(s_arg1, &buf1, NULL, &alloc1);
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new__THyPhy" "', argument " "1"" of type '" "char const *""'");
  }
  arg1 = reinterpret_cast< char * >(buf1);
  arg2 = static_cast< long >(INTEGER(s_arg2)[0]);
  result = (_THyPhy *)new _THyPhy((char const *)arg1,arg2);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhy, R_SWIG_OWNER |  0 );
  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_new__THyPhy__SWIG_3 ( SEXP s_arg1)
{
  _THyPhy *result = 0 ;
  char *arg1 = (char *) 0 ;
  int res1 ;
  char *buf1 = 0 ;
  int alloc1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_AsCharPtrAndSize(s_arg1, &buf1, NULL, &alloc1);
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new__THyPhy" "', argument " "1"" of type '" "char const *""'");
  }
  arg1 = reinterpret_cast< char * >(buf1);
  result = (_THyPhy *)new _THyPhy((char const *)arg1);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhy, R_SWIG_OWNER |  0 );
  if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_delete__THyPhy ( SEXP self)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__THyPhy" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  delete arg1;
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  R_ClearExternalPtr(self);
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_ExecuteBF__SWIG_0 ( SEXP self, SEXP s_arg2, SEXP s_arg3)
{
  _THyPhyString *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  char *arg2 = (char *) 0 ;
  bool arg3 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  char *buf2 = 0 ;
  int alloc2 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_ExecuteBF" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_AsCharPtrAndSize(s_arg2, &buf2, NULL, &alloc2);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_ExecuteBF" "', argument " "2"" of type '" "char const *""'");
  }
  arg2 = reinterpret_cast< char * >(buf2);
  arg3 = LOGICAL(s_arg3)[0] ? true : false;
  result = (_THyPhyString *)(arg1)->ExecuteBF((char const *)arg2,arg3);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_EXTERNAL |  0 );
  
  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_ExecuteBF__SWIG_1 ( SEXP self, SEXP s_arg2)
{
  _THyPhyString *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  char *arg2 = (char *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  char *buf2 = 0 ;
  int alloc2 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_ExecuteBF" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_AsCharPtrAndSize(s_arg2, &buf2, NULL, &alloc2);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_ExecuteBF" "', argument " "2"" of type '" "char const *""'");
  }
  arg2 = reinterpret_cast< char * >(buf2);
  result = (_THyPhyString *)(arg1)->ExecuteBF((char const *)arg2);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_EXTERNAL |  0 );
  
  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_InitTHyPhy ( SEXP self, SEXP s_arg2, SEXP s_arg3, SEXP s_arg4)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  _ProgressCancelHandler *arg2 = (_ProgressCancelHandler *) 0 ;
  char *arg3 = (char *) 0 ;
  long arg4 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res3 ;
  char *buf3 = 0 ;
  int alloc3 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_InitTHyPhy" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  {
    int res = SWIG_R_ConvertPtr(s_arg2, (void**)(&arg2), SWIGTYPE_p_f_p_char_int_double__bool, 0);
    if (!SWIG_IsOK(res)) {
      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "_THyPhy_InitTHyPhy" "', argument " "2"" of type '" "_ProgressCancelHandler *""'"); 
    }
  }
  res3 = SWIG_AsCharPtrAndSize(s_arg3, &buf3, NULL, &alloc3);
  if (!SWIG_IsOK(res3)) {
    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "_THyPhy_InitTHyPhy" "', argument " "3"" of type '" "char const *""'");
  }
  arg3 = reinterpret_cast< char * >(buf3);
  arg4 = static_cast< long >(INTEGER(s_arg4)[0]);
  (arg1)->InitTHyPhy(arg2,(char const *)arg3,arg4);
  r_ans = R_NilValue;
  
  
  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_ClearAll ( SEXP self)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_ClearAll" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  (arg1)->ClearAll();
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_AskFor ( SEXP self, SEXP s_arg2)
{
  void *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  char *arg2 = (char *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  char *buf2 = 0 ;
  int alloc2 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_AskFor" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_AsCharPtrAndSize(s_arg2, &buf2, NULL, &alloc2);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_AskFor" "', argument " "2"" of type '" "char const *""'");
  }
  arg2 = reinterpret_cast< char * >(buf2);
  result = (void *)(arg1)->AskFor((char const *)arg2);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, R_SWIG_EXTERNAL |  0 );
  
  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_DumpResult ( SEXP self, SEXP s_arg2)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *arg2 = (void *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_DumpResult" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_R_ConvertPtr(s_arg2, SWIG_as_voidptrptr(&arg2), 0, 0);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_DumpResult" "', argument " "2"" of type '" "void *""'"); 
  }
  (arg1)->DumpResult(arg2);
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_CanCast ( SEXP self, SEXP s_arg2, SEXP s_arg3, SEXP s_swig_copy)
{
  bool result;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *arg2 = (void *) 0 ;
  int arg3 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_CanCast" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_R_ConvertPtr(s_arg2, SWIG_as_voidptrptr(&arg2), 0, 0);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_CanCast" "', argument " "2"" of type '" "void const *""'"); 
  }
  arg3 = static_cast< int >(INTEGER(s_arg3)[0]);
  result = (bool)(arg1)->CanCast((void const *)arg2,arg3);
  r_ans = Rf_ScalarLogical(result);
  
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_CastResult ( SEXP self, SEXP s_arg2, SEXP s_arg3)
{
  _THyPhyReturnObject *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *arg2 = (void *) 0 ;
  int arg3 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_CastResult" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_R_ConvertPtr(s_arg2, SWIG_as_voidptrptr(&arg2), 0, 0);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_CastResult" "', argument " "2"" of type '" "void const *""'"); 
  }
  arg3 = static_cast< int >(INTEGER(s_arg3)[0]);
  result = (_THyPhyReturnObject *)(arg1)->CastResult((void const *)arg2,arg3);
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyReturnObject, R_SWIG_EXTERNAL |  0 );
  
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_SetCallbackHandler ( SEXP self, SEXP s_arg2)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  _ProgressCancelHandler *arg2 = (_ProgressCancelHandler *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_SetCallbackHandler" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  {
    int res = SWIG_R_ConvertPtr(s_arg2, (void**)(&arg2), SWIGTYPE_p_f_p_char_int_double__bool, 0);
    if (!SWIG_IsOK(res)) {
      SWIG_exception_fail(SWIG_ArgError(res), "in method '" "_THyPhy_SetCallbackHandler" "', argument " "2"" of type '" "_ProgressCancelHandler *""'"); 
    }
  }
  (arg1)->SetCallbackHandler(arg2);
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_GetCallbackHandler ( SEXP self)
{
  _ProgressCancelHandler *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_GetCallbackHandler" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  result = (_ProgressCancelHandler *)(arg1)->GetCallbackHandler();
  r_ans = SWIG_R_NewPointerObj((void *)(result), SWIGTYPE_p_f_p_char_int_double__bool, 0);
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_GetWarnings ( SEXP self)
{
  _THyPhyString *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_GetWarnings" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  result = (_THyPhyString *)(arg1)->GetWarnings();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_GetErrors ( SEXP self)
{
  _THyPhyString *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_GetErrors" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  result = (_THyPhyString *)(arg1)->GetErrors();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_GetStdout ( SEXP self)
{
  _THyPhyString *result = 0 ;
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_GetStdout" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  result = (_THyPhyString *)(arg1)->GetStdout();
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhyString, R_SWIG_EXTERNAL |  0 );
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_PushWarning ( SEXP self, SEXP s_arg2)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *arg2 = (void *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_PushWarning" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_R_ConvertPtr(s_arg2, SWIG_as_voidptrptr(&arg2), 0, 0);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_PushWarning" "', argument " "2"" of type '" "void *""'"); 
  }
  (arg1)->PushWarning(arg2);
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_PushError ( SEXP self, SEXP s_arg2)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *arg2 = (void *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_PushError" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_R_ConvertPtr(s_arg2, SWIG_as_voidptrptr(&arg2), 0, 0);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_PushError" "', argument " "2"" of type '" "void *""'"); 
  }
  (arg1)->PushError(arg2);
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhy_PushOutString ( SEXP self, SEXP s_arg2)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *arg2 = (void *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  int res2 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(self, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_THyPhy_PushOutString" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  res2 = SWIG_R_ConvertPtr(s_arg2, SWIG_as_voidptrptr(&arg2), 0, 0);
  if (!SWIG_IsOK(res2)) {
    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_THyPhy_PushOutString" "', argument " "2"" of type '" "void *""'"); 
  }
  (arg1)->PushOutString(arg2);
  r_ans = R_NilValue;
  
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyGetLongStatus ( SEXP s_swig_copy)
{
  long result;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (long)_THyPhyGetLongStatus();
  r_ans = Rf_ScalarInteger(result);
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyGetStringStatus ( )
{
  char *result = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (char *)_THyPhyGetStringStatus();
  r_ans = result ? Rf_mkString(reinterpret_cast< char * >(result)) : R_NilValue;
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig__THyPhyGetDoubleStatus ( SEXP s_swig_copy)
{
  double result;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (double)_THyPhyGetDoubleStatus();
  r_ans = SWIG_From_double(static_cast< double >(result));
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_globalInterfaceInstance_set ( SEXP s_globalInterfaceInstance)
{
  _THyPhy *arg1 = (_THyPhy *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  res1 = SWIG_R_ConvertPtr(s_globalInterfaceInstance, &argp1, SWIGTYPE_p__THyPhy, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "globalInterfaceInstance_set" "', argument " "1"" of type '" "_THyPhy *""'"); 
  }
  arg1 = reinterpret_cast< _THyPhy * >(argp1);
  globalInterfaceInstance = arg1;
  r_ans = R_NilValue;
  
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


SWIGEXPORT SEXP
R_swig_globalInterfaceInstance_get ( )
{
  _THyPhy *result = 0 ;
  unsigned int r_nprotect = 0;
  SEXP r_ans = R_NilValue ;
  VMAXTYPE r_vmax = vmaxget() ;
  
  result = (_THyPhy *)globalInterfaceInstance;
  r_ans = SWIG_R_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__THyPhy, R_SWIG_EXTERNAL |  0 );
  vmaxset(r_vmax);
  if(r_nprotect)  Rf_unprotect(r_nprotect);
  
  return r_ans;
}


#ifdef __cplusplus
}
#endif

/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */

static void *_p__THyPhyNumberTo_p__THyPhyReturnObject(void *x, int *SWIGUNUSEDPARM(newmemory)) {
    return (void *)((_THyPhyReturnObject *)  ((_THyPhyNumber *) x));
}
static void *_p__THyPhyMatrixTo_p__THyPhyReturnObject(void *x, int *SWIGUNUSEDPARM(newmemory)) {
    return (void *)((_THyPhyReturnObject *)  ((_THyPhyMatrix *) x));
}
static void *_p__THyPhyStringTo_p__THyPhyReturnObject(void *x, int *SWIGUNUSEDPARM(newmemory)) {
    return (void *)((_THyPhyReturnObject *)  ((_THyPhyString *) x));
}
static swig_type_info _swigt__p__THyPhy = {"_p__THyPhy", "_THyPhy *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p__THyPhyMatrix = {"_p__THyPhyMatrix", "_THyPhyMatrix *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p__THyPhyNumber = {"_p__THyPhyNumber", "_THyPhyNumber *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p__THyPhyReturnObject = {"_p__THyPhyReturnObject", "_THyPhyReturnObject *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p__THyPhyString = {"_p__THyPhyString", "_THyPhyString *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_f_p_char_int_double__bool = {"_p_f_p_char_int_double__bool", "_ProgressCancelHandler *|bool (*)(char *,int,double)", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};

static swig_type_info *swig_type_initial[] = {
  &_swigt__p__THyPhy,
  &_swigt__p__THyPhyMatrix,
  &_swigt__p__THyPhyNumber,
  &_swigt__p__THyPhyReturnObject,
  &_swigt__p__THyPhyString,
  &_swigt__p_char,
  &_swigt__p_double,
  &_swigt__p_f_p_char_int_double__bool,
  &_swigt__p_void,
};

static swig_cast_info _swigc__p__THyPhy[] = {  {&_swigt__p__THyPhy, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p__THyPhyMatrix[] = {  {&_swigt__p__THyPhyMatrix, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p__THyPhyNumber[] = {  {&_swigt__p__THyPhyNumber, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p__THyPhyReturnObject[] = {  {&_swigt__p__THyPhyReturnObject, 0, 0, 0},  {&_swigt__p__THyPhyNumber, _p__THyPhyNumberTo_p__THyPhyReturnObject, 0, 0},  {&_swigt__p__THyPhyMatrix, _p__THyPhyMatrixTo_p__THyPhyReturnObject, 0, 0},  {&_swigt__p__THyPhyString, _p__THyPhyStringTo_p__THyPhyReturnObject, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p__THyPhyString[] = {  {&_swigt__p__THyPhyString, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_double[] = {  {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_f_p_char_int_double__bool[] = {  {&_swigt__p_f_p_char_int_double__bool, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = {  {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};

static swig_cast_info *swig_cast_initial[] = {
  _swigc__p__THyPhy,
  _swigc__p__THyPhyMatrix,
  _swigc__p__THyPhyNumber,
  _swigc__p__THyPhyReturnObject,
  _swigc__p__THyPhyString,
  _swigc__p_char,
  _swigc__p_double,
  _swigc__p_f_p_char_int_double__bool,
  _swigc__p_void,
};


/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */


/* -----------------------------------------------------------------------------
 * Type initialization:
 * 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 
 * 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 
 * 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
 * cast linked list. The cast data is initially stored in something like a
 * two-dimensional array. Each row corresponds to a type (there are the same
 * number of rows as there are in the swig_type_initial array). Each entry in
 * 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 
 * 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. 
 * 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 
 *     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
 *     swig_cast_info to the linked list (because the cast->type) pointer will
 *     be correct.
 * ----------------------------------------------------------------------------- */

#ifdef __cplusplus
extern "C" {
#if 0
} /* c-mode */
#endif
#endif

#if 0
#define SWIGRUNTIME_DEBUG
#endif


SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
  size_t i;
  swig_module_info *module_head, *iter;
  int found, init;

  clientdata = clientdata;

  /* check to see if the circular list has been setup, if not, set it up */
  if (swig_module.next==0) {
    /* Initialize the swig_module */
    swig_module.type_initial = swig_type_initial;
    swig_module.cast_initial = swig_cast_initial;
    swig_module.next = &swig_module;
    init = 1;
  } else {
    init = 0;
  }

  /* Try and load any already created modules */
  module_head = SWIG_GetModule(clientdata);
  if (!module_head) {
    /* 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;
      }
      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 */
    swig_module.next = module_head->next;
    module_head->next = &swig_module;
  }

  /* When multiple interpeters 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 */
  if (init == 0) return;

  /* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
#endif
  for (i = 0; i < swig_module.size; ++i) {
    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

    /* if there is another module already loaded */
    if (swig_module.next != &swig_module) {
      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
    }
    if (type) {
      /* Overwrite clientdata field */
#ifdef SWIGRUNTIME_DEBUG
      printf("SWIG_InitializeModule: found type %s\n", type->name);
#endif
      if (swig_module.type_initial[i]->clientdata) {
	type->clientdata = swig_module.type_initial[i]->clientdata;
#ifdef SWIGRUNTIME_DEBUG
      printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
#endif
      }
    } else {
      type = swig_module.type_initial[i];
    }

    /* 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
      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
#endif
      if (swig_module.next != &swig_module) {
        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
#ifdef SWIGRUNTIME_DEBUG
	if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
#endif
      }
      if (ret) {
	if (type == swig_module.type_initial[i]) {
#ifdef SWIGRUNTIME_DEBUG
	  printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
#endif
	  cast->type = ret;
	  ret = 0;
	} else {
	  /* Check for casting already in the list */
	  swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
#ifdef SWIGRUNTIME_DEBUG
	  if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
#endif
	  if (!ocast) ret = 0;
	}
      }

      if (!ret) {
#ifdef SWIGRUNTIME_DEBUG
	printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
#endif
        if (type->cast) {
          type->cast->prev = cast;
          cast->next = type->cast;
        }
        type->cast = cast;
      }
      cast++;
    }
    /* Set entry in modules->types array equal to the type */
    swig_module.types[i] = type;
  }
  swig_module.types[i] = 0;

#ifdef SWIGRUNTIME_DEBUG
  printf("**** SWIG_InitializeModule: Cast List ******\n");
  for (i = 0; i < swig_module.size; ++i) {
    int j = 0;
    swig_cast_info *cast = swig_module.cast_initial[i];
    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
    while (cast->type) {
      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
      cast++;
      ++j;
    }
  printf("---- Total casts: %d\n",j);
  }
  printf("**** SWIG_InitializeModule: Cast List ******\n");
#endif
}

/* This function will propagate the clientdata field of type to
* any new swig_type_info structures that have been added into the list
* of equivalent types.  It is like calling
* SWIG_TypeClientData(type, clientdata) a second time.
*/
SWIGRUNTIME void
SWIG_PropagateClientData(void) {
  size_t i;
  swig_cast_info *equiv;
  static int init_run = 0;

  if (init_run) return;
  init_run = 1;

  for (i = 0; i < swig_module.size; i++) {
    if (swig_module.types[i]->clientdata) {
      equiv = swig_module.types[i]->cast;
      while (equiv) {
        if (!equiv->converter) {
          if (equiv->type && !equiv->type->clientdata)
            SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
        }
        equiv = equiv->next;
      }
    }
  }
}

#ifdef __cplusplus
#if 0
{ /* c-mode */
#endif
}
#endif


SWIGEXPORT void SWIG_init(void) {

}
#ifdef __cplusplus
extern "C" {
#endif

#include <R_ext/Rdynload.h>

#ifdef __cplusplus
}
#endif

SWIGINTERN R_CallMethodDef CallEntries[] = {
   {"R_swig_new__THyPhy__SWIG_1", (DL_FUNC) &R_swig_new__THyPhy__SWIG_1, 2},
   {"R_swig_new__THyPhyMatrix__SWIG_1", (DL_FUNC) &R_swig_new__THyPhyMatrix__SWIG_1, 3},
   {"R_swig_new__THyPhyNumber__SWIG_1", (DL_FUNC) &R_swig_new__THyPhyNumber__SWIG_1, 0},
   {"R_swig_new__THyPhyString__SWIG_1", (DL_FUNC) &R_swig_new__THyPhyString__SWIG_1, 1},
   {"R_swig__THyPhy_ExecuteBF__SWIG_1", (DL_FUNC) &R_swig__THyPhy_ExecuteBF__SWIG_1, 2},
   {"R_swig__THyPhyGetLongStatus", (DL_FUNC) &R_swig__THyPhyGetLongStatus, 1},
   {"R_swig__THyPhyGetStringStatus", (DL_FUNC) &R_swig__THyPhyGetStringStatus, 0},
   {"R_swig__THyPhyGetDoubleStatus", (DL_FUNC) &R_swig__THyPhyGetDoubleStatus, 1},
   {"R_swig_delete__THyPhyMatrix", (DL_FUNC) &R_swig_delete__THyPhyMatrix, 1},
   {"R_swig__THyPhyReturnObject_castToMatrix", (DL_FUNC) &R_swig__THyPhyReturnObject_castToMatrix, 1},
   {"R_swig_new__THyPhy__SWIG_2", (DL_FUNC) &R_swig_new__THyPhy__SWIG_2, 2},
   {"R_swig_new__THyPhyString__SWIG_2", (DL_FUNC) &R_swig_new__THyPhyString__SWIG_2, 0},
   {"R_swig_new__THyPhy__SWIG_3", (DL_FUNC) &R_swig_new__THyPhy__SWIG_3, 1},
   {"R_swig__THyPhyMatrix_mRows_get", (DL_FUNC) &R_swig__THyPhyMatrix_mRows_get, 2},
   {"R_swig_globalInterfaceInstance_get", (DL_FUNC) &R_swig_globalInterfaceInstance_get, 0},
   {"R_swig__THyPhyMatrix_mCols_get", (DL_FUNC) &R_swig__THyPhyMatrix_mCols_get, 2},
   {"R_swig__THyPhy_GetStdout", (DL_FUNC) &R_swig__THyPhy_GetStdout, 1},
   {"R_swig__THyPhyMatrix_mRows_set", (DL_FUNC) &R_swig__THyPhyMatrix_mRows_set, 2},
   {"R_swig_globalInterfaceInstance_set", (DL_FUNC) &R_swig_globalInterfaceInstance_set, 1},
   {"R_swig__THyPhyMatrix_mCols_set", (DL_FUNC) &R_swig__THyPhyMatrix_mCols_set, 2},
   {"R_swig__THyPhy_AskFor", (DL_FUNC) &R_swig__THyPhy_AskFor, 2},
   {"R_swig__THyPhyMatrix_MatrixCell", (DL_FUNC) &R_swig__THyPhyMatrix_MatrixCell, 4},
   {"R_swig_delete__THyPhyReturnObject", (DL_FUNC) &R_swig_delete__THyPhyReturnObject, 1},
   {"R_swig__THyPhy_CanCast", (DL_FUNC) &R_swig__THyPhy_CanCast, 4},
   {"R_swig__THyPhyMatrix_mData_get", (DL_FUNC) &R_swig__THyPhyMatrix_mData_get, 1},
   {"R_swig__THyPhyString_sData_get", (DL_FUNC) &R_swig__THyPhyString_sData_get, 1},
   {"R_swig__THyPhy_PushWarning", (DL_FUNC) &R_swig__THyPhy_PushWarning, 2},
   {"R_swig__THyPhy_PushOutString", (DL_FUNC) &R_swig__THyPhy_PushOutString, 2},
   {"R_swig__THyPhyMatrix_myType", (DL_FUNC) &R_swig__THyPhyMatrix_myType, 2},
   {"R_swig__THyPhyNumber_myType", (DL_FUNC) &R_swig__THyPhyNumber_myType, 2},
   {"R_swig__THyPhyReturnObject_myType", (DL_FUNC) &R_swig__THyPhyReturnObject_myType, 2},
   {"R_swig__THyPhyString_myType", (DL_FUNC) &R_swig__THyPhyString_myType, 2},
   {"R_swig__THyPhy_InitTHyPhy", (DL_FUNC) &R_swig__THyPhy_InitTHyPhy, 4},
   {"R_swig__THyPhy_SetCallbackHandler", (DL_FUNC) &R_swig__THyPhy_SetCallbackHandler, 2},
   {"R_swig__THyPhy_GetCallbackHandler", (DL_FUNC) &R_swig__THyPhy_GetCallbackHandler, 1},
   {"R_swig__THyPhyMatrix_mData_set", (DL_FUNC) &R_swig__THyPhyMatrix_mData_set, 2},
   {"R_swig__THyPhyString_sData_set", (DL_FUNC) &R_swig__THyPhyString_sData_set, 2},
   {"R_swig_delete__THyPhyNumber", (DL_FUNC) &R_swig_delete__THyPhyNumber, 1},
   {"R_swig__THyPhyReturnObject_castToNumber", (DL_FUNC) &R_swig__THyPhyReturnObject_castToNumber, 1},
   {"R_swig__THyPhy_ClearAll", (DL_FUNC) &R_swig__THyPhy_ClearAll, 1},
   {"R_swig__THyPhy_GetWarnings", (DL_FUNC) &R_swig__THyPhy_GetWarnings, 1},
   {"R_swig__THyPhyString_sLength_get", (DL_FUNC) &R_swig__THyPhyString_sLength_get, 2},
   {"R_swig__THyPhyReturnObject_castToString", (DL_FUNC) &R_swig__THyPhyReturnObject_castToString, 1},
   {"R_swig_delete__THyPhyString", (DL_FUNC) &R_swig_delete__THyPhyString, 1},
   {"R_swig__THyPhyString_sLength_set", (DL_FUNC) &R_swig__THyPhyString_sLength_set, 2},
   {"R_swig_delete__THyPhy", (DL_FUNC) &R_swig_delete__THyPhy, 1},
   {"R_swig__THyPhy_PushError", (DL_FUNC) &R_swig__THyPhy_PushError, 2},
   {"R_swig__THyPhyNumber_nValue_get", (DL_FUNC) &R_swig__THyPhyNumber_nValue_get, 2},
   {"R_swig__THyPhy_DumpResult", (DL_FUNC) &R_swig__THyPhy_DumpResult, 2},
   {"R_swig__THyPhy_CastResult", (DL_FUNC) &R_swig__THyPhy_CastResult, 3},
   {"R_swig__THyPhy_GetErrors", (DL_FUNC) &R_swig__THyPhy_GetErrors, 1},
   {"R_swig_new__THyPhy__SWIG_0", (DL_FUNC) &R_swig_new__THyPhy__SWIG_0, 3},
   {"R_swig_new__THyPhyMatrix__SWIG_0", (DL_FUNC) &R_swig_new__THyPhyMatrix__SWIG_0, 0},
   {"R_swig_new__THyPhyNumber__SWIG_0", (DL_FUNC) &R_swig_new__THyPhyNumber__SWIG_0, 1},
   {"R_swig_new__THyPhyString__SWIG_0", (DL_FUNC) &R_swig_new__THyPhyString__SWIG_0, 2},
   {"R_swig__THyPhyNumber_nValue_set", (DL_FUNC) &R_swig__THyPhyNumber_nValue_set, 2},
   {"R_swig__THyPhy_ExecuteBF__SWIG_0", (DL_FUNC) &R_swig__THyPhy_ExecuteBF__SWIG_0, 3},
   {NULL, NULL, 0}
};

extern "C" SWIGEXPORT void R_init_HyPhy(DllInfo *dll) {
    R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);


SWIG_init();
SWIG_InitializeModule(0);


}

