Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f726a5f
Draft of Lua Memory library. (yes, yet another library name)
Jan 22, 2018
2f3376f
Functional version of Lua Memory library. Module with string-like ope…
Jan 24, 2018
d3ea756
Add the tests for resizable memory.
Jan 29, 2018
4838a86
Fix bug that leads to double deallocation when resizing memory.
Feb 12, 2018
bb95c98
Add the C API to the manual.
Feb 12, 2018
840f4f5
Make some functions copied from Lua source as internal, not exposed i…
Feb 12, 2018
3d3ffa5
Show actual value type name in error messages of 'luamem_check*' func…
Feb 13, 2018
eff77ef
New operations 'memory.find' and 'memory.tostring'.
Feb 18, 2018
aed829f
Format the index as a table.
Feb 18, 2018
71d5d2d
Use C syntax hightlight on C API function signatures.
Feb 18, 2018
065df8b
Fix index links.
Feb 18, 2018
8480c7a
Changing the position of 'i' argument in 'memory.pack' and 'memory.un…
Feb 18, 2018
c8772ad
Fix to honor parameter .
Jun 4, 2018
671a9ad
First draft of a layout support like LuaData.
Jun 4, 2018
ecb4c03
fixup! First draft of a layout support like LuaData.
Jul 1, 2018
adffb5c
fixup! Draft of Lua Memory library. (yes, yet another library name)
Jul 1, 2018
eedfc30
Add support for boolean fields
Jul 1, 2018
6efbc76
Add support for string fields
Jul 2, 2018
180f296
Support for nested structures.
Jul 13, 2018
094c559
Provide uniform 'out of bounds' error message.
Jul 15, 2018
eef84ed
Fix calculation of bitwise field after it algines to 8 bits.
Jul 15, 2018
7935341
Add support for endianess of bitwise fields.
Jul 15, 2018
be9e8c4
fixup! Support for nested structures.
Jul 16, 2018
0c803c0
Add support for tostring in structs and unions
Aug 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2015 Tecgraf, PUC-Rio.
Copyright (C) 2015-2018 Renato Maia <maia.renato@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
LuaBuffer
=========
Lua Memory
==========

Seamless Support for Buffers in Lua
The purpose of this project is to support manipulation of memory areas in Lua.
These memory areas are much like Lua strings, but their contents can be modified in place and have an identity (selfness) independent from their contents.
The library provides the following functionalities:

The main purpose of this project is to support for buffers that provide a fixed-size memory area (userdata) to be manipulated in Lua. The library introduces the concept of "stream" which is either a buffer or an ordinary Lua string. The library provides the following functionalities:

- Support for writable memory buffers.
- C API to manipulate Lua streams (string|buffer) in a unified way.
- Alternative implementations of Lua libraries that manipulate generic Lua streams (string|buffer).

TODO
----

- Make buffers provide `buffer.*` functions as methods as before.
- Assure buffers always have a `\0` at the end.
- Write the manual
- Support for writable memory areas.
- C API to manipulate strings or memory areas in a unified way.

Documentation
-------------

- [Manual](doc/manual.md)
- [License](LICENSE)

TODO
----

- Finish adaptation of `string.pack` tests to test `memory.pack`.
- Add support for bitwise operations on the memory contents.

History
-------

Expand Down
24 changes: 0 additions & 24 deletions demo/buffer.lua

This file was deleted.

24 changes: 24 additions & 0 deletions demo/fill.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- create a memory
local m = memory.create(10)

-- fill memory with zeros
memory.fill(m, 0)

-- iterate over memory
for i = 1, memory.len(m) do
print(i, memory.get(m, i))
end

-- iterate to fill the memory
for i = 1, memory.len(m) do
memory.set(m, i, 2*i)
end

-- sets 4th, 5th and 6th bytes in the memory
memory.set(m, 4, 0xff, 0xff, 0xff)

-- copy 3 bytes from position 4 to position 1
memory.fill(m, m, 1, 3, 4)

-- clear the positions after the 3 first bytes
memory.fill(m, 0, 4)
27 changes: 27 additions & 0 deletions demo/layout.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
local ipv = {
[4] = layout.struct{
{ key = "version" , bits = 4 },
{ key = "ihl" , bits = 4 },
{ key = "tos" , bits = 6 },
{ key = "ecn" , bits = 2 },
{ key = "tot_len" , bits = 16 },
{ key = "id" , bits = 16 },
{ key = "flags" , bits = 3 },
{ key = "frag_off", bits = 13 },
{ key = "ttl" , bits = 8 },
{ key = "protocol", bits = 8 },
{ key = "check" , bits = 16 },
{ key = "src" , bits = 32, type = "string" },
{ key = "dst" , bits = 32, type = "string" },
},
[6] = layout.struct{
{ key = "version" , bits = 4 },
{ key = "tc" , bits = 8 },
{ key = "fl" , bits = 20 },
{ key = "tot_len" , bits = 16 },
{ key = "nh" , bits = 8 },
{ key = "hl" , bits = 8 },
{ key = "src" , bits = 128, type = "string" },
{ key = "dst" , bits = 128, type = "string" },
},
}
Loading