Index: math.t ================================================================== --- math.t +++ math.t @@ -1,8 +1,11 @@ -- vim: ft=terra local m = { - shorthand = {maxlen = 14} + shorthand = {maxlen = 14}; + ll = { + ctpop_u8 = terralib.intrinsic('llvm.ctpop.i8', uint8 -> uint8); + }; } local pstring = lib.mem.ptr(int8) -- swap in place -- faster on little endian @@ -54,10 +57,16 @@ ch = 38 + (ch - 0x61) else return 0, false end return ch, true end + +terra m.pow(n: intptr, fac: intptr): intptr + var o = n + for i=0,fac do n = n * o end + return n +end terra m.shorthand.gen(val: uint64, dest: rawstring): ptrdiff var lst = "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ:abcdefghijklmnopqrstuvwxyz" var buf: int8[m.shorthand.maxlen] var ptr = [&int8](buf) Index: mgtool.t ================================================================== --- mgtool.t +++ mgtool.t @@ -117,11 +117,11 @@ else tmppw[i] = tmppw[i] + 0x30 end end lib.dbg('assigning temporary password') dlg:auth_attach_pw(uid, reset, pstr { ptr = [rawstring](tmppw), ct = 32 }, - lib.str.plit 'temporary password'); + 'temporary password'); end local terra ipc_report(acks: lib.mem.ptr(lib.ipc.ack), rep: rawstring) var decbuf: int8[21] for i=0,acks.ct do @@ -381,13 +381,13 @@ return 1 end if cfmode.arglist.ct == 1 then var am = dlg:conf_get('credential-store') var mg: bool - if (not am) or am:cmp(lib.str.plit 'managed') then + if (not am) or am:cmp('managed') then mg = true - elseif am:cmp(lib.str.plit 'unmanaged') then + elseif am:cmp('unmanaged') then lib.warn('credential store is unmanaged; you will need to create credentials for the new root user manually!') mg = false else lib.bail('unknown credential store mode "',{am.ptr,am.ct},'"; should be either "managed" or "unmanaged"') end var kbuf: uint8[lib.crypt.const.maxdersz] var root = lib.store.actor.mk(&kbuf[0]) Index: parsav.t ================================================================== --- parsav.t +++ parsav.t @@ -274,10 +274,20 @@ if o[val] == nil then error('value ' .. val .. ' not in set') end return `bit { _v=[o[val] - 1], _set = &(obj) } end) terra set:sz() var ct: intptr = 0 + --for i = 0, [math.floor(#tbl/8)] do + -- ct = ct + lib.math.ll.ctpop_u8(self._store[i]) + --end + --[(function() + -- if #tbl % 8 ~= 0 then + -- local last = #tbl-1 + -- local msk = (2 ^ (#tbl % 8)) - 1 + -- return quote ct = ct + lib.math.ll.ctpop_u8(self._store[last] and [uint8](msk)) end + -- else return {} end + --end)()] for i = 0, [#tbl] do if (self._store[i/8] and (1 << i % 8)) ~= 0 then ct = ct + 1 end end return ct end @@ -453,10 +463,11 @@ 'render:docpage'; 'render:conf:profile'; 'render:conf:sec'; 'render:conf:users'; + 'render:conf:avi'; 'render:conf'; 'route'; } do Index: render/compose.t ================================================================== --- render/compose.t +++ render/compose.t @@ -17,15 +17,15 @@ if acc ~= nil then form:append(acc) return end var cotxt = form:poolstr(&co.srv.pool) -- defer cotxt:free() var doc = [lib.srv.convo.page] { - title = lib.str.plit 'compose'; + title = 'compose'; body = cotxt; - class = lib.str.plit 'compose'; + class = 'compose'; cache = true; } co:stdpage(doc) end return render_compose Index: render/conf.t ================================================================== --- render/conf.t +++ render/conf.t @@ -2,11 +2,11 @@ local pstr = lib.mem.ptr(int8) local pref = lib.mem.ref(int8) local mappings = { {url = 'profile', title = 'account profile', render = 'profile'}; - {url = 'avi', title = 'avatar', render = 'avatar'}; + {url = 'avi', title = 'avatar', render = 'avi'}; {url = 'ui', title = 'user interface', render = 'ui'}; {url = 'sec', title = 'security', render = 'sec_overlay'}; {url = 'rel', title = 'relationships', render = 'rel'}; {url = 'qnt', title = 'quarantine', render = 'quarantine'}; {url = 'acl', title = 'access control shortcuts', render = 'acl'}; @@ -85,13 +85,13 @@ else pgt = pg:poolstr(&co.srv.pool) end --defer pgt:free() co:stdpage([lib.srv.convo.page] { title = 'configure'; body = pgt; - class = lib.str.plit 'conf'; + class = 'conf'; cache = false; }) --if panel.ct ~= 0 then panel:free() end end return render_conf ADDED render/conf/avi.t Index: render/conf/avi.t ================================================================== --- render/conf/avi.t +++ render/conf/avi.t @@ -0,0 +1,15 @@ +-- vim: ft=terra +local pstr = lib.mem.ptr(int8) +local pref = lib.mem.ref(int8) + +local terra +render_conf_avi(co: &lib.srv.convo, path: lib.mem.ptr(pref)): pstr + var a = co:stra(128) + a:lpush '