Skip to content

Commit 73fcb8c

Browse files
committed
finished building quest, plus unit test suite.
1 parent 0d7b306 commit 73fcb8c

File tree

4 files changed

+2395
-17
lines changed

4 files changed

+2395
-17
lines changed

src/C4Wrapper.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# IMPORTS #
77
#############
88
# standard python packages
9-
import inspect, os, string, sys, time
9+
import logging, inspect, os, string, sys, time
1010
from ctypes import *
1111
from types import *
1212

@@ -20,8 +20,7 @@ class C4Wrapper( object ) :
2020
# INIT #
2121
##########
2222
def __init__( self ) :
23-
24-
c4_lib_loc = os.path.abspath( __file__ + '/../../../lib/c4/build/src/libc4/libc4.dylib' )
23+
c4_lib_loc = os.path.abspath( __file__ + '/../../lib/c4/build/src/libc4/libc4.dylib' )
2524
self.lib = cdll.LoadLibrary( c4_lib_loc )
2625
self.lib.c4_make.restype = POINTER(c_char)
2726
self.lib.c4_dump_table.restype = c_char_p # c4_dump_table returns a char*
@@ -30,7 +29,6 @@ def __init__( self ) :
3029
#########
3130
# RUN #
3231
#########
33-
# fullprog is a string of concatenated overlog commands.
3432
def run( self, allProgramData ) :
3533

3634
allProgramLines = allProgramData[0] # := list of every code line in the generated C4 program.
@@ -39,14 +37,9 @@ def run( self, allProgramData ) :
3937
completeProg = "".join( allProgramLines )
4038

4139
# ----------------------------------------- #
42-
print "PRINTING LEGIBLE INPUT PROG"
43-
for line in fullprog :
44-
line = line.split( ";" )
45-
for statement in line :
46-
statement = statement.rstrip()
47-
if not statement == "" :
48-
statement = statement + ";"
49-
print statement
40+
logging.debug( "PRINTING LEGIBLE INPUT PROG" )
41+
for statement in allProgramLines :
42+
logging.debug( statement )
5043

5144
# ----------------------------------------- #
5245
# initialize c4 instance
@@ -55,7 +48,8 @@ def run( self, allProgramData ) :
5548

5649
# ---------------------------------------- #
5750
# load program
58-
print "SUBMITTING SUBPROG : "
51+
logging.debug( "SUBMITTING SUBPROG : " )
52+
logging.debug( completeProg )
5953
c_prog = bytes( completeProg )
6054
self.lib.c4_install_str( self.c4_obj, c_prog )
6155

@@ -84,10 +78,9 @@ def saveC4Results_toArray( self, tableList ) :
8478
for table in tableList :
8579

8680
# output to stdout
87-
if DEBUG :
88-
print "---------------------------"
89-
print table
90-
print self.lib.c4_dump_table( self.c4_obj, table )
81+
logging.debug( "---------------------------" )
82+
logging.debug( table )
83+
logging.debug( self.lib.c4_dump_table( self.c4_obj, table ) )
9184

9285
# save in array
9386
results_array.append( "---------------------------" )

0 commit comments

Comments
 (0)