mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 05:27:35 +02:00
at great pains, the stubber can generate (ugly) code for getcwd
This commit is contained in:
parent
e93c1b1483
commit
6da435d21c
5 changed files with 731 additions and 483 deletions
|
@ -823,11 +823,9 @@ SEXP_API sexp sexp_register_simple_type (sexp ctx, sexp name, sexp slots);
|
|||
SEXP_API sexp sexp_register_c_type (sexp ctx, sexp name);
|
||||
SEXP_API sexp sexp_finalize_c_type (sexp ctx, sexp obj);
|
||||
#define sexp_register_c_type(ctx, name, finalizer) \
|
||||
sexp_register_type(ctx, name, sexp_make_fixnum(0), sexp_make_fixnum(0), \
|
||||
sexp_make_fixnum(0), sexp_make_fixnum(0), \
|
||||
sexp_make_fixnum(0), \
|
||||
sexp_make_fixnum(sexp_sizeof(cpointer)), \
|
||||
sexp_make_fixnum(0), sexp_make_fixnum(0), finalizer)
|
||||
sexp_register_type(ctx, name, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, SEXP_ZERO, \
|
||||
SEXP_ZERO, sexp_make_fixnum(sexp_sizeof(cpointer)), \
|
||||
SEXP_ZERO, SEXP_ZERO, finalizer)
|
||||
#endif
|
||||
|
||||
#define sexp_current_error_port(ctx) sexp_env_global_ref(sexp_context_env(ctx),sexp_global(ctx,SEXP_G_CUR_ERR_SYMBOL),SEXP_FALSE)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
delete-file link-file symbolic-link-file rename-file
|
||||
directory-files create-directory delete-directory
|
||||
current-seconds
|
||||
exit
|
||||
waitpid exit
|
||||
)
|
||||
(import-immutable (scheme))
|
||||
(include-shared "posix")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
(c-system-include "sys/types.h")
|
||||
(c-system-include "sys/wait.h")
|
||||
(c-system-include "time.h")
|
||||
(c-system-include "unistd.h")
|
||||
(c-system-include "dirent.h")
|
||||
|
@ -18,7 +19,8 @@
|
|||
(define-c errno (symbolic-link-file "symlink") (string string))
|
||||
(define-c errno (rename-file "rename") (string string))
|
||||
|
||||
;;(define-c string (current-directory "getcwd") ((value (array char)) int))
|
||||
(define-c non-null-string (current-directory "getcwd")
|
||||
((result (array char (auto-expand arg1))) (value 256 int)))
|
||||
(define-c errno (create-directory "mkdir") (string int))
|
||||
(define-c errno (delete-directory "rmdir") (string))
|
||||
|
||||
|
@ -28,9 +30,9 @@
|
|||
(define-c int (duplicate-fd "dup") (int))
|
||||
|
||||
(define-c pid_t fork ())
|
||||
;; (define-c pid_t wait ((result pointer int)))
|
||||
(define-c pid_t waitpid (int (result int) int))
|
||||
(define-c void exit (int))
|
||||
(define-c int (execute execvp) (string (array string null)))
|
||||
(define-c int (execute execvp) (string (array string)))
|
||||
|
||||
(define-c errno pipe ((result (array int 2))))
|
||||
|
||||
|
|
13
sexp.c
13
sexp.c
|
@ -837,8 +837,12 @@ sexp sexp_get_output_string (sexp ctx, sexp port) {
|
|||
#else
|
||||
|
||||
sexp sexp_make_input_string_port (sexp ctx, sexp str) {
|
||||
FILE *in = fmemopen(sexp_string_data(str), sexp_string_length(str), "r");
|
||||
sexp res = sexp_make_input_port(ctx, in, SEXP_FALSE);
|
||||
FILE *in;
|
||||
sexp res;
|
||||
if (! sexp_stringp(str))
|
||||
return sexp_type_exception(ctx, "open-input-string: not a string", str);
|
||||
in = fmemopen(sexp_string_data(str), sexp_string_length(str), "r");
|
||||
res = sexp_make_input_port(ctx, in, SEXP_FALSE);
|
||||
sexp_port_cookie(res) = str; /* for gc preservation */
|
||||
return res;
|
||||
}
|
||||
|
@ -916,7 +920,10 @@ sexp sexp_buffered_flush (sexp ctx, sexp p) {
|
|||
}
|
||||
|
||||
sexp sexp_make_input_string_port (sexp ctx, sexp str) {
|
||||
sexp res = sexp_make_input_port(ctx, NULL, SEXP_FALSE);
|
||||
sexp res;
|
||||
if (! sexp_stringp(str))
|
||||
return sexp_type_exception(ctx, "open-input-string: not a string", str);
|
||||
res = sexp_make_input_port(ctx, NULL, SEXP_FALSE);
|
||||
if (sexp_exceptionp(res)) return res;
|
||||
sexp_port_cookie(res) = str;
|
||||
sexp_port_buf(res) = sexp_string_data(str);
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue