update sproto for big-endian

This commit is contained in:
Cloud Wu
2014-11-26 21:18:49 +08:00
parent 84cb4bb4c1
commit 2b13eb250d
2 changed files with 15 additions and 15 deletions

View File

@@ -252,12 +252,12 @@ decode(void *ud, const char *tagname, int type, int index, struct sproto_type *s
switch (type) { switch (type) {
case SPROTO_TINTEGER: { case SPROTO_TINTEGER: {
// notice: in lua 5.2, 52bit integer support (not 64) // notice: in lua 5.2, 52bit integer support (not 64)
lua_Integer v = *(lua_Integer *)value; lua_Integer v = *(uint64_t*)value;
lua_pushinteger(L, v); lua_pushinteger(L, v);
break; break;
} }
case SPROTO_TBOOLEAN: { case SPROTO_TBOOLEAN: {
int v = *(lua_Integer*)value; int v = *(uint64_t*)value;
lua_pushboolean(L,v); lua_pushboolean(L,v);
break; break;
} }

View File

@@ -971,7 +971,7 @@ decode_array(sproto_callback cb, void *ud, struct field *f, uint8_t * stream) {
} }
case SPROTO_TBOOLEAN: case SPROTO_TBOOLEAN:
for (i=0;i<sz;i++) { for (i=0;i<sz;i++) {
int value = stream[i]; uint64_t value = stream[i];
cb(ud, f->name, SPROTO_TBOOLEAN, i+1, NULL, &value, sizeof(value)); cb(ud, f->name, SPROTO_TBOOLEAN, i+1, NULL, &value, sizeof(value));
} }
break; break;