Crossfire Server, Branch 1.12  R12190
Data Structures | Defines | Typedefs | Functions | Variables
cjson.c File Reference
#include <Python.h>
#include <stddef.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
Include dependency graph for cjson.c:

Go to the source code of this file.

Data Structures

struct  JSONData

Defines

#define False   0
#define INFINITY   HUGE_VAL
#define MODULE_VERSION   "1.0.5"
#define NAN   (HUGE_VAL-HUGE_VAL)
#define Py_IS_NAN(X)   ((X) != (X))
#define PY_SSIZE_T_MAX   INT_MAX
#define PY_SSIZE_T_MIN   INT_MIN
#define skipSpaces(d)   while (*((d)->ptr) && isspace(*((d)->ptr))) (d)->ptr++
#define SSIZE_T_F   "%d"
#define True   1

Typedefs

typedef struct JSONData JSONData
typedef int Py_ssize_t

Functions

static PyObject * decode_array (JSONData *jsondata)
static PyObject * decode_bool (JSONData *jsondata)
static PyObject * decode_inf (JSONData *jsondata)
static PyObject * decode_json (JSONData *jsondata)
static PyObject * decode_nan (JSONData *jsondata)
static PyObject * decode_null (JSONData *jsondata)
static PyObject * decode_number (JSONData *jsondata)
static PyObject * decode_object (JSONData *jsondata)
static PyObject * decode_string (JSONData *jsondata)
static PyObject * encode_dict (PyObject *object)
static PyObject * encode_list (PyObject *object)
static PyObject * encode_object (PyObject *object)
static PyObject * encode_string (PyObject *object)
static PyObject * encode_tuple (PyObject *object)
static PyObject * encode_unicode (PyObject *object)
static void getRowAndCol (char *begin, char *current, int *row, int *col)
PyMODINIT_FUNC initcjson (void)
static PyObject * JSON_decode (PyObject *self, PyObject *args, PyObject *kwargs)
static PyObject * JSON_encode (PyObject *self, PyObject *object)
 PyDoc_STRVAR (module_doc,"Fast JSON encoder/decoder module.")

Variables

static PyMethodDef cjson_methods []
static PyObject * JSON_DecodeError
static PyObject * JSON_EncodeError
static PyObject * JSON_Error

Define Documentation

#define False   0

Definition at line 55 of file cjson.c.

Referenced by decode_array(), decode_number(), decode_object(), decode_string(), and JSON_decode().

#define INFINITY   HUGE_VAL

Definition at line 58 of file cjson.c.

Referenced by decode_inf().

#define MODULE_VERSION   "1.0.5"

Definition at line 1107 of file cjson.c.

Referenced by initcjson().

#define NAN   (HUGE_VAL-HUGE_VAL)

Definition at line 62 of file cjson.c.

Referenced by decode_nan().

#define Py_IS_NAN (   X)    ((X) != (X))

Definition at line 66 of file cjson.c.

Referenced by encode_object().

#define PY_SSIZE_T_MAX   INT_MAX

Definition at line 46 of file cjson.c.

Referenced by encode_string(), and encode_unicode().

#define PY_SSIZE_T_MIN   INT_MIN

Definition at line 47 of file cjson.c.

#define skipSpaces (   d)    while (*((d)->ptr) && isspace(*((d)->ptr))) (d)->ptr++

Definition at line 69 of file cjson.c.

Referenced by decode_array(), decode_json(), decode_object(), and JSON_decode().

#define SSIZE_T_F   "%d"
#define True   1

Definition at line 54 of file cjson.c.

Referenced by decode_array(), decode_number(), decode_object(), and decode_string().


Typedef Documentation

typedef struct JSONData JSONData
typedef int Py_ssize_t

Definition at line 44 of file cjson.c.


Function Documentation

static PyObject * decode_array ( JSONData jsondata) [static]

Definition at line 329 of file cjson.c.

References decode_json(), False, getRowAndCol(), JSON_DecodeError, JSONData::ptr, skipSpaces, SSIZE_T_F, JSONData::str, and True.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_bool ( JSONData jsondata) [static]

Definition at line 102 of file cjson.c.

References JSONData::end, getRowAndCol(), JSON_DecodeError, JSONData::ptr, SSIZE_T_F, and JSONData::str.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_inf ( JSONData jsondata) [static]

Definition at line 218 of file cjson.c.

References JSONData::end, getRowAndCol(), INFINITY, JSON_DecodeError, JSONData::ptr, SSIZE_T_F, and JSONData::str.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_json ( JSONData jsondata) [static]

Definition at line 488 of file cjson.c.

References decode_array(), decode_bool(), decode_inf(), decode_nan(), decode_null(), decode_number(), decode_object(), decode_string(), JSON_DecodeError, JSONData::ptr, and skipSpaces.

Referenced by decode_array(), decode_object(), and JSON_decode().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_nan ( JSONData jsondata) [static]

Definition at line 245 of file cjson.c.

References JSONData::end, getRowAndCol(), JSON_DecodeError, NAN, JSONData::ptr, SSIZE_T_F, and JSONData::str.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_null ( JSONData jsondata) [static]

Definition at line 84 of file cjson.c.

References JSONData::end, getRowAndCol(), JSON_DecodeError, JSONData::ptr, SSIZE_T_F, and JSONData::str.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_number ( JSONData jsondata) [static]

Definition at line 263 of file cjson.c.

References False, getRowAndCol(), JSON_DecodeError, JSONData::ptr, SSIZE_T_F, JSONData::str, and True.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_object ( JSONData jsondata) [static]

Definition at line 393 of file cjson.c.

References decode_json(), False, getRowAndCol(), JSON_DecodeError, JSONData::ptr, skipSpaces, SSIZE_T_F, JSONData::str, and True.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * decode_string ( JSONData jsondata) [static]

Definition at line 124 of file cjson.c.

References JSONData::all_unicode, False, getRowAndCol(), JSON_DecodeError, JSONData::ptr, SSIZE_T_F, JSONData::str, and True.

Referenced by decode_json().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * encode_dict ( PyObject *  object) [static]

Definition at line 908 of file cjson.c.

References encode_object(), and JSON_EncodeError.

Referenced by encode_object().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * encode_list ( PyObject *  object) [static]

Definition at line 829 of file cjson.c.

References encode_object(), and JSON_EncodeError.

Referenced by encode_object().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * encode_object ( PyObject *  object) [static]

Definition at line 996 of file cjson.c.

References encode_dict(), encode_list(), encode_string(), encode_tuple(), encode_unicode(), JSON_EncodeError, and Py_IS_NAN.

Referenced by encode_dict(), encode_list(), encode_tuple(), and JSON_encode().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * encode_string ( PyObject *  object) [static]

Definition at line 566 of file cjson.c.

References PY_SSIZE_T_MAX.

Referenced by encode_object().

Here is the caller graph for this function:

static PyObject * encode_tuple ( PyObject *  object) [static]

Definition at line 766 of file cjson.c.

References encode_object().

Referenced by encode_object().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject * encode_unicode ( PyObject *  object) [static]

Definition at line 631 of file cjson.c.

References PY_SSIZE_T_MAX.

Referenced by encode_object().

Here is the caller graph for this function:

static void getRowAndCol ( char *  begin,
char *  current,
int *  row,
int *  col 
) [static]

Definition at line 73 of file cjson.c.

Referenced by decode_array(), decode_bool(), decode_inf(), decode_nan(), decode_null(), decode_number(), decode_object(), and decode_string().

Here is the caller graph for this function:

PyMODINIT_FUNC initcjson ( void  )

Definition at line 1108 of file cjson.c.

References cjson_methods, JSON_DecodeError, JSON_EncodeError, JSON_Error, and MODULE_VERSION.

Referenced by initPlugin().

Here is the caller graph for this function:

static PyObject* JSON_decode ( PyObject *  self,
PyObject *  args,
PyObject *  kwargs 
) [static]

Definition at line 1042 of file cjson.c.

References JSONData::all_unicode, decode_json(), JSONData::end, False, JSON_DecodeError, JSONData::ptr, skipSpaces, SSIZE_T_F, and JSONData::str.

Here is the call graph for this function:

static PyObject* JSON_encode ( PyObject *  self,
PyObject *  object 
) [static]

Definition at line 1036 of file cjson.c.

References encode_object().

Here is the call graph for this function:

PyDoc_STRVAR ( module_doc  ,
"Fast JSON encoder/decoder module."   
)

Variable Documentation

PyMethodDef cjson_methods[] [static]
Initial value:
 {
    { "encode", (PyCFunction)JSON_encode,  METH_O,
    PyDoc_STR("encode(object) -> generate the JSON representation for object.") },

    { "decode", (PyCFunction)JSON_decode,  METH_VARARGS|METH_KEYWORDS,
    PyDoc_STR("decode(string, all_unicode=False) -> parse the JSON representation into\n"
              "python objects. The optional argument `all_unicode', specifies how to\n"
              "convert the strings in the JSON representation into python objects.\n"
              "If it is False (default), it will return strings everywhere possible\n"
              "and unicode objects only where necessary, else it will return unicode\n"
              "objects everywhere (this is slower).") },

    { NULL, NULL, 0, NULL }  
}

Definition at line 1089 of file cjson.c.

Referenced by initcjson().

PyObject* JSON_DecodeError [static]
PyObject* JSON_EncodeError [static]

Definition at line 40 of file cjson.c.

Referenced by encode_dict(), encode_list(), encode_object(), and initcjson().

PyObject* JSON_Error [static]

Definition at line 39 of file cjson.c.

Referenced by initcjson().