From bae05df3b040c56f87d331a3f7b58529b1e8a014 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 28 May 2013 13:32:32 +0000 Subject: added a test class for the Java API plus a small refinement in the implementation for the binding --- src/runtime/java/org/grammaticalframework/PGF.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/runtime/java/org') diff --git a/src/runtime/java/org/grammaticalframework/PGF.java b/src/runtime/java/org/grammaticalframework/PGF.java index 777edbd98..6ff0a21a4 100644 --- a/src/runtime/java/org/grammaticalframework/PGF.java +++ b/src/runtime/java/org/grammaticalframework/PGF.java @@ -1,25 +1,31 @@ package org.grammaticalframework; public class PGF { - static native PGF readPGF(String path); + public static native PGF readPGF(String path); + + public void close() { + if (pool != 0) { + free(pool); + pool = 0; + gr = 0; + } + } - private int pool; - private int gr; + private static native void free(long pool); + + private long pool; + private long gr; - private PGF(int pool, int gr) { + private PGF(long pool, long gr) { this.pool = pool; this.gr = gr; } + protected void finalize () throws Throwable { + close(); + } + static { System.loadLibrary("jpgf"); } - - public void test() { - System.out.println("pool="+pool+", gr="+gr); - } - - public static void main(String[] args) { - readPGF("/home/krasimir/www.grammaticalframework.org/treebanks/PennTreebank/ParseEngAbs.pgf").test(); - } } -- cgit v1.2.3