diff options
| -rw-r--r-- | doc/runtime-api.html | 4 | ||||
| -rw-r--r-- | src/runtime/java/jpgf.c | 38 |
2 files changed, 40 insertions, 2 deletions
diff --git a/doc/runtime-api.html b/doc/runtime-api.html index 727adf31c..b0fc24b91 100644 --- a/doc/runtime-api.html +++ b/doc/runtime-api.html @@ -1081,7 +1081,7 @@ n0 -- n3 [style = "solid"] } </pre> <pre class="java"> -System.out.println(gr.graphvizAbstractTree(e)); //// TODO +System.out.println(gr.graphvizAbstractTree(e)); graph { n0[label = "AdjCN", style = "solid", shape = "plaintext"] n1[label = "PositA", style = "solid", shape = "plaintext"] @@ -1184,7 +1184,7 @@ graph { } </pre> <pre class="java"> -System.out.println(eng.graphvizParseTree(e)); //// TODO +System.out.println(eng.graphvizParseTree(e)); graph { node[shape=plaintext] diff --git a/src/runtime/java/jpgf.c b/src/runtime/java/jpgf.c index 6fdb1047e..2eb151836 100644 --- a/src/runtime/java/jpgf.c +++ b/src/runtime/java/jpgf.c @@ -371,6 +371,25 @@ Java_org_grammaticalframework_pgf_PGF_getFunctionsByCat(JNIEnv* env, jobject sel return functions; } +JNIEXPORT jstring JNICALL +Java_org_grammaticalframework_pgf_PGF_graphvizAbstractTree(JNIEnv* env, jobject self, jobject jexpr) +{ + GuPool* tmp_pool = gu_local_pool(); + + GuExn* err = gu_exn(tmp_pool); + GuStringBuf* sbuf = gu_new_string_buf(tmp_pool); + GuOut* out = gu_string_buf_out(sbuf); + + pgf_graphviz_abstract_tree(get_ref(env,self), + gu_variant_from_ptr(l2p(get_ref(env,jexpr))), + out, err); + + jstring jstr = gu2j_string_buf(env, sbuf); + + gu_pool_free(tmp_pool); + return jstr; +} + JNIEXPORT jstring JNICALL Java_org_grammaticalframework_pgf_Concr_getName(JNIEnv* env, jobject self) { @@ -1198,6 +1217,25 @@ Java_org_grammaticalframework_pgf_Concr_getPrintName(JNIEnv* env, jobject self, return jname; } +JNIEXPORT jstring JNICALL +Java_org_grammaticalframework_pgf_Concr_graphvizParseTree(JNIEnv* env, jobject self, jobject jexpr) +{ + GuPool* tmp_pool = gu_local_pool(); + + GuExn* err = gu_exn(tmp_pool); + GuStringBuf* sbuf = gu_new_string_buf(tmp_pool); + GuOut* out = gu_string_buf_out(sbuf); + + pgf_graphviz_parse_tree(get_ref(env,self), + gu_variant_from_ptr(l2p(get_ref(env,jexpr))), + out, err); + + jstring jstr = gu2j_string_buf(env, sbuf); + + gu_pool_free(tmp_pool); + return jstr; +} + JNIEXPORT jlong JNICALL Java_org_grammaticalframework_pgf_Pool_alloc(JNIEnv* env, jclass clazz) { |
