author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年12月31日 16:55:42 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2013年01月05日 23:49:53 +0100 |
commit | a573b3d4c3fc1f1cb81b0aafdfc3f3cf58b794cc (patch) | |
tree | 0ea906159b7edcfe9ceb51fb2a8ad95d6da8365c /gdt.lua | |
parent | 17b2cfc6223c61693ddfcce8880ff0e89616e432 (diff) | |
download | gsl-shell-a573b3d4c3fc1f1cb81b0aafdfc3f3cf58b794cc.tar.gz |
-rw-r--r-- | gdt.lua | 11 |
@@ -11,6 +11,10 @@ local gdt_table_cursor = ffi.typeof("gdt_table_cursor") local TAG_STRING = tonumber(cgdt.TAG_STRING) local TAG_NUMBER = tonumber(cgdt.TAG_NUMBER) +local function element_is_number(e) + return (e.word.hi <= TAG_NUMBER) +end + local function gdt_element(t, e) local val if e.word.hi <= TAG_NUMBER then @@ -30,6 +34,11 @@ local function gdt_table_get(t, i, j) return gdt_element(t, e) end +local function gdt_table_get_number_unsafe(t, i, j) + local e = cgdt.gdt_table_get(t, i - 1, j - 1) + if e.word.hi <= TAG_NUMBER then return e.number end +end + local function gdt_table_set(t, i, j, val) assert(i > 0 and i <= t.size1, 'invalid row index') assert(j > 0 and j <= t.size2, 'invalid column index') @@ -280,6 +289,8 @@ gdt = { get = gdt_table_get, set = gdt_table_set, filter = gdt_table_filter, + + get_number_unsafe = gdt_table_get_number_unsafe, } return gdt |