[Avida-cvs] [Avida2-svn] r352 - in trunk/source: bindings/Boost.Python cpu

kaben@myxo.css.msu.edu kaben at myxo.css.msu.edu
Tue Oct 18 12:20:44 PDT 2005


Author: kaben
Date: 2005-10-18 15:20:44 -0400 (Tue, 18 Oct 2005)
New Revision: 352

Added:
   trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.cc
   trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.h
   trunk/source/bindings/Boost.Python/cHardwareCPUDefs.pyste
   trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.cc
   trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.hh
Modified:
   trunk/source/bindings/Boost.Python/CMakeLists.txt
   trunk/source/bindings/Boost.Python/hardware_cpu.pyste
   trunk/source/bindings/Boost.Python/hardware_cpu_thread.pyste
   trunk/source/bindings/Boost.Python/hardware_status_printer.pyste
   trunk/source/bindings/Boost.Python/nHardware-fixups.cc
   trunk/source/bindings/Boost.Python/nHardware-fixups.h
   trunk/source/bindings/Boost.Python/tArray.pyste
   trunk/source/bindings/Boost.Python/tArray_instantiations.hh
   trunk/source/cpu/cHardwareCPU.cc
   trunk/source/cpu/cHardwareCPU.h
Log:

Repairs restoring lost Avida-ED functionality.



Modified: trunk/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- trunk/source/bindings/Boost.Python/CMakeLists.txt	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/CMakeLists.txt	2005-10-18 19:20:44 UTC (rev 352)
@@ -91,7 +91,7 @@
   fitness_matrix:: # XXX XXX
   genotype_birth_data:: # XXX XXX
   hardware_4stack_thread:: # XXX XXX
-  hardware_cpu_thread:: # XXX XXX
+  hardware_cpu_thread::${CMAKE_CURRENT_SOURCE_DIR}/hardware_cpu_thread-fixups.hh # XXX XXX
   inject_genotype_birth_data:: # XXX XXX
   inst_util:: # XXX XXX
   integrated_schedule::${CMAKE_CURRENT_SOURCE_DIR}/schedule.pyste: # XXX XXX
@@ -141,8 +141,8 @@
   avida_driver_population::${CMAKE_CURRENT_SOURCE_DIR}/avida_driver_base.pyste # XXX XXX XXX
   config:: # XXX XXX XXX
   count_tracker:: # XXX XXX XXX
-  nHardware::
-  nHardwareCPU::
+  nHardware::${CMAKE_CURRENT_SOURCE_DIR}/nHardware-fixups.h
+  nHardwareCPU::${CMAKE_CURRENT_SOURCE_DIR}/nHardwareCPU-fixups.h
   data_entry:: # XXX XXX XXX
   data_file:: # XXX XXX XXX
   data_file_manager:: # XXX XXX XXX
@@ -189,6 +189,7 @@
   file-fixups.cc
   genesis-fixups.cc
   hardware_cpu-fixups.cc
+  hardware_cpu_thread-fixups.cc
   py_avida_driver-fixups.cc
   py_hardware_tracer-fixups.cc
   resource_count-fixups.cc

Added: trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.cc	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.cc	2005-10-18 19:20:44 UTC (rev 352)
@@ -0,0 +1,13 @@
+
+#include "cHardwareCPUDefs-fixups.h"
+
+#include "nHardwareCPU.h"
+
+
+const int cHardwareCPUDefs::s_NUM_NOPS(nHardwareCPU::NUM_NOPS);
+const int cHardwareCPUDefs::s_REG_AX(nHardwareCPU::REG_AX);
+const int cHardwareCPUDefs::s_REG_BX(nHardwareCPU::REG_BX);
+const int cHardwareCPUDefs::s_REG_CX(nHardwareCPU::REG_CX);
+const int cHardwareCPUDefs::s_REG_DX(nHardwareCPU::REG_DX);
+const int cHardwareCPUDefs::s_NUM_REGISTERS(nHardwareCPU::NUM_REGISTERS);
+

Added: trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.h
===================================================================
--- trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.h	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/cHardwareCPUDefs-fixups.h	2005-10-18 19:20:44 UTC (rev 352)
@@ -0,0 +1,13 @@
+#ifndef CPU_DEFS_FIXUPS_HH
+#define CPU_DEFS_FIXUPS_HH
+
+struct cHardwareCPUDefs {
+  static const int s_NUM_NOPS;
+  static const int s_REG_AX;
+  static const int s_REG_BX;
+  static const int s_REG_CX;
+  static const int s_REG_DX;
+  static const int s_NUM_REGISTERS;
+};
+
+#endif

Added: trunk/source/bindings/Boost.Python/cHardwareCPUDefs.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/cHardwareCPUDefs.pyste	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/cHardwareCPUDefs.pyste	2005-10-18 19:20:44 UTC (rev 352)
@@ -0,0 +1,6 @@
+
+#Include("nHardwareCPU.h")
+
+cHardwareCPUDefs = Class("cHardwareCPUDefs", "cHardwareCPUDefs-fixups.h")
+
+# vim: set ft=python:

Modified: trunk/source/bindings/Boost.Python/hardware_cpu.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_cpu.pyste	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/hardware_cpu.pyste	2005-10-18 19:20:44 UTC (rev 352)
@@ -16,6 +16,7 @@
 set_policy(cHardwareCPU.IP, return_internal_reference())
 set_policy(cHardwareCPU.GetLabel, return_internal_reference())
 set_policy(cHardwareCPU.GetReadLabel, return_internal_reference())
+set_policy(cHardwareCPU.pyGetThreads, return_internal_reference())
 
 ### <sigh> Register() is written in two versions, one returning an int,
 ### and one returning a reference to an int. Pyste can't cope --

Added: trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.cc	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.cc	2005-10-18 19:20:44 UTC (rev 352)
@@ -0,0 +1,9 @@
+#include "cHeadCPU.h"
+#include "hardware_cpu_thread-fixups.hh"
+
+const int cHardwareCPU_Thread_GetRegister(cHardwareCPU_Thread & thread, int index){
+  return thread.reg[index];
+}
+const cHeadCPU &cHardwareCPU_Thread_GetHead(cHardwareCPU_Thread & thread, int index){
+  return thread.heads[index];
+}

Added: trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.hh
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.hh	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/hardware_cpu_thread-fixups.hh	2005-10-18 19:20:44 UTC (rev 352)
@@ -0,0 +1,21 @@
+#ifndef HARDWARE_CPU_THREAD_FIXUPS_HH
+#define HARDWARE_CPU_THREAD_FIXUPS_HH
+
+#ifndef HARDWARE_CPU_THREAD_HH
+#include "cHardwareCPU_Thread.h"
+#endif
+
+#ifndef HEAD_CPU_HH
+#include "cHeadCPU.h"
+#endif
+
+const int cHardwareCPU_Thread_GetRegister(
+  cHardwareCPU_Thread & thread,
+  int index
+);
+const cHeadCPU &cHardwareCPU_Thread_GetHead(
+  cHardwareCPU_Thread & thread,
+  int index
+);
+
+#endif

Modified: trunk/source/bindings/Boost.Python/hardware_cpu_thread.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_cpu_thread.pyste	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/hardware_cpu_thread.pyste	2005-10-18 19:20:44 UTC (rev 352)
@@ -1,9 +1,16 @@
 
 Include("cHardwareBase.h")
+Include("cHeadCPU.h")
 
-cHardwareCPU_Thread = Class("cHardwareCPU_Thread", "cHardwareCPU_Thread.h")
+cHardwareCPU_Thread = Class("cHardwareCPU_Thread", "hardware_cpu_thread-fixups.hh")
 
 exclude(cHardwareCPU_Thread.reg)
 exclude(cHardwareCPU_Thread.heads)
 
+add_method(cHardwareCPU_Thread, "cHardwareCPU_Thread_GetRegister")
+add_method(cHardwareCPU_Thread, "cHardwareCPU_Thread_GetHead")
+
+rename(cHardwareCPU_Thread.cHardwareCPU_Thread_GetRegister, "GetRegister")
+rename(cHardwareCPU_Thread.cHardwareCPU_Thread_GetHead, "GetHead")
+
 # vim: set ft=python:

Modified: trunk/source/bindings/Boost.Python/hardware_status_printer.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_status_printer.pyste	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/hardware_status_printer.pyste	2005-10-18 19:20:44 UTC (rev 352)
@@ -1,6 +1,7 @@
 
+Include("cHardware4Stack.h")
 Include("cHardwareCPU.h")
-Include("cHardware4Stack.h")
+Include("cHardwareSMT.h")
 Include("cOrganism.h")
 
 Import("hardware_tracer.pyste")

Modified: trunk/source/bindings/Boost.Python/nHardware-fixups.cc
===================================================================
--- trunk/source/bindings/Boost.Python/nHardware-fixups.cc	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/nHardware-fixups.cc	2005-10-18 19:20:44 UTC (rev 352)
@@ -16,3 +16,5 @@
 const int cHardwareDefs::s_HEAD_WRITE(nHardware::HEAD_WRITE);
 const int cHardwareDefs::s_HEAD_FLOW(nHardware::HEAD_FLOW);
 const int cHardwareDefs::s_NUM_HEADS(nHardware::NUM_HEADS);
+const int cHardwareDefs::s_STACK_SIZE(nHardware::STACK_SIZE);
+const int cHardwareDefs::s_IO_SIZE(nHardware::IO_SIZE);

Modified: trunk/source/bindings/Boost.Python/nHardware-fixups.h
===================================================================
--- trunk/source/bindings/Boost.Python/nHardware-fixups.h	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/nHardware-fixups.h	2005-10-18 19:20:44 UTC (rev 352)
@@ -16,6 +16,8 @@
   static const int s_HEAD_WRITE;
   static const int s_HEAD_FLOW;
   static const int s_NUM_HEADS;
+  static const int s_STACK_SIZE;
+  static const int s_IO_SIZE;
 };
 
 #endif

Modified: trunk/source/bindings/Boost.Python/tArray.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/tArray.pyste	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/tArray.pyste	2005-10-18 19:20:44 UTC (rev 352)
@@ -75,6 +75,7 @@
 Import("merit.pyste")
 Import("mutation.pyste")
 Import("int_sum.pyste")
+Import("hardware_cpu_thread.pyste")
 
 Include("cOrgMessage.h")
 
@@ -101,6 +102,10 @@
 tArray_cIntSum = tArray(cIntSum_str)
 declaration_code_string += commonClassWrapperFactors(cIntSum_str, tArray_cIntSum)
 
+cHardwareCPU_Thread_str = "cHardwareCPU_Thread"
+tArray_cHardwareCPU_Thread = tArray(cHardwareCPU_Thread_str)
+declaration_code_string += commonClassWrapperFactors(cHardwareCPU_Thread_str, tArray_cHardwareCPU_Thread) 
+
 double_str = "double"
 tArray_double = tArray(double_str)
 declaration_code_string += commonFundamentalWrapperFactors(double_str, tArray_double)

Modified: trunk/source/bindings/Boost.Python/tArray_instantiations.hh
===================================================================
--- trunk/source/bindings/Boost.Python/tArray_instantiations.hh	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/bindings/Boost.Python/tArray_instantiations.hh	2005-10-18 19:20:44 UTC (rev 352)
@@ -2,6 +2,7 @@
 #include "cMerit.h"
 #include "cMutation.h"
 #include "cIntSum.h"
+#include "cHardwareCPU_Thread.h"
 
 #include "tArray.h"
 

Modified: trunk/source/cpu/cHardwareCPU.cc
===================================================================
--- trunk/source/cpu/cHardwareCPU.cc	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/cpu/cHardwareCPU.cc	2005-10-18 19:20:44 UTC (rev 352)
@@ -3461,3 +3461,15 @@
 }
 
 
+  /*
+  FIXME: Breakage of interface. This function returns data that is
+  supposed to be private.
+
+  I need to make complete snapshots of hardware state from Python.  If I
+  have the time, I'll come back and fix the breakage.
+
+  @kgn
+  */
+const tArray<cHardwareCPU_Thread> &cHardwareCPU::pyGetThreads(){
+  return threads;
+}

Modified: trunk/source/cpu/cHardwareCPU.h
===================================================================
--- trunk/source/cpu/cHardwareCPU.h	2005-10-18 19:13:24 UTC (rev 351)
+++ trunk/source/cpu/cHardwareCPU.h	2005-10-18 19:20:44 UTC (rev 352)
@@ -240,7 +240,20 @@
 
   //void InitInstSet(const cString & filename, cInstSet & inst_set);
 
+  /*
+  FIXME: Breakage of interface. These functions return data that is
+  supposed to be private.
 
+  I need to make complete snapshots of hardware state from Python.
+  If I have the time, I'll come back and fix the breakage.
+
+  @kgn
+  */
+  cCPUStack pyGetGlobalStack(){ return global_stack; }
+  int pyGetThreadTimeUsed(){ return thread_time_used; }
+  const tArray<cHardwareCPU_Thread> &pyGetThreads();
+  bool pyGetAdvanceIP(){ return advance_ip; }
+
 private:
  
  /////////---------- Instruction Helpers ------------//////////




More information about the Avida-cvs mailing list