1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

* Where possible, accept const pointers as parameters.

This commit is contained in:
Dirk Herrmann 2000-05-18 10:20:22 +00:00
parent af45e3b06a
commit bcee10ddd2
4 changed files with 70 additions and 48 deletions

View file

@ -1,4 +1,13 @@
2000-05-17 Dirk Herrmann <D.Herrmann@tu-bs.de>
2000-05-18 Dirk Herrmann <D.Herrmann@tu-bs.de>
* gh.h gh_data.c gh_funcs.c (gh_new_procedure*, gh_chars2byvect,
gh_shorts2svect, gh_longs2ivect, gh_ulongs2uvect, gh_floats2fvect,
gh_doubles2dvect, gh_doubles2scm, gh_define, gh_lookup,
gh_module_lookup): Accept const pointers as parameters.
* gh.h gh_data.c (gh_int2scmb): Deprecated.
2000-05-18 Dirk Herrmann <D.Herrmann@tu-bs.de>
* __scm.h (SCM_DEBUG_REST_ARGUMENT): Renamed from
SCM_DEBUG_REST_ARGUMENTS in order to clarify that we don't test

View file

@ -80,23 +80,22 @@ SCM gh_eval_file_with_standard_handler(const char *scheme_code);
#define gh_defer_ints() SCM_DEFER_INTS
#define gh_allow_ints() SCM_ALLOW_INTS
SCM gh_new_procedure(char *proc_name, SCM (*fn)(),
SCM gh_new_procedure(const char *proc_name, SCM (*fn)(),
int n_required_args, int n_optional_args, int varp);
SCM gh_new_procedure0_0(char *proc_name, SCM (*fn)(void));
SCM gh_new_procedure0_1(char *proc_name, SCM (*fn)(SCM));
SCM gh_new_procedure0_2(char *proc_name, SCM (*fn)(SCM, SCM));
SCM gh_new_procedure1_0(char *proc_name, SCM (*fn)(SCM));
SCM gh_new_procedure1_1(char *proc_name, SCM (*fn)(SCM, SCM));
SCM gh_new_procedure1_2(char *proc_name, SCM (*fn)(SCM, SCM, SCM));
SCM gh_new_procedure2_0(char *proc_name, SCM (*fn)(SCM, SCM));
SCM gh_new_procedure2_1(char *proc_name, SCM (*fn)(SCM, SCM, SCM));
SCM gh_new_procedure2_2(char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM));
SCM gh_new_procedure3_0(char *proc_name, SCM (*fn)(SCM, SCM, SCM));
SCM gh_new_procedure4_0(char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM));
SCM gh_new_procedure5_0(char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM, SCM));
SCM gh_new_procedure0_0(const char *proc_name, SCM (*fn)(void));
SCM gh_new_procedure0_1(const char *proc_name, SCM (*fn)(SCM));
SCM gh_new_procedure0_2(const char *proc_name, SCM (*fn)(SCM, SCM));
SCM gh_new_procedure1_0(const char *proc_name, SCM (*fn)(SCM));
SCM gh_new_procedure1_1(const char *proc_name, SCM (*fn)(SCM, SCM));
SCM gh_new_procedure1_2(const char *proc_name, SCM (*fn)(SCM, SCM, SCM));
SCM gh_new_procedure2_0(const char *proc_name, SCM (*fn)(SCM, SCM));
SCM gh_new_procedure2_1(const char *proc_name, SCM (*fn)(SCM, SCM, SCM));
SCM gh_new_procedure2_2(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM));
SCM gh_new_procedure3_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM));
SCM gh_new_procedure4_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM));
SCM gh_new_procedure5_0(const char *proc_name, SCM (*fn)(SCM, SCM, SCM, SCM, SCM));
/* C to Scheme conversion */
SCM gh_int2scmb(int x); /* this is being phased out */
SCM gh_bool2scm(int x);
SCM gh_int2scm(int x);
SCM gh_ulong2scm(unsigned long x);
@ -110,15 +109,15 @@ SCM gh_symbol2scm(const char *symbol_str);
SCM gh_ints2scm(int *d, int n);
#ifdef HAVE_ARRAYS
SCM gh_chars2byvect(char *d, int n);
SCM gh_shorts2svect(short *d, int n);
SCM gh_longs2ivect(long *d, int n);
SCM gh_ulongs2uvect(unsigned long *d, int n);
SCM gh_floats2fvect(float *d, int n);
SCM gh_doubles2dvect(double *d, int n);
SCM gh_chars2byvect(const char *d, int n);
SCM gh_shorts2svect(const short *d, int n);
SCM gh_longs2ivect(const long *d, int n);
SCM gh_ulongs2uvect(const unsigned long *d, int n);
SCM gh_floats2fvect(const float *d, int n);
SCM gh_doubles2dvect(const double *d, int n);
#endif
SCM gh_doubles2scm(double *d, int n);
SCM gh_doubles2scm(const double *d, int n);
/* Scheme to C conversion */
int gh_scm2bool(SCM obj);
@ -160,7 +159,7 @@ int gh_null_p(SCM l);
#define gh_not(x) scm_not(x)
SCM gh_define(char *name, SCM val);
SCM gh_define(const char *name, SCM val);
/* vector manipulation routines */
/* note that gh_vector() does not behave quite like the Scheme (vector
@ -177,8 +176,8 @@ SCM gh_uniform_vector_ref (SCM v, SCM ilist);
#define gh_list_to_vector(ls) scm_vector(ls)
#define gh_vector_to_list(v) scm_vector_to_list(v)
SCM gh_lookup (char *sname);
SCM gh_module_lookup (SCM vector, char *sname);
SCM gh_lookup (const char *sname);
SCM gh_module_lookup (SCM vector, const char *sname);
SCM gh_cons(SCM x, SCM y);
#define gh_list scm_listify
@ -241,6 +240,14 @@ void gh_newline (void);
/* void gh_assert(int cond, char *msg, SCM obj); */
#if (SCM_DEBUG_DEPRECATED == 0)
SCM gh_int2scmb(int x); /* this is being phased out */
#endif /* SCM_DEBUG_DEPRECATED == 0 */
#ifdef __cplusplus
}
#endif

View file

@ -49,11 +49,17 @@
#endif
/* data conversion C->scheme */
#if (SCM_DEBUG_DEPRECATED == 0)
SCM
gh_int2scmb (int x) /* this is being phased out */
{
return SCM_BOOL(x);
}
#endif /* SCM_DEBUG_DEPRECATED == 0 */
SCM
gh_bool2scm (int x)
{
@ -144,7 +150,7 @@ gh_ints2scm (int *d, int n)
}
SCM
gh_doubles2scm (double *d, int n)
gh_doubles2scm (const double *d, int n)
{
int i;
SCM v = scm_make_vector(SCM_MAKINUM(n), SCM_UNSPECIFIED);
@ -172,7 +178,7 @@ makvect (char* m, int len, int type)
}
SCM
gh_chars2byvect (char *d, int n)
gh_chars2byvect (const char *d, int n)
{
char *m = scm_must_malloc (n * sizeof (char), "vector");
memcpy (m, d, n * sizeof (char));
@ -180,7 +186,7 @@ gh_chars2byvect (char *d, int n)
}
SCM
gh_shorts2svect (short *d, int n)
gh_shorts2svect (const short *d, int n)
{
char *m = scm_must_malloc (n * sizeof (short), "vector");
memcpy (m, d, n * sizeof (short));
@ -188,7 +194,7 @@ gh_shorts2svect (short *d, int n)
}
SCM
gh_longs2ivect (long *d, int n)
gh_longs2ivect (const long *d, int n)
{
char *m = scm_must_malloc (n * sizeof (long), "vector");
memcpy (m, d, n * sizeof (long));
@ -196,7 +202,7 @@ gh_longs2ivect (long *d, int n)
}
SCM
gh_ulongs2uvect (unsigned long *d, int n)
gh_ulongs2uvect (const unsigned long *d, int n)
{
char *m = scm_must_malloc (n * sizeof (unsigned long), "vector");
memcpy (m, d, n * sizeof (unsigned long));
@ -204,7 +210,7 @@ gh_ulongs2uvect (unsigned long *d, int n)
}
SCM
gh_floats2fvect (float *d, int n)
gh_floats2fvect (const float *d, int n)
{
char *m = scm_must_malloc (n * sizeof (float), "vector");
memcpy (m, d, n * sizeof (float));
@ -212,7 +218,7 @@ gh_floats2fvect (float *d, int n)
}
SCM
gh_doubles2dvect (double *d, int n)
gh_doubles2dvect (const double *d, int n)
{
char *m = scm_must_malloc (n * sizeof (double), "vector");
memcpy (m, d, n * sizeof (double));
@ -678,13 +684,13 @@ gh_uniform_vector_ref (SCM v, SCM ilist)
-twp] */
SCM
gh_lookup (char *sname)
gh_lookup (const char *sname)
{
return gh_module_lookup (SCM_BOOL_F, sname);
}
SCM
gh_module_lookup (SCM vec, char *sname)
gh_module_lookup (SCM vec, const char *sname)
{
SCM sym = gh_symbol2scm (sname);
if (SCM_TRUE_P (scm_symbol_bound_p (vec, sym)))

View file

@ -49,7 +49,7 @@
/* allows you to define new scheme primitives written in C */
SCM
gh_new_procedure (char *proc_name, SCM (*fn) (),
gh_new_procedure (const char *proc_name, SCM (*fn) (),
int n_required_args, int n_optional_args, int varp)
{
return scm_make_gsubr (proc_name, n_required_args, n_optional_args,
@ -57,80 +57,80 @@ gh_new_procedure (char *proc_name, SCM (*fn) (),
}
SCM
gh_new_procedure0_0 (char *proc_name, SCM (*fn) ())
gh_new_procedure0_0 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 0, 0, 0);
}
SCM
gh_new_procedure0_1 (char *proc_name, SCM (*fn) ())
gh_new_procedure0_1 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 0, 1, 0);
}
SCM
gh_new_procedure0_2 (char *proc_name, SCM (*fn) ())
gh_new_procedure0_2 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 0, 2, 0);
}
SCM
gh_new_procedure1_0 (char *proc_name, SCM (*fn) ())
gh_new_procedure1_0 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 1, 0, 0);
}
SCM
gh_new_procedure1_1 (char *proc_name, SCM (*fn) ())
gh_new_procedure1_1 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 1, 1, 0);
}
SCM
gh_new_procedure1_2 (char *proc_name, SCM (*fn) ())
gh_new_procedure1_2 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 1, 2, 0);
}
SCM
gh_new_procedure2_0 (char *proc_name, SCM (*fn) ())
gh_new_procedure2_0 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 2, 0, 0);
}
SCM
gh_new_procedure2_1 (char *proc_name, SCM (*fn) ())
gh_new_procedure2_1 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 2, 1, 0);
}
SCM
gh_new_procedure2_2 (char *proc_name, SCM (*fn) ())
gh_new_procedure2_2 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 2, 2, 0);
}
SCM
gh_new_procedure3_0 (char *proc_name, SCM (*fn) ())
gh_new_procedure3_0 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 3, 0, 0);
}
SCM
gh_new_procedure4_0 (char *proc_name, SCM (*fn) ())
gh_new_procedure4_0 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 4, 0, 0);
}
SCM
gh_new_procedure5_0 (char *proc_name, SCM (*fn) ())
gh_new_procedure5_0 (const char *proc_name, SCM (*fn) ())
{
return gh_new_procedure (proc_name, fn, 5, 0, 0);
}
/* some (possibly most) Scheme functions available from C */
SCM
gh_define (char *name, SCM val)
gh_define (const char *name, SCM val)
{
return scm_sysintern (name, val);
}