Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Functions | Variables
generator.h File Reference
#include <math.h>
#include <ctype.h>
#include "ruby.h"
#include "ruby/re.h"
Include dependency graph for generator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JSON_Generator_StateStruct
 

Macros

#define rb_intern_str(string)   SYM2ID(rb_str_intern(string))
 
#define rb_obj_instance_variables(object)   rb_funcall(object, rb_intern("instance_variables"), 0)
 
#define option_given_p(opts, key)   RTEST(rb_funcall(opts, i_key_p, 1, key))
 
#define UNI_STRICT_CONVERSION   1
 
#define UNI_REPLACEMENT_CHAR   (UTF32)0x0000FFFD
 
#define UNI_MAX_BMP   (UTF32)0x0000FFFF
 
#define UNI_MAX_UTF16   (UTF32)0x0010FFFF
 
#define UNI_MAX_UTF32   (UTF32)0x7FFFFFFF
 
#define UNI_MAX_LEGAL_UTF32   (UTF32)0x0010FFFF
 
#define UNI_SUR_HIGH_START   (UTF32)0xD800
 
#define UNI_SUR_HIGH_END   (UTF32)0xDBFF
 
#define UNI_SUR_LOW_START   (UTF32)0xDC00
 
#define UNI_SUR_LOW_END   (UTF32)0xDFFF
 
#define GET_STATE_TO(self, state)   TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
 
#define GET_STATE(self)
 
#define GENERATE_JSON(type)
 
#define NEW_TYPEDDATA_WRAPPER   1
 

Typedefs

typedef unsigned long UTF32
 
typedef unsigned short UTF16
 
typedef unsigned char UTF8
 
typedef struct JSON_Generator_StateStruct JSON_Generator_State
 

Functions

static unsigned char isLegalUTF8 (const UTF8 *source, unsigned long length)
 
static void unicode_escape (char *buf, UTF16 character)
 
static void unicode_escape_to_buffer (FBuffer *buffer, char buf[6], UTF16 character)
 
static void convert_UTF8_to_JSON_ASCII (FBuffer *buffer, VALUE string)
 
static void convert_UTF8_to_JSON (FBuffer *buffer, VALUE string)
 
static char * fstrndup (const char *ptr, unsigned long len)
 
static VALUE mHash_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mArray_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mInteger_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mFloat_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mString_included_s (VALUE self, VALUE modul)
 
static VALUE mString_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mString_to_json_raw_object (VALUE self)
 
static VALUE mString_to_json_raw (int argc, VALUE *argv, VALUE self)
 
static VALUE mString_Extend_json_create (VALUE self, VALUE o)
 
static VALUE mTrueClass_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mFalseClass_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mNilClass_to_json (int argc, VALUE *argv, VALUE self)
 
static VALUE mObject_to_json (int argc, VALUE *argv, VALUE self)
 
static void State_free (void *state)
 
static VALUE cState_s_allocate (VALUE klass)
 
static VALUE cState_configure (VALUE self, VALUE opts)
 
static VALUE cState_to_h (VALUE self)
 
static void generate_json (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_object (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_array (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_string (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_null (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_false (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_true (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_integer (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_fixnum (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_bignum (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static void generate_json_float (FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
 
static VALUE cState_partial_generate (VALUE self, VALUE obj)
 
static VALUE cState_generate (VALUE self, VALUE obj)
 
static VALUE cState_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE cState_from_state_s (VALUE self, VALUE opts)
 
static VALUE cState_indent (VALUE self)
 
static VALUE cState_indent_set (VALUE self, VALUE indent)
 
static VALUE cState_space (VALUE self)
 
static VALUE cState_space_set (VALUE self, VALUE space)
 
static VALUE cState_space_before (VALUE self)
 
static VALUE cState_space_before_set (VALUE self, VALUE space_before)
 
static VALUE cState_object_nl (VALUE self)
 
static VALUE cState_object_nl_set (VALUE self, VALUE object_nl)
 
static VALUE cState_array_nl (VALUE self)
 
static VALUE cState_array_nl_set (VALUE self, VALUE array_nl)
 
static VALUE cState_max_nesting (VALUE self)
 
static VALUE cState_max_nesting_set (VALUE self, VALUE depth)
 
static VALUE cState_allow_nan_p (VALUE self)
 
static VALUE cState_ascii_only_p (VALUE self)
 
static VALUE cState_depth (VALUE self)
 
static VALUE cState_depth_set (VALUE self, VALUE depth)
 
static FBuffercState_prepare_buffer (VALUE self)
 

Variables

static const int halfShift = 10
 
static const UTF32 halfBase = 0x0010000UL
 
static const UTF32 halfMask = 0x3FFUL
 
static const rb_data_type_t JSON_Generator_State_type
 

Macro Definition Documentation

◆ GENERATE_JSON

#define GENERATE_JSON (   type)
Value:
FBuffer *buffer; \
VALUE Vstate; \
JSON_Generator_State *state; \
rb_scan_args(argc, argv, "01", &Vstate); \
Vstate = cState_from_state_s(cState, Vstate); \
TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \
buffer = cState_prepare_buffer(Vstate); \
generate_json_##type(buffer, Vstate, state, self); \
return fbuffer_to_s(buffer)
static FBuffer * cState_prepare_buffer(VALUE self)
static VALUE cState
Definition: generator.c:9
int argc
Definition: ruby.c:183
static VALUE cState_from_state_s(VALUE self, VALUE opts)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:1919
static const rb_data_type_t JSON_Generator_State_type
Definition: generator.h:164
char ** argv
Definition: ruby.c:184

Definition at line 86 of file generator.h.

Referenced by mArray_to_json(), mFalseClass_to_json(), mFloat_to_json(), mHash_to_json(), mInteger_to_json(), mNilClass_to_json(), mString_to_json(), and mTrueClass_to_json().

◆ GET_STATE

#define GET_STATE (   self)

◆ GET_STATE_TO

#define GET_STATE_TO (   self,
  state 
)    TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)

Definition at line 79 of file generator.h.

Referenced by cState_init_copy().

◆ NEW_TYPEDDATA_WRAPPER

#define NEW_TYPEDDATA_WRAPPER   1

Definition at line 165 of file generator.h.

◆ option_given_p

#define option_given_p (   opts,
  key 
)    RTEST(rb_funcall(opts, i_key_p, 1, key))

Definition at line 23 of file generator.h.

Referenced by cParser_initialize(), and cState_configure().

◆ rb_intern_str

#define rb_intern_str (   string)    SYM2ID(rb_str_intern(string))

◆ rb_obj_instance_variables

#define rb_obj_instance_variables (   object)    rb_funcall(object, rb_intern("instance_variables"), 0)

Definition at line 20 of file generator.h.

Referenced by InitVM_Object(), and set_state_ivars().

◆ UNI_MAX_BMP

#define UNI_MAX_BMP   (UTF32)0x0000FFFF

Definition at line 34 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

◆ UNI_MAX_LEGAL_UTF32

#define UNI_MAX_LEGAL_UTF32   (UTF32)0x0010FFFF

Definition at line 37 of file generator.h.

◆ UNI_MAX_UTF16

#define UNI_MAX_UTF16   (UTF32)0x0010FFFF

Definition at line 35 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

◆ UNI_MAX_UTF32

#define UNI_MAX_UTF32   (UTF32)0x7FFFFFFF

Definition at line 36 of file generator.h.

◆ UNI_REPLACEMENT_CHAR

#define UNI_REPLACEMENT_CHAR   (UTF32)0x0000FFFD

Definition at line 33 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII(), and unescape_unicode().

◆ UNI_STRICT_CONVERSION

#define UNI_STRICT_CONVERSION   1

Definition at line 27 of file generator.h.

◆ UNI_SUR_HIGH_END

#define UNI_SUR_HIGH_END   (UTF32)0xDBFF

Definition at line 40 of file generator.h.

◆ UNI_SUR_HIGH_START

#define UNI_SUR_HIGH_START   (UTF32)0xD800

Definition at line 39 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII(), and json_string_unescape().

◆ UNI_SUR_LOW_END

#define UNI_SUR_LOW_END   (UTF32)0xDFFF

Definition at line 42 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

◆ UNI_SUR_LOW_START

#define UNI_SUR_LOW_START   (UTF32)0xDC00

Definition at line 41 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

Typedef Documentation

◆ JSON_Generator_State

◆ UTF16

typedef unsigned short UTF16

Definition at line 30 of file generator.h.

◆ UTF32

typedef unsigned long UTF32

Definition at line 29 of file generator.h.

◆ UTF8

typedef unsigned char UTF8

Definition at line 31 of file generator.h.

Function Documentation

◆ convert_UTF8_to_JSON()

static void convert_UTF8_to_JSON ( FBuffer buffer,
VALUE  string 
)
static

◆ convert_UTF8_to_JSON_ASCII()

static void convert_UTF8_to_JSON_ASCII ( FBuffer buffer,
VALUE  string 
)
static

◆ cState_allow_nan_p()

static VALUE cState_allow_nan_p ( VALUE  self)
static

◆ cState_array_nl()

static VALUE cState_array_nl ( VALUE  self)
static

◆ cState_array_nl_set()

static VALUE cState_array_nl_set ( VALUE  self,
VALUE  array_nl 
)
static

◆ cState_ascii_only_p()

static VALUE cState_ascii_only_p ( VALUE  self)
static

◆ cState_configure()

static VALUE cState_configure ( VALUE  self,
VALUE  opts 
)
static

◆ cState_depth()

static VALUE cState_depth ( VALUE  self)
static

◆ cState_depth_set()

static VALUE cState_depth_set ( VALUE  self,
VALUE  depth 
)
static

◆ cState_from_state_s()

static VALUE cState_from_state_s ( VALUE  self,
VALUE  opts 
)
static

◆ cState_generate()

static VALUE cState_generate ( VALUE  self,
VALUE  obj 
)
static

◆ cState_indent()

static VALUE cState_indent ( VALUE  self)
static

◆ cState_indent_set()

static VALUE cState_indent_set ( VALUE  self,
VALUE  indent 
)
static

◆ cState_initialize()

static VALUE cState_initialize ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ cState_max_nesting()

static VALUE cState_max_nesting ( VALUE  self)
static

◆ cState_max_nesting_set()

static VALUE cState_max_nesting_set ( VALUE  self,
VALUE  depth 
)
static

◆ cState_object_nl()

static VALUE cState_object_nl ( VALUE  self)
static

◆ cState_object_nl_set()

static VALUE cState_object_nl_set ( VALUE  self,
VALUE  object_nl 
)
static

◆ cState_partial_generate()

static VALUE cState_partial_generate ( VALUE  self,
VALUE  obj 
)
static

◆ cState_prepare_buffer()

static FBuffer* cState_prepare_buffer ( VALUE  self)
static

◆ cState_s_allocate()

static VALUE cState_s_allocate ( VALUE  klass)
static

◆ cState_space()

static VALUE cState_space ( VALUE  self)
static

◆ cState_space_before()

static VALUE cState_space_before ( VALUE  self)
static

◆ cState_space_before_set()

static VALUE cState_space_before_set ( VALUE  self,
VALUE  space_before 
)
static

◆ cState_space_set()

static VALUE cState_space_set ( VALUE  self,
VALUE  space 
)
static

◆ cState_to_h()

static VALUE cState_to_h ( VALUE  self)
static

◆ fstrndup()

static char* fstrndup ( const char *  ptr,
unsigned long  len 
)
static

◆ generate_json()

static void generate_json ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_array()

static void generate_json_array ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_bignum()

static void generate_json_bignum ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_false()

static void generate_json_false ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_fixnum()

static void generate_json_fixnum ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_float()

static void generate_json_float ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_integer()

static void generate_json_integer ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_null()

static void generate_json_null ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_object()

static void generate_json_object ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_string()

static void generate_json_string ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ generate_json_true()

static void generate_json_true ( FBuffer buffer,
VALUE  Vstate,
JSON_Generator_State state,
VALUE  obj 
)
static

◆ isLegalUTF8()

static unsigned char isLegalUTF8 ( const UTF8 source,
unsigned long  length 
)
static

◆ mArray_to_json()

static VALUE mArray_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mFalseClass_to_json()

static VALUE mFalseClass_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mFloat_to_json()

static VALUE mFloat_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mHash_to_json()

static VALUE mHash_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mInteger_to_json()

static VALUE mInteger_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mNilClass_to_json()

static VALUE mNilClass_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mObject_to_json()

static VALUE mObject_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mString_Extend_json_create()

static VALUE mString_Extend_json_create ( VALUE  self,
VALUE  o 
)
static

◆ mString_included_s()

static VALUE mString_included_s ( VALUE  self,
VALUE  modul 
)
static

◆ mString_to_json()

static VALUE mString_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mString_to_json_raw()

static VALUE mString_to_json_raw ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ mString_to_json_raw_object()

static VALUE mString_to_json_raw_object ( VALUE  self)
static

◆ mTrueClass_to_json()

static VALUE mTrueClass_to_json ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ State_free()

static void State_free ( void *  state)
static

◆ unicode_escape()

static void unicode_escape ( char *  buf,
UTF16  character 
)
static

◆ unicode_escape_to_buffer()

static void unicode_escape_to_buffer ( FBuffer buffer,
char  buf[6],
UTF16  character 
)
static

Variable Documentation

◆ halfBase

const UTF32 halfBase = 0x0010000UL
static

Definition at line 46 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

◆ halfMask

const UTF32 halfMask = 0x3FFUL
static

Definition at line 47 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

◆ halfShift

const int halfShift = 10
static

Definition at line 44 of file generator.h.

Referenced by convert_UTF8_to_JSON_ASCII().

◆ JSON_Generator_State_type

const rb_data_type_t JSON_Generator_State_type
static

Definition at line 164 of file generator.h.