X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=blobdiff_plain;f=irrlicht%2Fforeign.scm;h=f6e203622f55db18eae8907fce38f3c26533c4dd;hp=ff46223674e7aa73a341b563502c496e40cb2ea1;hb=98052b04792129db97286fdd77ef3b0de8912286;hpb=661f003f90a2ab35026cf17215f28dcb73f54084 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))))