From: Petri Lehtinen Date: Sat, 14 Aug 2010 18:02:08 +0000 (+0300) Subject: Merge branch '1.3' X-Git-Tag: v2.0~52 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=commitdiff_plain;h=56643d4311ecb26001527520da6264d92eab3d76 Merge branch '1.3' Conflicts: doc/apiref.rst src/jansson_private.h --- 56643d4311ecb26001527520da6264d92eab3d76 diff --cc doc/apiref.rst index 1d67881,2c6cf3b..c3a0554 --- a/doc/apiref.rst +++ b/doc/apiref.rst @@@ -287,46 -293,13 +293,52 @@@ U+10FFFF are allowed Number ====== + The JSON specification only contains one numeric type, "number". The C + programming language has distinct types for integer and floating-point + numbers, so for practical reasons Jansson also has distinct types for + the two. They are called "integer" and "real", respectively. For more + information, see :ref:`rfc-conformance`. + -.. cfunction:: json_t *json_integer(int value) +.. ctype:: json_int_t + + This is the C type that is used to store JSON integer values. It + represents the widest integer type available on your system. In + practice it's just a typedef of ``long long`` if your compiler + supports it, otherwise ``long``. + + Usually, you can safely use plain ``int`` in place of + ``json_int_t``, and the implicit C integer conversion handles the + rest. Only when you know that you need the full 64-bit range, you + should use ``json_int_t`` explicitly. + +``JSON_INTEGER_IS_LONG_LONG`` + + This is a preprocessor variable that holds the value 1 if + :ctype:`json_int_t` is ``long long``, and 0 if it's ``long``. It + can be used as follows:: + + #if JSON_INTEGER_IS_LONG_LONG + /* Code specific for long long */ + #else + /* Code specific for long */ + #endif + +``JSON_INTEGER_FORMAT`` + + This is a macro that expands to a :cfunc:`printf()` conversion + specifier that corresponds to :ctype:`json_int_t`, without the + leading ``%`` sign, i.e. either ``"lld"`` or ``"ld"``. This macro + is required because the actual type of :ctype:`json_int_t` can be + either ``long`` or ``long long``, and :cfunc:`printf()` reuiqres + different length modifiers for the two. + + Example:: + + json_int_t x = 123123123; + printf("x is %" JSON_INTEGER_FORMAT "\n", x); + + +.. cfunction:: json_t *json_integer(json_int_t value) .. refcounting:: new diff --cc src/jansson_private.h index bd80346,55532eb..e9e0097 --- a/src/jansson_private.h +++ b/src/jansson_private.h @@@ -51,8 -52,8 +52,8 @@@ typedef struct #define json_to_integer(json_) container_of(json_, json_integer_t, json) typedef struct { - unsigned long serial; + size_t serial; - char key[]; + char key[1]; } object_key_t; const object_key_t *jsonp_object_iter_fullkey(void *iter);