Moved generic type-checking code to common.swg
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@659 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5740349084
commit
3dfabddeee
3 changed files with 142 additions and 234 deletions
139
Lib/common.swg
Normal file
139
Lib/common.swg
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/***********************************************************************
|
||||
* common.swg
|
||||
*
|
||||
* This file contains generic SWIG runtime support for pointer
|
||||
* type checking as well as a few commonly used macros to control
|
||||
* external linkage.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (c) 1999-2000, The University of Chicago
|
||||
*
|
||||
* This file may be freely redistributed without license or fee provided
|
||||
* this copyright message remains intact.
|
||||
************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined(_MSC_VER)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIGSTATICRUNTIME(a) SWIGEXPORT(a)
|
||||
#else
|
||||
#define SWIGSTATICRUNTIME(a) static a
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _swig_type_info {
|
||||
char *name;
|
||||
void *(*converter)(void *);
|
||||
struct _swig_type_info *next;
|
||||
struct _swig_type_info *prev;
|
||||
} _swig_type_info;
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
SWIGEXPORT(_swig_type_info *) SWIG_TypeRegister(_swig_type_info *);
|
||||
SWIGEXPORT(_swig_type_info *) SWIG_TypeCheck(char *c, _swig_type_info *);
|
||||
SWIGEXPORT(void *) SWIG_TypeCast(_swig_type_info *, void *);
|
||||
#else
|
||||
|
||||
static _swig_type_info *swig_types = 0;
|
||||
|
||||
/* Register a type mapping with the type-checking */
|
||||
SWIGSTATICRUNTIME(_swig_type_info *)
|
||||
SWIG_TypeRegister(_swig_type_info *ti)
|
||||
{
|
||||
_swig_type_info *tc, *head, *ret, *next;
|
||||
/* Check to see if this type has already been registered */
|
||||
tc = swig_types;
|
||||
while (tc) {
|
||||
if (strcmp(tc->name, ti->name) == 0) {
|
||||
/* Already exists in the table. Just add additional types to the list */
|
||||
head = tc;
|
||||
next = tc->next;
|
||||
goto l1;
|
||||
}
|
||||
tc = tc->prev;
|
||||
}
|
||||
head = ti;
|
||||
next = 0;
|
||||
|
||||
/* Place in list */
|
||||
ti->prev = swig_types;
|
||||
swig_types = ti;
|
||||
|
||||
/* Build linked lists */
|
||||
l1:
|
||||
ret = head;
|
||||
tc = ti + 1;
|
||||
/* Patch up the rest of the links */
|
||||
while (tc->name) {
|
||||
head->next = tc;
|
||||
tc->prev = head;
|
||||
head = tc;
|
||||
tc++;
|
||||
}
|
||||
head->next = next;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check the typename */
|
||||
SWIGSTATICRUNTIME(_swig_type_info *)
|
||||
SWIG_TypeCheck(char *c, _swig_type_info *ty)
|
||||
{
|
||||
_swig_type_info *s, *temp2;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element always just a name */
|
||||
while (s) {
|
||||
if (strcmp(s->name,c) == 0) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Cast a pointer (needed for C++ inheritance */
|
||||
SWIGSTATICRUNTIME(void *)
|
||||
SWIG_TypeCast(_swig_type_info *ty, void *ptr)
|
||||
{
|
||||
if ((!ty) || (!ty->converter)) return ptr;
|
||||
return (*ty->converter)(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
@ -6,14 +6,8 @@
|
|||
* type checking.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (c) 1999-2000, The University of Chicago
|
||||
*
|
||||
* This file may be freely redistributed without license or fee provided
|
||||
* this copyright message remains intact.
|
||||
************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -21,49 +15,6 @@ extern "C" {
|
|||
#endif
|
||||
#include "Python.h"
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined(_MSC_VER)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIGSTATICRUNTIME(a) SWIGEXPORT(a)
|
||||
#else
|
||||
#define SWIGSTATICRUNTIME(a) static a
|
||||
#endif
|
||||
|
||||
/* Type information structure */
|
||||
|
||||
typedef struct _swig_type_info {
|
||||
char *name;
|
||||
void *(*converter)(void *);
|
||||
struct _swig_type_info *next;
|
||||
struct _swig_type_info *prev;
|
||||
} _swig_type_info;
|
||||
|
||||
/* Constant information structure */
|
||||
typedef struct _swig_const_info {
|
||||
int type;
|
||||
char *name;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
void *pvalue;
|
||||
_swig_type_info **ptype;
|
||||
} _swig_const_info;
|
||||
|
||||
#define SWIG_PY_INT 1
|
||||
#define SWIG_PY_FLOAT 2
|
||||
#define SWIG_PY_STRING 3
|
||||
|
|
@ -73,15 +24,11 @@ typedef struct _swig_const_info {
|
|||
|
||||
SWIGEXPORT(PyObject *) SWIG_newvarlink();
|
||||
SWIGEXPORT(void) SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
|
||||
SWIGEXPORT(_swig_type_info *) SWIG_TypeRegister(_swig_type_info *);
|
||||
SWIGEXPORT(_swig_type_info *) SWIG_TypeCheck(char *, _swig_type_info *);
|
||||
SWIGEXPORT(int) SWIG_ConvertPtr(PyObject *, void **, _swig_type_info *, int);
|
||||
SWIGEXPORT(void) SWIG_MakePtr(char *c, void *, _swig_type_info *);
|
||||
SWIGEXPORT(PyObject *) SWIG_NewPointerObj(void *, _swig_type_info *);
|
||||
SWIGEXPORT(void) SWIG_InstallConstants(PyObject *d, _swig_const_info constants[]);
|
||||
|
||||
/* External declarations when using runtime libraries */
|
||||
|
||||
#else
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -189,76 +136,6 @@ SWIG_addvarlink(PyObject *p, char *name,
|
|||
gv->next = v->vars;
|
||||
v->vars = gv;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Pointer type-checking
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static _swig_type_info *swig_types = 0;
|
||||
|
||||
/* Register type mappings with the type-checker */
|
||||
SWIGSTATICRUNTIME(_swig_type_info *)
|
||||
SWIG_TypeRegister(_swig_type_info *ti) {
|
||||
_swig_type_info *tc, *head, *ret, *next;
|
||||
/* Check to see if this type has already been registered */
|
||||
tc = swig_types;
|
||||
while (tc) {
|
||||
if (strcmp(tc->name, ti->name) == 0) {
|
||||
/* Already exists in the table. Just add additional types to the list */
|
||||
head = tc;
|
||||
next = tc->next;
|
||||
goto l1;
|
||||
}
|
||||
tc = tc->prev;
|
||||
}
|
||||
head = ti;
|
||||
next = 0;
|
||||
|
||||
/* Place in list */
|
||||
ti->prev = swig_types;
|
||||
swig_types = ti;
|
||||
|
||||
/* Build linked lists */
|
||||
l1:
|
||||
ret = head;
|
||||
tc = ti + 1;
|
||||
while (tc->name) {
|
||||
head->next = tc;
|
||||
tc->prev = head;
|
||||
head = tc;
|
||||
tc++;
|
||||
}
|
||||
head->next = next;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check the typename */
|
||||
SWIGSTATICRUNTIME(_swig_type_info *)
|
||||
SWIG_TypeCheck(char *c, _swig_type_info *ty) {
|
||||
_swig_type_info *s;
|
||||
char *sn;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element is always just the name */
|
||||
while (s) {
|
||||
sn = s->name;
|
||||
if ((c == sn) || ((*c == *sn) && (strcmp(sn,c) == 0))) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGSTATICRUNTIME(int)
|
||||
SWIG_ConvertPtr(PyObject *obj, void **ptr, _swig_type_info *ty, int flags) {
|
||||
|
|
@ -336,9 +213,7 @@ cobject:
|
|||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) goto type_error;
|
||||
if (tc->converter) {
|
||||
*ptr = (*tc->converter)((void *) p);
|
||||
}
|
||||
*ptr = SWIG_TypeCast(tc,p);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,129 +1,25 @@
|
|||
/*
|
||||
* $Header$
|
||||
*
|
||||
* swigtcl.swg
|
||||
* swigtcl8.swg
|
||||
*/
|
||||
|
||||
#include <tcl.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define SWIGTCL
|
||||
#define SWIGTCL8
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined(_MSC_VER)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIGSTATICRUNTIME(a) SWIGEXPORT(a)
|
||||
#else
|
||||
#define SWIGSTATICRUNTIME(a) static a
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _swig_type_info {
|
||||
char *name;
|
||||
void *(*converter)(void *);
|
||||
struct _swig_type_info *next;
|
||||
struct _swig_type_info *prev;
|
||||
} _swig_type_info;
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
SWIGEXPORT(_swig_type_info *) SWIG_TypeRegister(_swig_type_info *);
|
||||
SWIGEXPORT(_swig_type_info *) SWIG_TypeCheck(char *c, _swig_type_info *);
|
||||
SWIGEXPORT(int) SWIG_ConvertPtrFromString(Tcl_Interp *, char *, void **, _swig_type_info *);
|
||||
SWIGEXPORT(int) SWIG_ConvertPtr(Tcl_Interp *, Tcl_Obj *, void **, _swig_type_info *);
|
||||
SWIGEXPORT(void) SWIG_MakePtr(char *, void *, _swig_type_info *);
|
||||
SWIGEXPORT(Tcl_Obj *) SWIG_NewPointerObj(void *, _swig_type_info *);
|
||||
SWIGEXPORT(int) SWIG_GetArgs(Tcl_Interp *, int, Tcl_Obj *CONST [], const char *, ...);
|
||||
SWIGEXPORT(char *) SWIG_PointerTypeFromString(char *c);
|
||||
|
||||
#else
|
||||
static _swig_type_info *swig_types = 0;
|
||||
|
||||
/* Register type mappings with the type-checker */
|
||||
SWIGSTATICRUNTIME(_swig_type_info *)
|
||||
SWIG_TypeRegister(_swig_type_info *ti)
|
||||
{
|
||||
_swig_type_info *tc, *head, *ret, *next;
|
||||
/* Check to see if this type has already been registered */
|
||||
tc = swig_types;
|
||||
while (tc) {
|
||||
if (strcmp(tc->name, ti->name) == 0) {
|
||||
/* Already exists in the table. Just add additional types to the list */
|
||||
head = tc;
|
||||
next = tc->next;
|
||||
goto l1;
|
||||
}
|
||||
tc = tc->prev;
|
||||
}
|
||||
head = ti;
|
||||
next = 0;
|
||||
|
||||
/* Place in list */
|
||||
ti->prev = swig_types;
|
||||
swig_types = ti;
|
||||
|
||||
/* Build linked lists */
|
||||
l1:
|
||||
ret = head;
|
||||
tc = ti + 1;
|
||||
/* Patch up the rest of the links */
|
||||
while (tc->name) {
|
||||
head->next = tc;
|
||||
tc->prev = head;
|
||||
head = tc;
|
||||
tc++;
|
||||
}
|
||||
head->next = next;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check the typename */
|
||||
SWIGSTATICRUNTIME(_swig_type_info *)
|
||||
SWIG_TypeCheck(char *c, _swig_type_info *ty)
|
||||
{
|
||||
_swig_type_info *s, *temp2;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element always just a name */
|
||||
while (s) {
|
||||
if (strcmp(s->name,c) == 0) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGSTATICRUNTIME(int)
|
||||
|
|
@ -157,9 +53,7 @@ SWIG_ConvertPtrFromString(Tcl_Interp *interp, char *c, void **ptr, _swig_type_in
|
|||
Tcl_AppendElement(interp, ty->name);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if (tc->converter) {
|
||||
*ptr = (*tc->converter)((void *) p);
|
||||
}
|
||||
*ptr = SWIG_TypeCast(tc,p);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue