diff options
author | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2019-03-13 17:35:15 +0100 |
---|---|---|
committer | Stefan Israelsson Tampe <stefan.itampe@gmail.com> | 2019-03-13 17:35:15 +0100 |
commit | 26b8e6d6040df10093b0ede3a2ac04b3f1c8a22b (patch) | |
tree | 3f27a05cbb9911c9ad82fa8b09a52c92306d2fd2 | |
parent | 7a4c715f24fb10b6b0724704b7120da4c2b173bb (diff) |
remove warnings, reordering
-rw-r--r-- | modules/Makefile.am | 2 | ||||
-rw-r--r-- | modules/language/python/compile.scm | 8 | ||||
-rw-r--r-- | modules/language/python/module/_python.scm | 6 | ||||
-rw-r--r-- | modules/language/python/module/copy.scm | 2 | ||||
-rw-r--r-- | modules/language/python/module/decimal.scm | 1 | ||||
-rw-r--r-- | modules/language/python/module/functools.scm | 3 | ||||
-rw-r--r-- | modules/language/python/module/operator.scm | 5 | ||||
-rw-r--r-- | modules/language/python/module/os.scm | 13 | ||||
-rw-r--r-- | modules/language/python/module/pwd.scm | 2 | ||||
-rw-r--r-- | modules/language/python/spec.scm | 15 | ||||
-rw-r--r-- | modules/oop/pf-objects.scm | 10 |
11 files changed, 38 insertions, 29 deletions
diff --git a/modules/Makefile.am b/modules/Makefile.am index 132b90b..c117a50 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -59,7 +59,6 @@ SOURCES = \ language/python/module/_random.scm \ language/python/module/random.py \ language/python/module/sys.scm \ - language/python/module/random.py \ language/python/module/weakref.scm \ language/python/module/abc.scm \ language/python/module/threading.scm \ @@ -71,7 +70,6 @@ SOURCES = \ language/python/module/struct.scm \ language/python/module/_socket.scm \ language/python/module/signal.scm \ - language/python/module/resource.scm \ language/python/module/select.scm \ language/python/module/math.scm \ language/python/module/copy.scm \ diff --git a/modules/language/python/compile.scm b/modules/language/python/compile.scm index 973ae3a..6c46ea1 100644 --- a/modules/language/python/compile.scm +++ b/modules/language/python/compile.scm @@ -21,7 +21,7 @@ #:use-module ((language python format2) #:select (fnm)) #:use-module ((language python with) #:select ()) #:use-module (ice-9 pretty-print) - #:export (comp exit-fluid exit-prompt pks)) + #:export (comp exit-fluid exit-prompt pks do-pr)) (define-syntax-rule (aif it p x y) (let ((it p)) (if it x y))) @@ -294,12 +294,12 @@ (fold f (f (car l) init) (cdr l)) init)) -(define do-pr #t) +(define do-pr #f) (define (pr . x) (if do-pr (let () - (define port (open-file "/home/stis/src/python-on-guile/modules/log.txt" "a")) + (define port (open-file "log.txt" "a")) (with-output-to-port port (lambda () (pretty-print (syntax->datum x)))) @@ -307,7 +307,7 @@ (car (reverse x))) (define (pf x) - (define port (open-file "/home/stis/src/python-on-guile/modules/compile.log" "a")) + (define port (open-file "compile.log" "a")) (with-output-to-port port (lambda () (pretty-print (syntax->datum x)) x)) (close port) diff --git a/modules/language/python/module/_python.scm b/modules/language/python/module/_python.scm index e950496..9a7a01e 100644 --- a/modules/language/python/module/_python.scm +++ b/modules/language/python/module/_python.scm @@ -47,8 +47,8 @@ #:export (print repr complex float int str set all any bin callable reversed chr classmethod staticmethod objectmethod - divmod enumerate - getattr hasattr setattr hex isinstance issubclass + divmod enumerate delattr + getattr hasattr setattr delattr hex isinstance issubclass iter sum id input oct ord pow super sorted zip vars slice)) @@ -432,3 +432,5 @@ (set! (@@ (language python module) m?) (lambda (x) (isinstance x (@@ (language python module) Module)))) + +(define (delattr o key) (rawdel o key)) diff --git a/modules/language/python/module/copy.scm b/modules/language/python/module/copy.scm index 9393aa0..b4387c3 100644 --- a/modules/language/python/module/copy.scm +++ b/modules/language/python/module/copy.scm @@ -9,4 +9,4 @@ ((#:obj x) x) (x x))) (define (copy x) (s ((@@ (persist persistance) copy) x))) -(define (deepcopy x) (S ((@@ (persist persistance) deep-copy) x))) +(define (deepcopy x) (s ((@@ (persist persistance) deep-copy) x))) diff --git a/modules/language/python/module/decimal.scm b/modules/language/python/module/decimal.scm index e58ba34..6186132 100644 --- a/modules/language/python/module/decimal.scm +++ b/modules/language/python/module/decimal.scm @@ -21,6 +21,7 @@ #:use-module (oop goops) #:use-module (language python module re) #:use-module (ice-9 control) + #:use-module (ice-9 format) #:use-module ((ice-9 match) #:select ((match . ice:match))) #:export ( ;; Two major classes diff --git a/modules/language/python/module/functools.scm b/modules/language/python/module/functools.scm index c065900..a59b006 100644 --- a/modules/language/python/module/functools.scm +++ b/modules/language/python/module/functools.scm @@ -1,5 +1,6 @@ (define-module (language python module functools) #:use-module (ice-9 control) + #:use-module (ice-9 format) #:use-module (oop pf-objects) #:use-module (language python for) #:use-module (language python try) @@ -532,7 +533,7 @@ (lp2 (cdr s1)) (lp3 (cdr s2))) cand))) - (raise RunTimeError "Inconsistant hierarky"))))) + (raise RuntimeError "Inconsistant hierarky"))))) (let lp ((s sequences)) (if (pair? s) diff --git a/modules/language/python/module/operator.scm b/modules/language/python/module/operator.scm index 2500563..536c203 100644 --- a/modules/language/python/module/operator.scm +++ b/modules/language/python/module/operator.scm @@ -1,6 +1,7 @@ (define-module (language python module operator) #:use-module (oop pf-objects) #:use-module (ice-9 control) + #:use-module (ice-9 format) #:use-module (language python number) #:use-module (language python list) #:use-module (language python string) @@ -104,7 +105,7 @@ (define* (length_hint obj #:optional (default 0)) (if (not (and (number? default) (integer? default))) - (raise TypeError (format #f "default=~ a is not an integer" default))) + (raise TypeError (format #f "default=~a is not an integer" default))) (let/ec ret (try (lambda () @@ -130,7 +131,7 @@ default) ((not (and (number? val) (integer? val))) (raise TypeError - (format #f "__length_hint__() must be integer, not ~ a" val))) + (format #f "__length_hint__() must be integer, not ~a" val))) ((< val 0) (raise ValueError "__length_hint__() should return integer >= 0")) diff --git a/modules/language/python/module/os.scm b/modules/language/python/module/os.scm index a17cc86..17edfed 100644 --- a/modules/language/python/module/os.scm +++ b/modules/language/python/module/os.scm @@ -27,8 +27,8 @@ #:use-module (language python module resource) #:use-module (language python list) - #:replace (getcwd getuid getenv stat) - #:export (error name ctermid environ environb chdir fchdir + #:replace (getcwd getuid getenv stat environ) + #:export (error name ctermid environb chdir fchdir fsencode fdencode fspath PathLike getenvb get_exec_path getgid getegid geteuid fdopen getgroups getgrouplist getlogin getpgid getpgrp getpid @@ -927,10 +927,7 @@ (defineu stat (0 2) (let ((f (pointer->procedure int (dynamic-func "__fxstatat" (dynamic-link)) - (list int int '* '* int))) - (g (pointer->procedure '* - (dynamic-func "scm_stat2scm_" (dynamic-link)) - '(*)))) + (list int int '* '* int)))) (lam (path (= dir_fd None) (= follow_symlinks #t)) (if (number? path) (ca (stat_result ((@ (guile) stat) path))) @@ -948,8 +945,8 @@ bvp (if follow_symlinks 0 - AT_SYMLINK_NOFOLLOW))) - (stat_result (ca (pointer->scm (g bvp))))))))))) + AT_SYMLINK_NOFOLLOW))) + (stat_result (error "not implemented"))))))))) (define lstat (lambda* (path #:key (dir_fd None)) diff --git a/modules/language/python/module/pwd.scm b/modules/language/python/module/pwd.scm index 0fa7013..ef327ac 100644 --- a/modules/language/python/module/pwd.scm +++ b/modules/language/python/module/pwd.scm @@ -65,7 +65,7 @@ (if (pair? l) (begin (catch #t - (lambda () (yield (getpwname (car l)))) + (lambda () (yield (getpwnam (car l)))) (lambda x #f)) (lp (cdr l))))))))) diff --git a/modules/language/python/spec.scm b/modules/language/python/spec.scm index 46ac186..4b05cbf 100644 --- a/modules/language/python/spec.scm +++ b/modules/language/python/spec.scm @@ -12,19 +12,20 @@ #:use-module (language scheme compile-tree-il) #:use-module (language scheme decompile-tree-il) #:use-module (ice-9 rdelim) - #:export (python)) + #:export (python dolog)) ;;; ;;; Language definition ;;; - +(define dolog #f) (define (pr . x) - (define port (open-file "/home/stis/src/python-on-guile/log.txt" "a")) - (with-output-to-port port - (lambda () - (pretty-print x) (car (reverse x)))) - (close port) + (when dolog + (define port (open-file "log.txt" "a")) + (with-output-to-port port + (lambda () + (pretty-print x) (car (reverse x)))) + (close port)) (car (reverse x))) (define (c int x) (pr (comp int (pr (p (pr x)))))) diff --git a/modules/oop/pf-objects.scm b/modules/oop/pf-objects.scm index e2f0d8b..86a22ef 100644 --- a/modules/oop/pf-objects.scm +++ b/modules/oop/pf-objects.scm @@ -17,7 +17,7 @@ py-super-mac py-super py-equal? *class* *self* pyobject? pytype? type object pylist-set! pylist-ref tr - resolve-method-g rawref rawset py-dict + resolve-method-g rawref rawset rawdel py-dict ref-class fastref fastset )) @@ -186,6 +186,9 @@ explicitly tell it to not update etc. (car l) #f))) +(define-method (rawdel (o <procedure>) key) + (error "not implemented yet")) + (define-method (set (o <procedure>) key val) (set-procedure-property!- o key val)) @@ -762,6 +765,11 @@ explicitly tell it to not update etc. (define-method (rawref (x <pf> ) key . l) (mref x key l)) (define-method (rawref (x <p> ) key . l) (mref x key l)) +(define-method (rawdel (x <p> ) key) + (hash-remove! (slot-ref x 'h) + (if (symbol? key) + key + (string->symbol key)))) (define-method (set (f <procedure>) key val) (set-procedure-property!- f key val)) |