added mkInt and mkFloat in the Haskell binding to make it easy to create literal expressions

This commit is contained in:
krasimir
2015-11-19 13:18:19 +00:00
parent fe7397efe4
commit 9f9b23d0dd
5 changed files with 59 additions and 1 deletions

View File

@@ -112,6 +112,36 @@ pgf_expr_string(GuString str, GuPool* pool)
lit);
}
PgfExpr
pgf_expr_int(int val, GuPool* pool)
{
PgfLiteral lit;
PgfLiteralInt* plit =
gu_new_variant(PGF_LITERAL_INT,
PgfLiteralInt,
&lit, pool);
plit->val = val;
return gu_new_variant_i(pool,
PGF_EXPR_LIT,
PgfExprLit,
lit);
}
PgfExpr
pgf_expr_float(double val, GuPool* pool)
{
PgfLiteral lit;
PgfLiteralFlt* plit =
gu_new_variant(PGF_LITERAL_FLT,
PgfLiteralFlt,
&lit, pool);
plit->val = val;
return gu_new_variant_i(pool,
PGF_EXPR_LIT,
PgfExprLit,
lit);
}
typedef struct PgfExprParser PgfExprParser;
typedef enum {

View File

@@ -149,6 +149,12 @@ pgf_expr_apply(PgfApplication*, GuPool* pool);
PgfExpr
pgf_expr_string(GuString, GuPool* pool);
PgfExpr
pgf_expr_int(int val, GuPool* pool);
PgfExpr
pgf_expr_float(double val, GuPool* pool);
PgfExpr
pgf_read_expr(GuIn* in, GuPool* pool, GuExn* err);