commit ce9d1e1c64e3575c0987999263b82741235499e2 Author: Andy Wingo Date: Tue Dec 15 11:40:58 2009 +0100 guile 1.9 compatibility in guile-runtime.c * guile/g-wrap/guile-runtime.c (gw_guile_add_subr_method): In Guile 1.9 it's OK to have a subr as a method procedure, which is good, as there is no more scm_closure. (gw_guile_ensure_latent_variables_hash_and_binder): (gw_guile_procedure_to_method_public): Avoid deprecated SCM_INUM things. diff --git a/guile/g-wrap/guile-runtime.c b/guile/g-wrap/guile-runtime.c index ad49108..f71e8fd 100644 --- a/guile/g-wrap/guile-runtime.c +++ b/guile/g-wrap/guile-runtime.c @@ -1,5 +1,5 @@ /********************************************************************** -Copyright (C) 2003-2005 Andreas Rottmann +Copyright (C) 2003-2005, 2009 Andreas Rottmann This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -197,6 +197,9 @@ gw_guile_add_subr_method (SCM generic, SCM subr, SCM all_specializers, formals = scm_cons (scm_from_locale_symbol (buffer), formals); } +#if SCM_MAJOR_VERSION <= 1 && SCM_MINOR_VERSION < 9 + /* in Guile 1.8 and before, the procedure for a method had to be an + interpreted closure. */ if (use_optional_args) { SCM f_apply = scm_c_eval_string ("apply"); @@ -213,6 +216,9 @@ gw_guile_add_subr_method (SCM generic, SCM subr, SCM all_specializers, procm = scm_closure (scm_list_2 (formals, scm_cons (subr, formals)), scm_top_level_env (SCM_TOP_LEVEL_LOOKUP_CLOSURE)); } +#else + procm = subr; +#endif meth = scm_apply_0 (scm_sym_make, scm_list_5 (scm_class_method, @@ -456,7 +462,7 @@ gw_guile_ensure_latent_variables_hash_and_binder (SCM module) return SCM_BOOL_F; /* won't get here */ } - scm_struct_set_x (module, SCM_MAKINUM (scm_module_index_binder), + scm_struct_set_x (module, scm_from_int (scm_module_index_binder), scm_c_make_gsubr ("%gw-module-binder", 3, 0, 0, gw_module_binder_proc)); @@ -531,11 +537,12 @@ gw_guile_procedure_to_method_public (SCM proc, SCM specializers, SCM pair; SCM existing_latents; SCM entry; + int c_n_req_args; SCM_VALIDATE_PROC (1, proc); SCM_VALIDATE_LIST (2, specializers); SCM_VALIDATE_SYMBOL (3, generic_name); - SCM_VALIDATE_INUM (4, n_req_args); + SCM_VALIDATE_INT_COPY (4, n_req_args, c_n_req_args); /* the fifth is a bool */ generics = gw_guile_ensure_generics_module (); @@ -553,7 +560,7 @@ gw_guile_procedure_to_method_public (SCM proc, SCM specializers, proc, specializers, scm_current_module (), - scm_to_int (n_req_args), + c_n_req_args, scm_is_true (use_optional_args)); return; } commit 6821dfbd43514e55ce78850d3aabf86f3326c8f4 Author: Andy Wingo Date: Tue Dec 15 12:13:54 2009 +0100 use Scheme's add-method! * guile/g-wrap/guile-runtime.c: Keep a pointer to the `make' variable, not the value. (gw_guile_add_subr_method): Call the Scheme add-method! instead of scm_add_method. The C function is removed in Guile 1.9. diff --git a/guile/g-wrap/guile-runtime.c b/guile/g-wrap/guile-runtime.c index f71e8fd..715e542 100644 --- a/guile/g-wrap/guile-runtime.c +++ b/guile/g-wrap/guile-runtime.c @@ -36,7 +36,8 @@ USA. static SCM is_a_p_proc = SCM_UNSPECIFIED; static SCM module_add_x = SCM_UNSPECIFIED; -static SCM scm_sym_make = SCM_UNSPECIFIED; +static SCM var_make = SCM_UNSPECIFIED; +static SCM var_add_method_x = SCM_UNSPECIFIED; /* TODO: Use snarfer for kewords & symbols */ static SCM k_specializers = SCM_UNSPECIFIED; @@ -220,11 +221,11 @@ gw_guile_add_subr_method (SCM generic, SCM subr, SCM all_specializers, procm = subr; #endif - meth = scm_apply_0 (scm_sym_make, + meth = scm_apply_0 (SCM_VARIABLE_REF (var_make), scm_list_5 (scm_class_method, k_specializers, specializers, k_procedure, procm)); - scm_add_method (generic, meth); + scm_call_2 (SCM_VARIABLE_REF (var_add_method_x), generic, meth); } /* What's going on here? @@ -349,7 +350,7 @@ allocate_generic_variable (SCM module, SCM sym) if (scm_is_false (var)) { /* Symbol unbound, make a new generic */ - generic = scm_apply_0 (scm_sym_make, + generic = scm_apply_0 (SCM_VARIABLE_REF (var_make), scm_list_3 (scm_class_generic, k_name, sym)); return scm_make_variable (generic); } else if (scm_is_true (scm_call_2 (is_a_p_proc, scm_variable_ref (var), @@ -361,7 +362,7 @@ allocate_generic_variable (SCM module, SCM sym) } else if (scm_is_true (scm_procedure_p (scm_variable_ref (var)))) { /* Make a generic that falls back on the original binding. NB: generics also satisfy procedure?. */ - generic = scm_apply_0 (scm_sym_make, + generic = scm_apply_0 (SCM_VARIABLE_REF (var_make), scm_list_5 (scm_class_generic, k_name, sym, k_default, scm_variable_ref (var))); @@ -879,9 +880,10 @@ gw_guile_runtime_init (void) { scm_load_goops(); - scm_sym_make = scm_permanent_object ( - SCM_VARIABLE_REF (scm_c_module_lookup (scm_module_goops, - "make"))); + var_make = + scm_permanent_object (scm_c_module_lookup (scm_module_goops, "make")); + var_add_method_x = + scm_permanent_object (scm_c_module_lookup (scm_module_goops, "add-method!")); is_a_p_proc = scm_permanent_object ( SCM_VARIABLE_REF (scm_c_module_lookup (scm_module_goops, "is-a?"))); From eeb1aaeaf26ef510cbb535a7e9e04776cd74926f Mon Sep 17 00:00:00 2001 From: Andreas Rottmann Date: Sun, 27 Feb 2011 15:37:39 +0000 Subject: Fix SCM_VERSION_17X compatibility macro definition for Guile 2.x * guile/g-wrap/guile-compatibility.h: Also define SCM_VERSION_17X on Guile 2.x. --- diff --git a/guile/g-wrap/guile-compatibility.h b/guile/g-wrap/guile-compatibility.h index 1169725..c875e98 100644 --- a/guile/g-wrap/guile-compatibility.h +++ b/guile/g-wrap/guile-compatibility.h @@ -38,8 +38,10 @@ extern "C" { #endif /* Define this macro if Guile 1.7.x or better is in use. */ -#if defined (SCM_MINOR_VERSION) && (SCM_MINOR_VERSION >= 7) && \ - defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION >= 1) +#if defined (SCM_MAJOR_VERSION) && \ + ((SCM_MAJOR_VERSION >= 2) || \ + ((SCM_MAJOR_VERSION == 1) && \ + defined (SCM_MINOR_VERSION) && (SCM_MINOR_VERSION >= 7))) #define SCM_VERSION_17X 1 #endif -- cgit v0.8.3.4