Guile Module Changes

Updating to swigrun.swg

The changes to swigrun.swg cause an incompatibility in the guile-gh module. There are actually two ways to update the module so that it works.

As of January 31, 2005 the guile-gh-other.patch has been committed into CVS. I will leave this page up for reference for a while, but for the latest code and the latest documentation, see the current SWIG CVS

I have been working to upgrade guile to use swigrun.swg. Previously, the argument against swigrun.swg was that swigrun.swg uses a strcmp() function call to check if a type is equal to a cast while currently guile uses a pointer comparison, which is faster. Well, my changes to the swig type system now allow for comparing the casting types using a pointer comparison (see the SWIG_TypeCheckStruct() function in swigrun.swg).

This patch is no longer as critical, since the SCM wrapper supports the new features like GOOPS and garbage collection. It is mainly here now as a cleanup and update of the code only to be applied if my changes to swigrun.swg ever get merged.

The following paragraph should be added to Doc/Manual/Guile.html when this patch is applied.

Every module creates its own smob type and stores the tag value returned from scm_make_smob_type_mfpe() in the clientdata field of the module. So the lower 16 bits of the car of the smob store the tag and the upper 16 bits store the index this type is in the array. We can then, given a smob, find its swig_type_info struct by using the tag (lower 16 bits of car) to find which module this type is in (since each tag is unique for the module). Then we use the upper 16 bits to index into the array of types attached to this module. Looking up the module from the tag is worst case O(# of modules) but average case O(1). This is because the modules are stored in a circularly linked list, and when we start searching the modules for the tag, we start looking with the module that the function doing the lookup is in. SWIG_Guile_ConvertPtr() takes as its first argument the swig_module_info * of the calling function, which is where we start comparing tags. Most types will be looked up in the same module that created them, so the first module we check will most likely be correct. Once we have a swig_type_info structure, we loop through the linked list of casts, using pointer comparisons.

Goops

Todo:

Patches


Last updated Monday January 31, 2004