Skip to content

Commit

Permalink
add non-throwing Scheme to C integer conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
owaddell-beckman committed Oct 4, 2023
1 parent 86307bd commit 4a5de4f
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 66 deletions.
6 changes: 6 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2439,3 +2439,9 @@
c/number.c mats/foreign1.c mats/foreign.ms release_notes/release_notes.stex
- fix 32-bit C integer/unsigned to bignum conversion
c/number.c release_notes/release_notes.stex
- add functions that try to convert from Scheme to C signed and unsigned
integers without throwing exceptions; use the new functions in Sscheme_start
and run_script
boot/*/scheme.h c/externs.h c/number.c c/scheme.c csug/foreign.stex
mats/foreign1.c mats/foreign.ms release_notes/release_notes.stex
s/mkheader.ss
6 changes: 6 additions & 0 deletions boot/a6le/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/a6nt/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/a6osx/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/arm32le/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/i3le/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/i3nt/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/i3osx/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/ta6le/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/ta6nt/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/ta6osx/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/ti3le/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/ti3nt/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
6 changes: 6 additions & 0 deletions boot/ti3osx/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ EXPORT iptr Sinteger_value(ptr);
EXPORT Sint32_t Sinteger32_value(ptr);
#define Sunsigned32_value(x) (Suint32_t)Sinteger32_value(x)
EXPORT Sint64_t Sinteger64_value(ptr);
EXPORT int Stry_integer_value(ptr, iptr*, const char**);
EXPORT int Stry_integer32_value(ptr, Sint32_t*, const char**);
EXPORT int Stry_integer64_value(ptr, Sint64_t*, const char**);
#define Sunsigned64_value(x) (Suint64_t)Sinteger64_value(x)
EXPORT int Stry_unsigned_value(ptr, uptr*, const char**);
EXPORT int Stry_unsigned32_value(ptr, Suint32_t*, const char**);
EXPORT int Stry_unsigned64_value(ptr, Suint64_t*, const char**);

/* Mutators */
EXPORT void Sset_box(ptr, ptr);
Expand Down
1 change: 0 additions & 1 deletion c/externs.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ extern void S_generic_invoke(ptr tc, ptr code);
/* number.c */
extern void S_number_init(void);
extern ptr S_normalize_bignum(ptr x);
extern IBOOL S_integer_valuep(ptr x);
extern iptr S_integer_value(const char *who, ptr x);
extern I64 S_int64_value(char *who, ptr x);
extern IBOOL S_big_eq(ptr x, ptr y);
Expand Down
Loading

0 comments on commit 4a5de4f

Please sign in to comment.