X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=irrlicht%2Fforeign.scm;h=f6e203622f55db18eae8907fce38f3c26533c4dd;hb=b66897512cbe56969f0a9b2d4043fc8764c35e19;hp=ff46223674e7aa73a341b563502c496e40cb2ea1;hpb=c9c098c6a9363eb59f435eb195a4bc5b9098b1dd;p=guile-irrlicht.git diff --git a/irrlicht/foreign.scm b/irrlicht/foreign.scm index ff46223..f6e2036 100644 --- a/irrlicht/foreign.scm +++ b/irrlicht/foreign.scm @@ -18,6 +18,25 @@ ;;; . -(define-module (irrlicht foreign)) +(define-module (irrlicht foreign) + #:use-module (irrlicht base) + #:export (get-irrlicht-proc)) -(load-extension "libguile-irrlicht" "init_guile_irrlicht") +;; We use a hash table to store foreign irrlicht methods related with their +;; classes +;; This is needed because we need to "simulate" C++ inheritance +(define remote-proc-table (make-hash-table)) + +(define (get-irrlicht-proc proc-name . objects) + (let* ((name (if (null? objects) + proc-name + (let ((classes (map irr-class objects))) + (string-join (cons (car classes) (cons proc-name (cdr classes))) "_")))) + (proc (hash-ref remote-proc-table name))) + (cond ((not proc) + (load-extension "libguile-irrlicht" "init_guile_irrlicht") + (let ((new-proc (eval-string name))) + (hash-set! remote-proc-table name new-proc) + new-proc)) + (else + proc))))