Drop support for guile 1.6 and older

This commit is contained in:
Geert Janssens 2013-04-19 12:49:40 +02:00
commit 3c47730803
4 changed files with 30 additions and 155 deletions

View file

@ -12,6 +12,7 @@
<!-- INDEX --> <!-- INDEX -->
<div class="sectiontoc"> <div class="sectiontoc">
<ul> <ul>
<li><a href="#Guile_nn1">Supported Guile Versions</a>
<li><a href="#Guile_nn2">Meaning of "Module"</a> <li><a href="#Guile_nn2">Meaning of "Module"</a>
<li><a href="#Guile_nn3">Using the SCM or GH Guile API</a> <li><a href="#Guile_nn3">Using the SCM or GH Guile API</a>
<li><a href="#Guile_nn4">Linkage</a> <li><a href="#Guile_nn4">Linkage</a>
@ -47,7 +48,15 @@
<p> <p>
This section details guile-specific support in SWIG. This section details guile-specific support in SWIG.
<H2><a name="Guile_nn2"></a>23.1 Meaning of "Module"</H2> <H2><a name="Guile_nn1"></a>23.1 Supported Guile Versions</H2>
<p>
SWIG works with Guile versions 1.8.x and 2.0.x. Support for version
1.6.x has been dropped. The last version of SWIG that still works with
Guile version 1.6.x is SWIG 2.0.9.
<H2><a name="Guile_nn2"></a>23.2 Meaning of "Module"</H2>
<p> <p>
@ -55,7 +64,7 @@ There are three different concepts of "module" involved, defined
separately for SWIG, Guile, and Libtool. To avoid horrible confusion, separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
we explicitly prefix the context, e.g., "guile-module". we explicitly prefix the context, e.g., "guile-module".
<H2><a name="Guile_nn3"></a>23.2 Using the SCM or GH Guile API</H2> <H2><a name="Guile_nn3"></a>23.3 Using the SCM or GH Guile API</H2>
<p>The guile module can currently export wrapper files that use the guile GH interface or the <p>The guile module can currently export wrapper files that use the guile GH interface or the
@ -103,7 +112,7 @@ for the specific API. Currently only the guile language module has created a ma
but there is no reason other languages (like mzscheme or chicken) couldn't also use this. but there is no reason other languages (like mzscheme or chicken) couldn't also use this.
If that happens, there is A LOT less code duplication in the standard typemaps.</p> If that happens, there is A LOT less code duplication in the standard typemaps.</p>
<H2><a name="Guile_nn4"></a>23.3 Linkage</H2> <H2><a name="Guile_nn4"></a>23.4 Linkage</H2>
<p> <p>
@ -111,7 +120,7 @@ Guile support is complicated by a lack of user community cohesiveness,
which manifests in multiple shared-library usage conventions. A set of which manifests in multiple shared-library usage conventions. A set of
policies implementing a usage convention is called a <b>linkage</b>. policies implementing a usage convention is called a <b>linkage</b>.
<H3><a name="Guile_nn5"></a>23.3.1 Simple Linkage</H3> <H3><a name="Guile_nn5"></a>23.4.1 Simple Linkage</H3>
<p> <p>
@ -206,7 +215,7 @@ placed between the <code>define-module</code> form and the
<code>SWIG_init</code> via a preprocessor define to avoid symbol <code>SWIG_init</code> via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available. clashes. For this case, however, passive linkage is available.
<H3><a name="Guile_nn6"></a>23.3.2 Passive Linkage</H3> <H3><a name="Guile_nn6"></a>23.4.2 Passive Linkage</H3>
<p>Passive linkage is just like simple linkage, but it generates an <p>Passive linkage is just like simple linkage, but it generates an
@ -216,7 +225,7 @@ package name (see below).
<p>You should use passive linkage rather than simple linkage when you <p>You should use passive linkage rather than simple linkage when you
are using multiple modules. are using multiple modules.
<H3><a name="Guile_nn7"></a>23.3.3 Native Guile Module Linkage</H3> <H3><a name="Guile_nn7"></a>23.4.3 Native Guile Module Linkage</H3>
<p>SWIG can also generate wrapper code that does all the Guile module <p>SWIG can also generate wrapper code that does all the Guile module
@ -257,7 +266,7 @@ Newer Guile versions have a shorthand procedure for this:
</div> </div>
</ul> </ul>
<H3><a name="Guile_nn8"></a>23.3.4 Old Auto-Loading Guile Module Linkage</H3> <H3><a name="Guile_nn8"></a>23.4.4 Old Auto-Loading Guile Module Linkage</H3>
<p>Guile used to support an autoloading facility for object-code <p>Guile used to support an autoloading facility for object-code
@ -283,7 +292,7 @@ option, SWIG generates an exported module initialization function with
an appropriate name. an appropriate name.
<H3><a name="Guile_nn9"></a>23.3.5 Hobbit4D Linkage</H3> <H3><a name="Guile_nn9"></a>23.4.5 Hobbit4D Linkage</H3>
<p> <p>
@ -308,7 +317,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
experimental; the (hobbit4d link) conventions are not well understood. experimental; the (hobbit4d link) conventions are not well understood.
</p> </p>
<H2><a name="Guile_nn10"></a>23.4 Underscore Folding</H2> <H2><a name="Guile_nn10"></a>23.5 Underscore Folding</H2>
<p> <p>
@ -320,7 +329,7 @@ complained so far.
<code>%rename</code> to specify the Guile name of the wrapped <code>%rename</code> to specify the Guile name of the wrapped
functions and variables (see CHANGES). functions and variables (see CHANGES).
<H2><a name="Guile_nn11"></a>23.5 Typemaps</H2> <H2><a name="Guile_nn11"></a>23.6 Typemaps</H2>
<p> <p>
@ -412,7 +421,7 @@ constant will appear as a scheme variable. See
<a href="Customization.html#Customization_features">Features and the %feature directive</a> <a href="Customization.html#Customization_features">Features and the %feature directive</a>
for info on how to apply the %feature.</p> for info on how to apply the %feature.</p>
<H2><a name="Guile_nn12"></a>23.6 Representation of pointers as smobs</H2> <H2><a name="Guile_nn12"></a>23.7 Representation of pointers as smobs</H2>
<p> <p>
@ -433,7 +442,7 @@ representing the expected pointer type. See also
If the Scheme object passed was not a SWIG smob representing a compatible If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a <code>wrong-type-arg</code> exception is raised. pointer, a <code>wrong-type-arg</code> exception is raised.
<H3><a name="Guile_nn13"></a>23.6.1 GH Smobs</H3> <H3><a name="Guile_nn13"></a>23.7.1 GH Smobs</H3>
<p> <p>
@ -462,7 +471,7 @@ 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 Once we have a swig_type_info structure, we loop through the linked list of
casts, using pointer comparisons.</p> casts, using pointer comparisons.</p>
<H3><a name="Guile_nn14"></a>23.6.2 SCM Smobs</H3> <H3><a name="Guile_nn14"></a>23.7.2 SCM Smobs</H3>
<p>The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. <p>The SCM interface (using the "-scm" argument to swig) uses swigrun.swg.
@ -477,7 +486,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra
GOOPS class.</p> GOOPS class.</p>
<H3><a name="Guile_nn15"></a>23.6.3 Garbage Collection</H3> <H3><a name="Guile_nn15"></a>23.7.3 Garbage Collection</H3>
<p>Garbage collection is a feature of the new SCM interface, and it is automatically included <p>Garbage collection is a feature of the new SCM interface, and it is automatically included
@ -491,7 +500,7 @@ is exactly like described in <a href="Customization.html#Customization_ownership
Object ownership and %newobject</a> in the SWIG manual. All typemaps use an $owner var, and Object ownership and %newobject</a> in the SWIG manual. All typemaps use an $owner var, and
the guile module replaces $owner with 0 or 1 depending on feature:new.</p> the guile module replaces $owner with 0 or 1 depending on feature:new.</p>
<H2><a name="Guile_nn16"></a>23.7 Exception Handling</H2> <H2><a name="Guile_nn16"></a>23.8 Exception Handling</H2>
<p> <p>
@ -517,7 +526,7 @@ mapping:
The default when not specified here is to use "swig-error". The default when not specified here is to use "swig-error".
See Lib/exception.i for details. See Lib/exception.i for details.
<H2><a name="Guile_nn17"></a>23.8 Procedure documentation</H2> <H2><a name="Guile_nn17"></a>23.9 Procedure documentation</H2>
<p>If invoked with the command-line option <code>-procdoc <p>If invoked with the command-line option <code>-procdoc
@ -553,7 +562,7 @@ like this:
typemap argument <code>doc</code>. See <code>Lib/guile/typemaps.i</code> for typemap argument <code>doc</code>. See <code>Lib/guile/typemaps.i</code> for
details. details.
<H2><a name="Guile_nn18"></a>23.9 Procedures with setters</H2> <H2><a name="Guile_nn18"></a>23.10 Procedures with setters</H2>
<p>For global variables, SWIG creates a single wrapper procedure <p>For global variables, SWIG creates a single wrapper procedure
@ -581,7 +590,7 @@ struct members, the procedures <code>(<var>struct</var>-<var>member</var>-get
pointer)</code> and <code>(<var>struct-member</var>-set pointer pointer)</code> and <code>(<var>struct-member</var>-set pointer
value)</code> are <em>not</em> generated. value)</code> are <em>not</em> generated.
<H2><a name="Guile_nn19"></a>23.10 GOOPS Proxy Classes</H2> <H2><a name="Guile_nn19"></a>23.11 GOOPS Proxy Classes</H2>
<p>SWIG can also generate classes and generic functions for use with <p>SWIG can also generate classes and generic functions for use with
@ -730,7 +739,7 @@ Notice that &lt;Foo&gt; is used before it is defined. The fix is to just put th
<code>%import "foo.h"</code> before the <code>%inline</code> block. <code>%import "foo.h"</code> before the <code>%inline</code> block.
</p> </p>
<H3><a name="Guile_nn20"></a>23.10.1 Naming Issues</H3> <H3><a name="Guile_nn20"></a>23.11.1 Naming Issues</H3>
<p>As you can see in the example above, there are potential naming conflicts. The default exported <p>As you can see in the example above, there are potential naming conflicts. The default exported
@ -767,7 +776,7 @@ guile-modules. For example,</p>
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
</pre></div> </pre></div>
<H3><a name="Guile_nn21"></a>23.10.2 Linking</H3> <H3><a name="Guile_nn21"></a>23.11.2 Linking</H3>
<p>The guile-modules generated above all need to be linked together. GOOPS support requires <p>The guile-modules generated above all need to be linked together. GOOPS support requires

View file

@ -1,47 +1,3 @@
#ifdef GUILE_VERSION_1_6
#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED))
#define gh_apply(a, b) scm_apply(a, b, SCM_EOL)
#define gh_bool2scm SCM_BOOL
#define gh_boolean_p SCM_BOOLP
#define gh_car SCM_CAR
#define gh_cdr SCM_CDR
#define gh_cons scm_cons
#define gh_double2scm scm_make_real
#define gh_int2scm scm_long2num
#define gh_length(lst) scm_num2ulong(scm_length(lst), SCM_ARG1, FUNC_NAME)
#define gh_list scm_listify
#define gh_list_to_vector scm_vector
#define gh_make_vector scm_make_vector
#define gh_null_p SCM_NULLP
#define gh_number_p SCM_NUMBERP
#define gh_pair_p SCM_CONSP
#define gh_scm2bool SCM_NFALSEP
#define gh_scm2char SCM_CHAR
#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME)
#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2short(a) scm_num2short(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2newstr SWIG_Guile_scm2newstr
#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2ushort(a) scm_num2ushort(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2uint(a) scm_num2uint(a, SCM_ARG1, FUNC_NAME)
#define gh_ulong2scm scm_ulong2num
#define gh_long2scm scm_long2num
#define gh_str02scm scm_makfrom0str
#define gh_long_long2scm scm_long_long2num
#define gh_scm2long_long(a) scm_num2long_long(a, SCM_ARG1, FUNC_NAME)
#define gh_ulong_long2scm scm_ulong_long2num
#define gh_scm2ulong_long(a) scm_num2ulong_long(a, SCM_ARG1, FUNC_NAME)
#define gh_string_p SCM_STRINGP
#define gh_vector_length SCM_VECTOR_LENGTH
#define gh_vector_p SCM_VECTORP
#define gh_vector_ref scm_vector_ref
#define gh_vector_set_x scm_vector_set_x
#define gh_char2scm SCM_MAKE_CHAR
#else
#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) #define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED))
#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) #define gh_apply(a, b) scm_apply(a, b, SCM_EOL)
#define gh_bool2scm scm_from_bool #define gh_bool2scm scm_from_bool
@ -81,5 +37,3 @@
#define gh_vector_ref scm_vector_ref #define gh_vector_ref scm_vector_ref
#define gh_vector_set_x scm_vector_set_x #define gh_vector_set_x scm_vector_set_x
#define gh_char2scm SCM_MAKE_CHAR #define gh_char2scm SCM_MAKE_CHAR
#endif

View file

@ -19,22 +19,7 @@ extern "C" {
/* In the code below, use guile 2.0 compatible functions where possible. /* In the code below, use guile 2.0 compatible functions where possible.
Functions that don't exist in older versions will be mapped to Functions that don't exist in older versions will be mapped to
a deprecated equivalent for those versions only */ a deprecated equivalent for those versions only */
/* ... setup guile 2-like interface for guile 1.6 */ /* ... setup guile 2-like interface for guile 1.8 */
#if (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 6)
# define scm_from_locale_keyword scm_c_make_keyword
# define scm_from_locale_symbol scm_str2symbol
# define scm_is_null SCM_NULLP
# define scm_is_true SCM_NFALSEP
# define scm_is_string SCM_STRINGP
/* Used later on to setup different code paths where it's
not possible to use a guile 2-like interface */
# define GUILE_VERSION_1_6
#endif
/* ... setup guile 2-like interface for guile 1.6 and 1.8 */
#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) #if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2)
static SCM static SCM

View file

@ -16,22 +16,6 @@ extern "C" {
/* In the code below, use guile 2.0 compatible functions where possible. /* In the code below, use guile 2.0 compatible functions where possible.
Functions that don't exist in older versions will be mapped to Functions that don't exist in older versions will be mapped to
a deprecated equivalent for those versions only */ a deprecated equivalent for those versions only */
/* ... setup guile 2-like interface for guile 1.6 */
#if (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 6)
# define scm_from_locale_keyword scm_c_make_keyword
# define scm_from_locale_symbol scm_str2symbol
# define scm_is_null SCM_NULLP
# define scm_is_true SCM_NFALSEP
# define scm_is_string SCM_STRINGP
/* Used later on to setup different code paths where it's
not possible to use a guile 2-like interface */
# define GUILE_VERSION_1_6
#endif
/* ... setup guile 2-like interface for guile 1.6 and 1.8 */
#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) #if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2)
static SCM static SCM
@ -59,17 +43,10 @@ typedef struct swig_guile_clientdata {
#define SWIG_scm2str(s) \ #define SWIG_scm2str(s) \
SWIG_Guile_scm2newstr(s, NULL) SWIG_Guile_scm2newstr(s, NULL)
#ifdef GUILE_VERSION_1_6
# define SWIG_malloc(size) \
SCM_MUST_MALLOC(size)
# define SWIG_free(mem) \
scm_must_free(mem)
#else
# define SWIG_malloc(size) \ # define SWIG_malloc(size) \
scm_malloc(size) scm_malloc(size)
# define SWIG_free(mem) \ # define SWIG_free(mem) \
free(mem) free(mem)
#endif
#define SWIG_ConvertPtr(s, result, type, flags) \ #define SWIG_ConvertPtr(s, result, type, flags) \
SWIG_Guile_ConvertPtr(s, result, type, flags) SWIG_Guile_ConvertPtr(s, result, type, flags)
#define SWIG_MustGetPtr(s, type, argnum, flags) \ #define SWIG_MustGetPtr(s, type, argnum, flags) \
@ -105,9 +82,7 @@ SWIGINTERN char *
SWIG_Guile_scm2newstr(SCM str, size_t *len) { SWIG_Guile_scm2newstr(SCM str, size_t *len) {
#define FUNC_NAME "SWIG_Guile_scm2newstr" #define FUNC_NAME "SWIG_Guile_scm2newstr"
char *ret; char *ret;
# ifndef GUILE_VERSION_1_6
char *tmp; char *tmp;
# endif
size_t l; size_t l;
SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME);
@ -116,13 +91,9 @@ SWIG_Guile_scm2newstr(SCM str, size_t *len) {
ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
if (!ret) return NULL; if (!ret) return NULL;
# ifdef GUILE_VERSION_1_6
memcpy(ret, SCM_STRING_CHARS(str), l);
# else
tmp = scm_to_locale_string(str); tmp = scm_to_locale_string(str);
memcpy(ret, tmp, l); memcpy(ret, tmp, l);
free(tmp); free(tmp);
# endif
ret[l] = '\0'; ret[l] = '\0';
if (len) *len = l; if (len) *len = l;
@ -415,22 +386,6 @@ ensure_smob_tag(SCM swig_module,
const char *smob_name, const char *smob_name,
const char *scheme_variable_name) const char *scheme_variable_name)
{ {
#ifdef GUILE_VERSION_1_6
SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name),
scm_module_lookup_closure(swig_module),
SCM_BOOL_T);
if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
*tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0);
SCM_VARIABLE_SET(variable,
scm_ulong2num(*tag_variable));
return 1;
}
else {
*tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0,
"SWIG_Guile_Init");
return 0;
}
#else
SCM variable = scm_module_variable(swig_module, SCM variable = scm_module_variable(swig_module,
scm_from_locale_symbol(scheme_variable_name)); scm_from_locale_symbol(scheme_variable_name));
if (scm_is_false(variable)) { if (scm_is_false(variable)) {
@ -443,7 +398,6 @@ ensure_smob_tag(SCM swig_module,
*tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable));
return 0; return 0;
} }
#endif
} }
SWIGINTERN SCM SWIGINTERN SCM
@ -495,16 +449,6 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
module = SWIG_Guile_Init(); module = SWIG_Guile_Init();
#ifdef GUILE_VERSION_1_6
variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
scm_module_lookup_closure(module),
SCM_BOOL_T);
if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
return NULL;
} else {
return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init");
}
#else
variable = scm_module_variable(module, variable = scm_module_variable(module,
scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME));
if (scm_is_false(variable)) { if (scm_is_false(variable)) {
@ -512,7 +456,6 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
} else { } else {
return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable));
} }
#endif
} }
SWIGINTERN void SWIGINTERN void
@ -523,17 +466,9 @@ SWIG_Guile_SetModule(swig_module_info *swig_module)
module = SWIG_Guile_Init(); module = SWIG_Guile_Init();
#ifdef GUILE_VERSION_1_6
variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
scm_module_lookup_closure(module),
SCM_BOOL_T);
SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module));
#else
scm_module_define(module, scm_module_define(module,
scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
scm_from_ulong((unsigned long) swig_module)); scm_from_ulong((unsigned long) swig_module));
#endif
} }
SWIGINTERN int SWIGINTERN int
@ -545,11 +480,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
int num_args_passed = 0; int num_args_passed = 0;
for (i = 0; i<reqargs; i++) { for (i = 0; i<reqargs; i++) {
if (!SCM_CONSP(rest)) if (!SCM_CONSP(rest))
#ifdef GUILE_VERSION_1_6
scm_wrong_num_args(scm_makfrom0str((char *) procname));
#else
scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure")); scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
#endif
*dest++ = SCM_CAR(rest); *dest++ = SCM_CAR(rest);
rest = SCM_CDR(rest); rest = SCM_CDR(rest);
num_args_passed++; num_args_passed++;
@ -562,11 +493,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
for (; i<optargs; i++) for (; i<optargs; i++)
*dest++ = SCM_UNDEFINED; *dest++ = SCM_UNDEFINED;
if (!SCM_NULLP(rest)) if (!SCM_NULLP(rest))
#ifdef GUILE_VERSION_1_6
scm_wrong_num_args(scm_makfrom0str((char *) procname));
#else
scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure")); scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
#endif
return num_args_passed; return num_args_passed;
} }