issue #196 use a macro for slices

cmake
Dibyendu Majumdar 3 years ago
parent b717be20e0
commit 71644f5450

@ -794,6 +794,10 @@ typedef struct RaviArray {
struct Table *metatable;
} RaviArray;
#define getsliceunderlying(L,s,o) \
{ TValue *io=(o); const RaviArray *is = (s); \
io->value_.gc = obj2gco(is->parent); settt_(io, ctb(is->parent->tt)); \
checkliveness(L,io); }
/*
** 'module' operation for hashing (size is always a power of 2)

@ -882,7 +882,7 @@ LUA_API void ravi_get_integer_array_rawdata(lua_State *L, int idx, Ravi_IntegerA
* implementation having array values starting at 0.
* A slice must not attempt to release the data array as this is not owned by
* it,
* and in fact may point to garbage from a memory allocater's point of view.
* and in fact may point to garbage from a memory allocator's point of view.
*/
LUA_API void ravi_create_slice(lua_State *L, int idx, unsigned int start,
unsigned int len) {
@ -890,7 +890,6 @@ LUA_API void ravi_create_slice(lua_State *L, int idx, unsigned int start,
RaviArray *slice;
const char *errmsg = NULL;
lua_lock(L);
/* The do-while loop here is just for error handling */
parent = index2addr(L, idx);
if (!ttistable(parent)) {
errmsg = "integer[] or number[] expected";

@ -400,11 +400,9 @@ static void reallymarkobject (global_State *g, GCObject *o) {
markobjectN(g, gco2array(o)->metatable); /* mark its metatable */
set2black(o);
if (slice->flags & RAVI_ARRAY_SLICE) {
TValue pvalue;
lua_assert(slice->parent);
TValue pvalue = {
.tt_ = ctb(slice->parent->tt),
.value_.gc = obj2gco(slice->parent)
}; // FIXME we should use appropriate macro here
getsliceunderlying(g->mainthread, slice, &pvalue);
if (valiswhite(&pvalue)) {
o = gcvalue(&pvalue);
goto reentry;

Loading…
Cancel
Save