MCPcopy Create free account
hub / github.com/Tencent/UnLua / lpb_pushinteger

Function lpb_pushinteger

Plugins/UnLuaExtensions/LuaProtobuf/Source/src/pb.cpp:348–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348static void lpb_pushinteger(lua_State *L, int64_t n, int u, int mode) {
349 if (mode != LPB_NUMBER && ((u && n < 0) || n < INT_MIN || n > UINT_MAX)) {
350 char buff[32], *p = buff + sizeof(buff) - 1;
351 int neg = !u && n < 0;
352 uint64_t un = !u && neg ? ~(uint64_t)n + 1 : (uint64_t)n;
353 if (mode == LPB_STRING) {
354 for (*p = '\0'; un > 0; un /= 10)
355 *--p = "0123456789"[un % 10];
356 } else if (mode == LPB_HEXSTRING) {
357 for (*p = '\0'; un > 0; un >>= 4)
358 *--p = "0123456789ABCDEF"[un & 0xF];
359 *--p = 'x', *--p = '0';
360 }
361 if (neg) *--p = '-';
362 *--p = '#';
363 lua_pushstring(L, p);
364 } else if (LUA_VERSION_NUM >= 503 && sizeof(lua_Integer) >= 8)
365 lua_pushinteger(L, (lua_Integer)n);
366 else
367 lua_pushnumber(L, (lua_Number)n);
368}
369
370typedef union lpb_Value {
371 pb_Slice s[1];

Callers 12

Lconv_encode_int32Function · 0.85
Lconv_encode_uint32Function · 0.85
Lconv_encode_sint32Function · 0.85
Lconv_decode_sint32Function · 0.85
Lconv_encode_sint64Function · 0.85
Lconv_decode_sint64Function · 0.85
Lconv_encode_floatFunction · 0.85
Lconv_encode_doubleFunction · 0.85
lpb_unpackscalarFunction · 0.85
Lpb_enumFunction · 0.85
lpb_pushdeffieldFunction · 0.85
lpbD_rawfieldFunction · 0.85

Calls 3

lua_pushstringFunction · 0.85
lua_pushintegerFunction · 0.85
lua_pushnumberFunction · 0.85

Tested by

no test coverage detected