Commit 82384162 authored by Kai Zhang's avatar Kai Zhang

remove unnecessary c codes

parent 31107168
......@@ -3,11 +3,12 @@
#include <igraph/igraph.h>
igraph_strvector_t* igraph_strvector_new(long int size)
igraph_integer_t igraph_get_eid_(igraph_t* graph, igraph_integer_t pfrom, igraph_integer_t pto,
igraph_bool_t directed, igraph_bool_t error)
{
igraph_strvector_t* vector = (igraph_strvector_t*) malloc (sizeof (igraph_strvector_t));
igraph_strvector_init(vector, size);
return vector;
igraph_integer_t eid;
igraph_get_eid(graph, &eid, pfrom, pto, directed, error);
return eid;
}
char** igraph_strvector_get_(igraph_strvector_t* s, long int i)
......@@ -17,14 +18,6 @@ char** igraph_strvector_get_(igraph_strvector_t* s, long int i)
return x;
}
igraph_integer_t igraph_get_eid_(igraph_t* graph, igraph_integer_t pfrom, igraph_integer_t pto,
igraph_bool_t directed, igraph_bool_t error)
{
igraph_integer_t eid;
igraph_get_eid(graph, &eid, pfrom, pto, directed, error);
return eid;
}
void haskelligraph_init()
{
/* attach attribute table */
......
......@@ -12,7 +12,7 @@ import System.IO.Unsafe (unsafePerformIO)
{#import IGraph.Internal.Graph #}
{#import IGraph.Internal.Data #}
#include "cbits/haskelligraph.c"
#include "igraph/igraph.h"
makeAttributeRecord :: Show a => String -> [a] -> AttributeRecord
makeAttributeRecord name xs = unsafePerformIO $ do
......@@ -21,7 +21,6 @@ makeAttributeRecord name xs = unsafePerformIO $ do
return $ AttributeRecord ptr 2 value
data AttributeRecord = AttributeRecord CString Int StrVectorPtr
deriving (Show)
instance Storable AttributeRecord where
sizeOf _ = {#sizeof igraph_attribute_record_t #}
......@@ -29,11 +28,14 @@ instance Storable AttributeRecord where
peek p = AttributeRecord
<$> ({#get igraph_attribute_record_t->name #} p)
<*> liftM fromIntegral ({#get igraph_attribute_record_t->type #} p)
<*> liftM castPtr ({#get igraph_attribute_record_t->value #} p)
<*> ( do ptr <- {#get igraph_attribute_record_t->value #} p
fptr <- newForeignPtr_ . castPtr $ ptr
return $ StrVectorPtr fptr )
poke p (AttributeRecord name t vptr) = do
{#set igraph_attribute_record_t.name #} p name
{#set igraph_attribute_record_t.type #} p $ fromIntegral t
{#set igraph_attribute_record_t.value #} p $ castPtr vptr
withStrVectorPtr vptr $ \ptr ->
{#set igraph_attribute_record_t.value #} p $ castPtr ptr
{#fun pure igraph_cattribute_has_attr as ^ { `IGraphPtr', `Int', `String' } -> `Bool' #}
......
......@@ -79,12 +79,10 @@ vectorPPtrToList vpptr = do
fptr <- newForeignPtr_ $ castPtr vptr
vectorPtrToList $ VectorPtr fptr
data StrVector
{#pointer *igraph_strvector_t as StrVectorPtr -> StrVector #}
{#fun igraph_strvector_new as ^ { `Int' } -> `StrVectorPtr' #}
{#pointer *igraph_strvector_t as StrVectorPtr foreign finalizer igraph_strvector_destroy newtype#}
{#fun igraph_strvector_destroy as ^ { `StrVectorPtr' } -> `()' #}
{#fun igraph_strvector_init as igraphStrvectorNew { +, `Int' } -> `StrVectorPtr' #}
{#fun igraph_strvector_get_ as igraphStrvectorGet' { `StrVectorPtr', `Int' } -> `Ptr CString' id #}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment