on master help sign in
#7, avoid camel-case names in the C code
e06e524Neil Mitchell
cbits/hexml.c+2−2
@@ -188,7 +188,7 @@ attr* hexml_node_attributes(const document* d, const node* n, int* res)
188}
188}
189
189
190
190
191−attr* hexml_node_attributeBy(const document* d, const node* n, const char* s, int slen)
191+attr* hexml_node_attribute(const document* d, const node* n, const char* s, int slen)
192{
192{
193 if (slen == -1) slen = (int) strlen(s);
193 if (slen == -1) slen = (int) strlen(s);
194 const int limit = end(n->attrs);
194 const int limit = end(n->attrs);
@@ -202,7 +202,7 @@ attr* hexml_node_attributeBy(const document* d, const node* n, const char* s, in
202}
202}
203
203
204// Search for given strings within a node
204// Search for given strings within a node
205−node* hexml_node_childBy(const document* d, const node* parent, const node* prev, const char* s, int slen)
205+node* hexml_node_child(const document* d, const node* parent, const node* prev, const char* s, int slen)
206{
206{
207 if (slen == -1) slen = (int) strlen(s);
207 if (slen == -1) slen = (int) strlen(s);
208 int i = prev == NULL ? parent->nodes.start : (int) (prev + 1 - d->nodes.nodes);
208 int i = prev == NULL ? parent->nodes.start : (int) (prev + 1 - d->nodes.nodes);
cbits/hexml.h+2−2
@@ -52,5 +52,5 @@ attr* hexml_node_attributes(const document* d, const node* n, int* res);
52
52
53// Search for given strings within a node, note that prev may be NULL
53// Search for given strings within a node, note that prev may be NULL
54// Requires the string passed to document_parse to be valid.
54// Requires the string passed to document_parse to be valid.
55−node* hexml_node_childBy(const document* d, const node* parent, const node* prev, const char* s, int slen);
55+node* hexml_node_child(const document* d, const node* parent, const node* prev, const char* s, int slen);
56−attr* hexml_node_attributeBy(const document* d, const node* n, const char* s, int slen);
56+attr* hexml_node_attribute(const document* d, const node* n, const char* s, int slen);
src/Text/XML/Hexml.hs+4−4
@@ -55,8 +55,8 @@ foreign import ccall hexml_document_node :: Ptr CDocument -> IO (Ptr CNode)
55foreign import ccall hexml_node_children :: Ptr CDocument -> Ptr CNode -> Ptr CInt -> IO (Ptr CNode)
55foreign import ccall hexml_node_children :: Ptr CDocument -> Ptr CNode -> Ptr CInt -> IO (Ptr CNode)
56foreign import ccall hexml_node_attributes :: Ptr CDocument -> Ptr CNode -> Ptr CInt -> IO (Ptr CAttr)
56foreign import ccall hexml_node_attributes :: Ptr CDocument -> Ptr CNode -> Ptr CInt -> IO (Ptr CAttr)
57
57
58−foreign import ccall hexml_node_childBy :: Ptr CDocument -> Ptr CNode -> Ptr CNode -> CString -> CInt -> IO (Ptr CNode)
58+foreign import ccall hexml_node_child :: Ptr CDocument -> Ptr CNode -> Ptr CNode -> CString -> CInt -> IO (Ptr CNode)
59−foreign import ccall hexml_node_attributeBy :: Ptr CDocument -> Ptr CNode -> CString -> CInt -> IO (Ptr CAttr)
59+foreign import ccall hexml_node_attribute :: Ptr CDocument -> Ptr CNode -> CString -> CInt -> IO (Ptr CAttr)
60
60
61-- | A node in an XML document, created by 'parse', then calling functions such
61-- | A node in an XML document, created by 'parse', then calling functions such
62-- as 'children' on that initial 'Node'.
62-- as 'children' on that initial 'Node'.
@@ -175,7 +175,7 @@ childrenBy (Node src doc n) str = go nullPtr
175 where
175 where
176 go old = unsafePerformIO $ withForeignPtr doc $ \d ->
176 go old = unsafePerformIO $ withForeignPtr doc $ \d ->
177 BS.unsafeUseAsCStringLen str $ \(bs, len) -> do
177 BS.unsafeUseAsCStringLen str $ \(bs, len) -> do
178− r <- hexml_node_childBy d n old bs $ fromIntegral len
178+ r <- hexml_node_child d n old bs $ fromIntegral len
179 touchBS src
179 touchBS src
180 return $ if r == nullPtr then [] else Node src doc r : go r
180 return $ if r == nullPtr then [] else Node src doc r : go r
181
181
@@ -186,7 +186,7 @@ childrenBy (Node src doc n) str = go nullPtr
186attributeBy :: Node -> BS.ByteString -> Maybe Attribute
186attributeBy :: Node -> BS.ByteString -> Maybe Attribute
187attributeBy (Node src doc n) str = unsafePerformIO $ withForeignPtr doc $ \d ->
187attributeBy (Node src doc n) str = unsafePerformIO $ withForeignPtr doc $ \d ->
188 BS.unsafeUseAsCStringLen str $ \(bs, len) -> do
188 BS.unsafeUseAsCStringLen str $ \(bs, len) -> do
189− r <- hexml_node_attributeBy d n bs $ fromIntegral len
189+ r <- hexml_node_attribute d n bs $ fromIntegral len
190 touchBS src
190 touchBS src
191 return $ if r == nullPtr then Nothing else Just $ attrPeek src doc r
191 return $ if r == nullPtr then Nothing else Just $ attrPeek src doc r
192
192