;; -*-theme-d-*-

;; Copyright (C) 2025 Tommi Höynälänmaa

;; This file is part of Theme-D-Intr.

;; You can redistribute and/or modify this file under the terms of the
;; GNU General Public License as published by the Free Software
;; Foundation, either version 3 of the License, or (at your option) any
;; later version.

;; This file is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see https://www.gnu.org/licenses/.

(define-interface (intr-gtk4-examples calc2 plugin-model)

  (import (standard-library core)
          (standard-library plugins))

  (import (intr-gtk4-examples calc2 _intr-imports))

  (declare gl-i-nr-user-fns <integer>)

  (declare gl-i-max-nargs <integer>)

  (define <foreign-var-type>
    (:union (:unit-type 'normal-var) (:unit-type 'ngp) (:unit-type 'vgp)))

  (define <foreign-var> (:tuple <symbol> <foreign-var-type>))

  (define-class <plugin-function-model>
    (fields
     (s-cur-plugin (:alt-maybe <symbol>) public public)
     (foreign-var-cur (:alt-maybe <foreign-var>) public public)
     (i-nargs <integer> public public)
     (module-cur (:alt-maybe <module>) public public)
     (proc-cur (:alt-maybe <object>) public public)))

  (define-class <plugin-model>
    (fields
     (l-s-plugins (:uniform-list <symbol>) public public)
     (l-functions (:uniform-list <plugin-function-model>) public public)))

  (declare-simple-method make-function-models
    (<integer>) (:uniform-list <plugin-function-model>) pure)
    
  (declare-simple-method get-plugin-directory () <string> pure)

  (declare-simple-method compute-plugin-list
    () (:uniform-list <symbol>) nonpure)

  (declare-simple-method get-plugin-string-list
    (<plugin-model>) <gtk-string-list> nonpure)

  (declare-simple-method get-plugin-proc-name
    (<foreign-var>) <symbol> pure)

  (declare-simple-method plugin-function-reset
    (<plugin-function-model>) <none> nonpure)

  (declare-simple-method calc2-load-plugin
    (<symbol>) <module> nonpure)

  (declare-simple-method foreign-var-exists?
    (<module> <foreign-var>) <boolean> pure)

  (declare-simple-method check-plugins
    (<plugin-function-model> (:uniform-list <symbol>)) <none> nonpure)

  (declare-simple-method load-plugin-config
    (<plugin-model>) <none> nonpure)

  (declare-simple-method save-plugin-config
    (<plugin-model>) <none> nonpure))


