[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)
- [elpa] 224/255: handle IGS shouts, (continued)
- [elpa] 224/255: handle IGS shouts, Eric Schulte, 2014/03/15
- [elpa] 226/255: remove shouts from comments, Eric Schulte, 2014/03/15
- [elpa] 151/255: Revert "push all buffer-local variables into an igs object", Eric Schulte, 2014/03/15
- [elpa] 237/255: thoughts about browser-based implementation, Eric Schulte, 2014/03/15
- [elpa] 236/255: factor general comint utils out of igs.el, Eric Schulte, 2014/03/15
- [elpa] 192/255: two consecutive passes ends the game, Eric Schulte, 2014/03/15
- [elpa] 210/255: using curry, rcurry and compose helpers, Eric Schulte, 2014/03/15
- [elpa] 203/255: adding GPL copyright file, Eric Schulte, 2014/03/15
- [elpa] 243/255: undo through gtp pipe, Eric Schulte, 2014/03/15
- [elpa] 246/255: customizable default gnugo options, Eric Schulte, 2014/03/15
- [elpa] 241/255: igs class definitions up front for better loading,
Eric Schulte <=
- [elpa] 247/255: notes, Eric Schulte, 2014/03/15
- [elpa] 235/255: better line truncation, Eric Schulte, 2014/03/15
- [elpa] 250/255: mark dead stones at end of game, Eric Schulte, 2014/03/15
- [elpa] 229/255: igs TODO: consistent game un-observation, Eric Schulte, 2014/03/15
- [elpa] 242/255: need assoc for aget, Eric Schulte, 2014/03/15
- [elpa] 228/255: refresh the game list buffer, Eric Schulte, 2014/03/15
- [elpa] 211/255: scale column width by buffer width, Eric Schulte, 2014/03/15
- [elpa] 233/255: igs handle adjourned and resigned games, Eric Schulte, 2014/03/15
- [elpa] 244/255: igs-pipe handles resignation and comments, Eric Schulte, 2014/03/15
- [elpa] 245/255: misc fixes, Eric Schulte, 2014/03/15