mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-13 13:12:51 -06:00
optimized peeking from GuStringBuf
This commit is contained in:
@@ -106,6 +106,12 @@ foreign import ccall unsafe "gu/enum.h gu_enum_next"
|
||||
foreign import ccall unsafe "gu/string.h gu_string_buf_freeze"
|
||||
gu_string_buf_freeze :: Ptr GuStringBuf -> Ptr GuPool -> IO CString
|
||||
|
||||
foreign import ccall unsafe "gu/string.h gu_string_buf_data"
|
||||
gu_string_buf_data :: Ptr GuStringBuf -> IO CString
|
||||
|
||||
foreign import ccall unsafe "gu/string.h gu_string_buf_length"
|
||||
gu_string_buf_length :: Ptr GuStringBuf -> IO CSizeT
|
||||
|
||||
foreign import ccall unsafe "gu/utf8.h gu_utf8_decode"
|
||||
gu_utf8_decode :: Ptr CString -> IO GuUCS
|
||||
|
||||
@@ -186,6 +192,12 @@ peekUtf8CStringLen ptr len =
|
||||
cs <- decode pptr end
|
||||
return (((toEnum . fromEnum) x) : cs)
|
||||
|
||||
peekUtf8CStringBuf :: Ptr GuStringBuf -> IO String
|
||||
peekUtf8CStringBuf sbuf = do
|
||||
ptr <- gu_string_buf_data sbuf
|
||||
len <- gu_string_buf_length sbuf
|
||||
peekUtf8CStringLen ptr (fromIntegral len)
|
||||
|
||||
pokeUtf8CString :: String -> CString -> IO ()
|
||||
pokeUtf8CString s ptr =
|
||||
alloca $ \pptr ->
|
||||
|
||||
Reference in New Issue
Block a user