emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 241/255: igs class definitions up front for better loading


From: Eric Schulte
Subject: [elpa] 241/255: igs class definitions up front for better loading
Date: Sun, 16 Mar 2014 01:02:56 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 429328cda61173b16ebba2944fbb9233b9898e35
Author: Eric Schulte <address@hidden>
Date:   Fri Aug 9 15:43:46 2013 -0600

    igs class definitions up front for better loading
---
 back-ends/igs.el |  227 +++++++++++++++++++++++++++---------------------------
 1 files changed, 113 insertions(+), 114 deletions(-)

diff --git a/back-ends/igs.el b/back-ends/igs.el
index 6c82daf..88cccce 100644
--- a/back-ends/igs.el
+++ b/back-ends/igs.el
@@ -114,6 +114,118 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
 (defvar *igs-current-game* nil
   "Number of the current IGS game (may change frequently).")
 
+
+;;; Class and interface
+(defclass igs ()
+  ((buffer :initarg :buffer :accessor buffer :initform nil)
+   ;; number of an observed IGS game
+   (number :initarg :number :accessor number :initform nil)
+   (active :initarg :active :accessor active :initform t)))
+
+(defmethod go-connect ((igs igs)) (igs-connect igs))
+
+(defmacro with-igs (igs &rest body)
+  (declare (indent 1))
+  `(with-current-buffer (buffer ,igs) ,@body))
+
+(defmethod go-level ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :level)))
+
+(defmethod set-go-level ((igs igs) level)
+  (signal 'unsupported-back-end-command (list igs :set-level level)))
+
+(defmethod go-size ((igs igs))
+  (with-igs igs (aget (igs-current-game) :size)))
+
+(defmethod set-go-size ((igs igs) size)
+  (signal 'unsupported-back-end-command (list igs :set-size size)))
+
+(defmethod go-name ((igs igs))
+  (with-igs igs (let ((game (igs-current-game)))
+                  (format "%s(%s) vs %s(%s)"
+                          (aget game :white-name)
+                          (aget game :white-rank)
+                          (aget game :black-name)
+                          (aget game :black-rank)))))
+
+(defmethod set-go-name ((igs igs) name)
+  (signal 'unsupported-back-end-command (list igs :set-name name)))
+
+(defmethod go-move ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :move)))
+
+(defmethod set-go-move ((igs igs) move)
+  (signal 'unsupported-back-end-command (list igs :set-move move)))
+
+(defmethod go-labels ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :labels)))
+
+(defmethod set-go-labels ((igs igs) labels)
+  (signal 'unsupported-back-end-command (list igs :set-labels labels)))
+
+(defmethod go-comment ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :comment)))
+
+(defmethod set-go-comment ((igs igs) comment)
+  (signal 'unsupported-back-end-command (list igs :set-comment comment)))
+
+(defmethod go-alt ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :alt)))
+
+(defmethod set-go-alt ((igs igs) alt)
+  (signal 'unsupported-back-end-command (list igs :set-alt alt)))
+
+(defmethod go-color ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :color)))
+
+(defmethod set-go-color ((igs igs) color)
+  (signal 'unsupported-back-end-command (list igs :set-color color)))
+
+(defmethod go-player-name ((igs igs) color)
+  (with-igs igs (aget (igs-current-game)
+                      (case color
+                        (:W :white-name)
+                        (:B :black-name)))))
+
+(defmethod set-go-player-name ((igs igs) color name)
+  (signal 'unsupported-back-end-command (list igs :set-player-name color 
name)))
+
+(defmethod go-player-time ((igs igs) color)
+  (signal 'unsupported-back-end-command (list igs :player-time color)))
+
+(defmethod set-go-player-time ((igs igs) color time)
+  (signal 'unsupported-back-end-command (list igs :set-player-time color 
time)))
+
+;; non setf'able generic functions
+(defmethod go-undo ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :undo)))
+
+(defmethod go-pass ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :pass)))
+
+(defmethod go-resign ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :resign)))
+
+(defmethod go-reset ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :reset)))
+
+(defmethod go-quit ((igs igs))
+  (with-igs igs
+    (if (number igs)
+        (progn
+          ;; TOOD: ensure still on our server-side observation list
+          ;;       (e.g., hasn't been removed after a resignation)
+          (when (active igs)
+            (igs-send (format "observe %d" (number igs))))
+          (setf (number igs) nil))
+      (igs-send "quit"))))
+
+(defmethod go-score ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :score)))
+
+(defmethod go-territory ((igs igs))
+  (signal 'unsupported-back-end-command (list igs :territory)))
+
 (defmacro igs-w-proc (proc &rest body)
   (declare (indent 1))
   `(with-current-buffer (process-buffer proc) ,@body))
@@ -366,11 +478,10 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
        (igs-update-game-info (cons :B black-info))))))
 
 
-;;; IGS interface
+;;; Interface
 ;;
 ;; If we find another backend providing game lists and observations
 ;; then this could be generalized to an interface.
-
 (defun igs-start (&optional name)
   "Connect to an IGS server and return the `igs' instance."
   (interactive)
@@ -388,116 +499,4 @@ This is used to re-send messages to keep the IGS server 
from timing out.")
   (setf *igs-games* nil)
   (igs-send "games"))
 
-
-;;; Class and interface
-(defclass igs ()
-  ((buffer :initarg :buffer :accessor buffer :initform nil)
-   ;; number of an observed IGS game
-   (number :initarg :number :accessor number :initform nil)
-   (active :initarg :active :accessor active :initform t)))
-
-(defmethod go-connect ((igs igs)) (igs-connect igs))
-
-(defmacro with-igs (igs &rest body)
-  (declare (indent 1))
-  `(with-current-buffer (buffer ,igs) ,@body))
-
-(defmethod go-level ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :level)))
-
-(defmethod set-go-level ((igs igs) level)
-  (signal 'unsupported-back-end-command (list igs :set-level level)))
-
-(defmethod go-size ((igs igs))
-  (with-igs igs (aget (igs-current-game) :size)))
-
-(defmethod set-go-size ((igs igs) size)
-  (signal 'unsupported-back-end-command (list igs :set-size size)))
-
-(defmethod go-name ((igs igs))
-  (with-igs igs (let ((game (igs-current-game)))
-                  (format "%s(%s) vs %s(%s)"
-                          (aget game :white-name)
-                          (aget game :white-rank)
-                          (aget game :black-name)
-                          (aget game :black-rank)))))
-
-(defmethod set-go-name ((igs igs) name)
-  (signal 'unsupported-back-end-command (list igs :set-name name)))
-
-(defmethod go-move ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :move)))
-
-(defmethod set-go-move ((igs igs) move)
-  (signal 'unsupported-back-end-command (list igs :set-move move)))
-
-(defmethod go-labels ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :labels)))
-
-(defmethod set-go-labels ((igs igs) labels)
-  (signal 'unsupported-back-end-command (list igs :set-labels labels)))
-
-(defmethod go-comment ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :comment)))
-
-(defmethod set-go-comment ((igs igs) comment)
-  (signal 'unsupported-back-end-command (list igs :set-comment comment)))
-
-(defmethod go-alt ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :alt)))
-
-(defmethod set-go-alt ((igs igs) alt)
-  (signal 'unsupported-back-end-command (list igs :set-alt alt)))
-
-(defmethod go-color ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :color)))
-
-(defmethod set-go-color ((igs igs) color)
-  (signal 'unsupported-back-end-command (list igs :set-color color)))
-
-(defmethod go-player-name ((igs igs) color)
-  (with-igs igs (aget (igs-current-game)
-                      (case color
-                        (:W :white-name)
-                        (:B :black-name)))))
-
-(defmethod set-go-player-name ((igs igs) color name)
-  (signal 'unsupported-back-end-command (list igs :set-player-name color 
name)))
-
-(defmethod go-player-time ((igs igs) color)
-  (signal 'unsupported-back-end-command (list igs :player-time color)))
-
-(defmethod set-go-player-time ((igs igs) color time)
-  (signal 'unsupported-back-end-command (list igs :set-player-time color 
time)))
-
-;; non setf'able generic functions
-(defmethod go-undo ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :undo)))
-
-(defmethod go-pass ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :pass)))
-
-(defmethod go-resign ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :resign)))
-
-(defmethod go-reset ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :reset)))
-
-(defmethod go-quit ((igs igs))
-  (with-igs igs
-    (if (number igs)
-        (progn
-          ;; TOOD: ensure still on our server-side observation list
-          ;;       (e.g., hasn't been removed after a resignation)
-          (when (active igs)
-            (igs-send (format "observe %d" (number igs))))
-          (setf (number igs) nil))
-      (igs-send "quit"))))
-
-(defmethod go-score ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :score)))
-
-(defmethod go-territory ((igs igs))
-  (signal 'unsupported-back-end-command (list igs :territory)))
-
 (provide 'igs)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]