mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 16:42:51 -06:00
createFunction now takes arity as argument
This commit is contained in:
@@ -51,7 +51,7 @@ grammar2PGF opts gr am probs = do
|
|||||||
modifyPGF gr $ do
|
modifyPGF gr $ do
|
||||||
sequence_ [setAbstractFlag name value | (name,value) <- flags]
|
sequence_ [setAbstractFlag name value | (name,value) <- flags]
|
||||||
sequence_ [createCategory c ctxt p | (c,ctxt,p) <- cats]
|
sequence_ [createCategory c ctxt p | (c,ctxt,p) <- cats]
|
||||||
sequence_ [createFunction f ty p | (f,ty,_,_,p) <- funs]
|
sequence_ [createFunction f ty arity p | (f,ty,arity,_,p) <- funs]
|
||||||
where
|
where
|
||||||
adefs =
|
adefs =
|
||||||
[((cPredefAbs,c), AbsCat (Just (L NoLoc []))) | c <- [cFloat,cInt,cString]] ++
|
[((cPredefAbs,c), AbsCat (Just (L NoLoc []))) | c <- [cFloat,cInt,cString]] ++
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ PgfRevision pgf_checkout_revision(PgfDB *db, PgfText *name,
|
|||||||
PGF_API
|
PGF_API
|
||||||
void pgf_create_function(PgfDB *db, PgfRevision revision,
|
void pgf_create_function(PgfDB *db, PgfRevision revision,
|
||||||
PgfText *name,
|
PgfText *name,
|
||||||
PgfType ty, prob_t prob,
|
PgfType ty, size_t arity, prob_t prob,
|
||||||
PgfMarshaller *m,
|
PgfMarshaller *m,
|
||||||
PgfExn *err)
|
PgfExn *err)
|
||||||
{
|
{
|
||||||
@@ -651,7 +651,7 @@ void pgf_create_function(PgfDB *db, PgfRevision revision,
|
|||||||
ref<PgfAbsFun> absfun = PgfDB::malloc<PgfAbsFun>(name->size+1);
|
ref<PgfAbsFun> absfun = PgfDB::malloc<PgfAbsFun>(name->size+1);
|
||||||
absfun->ref_count = 1;
|
absfun->ref_count = 1;
|
||||||
absfun->type = m->match_type(&u, ty);
|
absfun->type = m->match_type(&u, ty);
|
||||||
absfun->arity = 0;
|
absfun->arity = arity;
|
||||||
absfun->defns = 0;
|
absfun->defns = 0;
|
||||||
absfun->ep.prob = prob;
|
absfun->ep.prob = prob;
|
||||||
ref<PgfExprFun> efun =
|
ref<PgfExprFun> efun =
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ PgfRevision pgf_checkout_revision(PgfDB *db, PgfText *name,
|
|||||||
PGF_API_DECL
|
PGF_API_DECL
|
||||||
void pgf_create_function(PgfDB *db, PgfRevision revision,
|
void pgf_create_function(PgfDB *db, PgfRevision revision,
|
||||||
PgfText *name,
|
PgfText *name,
|
||||||
PgfType ty, prob_t prob,
|
PgfType ty, size_t arity, prob_t prob,
|
||||||
PgfMarshaller *m,
|
PgfMarshaller *m,
|
||||||
PgfExn *err);
|
PgfExn *err);
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ foreign import ccall pgf_commit_revision :: Ptr PgfDB -> Ptr PgfRevision -> Ptr
|
|||||||
|
|
||||||
foreign import ccall pgf_checkout_revision :: Ptr PgfDB -> Ptr PgfText -> Ptr PgfExn -> IO (Ptr PgfRevision)
|
foreign import ccall pgf_checkout_revision :: Ptr PgfDB -> Ptr PgfText -> Ptr PgfExn -> IO (Ptr PgfRevision)
|
||||||
|
|
||||||
foreign import ccall pgf_create_function :: Ptr PgfDB -> Ptr PgfRevision -> Ptr PgfText -> StablePtr Type -> (#type prob_t) -> Ptr PgfMarshaller -> Ptr PgfExn -> IO ()
|
foreign import ccall pgf_create_function :: Ptr PgfDB -> Ptr PgfRevision -> Ptr PgfText -> StablePtr Type -> CSize -> (#type prob_t) -> Ptr PgfMarshaller -> Ptr PgfExn -> IO ()
|
||||||
|
|
||||||
foreign import ccall pgf_drop_function :: Ptr PgfDB -> Ptr PgfRevision -> Ptr PgfText -> Ptr PgfExn -> IO ()
|
foreign import ccall pgf_drop_function :: Ptr PgfDB -> Ptr PgfRevision -> Ptr PgfText -> Ptr PgfExn -> IO ()
|
||||||
|
|
||||||
|
|||||||
@@ -109,12 +109,12 @@ checkoutPGF p name =
|
|||||||
else do fptr2 <- C.newForeignPtr c_revision (withForeignPtr (a_db p) (\c_db -> pgf_free_revision c_db c_revision))
|
else do fptr2 <- C.newForeignPtr c_revision (withForeignPtr (a_db p) (\c_db -> pgf_free_revision c_db c_revision))
|
||||||
return (Just (PGF (a_db p) fptr2 (languages p)))
|
return (Just (PGF (a_db p) fptr2 (languages p)))
|
||||||
|
|
||||||
createFunction :: Fun -> Type -> Float -> Transaction ()
|
createFunction :: Fun -> Type -> Int -> Float -> Transaction ()
|
||||||
createFunction name ty prob = Transaction $ \c_db c_revision c_exn ->
|
createFunction name ty arity prob = Transaction $ \c_db c_revision c_exn ->
|
||||||
withText name $ \c_name ->
|
withText name $ \c_name ->
|
||||||
bracket (newStablePtr ty) freeStablePtr $ \c_ty ->
|
bracket (newStablePtr ty) freeStablePtr $ \c_ty ->
|
||||||
withForeignPtr marshaller $ \m -> do
|
withForeignPtr marshaller $ \m -> do
|
||||||
pgf_create_function c_db c_revision c_name c_ty prob m c_exn
|
pgf_create_function c_db c_revision c_name c_ty (fromIntegral arity) prob m c_exn
|
||||||
|
|
||||||
dropFunction :: Fun -> Transaction ()
|
dropFunction :: Fun -> Transaction ()
|
||||||
dropFunction name = Transaction $ \c_db c_revision c_exn ->
|
dropFunction name = Transaction $ \c_db c_revision c_exn ->
|
||||||
|
|||||||
Reference in New Issue
Block a user