Skip to content

Commit

Permalink
implement close()
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevan Little committed Apr 4, 2013
1 parent 8832e2f commit 9033d41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/scala/org/moe/runtime/builtins/IOClass.scala
Expand Up @@ -137,6 +137,15 @@ object IOClass {
)
)

ioClass.addMethod(
new MoeMethod(
"close",
new MoeSignature(),
env,
(e) => self(e).close(r)
)
)

/**
* NOTE:
* This list needs some work, I have been punting on
Expand Down
Expand Up @@ -56,6 +56,12 @@ class MoeIOObject(
Source.fromFile(file).mkString
)

def close (r: MoeRuntime): MoeUndefObject = {
reader.close()
writer.close()
r.NativeObjects.getUndef
}

// MoeNativeObject overrides

override def copy = new MoeIOObject(
Expand Down

0 comments on commit 9033d41

Please sign in to comment.