254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
if #tbl >= 2^32 then ty = uint64 -- hey, can't be too safe
elseif #tbl >= 2^16 then ty = uint32
elseif #tbl >= 2^8 then ty = uint16 end
local o = { t = ty, members = tbl }
local strings = {}
for i, name in ipairs(tbl) do
o[name] = `[ty]([i - 1])
strings[i] = `[lib.mem.ref(int8)]{ptr=[name], ct=[#name]}
end
o._str = terra(val: ty)
var l = array([strings])
return l[val]
end
return o
end
................................................................................
lib.pq = lib.loadlib('libpq','libpq-fe.h')
lib.jc = lib.loadlib('json-c','json.h')
lib.load {
'mem', 'math', 'str', 'file', 'crypt', 'ipc';
'http', 'html', 'session', 'tpl', 'store', 'acl';
'smackdown'; -- md-alike parser
'conv'; -- miscellaneous conversion/munging functions
}
local be = {}
for _, b in pairs(config.backends) do
be[#be+1] = terralib.loadfile(string.format('backend/%s.t',b))()
end
lib.store.backends = global(`array([be]))
|
|
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
if #tbl >= 2^32 then ty = uint64 -- hey, can't be too safe
elseif #tbl >= 2^16 then ty = uint32
elseif #tbl >= 2^8 then ty = uint16 end
local o = { t = ty, members = tbl }
local strings = {}
for i, name in ipairs(tbl) do
o[name] = `[ty]([i - 1])
strings[i] = `[lib.str.t]{ptr=[name], ct=[#name]}
end
o._str = terra(val: ty)
var l = array([strings])
return l[val]
end
return o
end
................................................................................
lib.pq = lib.loadlib('libpq','libpq-fe.h')
lib.jc = lib.loadlib('json-c','json.h')
lib.load {
'mem', 'math', 'str', 'file', 'crypt', 'ipc';
'http', 'html', 'session', 'tpl', 'store', 'acl';
'mime'; -- mimetype database & whitelist
'smackdown'; -- md-alike parser
'munge'; -- miscellaneous conversion/munging functions
}
local be = {}
for _, b in pairs(config.backends) do
be[#be+1] = terralib.loadfile(string.format('backend/%s.t',b))()
end
lib.store.backends = global(`array([be]))
|