[gnome-chess] ChessEngine: profile and binary should be private



commit f4b137e3183983b8704befd236d77c6efd27f05f
Author: Michael Catanzaro <mike catanzaro gmail com>
Date:   Sat May 11 19:49:23 2013 -0500

    ChessEngine: profile and binary should be private

 src/chess-engine-cecp.vala |    3 ++-
 src/chess-engine-uci.vala  |    3 ++-
 src/chess-engine.vala      |   12 +++++++++---
 src/gnome-chess.vala       |    6 ++----
 4 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/chess-engine-cecp.vala b/src/chess-engine-cecp.vala
index 4a7aff5..65bd5df 100644
--- a/src/chess-engine-cecp.vala
+++ b/src/chess-engine-cecp.vala
@@ -4,8 +4,9 @@ public class ChessEngineCECP : ChessEngine
     private bool moving = false;
     private string[] options;
 
-    public ChessEngineCECP (string[] options)
+    public ChessEngineCECP (string binary, string args, string[] options)
     {
+        base (binary, args);
         this.options = options;
         starting.connect (start_cb);
     }
diff --git a/src/chess-engine-uci.vala b/src/chess-engine-uci.vala
index d50a996..505b906 100644
--- a/src/chess-engine-uci.vala
+++ b/src/chess-engine-uci.vala
@@ -5,8 +5,9 @@ public class ChessEngineUCI : ChessEngine
     private string[] options;
     private bool waiting_for_move;
 
-    public ChessEngineUCI (string[] options)
+    public ChessEngineUCI (string binary, string args, string[] options)
     {
+        base (binary, args);
         this.options = options;
         buffer = new char[0];
         moves = "";
diff --git a/src/chess-engine.vala b/src/chess-engine.vala
index c27e203..ee49f87 100644
--- a/src/chess-engine.vala
+++ b/src/chess-engine.vala
@@ -1,7 +1,7 @@
 public abstract class ChessEngine : Object
 {
-    public string binary;
-    public string args;
+    private string binary;
+    private string args;
 
     private Pid pid;
     private int stdin_fd;
@@ -29,7 +29,13 @@ public abstract class ChessEngine : Object
             return _ready;
         }
     }
-    
+
+    public ChessEngine (string binary, string args)
+    {
+        this.binary = binary;
+        this.args = args;
+    }
+
     public bool start ()
     {
         string[] argv = { binary, args, null };
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 71e8740..6561f2f 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -527,16 +527,14 @@ public class Application : Gtk.Application
         }
 
         if (profile.protocol == "cecp")
-            engine = new ChessEngineCECP (options);
+            engine = new ChessEngineCECP (profile.binary, profile.args, options);
         else if (profile.protocol == "uci")
-            engine = new ChessEngineUCI (options);
+            engine = new ChessEngineUCI (profile.binary, profile.args, options);
         else
         {
             warning ("Unknown AI protocol %s", profile.protocol);
             return null;
         }
-        engine.binary = profile.binary;
-        engine.args = profile.args;
 
         return engine;
     }


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