Fix a few bugs in the tcl module related to clientdata propagation.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6357 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
John Lenz 2004-10-07 02:31:14 +00:00
commit 143bfb2a62
16 changed files with 257 additions and 63 deletions

View file

@ -62,6 +62,7 @@ SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *);
SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *);
SWIGIMPORT(char *) SWIG_PackData(char *, void *, int);
SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int);
SWIGIMPORT(void) SWIG_PropagateClientData(swig_type_info *type);
#else
@ -77,7 +78,7 @@ SWIG_TypeRegister(swig_type_info *ti) {
while (tc) {
if (strcmp(tc->name, ti->name) == 0) {
/* Already exists in the table. Just add additional types to the list */
if (tc->clientdata) ti->clientdata = tc->clientdata;
if (ti->clientdata) tc->clientdata = ti->clientdata;
head = tc;
next = tc->next;
goto l1;
@ -104,6 +105,7 @@ SWIG_TypeRegister(swig_type_info *ti) {
}
if (next) next->prev = head;
head->next = next;
return ret;
}
@ -285,6 +287,29 @@ SWIG_UnpackData(char *c, void *ptr, size_t sz) {
return c;
}
/* 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(swig_type_info *type) {
swig_type_info *equiv = type->next;
swig_type_info *tc;
if (!type->clientdata) return;
while (equiv) {
if (!equiv->converter) {
tc = *swig_type_list_handle;
while (tc) {
if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
SWIG_TypeClientData(tc, type->clientdata);
tc = tc->prev;
}
}
equiv = equiv->next;
}
}
#endif
#ifdef __cplusplus

View file

@ -42,8 +42,6 @@ typedef struct swig_guile_clientdata {
SWIG_Guile_IsPointerOfType(object, type)
#define SWIG_IsPointer(object) \
SWIG_Guile_IsPointer(object)
#define SWIG_PropagateClientData(type) \
SWIG_Guile_PropagateClientData(type)
#define SWIG_contract_assert(expr, msg) \
if (!(expr)) \
scm_error(scm_str2symbol("swig-contract-assertion-failed"), \
@ -67,9 +65,6 @@ SWIGIMPORT(void *) SWIG_Guile_MustGetPtr(SCM s, swig_type_info *type, int argnum
SWIGIMPORT(SCM) SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner);
/* Get arguments from an argument list */
SWIGIMPORT(int) SWIG_Guile_GetArgs(SCM *dest, SCM rest, int reqargs, int optargs, const char *procname);
/* Propagate client data to equivalent types */
SWIGIMPORT(void)
SWIG_Guile_PropagateClientData(swig_type_info *type);
/* Make a pointer object non-collectable */
SWIGIMPORT(void)
SWIG_Guile_MarkPointerNoncollectable(SCM s);
@ -417,29 +412,6 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
return num_args_passed;
}
/* 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_Guile_PropagateClientData(swig_type_info *type) {
swig_type_info *equiv = type->next;
swig_type_info *tc;
if (!type->clientdata) return;
while (equiv) {
if (!equiv->converter) {
tc = swig_type_list;
while (tc) {
if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
SWIG_TypeClientData(tc, type->clientdata);
tc = tc->prev;
}
}
equiv = equiv->next;
}
}
#endif
#ifdef __cplusplus

View file

@ -63,6 +63,7 @@ typedef struct swig_class {
swig_method *methods;
swig_attribute *attributes;
struct swig_class **bases;
char **base_names;
} swig_class;
typedef struct swig_instance {
@ -525,6 +526,11 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
bi = cls_stack_bi[cls_stack_top];
cls = cls_stack[cls_stack_top];
if (bi != -1) {
if (!cls->bases[bi] && cls->base_names[bi]) {
/* lookup and cache the base class */
swig_type_info *info = SWIG_TypeQuery(cls->base_names[bi]);
if (info) cls->bases[bi] = (swig_class *) info->clientdata;
}
cls = cls->bases[bi];
if (cls) {
cls_stack_bi[cls_stack_top]++;

View file

@ -670,6 +670,9 @@ SWIGEXPORT(int) SWIG_init(Tcl_Interp *interp) {
for (i = 0; swig_types_initial[i]; i++) {
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
}
for (i = 0; swig_types_initial[i]; i++) {
SWIG_PropagateClientData(swig_types[i]);
}
_init = 1;
}
for (i = 0; swig_commands[i].name; i++) {