[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] lbuffer - a mutable string module for lua (in very early period)
- From: Xavier Wang <weasley.wx@...>
- Date: Sat, 8 Oct 2011 10:51:44 +0800
hi dear list :)
I have written a module named lbuffer for Lua in holidays. it
provides the mutable string features. it's also in very early period:
no doc, no makefile :( I write this module is just to prevent useless
memory copies in string operations. it supports pack/unpack feature,
subbuffer feature, many modify operations and a lot of compatible
functions. below is the readme file of project.
lbuffer - a mutable string support to lua
lbuffer is a C module for lua, it provides mutable string feature to
lua language. it has all routines from lua's string module, except
pattern match, reverse and byte-code dump. and add several modify
functions. it provides:
* change the value of buffer without copy it.
* a pair of full feature pack/unpack functions.
* get a subbuffer from the origial buffer, and the changes to
subbufer will affects origial buffer.
and you can add lbuffer.h and recompile the other C module to get full
lbuffer compatible with other lua module. just add:
-DLB_OVERLOAD_LUA_API -include lbuffer.h
when you compile other Lua C modules (using gcc). e.g. if you compile
a lbuffer compatible md5 module, you can use them together like
print(md5.sumhexa(buffer "hello world"))
compile it just like other lua module. in *nix, just:
gcc -shared -obuffer.so *.c -llua51
and in Windows using MinGW, just:
gcc -mdll -DLUA_BUILD_AS_DLL -I/path/to/lua/include *.c
/path/to/lua51.dll -o buffer.dll
and in Windows using MSVC, just create a Win32/DLL Project, and add
all .c and .h files to project, set output name to buffer.dll and
if you want subbuffer feature, you need define a macro named
LB_SUBBUFFER, because subbuffer will slow the memory realloc function
in *all* buffers.
-- main usage see test.lua
local b = buffer "hello"
b:sub(6,5):assign " "
assert(b :eq "hello world")