From b0a74ddc59ef008f855784ca78dddd0cc31bd79d Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 27 Nov 2013 12:35:11 +0000 Subject: added API in the C runtime and the Java binding for checking whether a given function is linearizable in a given language. This is used in the Android UI for better vizualizations --- src/runtime/c/pgf/pgf.c | 8 +++++++ src/runtime/c/pgf/pgf.h | 27 +++------------------- src/runtime/java/jpgf.c | 11 +++++++++ .../java/org/grammaticalframework/pgf/Concr.java | 2 ++ 4 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c index b9f555978..155b93135 100644 --- a/src/runtime/c/pgf/pgf.c +++ b/src/runtime/c/pgf/pgf.c @@ -158,3 +158,11 @@ pgf_print_name(PgfConcr* concr, PgfCId id) name = id; return name; } + +bool +pgf_has_linearization(PgfConcr* concr, PgfCId id) +{ + PgfCncOverloadMap* overl_table = + gu_map_get(concr->fun_indices, id, PgfCncOverloadMap*); + return (overl_table != NULL); +} diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h index 606cb9940..20e6b1fa8 100644 --- a/src/runtime/c/pgf/pgf.h +++ b/src/runtime/c/pgf/pgf.h @@ -1,27 +1,3 @@ -/* - * Copyright 2010 University of Gothenburg. - * - * This file is part of libpgf. - * - * Libpgf is free software: you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Libpgf is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libpgf. If not, see . - */ - -/** @file - * - * The public libpgf API. - */ - #ifndef PGF_H_ #define PGF_H_ @@ -114,6 +90,9 @@ pgf_function_type(PgfPGF* pgf, PgfCId funname); GuString pgf_print_name(PgfConcr*, PgfCId id); +bool +pgf_has_linearization(PgfConcr* concr, PgfCId id); + void pgf_linearize(PgfConcr* concr, PgfExpr expr, GuOut* out, GuExn* err); diff --git a/src/runtime/java/jpgf.c b/src/runtime/java/jpgf.c index d70301a62..8cfe2c705 100644 --- a/src/runtime/java/jpgf.c +++ b/src/runtime/java/jpgf.c @@ -472,6 +472,17 @@ Java_org_grammaticalframework_pgf_Concr_lookupMorpho(JNIEnv* env, jobject self, return analyses; } +JNIEXPORT jboolean JNICALL +Java_org_grammaticalframework_pgf_Concr_hasLinearization(JNIEnv* env, jobject self, jstring jid) +{ + PgfConcr* concr = get_ref(env, self); + GuPool* tmp_pool = gu_new_pool(); + PgfCId id = j2gu_string(env, jid, tmp_pool); + bool res = pgf_has_linearization(concr, id); + gu_pool_free(tmp_pool); + return res; +} + JNIEXPORT void JNICALL Java_org_grammaticalframework_pgf_Pool_free(JNIEnv* env, jobject self, jlong ref) { diff --git a/src/runtime/java/org/grammaticalframework/pgf/Concr.java b/src/runtime/java/org/grammaticalframework/pgf/Concr.java index 81f696aaf..779d461cc 100644 --- a/src/runtime/java/org/grammaticalframework/pgf/Concr.java +++ b/src/runtime/java/org/grammaticalframework/pgf/Concr.java @@ -25,6 +25,8 @@ public class Concr { public native List lookupMorpho(String sentence); + public native boolean hasLinearization(String id); + ////////////////////////////////////////////////////////////////// // private stuff -- cgit v1.2.3