This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro ccallWrap(lib, fnSym, retType, argTypes) | |
argTypes = eval(argTypes) | |
assertOp = :(sym::Type).head | |
args = [gensym() for i in 1:length(argTypes)] | |
fnArgs = [Expr(assertOp, {args[i], argTypes[i]}, Any) | |
for i in 1:length(argTypes)] | |
dlsymExpr = Expr(:call, {:dlsym, lib, fnSym}, Any) | |
ccallExpr = Expr(:call,{:ccall, dlsymExpr, retType, argTypes, args...},Any) | |
fnBody = Expr(:block, {ccallExpr}, Any) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns the new cell index from the specified cell in the | |
# specified direction. The index is only valid if the | |
# starting cell and direction have been checked by the | |
# out_of_bounds function first. | |
function shift(cell_::Int8, dir::Int8) | |
div5_mod2(x) = (x - 1)/5 % 2 != 0 | |
if dir == E | |
return int8(cell_ + 1) | |
elseif dir == ESE | |
if div5_mod2(cell_) |