void test_u64(struct aura_node *n) { int ret; struct aura_buffer *retbuf; ret = aura_call(n, "echo64", &retbuf, 0xbeefc0deb00bc0de); if (ret != 0) BUG(n, "Call failed!"); uint64_t v = aura_buffer_get_u64(retbuf); if (v != 0xbeefc0deb00bc0de) slog(0, SLOG_ERROR, "U64 test NOT ok: %llx vs %llx", v, 0xbeefc0deb00bc0de); aura_buffer_release(n, retbuf); slog(0, SLOG_INFO, "U64 echo test passed"); }
static int buffer_to_lua(lua_State *L, struct aura_node *node, const struct aura_object *o, struct aura_buffer *buf) { const char *fmt = o->ret_fmt; int nargs = 0; while (*fmt) { double tmp; switch (*fmt++) { case URPC_U8: tmp = aura_buffer_get_u8(buf); lua_pushnumber(L, tmp); break; case URPC_S8: tmp = aura_buffer_get_s8(buf); lua_pushnumber(L, tmp); break; case URPC_U16: tmp = aura_buffer_get_u16(buf); lua_pushnumber(L, tmp); break; case URPC_S16: tmp = aura_buffer_get_s16(buf); lua_pushnumber(L, tmp); break; case URPC_U32: tmp = aura_buffer_get_u32(buf); lua_pushnumber(L, tmp); break; case URPC_S32: tmp = aura_buffer_get_s32(buf); lua_pushnumber(L, tmp); break; case URPC_U64: tmp = aura_buffer_get_u64(buf); lua_pushnumber(L, tmp); break; case URPC_S64: tmp = aura_buffer_get_s64(buf); lua_pushnumber(L, tmp); break; case URPC_BIN: { void *udata; const void *srcdata; int len = atoi(fmt); if (len == 0) BUG(node, "Internal deserilizer bug processing: %s", fmt); udata = lua_newuserdata(L, len); if (!udata) BUG(node, "Failed to allocate userdata"); srcdata = aura_buffer_get_bin(buf, len); memcpy(udata, srcdata, len); while (*fmt && (*fmt++ != '.')); break; } default: BUG(node, "Unexpected format token: %s", --fmt); } nargs++; } ; return nargs; }