forked from GitHub/gf-core
construction of Int and Float literals in the Java binding
This commit is contained in:
@@ -1226,6 +1226,46 @@ Java_org_grammaticalframework_pgf_Expr_initStringLit(JNIEnv* env, jclass clazz,
|
|||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL
|
||||||
|
Java_org_grammaticalframework_pgf_Expr_initIntLit(JNIEnv* env, jclass clazz, jint jd, jlong jpool)
|
||||||
|
{
|
||||||
|
GuPool* pool = l2p(jpool);
|
||||||
|
PgfExpr expr;
|
||||||
|
|
||||||
|
PgfExprLit* e =
|
||||||
|
gu_new_variant(PGF_EXPR_LIT,
|
||||||
|
PgfExprLit,
|
||||||
|
&expr, pool);
|
||||||
|
|
||||||
|
PgfLiteralInt* nlit =
|
||||||
|
gu_new_variant(PGF_LITERAL_INT,
|
||||||
|
PgfLiteralInt,
|
||||||
|
&e->lit, pool);
|
||||||
|
nlit->val = jd;
|
||||||
|
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL
|
||||||
|
Java_org_grammaticalframework_pgf_Expr_initFloatLit(JNIEnv* env, jclass clazz, jdouble jf, jlong jpool)
|
||||||
|
{
|
||||||
|
GuPool* pool = l2p(jpool);
|
||||||
|
PgfExpr expr;
|
||||||
|
|
||||||
|
PgfExprLit* e =
|
||||||
|
gu_new_variant(PGF_EXPR_LIT,
|
||||||
|
PgfExprLit,
|
||||||
|
&expr, pool);
|
||||||
|
|
||||||
|
PgfLiteralFlt* flit =
|
||||||
|
gu_new_variant(PGF_LITERAL_FLT,
|
||||||
|
PgfLiteralFlt,
|
||||||
|
&e->lit, pool);
|
||||||
|
flit->val = jf;
|
||||||
|
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_org_grammaticalframework_pgf_Expr_initApp__Lorg_grammaticalframework_pgf_Expr_2_3Lorg_grammaticalframework_pgf_Expr_2J
|
Java_org_grammaticalframework_pgf_Expr_initApp__Lorg_grammaticalframework_pgf_Expr_2_3Lorg_grammaticalframework_pgf_Expr_2J
|
||||||
(JNIEnv* env, jclass clazz, jobject jfun, jobjectArray args, jlong jpool)
|
(JNIEnv* env, jclass clazz, jobject jfun, jobjectArray args, jlong jpool)
|
||||||
|
|||||||
@@ -31,6 +31,20 @@ public class Expr implements Serializable {
|
|||||||
this.ref = initStringLit(s, pool.ref);
|
this.ref = initStringLit(s, pool.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Constructs an expression which represents an integer literal */
|
||||||
|
public Expr(int d) {
|
||||||
|
this.pool = new Pool();
|
||||||
|
this.master = null;
|
||||||
|
this.ref = initIntLit(d, pool.ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructs an expression which represents a floating point literal */
|
||||||
|
public Expr(double f) {
|
||||||
|
this.pool = new Pool();
|
||||||
|
this.master = null;
|
||||||
|
this.ref = initFloatLit(f, pool.ref);
|
||||||
|
}
|
||||||
|
|
||||||
/** Constructs an expression which is a function application
|
/** Constructs an expression which is a function application
|
||||||
* @param fun The name of the top-level function.
|
* @param fun The name of the top-level function.
|
||||||
* @param args the arguments for the function.
|
* @param args the arguments for the function.
|
||||||
@@ -85,6 +99,8 @@ public class Expr implements Serializable {
|
|||||||
private static native String showExpr(long ref);
|
private static native String showExpr(long ref);
|
||||||
|
|
||||||
private static native long initStringLit(String s, long pool);
|
private static native long initStringLit(String s, long pool);
|
||||||
|
private static native long initIntLit(int d, long pool);
|
||||||
|
private static native long initFloatLit(double f, long pool);
|
||||||
private static native long initApp(Expr fun, Expr[] args, long pool);
|
private static native long initApp(Expr fun, Expr[] args, long pool);
|
||||||
private static native long initApp(String fun, Expr[] args, long pool);
|
private static native long initApp(String fun, Expr[] args, long pool);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user