Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
psych_parser.c File Reference
`#include <psych.h>`
Include dependency graph for psych_parser.c:

Go to the source code of this file.

## Macros
#define | PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc)

## Functions
static int | io_reader (void *data, unsigned char *buf, size_t size, size_t *read)
static void | dealloc (void *ptr)
static VALUE | allocate (VALUE klass)
static VALUE | make_exception (yaml_parser_t *parser, VALUE path)
static VALUE | transcode_string (VALUE src, int *parser_encoding)
static VALUE | transcode_io (VALUE src, int *parser_encoding)
static VALUE | protected_start_stream (VALUE pointer)
static VALUE | protected_start_document (VALUE pointer)
static VALUE | protected_end_document (VALUE pointer)
static VALUE | protected_alias (VALUE pointer)
static VALUE | protected_scalar (VALUE pointer)
static VALUE | protected_start_sequence (VALUE pointer)
static VALUE | protected_end_sequence (VALUE handler)
static VALUE | protected_start_mapping (VALUE pointer)
static VALUE | protected_end_mapping (VALUE handler)
static VALUE | protected_empty (VALUE handler)
static VALUE | protected_end_stream (VALUE handler)
static VALUE | parse (int argc, VALUE *argv, VALUE self)
static VALUE | mark (VALUE self)
void | Init_psych_parser ()

## Variables
VALUE | cPsychParser
VALUE | ePsychSyntaxError
static ID | id_read
static ID | id_path
static ID | id_empty
static ID | id_start_stream
static ID | id_end_stream
static ID | id_start_document
static ID | id_end_document
static ID | id_alias
static ID | id_scalar
static ID | id_start_sequence
static ID | id_end_sequence
static ID | id_start_mapping
static ID | id_end_mapping

## Macro Definition Documentation

#define PSYCH_TRANSCODE | ( |  | _str,
|  |  | _yaml_enc,
|  |  | _internal_enc
| ) |  |

Value:
do { \
rb_enc_associate_index((_str), (_yaml_enc)); \
if(_internal_enc) \
(_str) = rb_str_export_to_enc((_str), (_internal_enc)); \
} while (0)
rb_enc_associate_index
VALUE rb_enc_associate_index(VALUE obj, int idx)
Definition: encoding.c:748
rb_str_export_to_enc
VALUE rb_str_export_to_enc(VALUE, rb_encoding *)
Definition: string.c:632
if
if(RB_TYPE_P(r, T_FLOAT))
Definition: bigdecimal.c:1186

Definition at line 20 of file psych_parser.c.

Referenced by parse().

## Function Documentation

static VALUE allocate | ( | VALUE | klass | ) |
| static

Definition at line 52 of file psych_parser.c.

References Data_Wrap_Struct(), dealloc(), parser, xmalloc, and yaml_parser_initialize().

Referenced by Init_psych_parser().

static void dealloc | ( | void * | ptr | ) |
| static

Definition at line 43 of file psych_parser.c.

References parser, xfree, and yaml_parser_delete().

Referenced by allocate().

void Init_psych_parser | ( |  | ) |

Definition at line 538 of file psych_parser.c.

References allocate(), cPsychParser, ePsychSyntaxError, id_alias, id_empty, id_end_document, id_end_mapping, id_end_sequence, id_end_stream, id_path, id_read, id_scalar, id_start_document, id_start_mapping, id_start_sequence, id_start_stream, INT2NUM, mark(), mPsych, parse(), rb_cObject, rb_const_get(), rb_define_alloc_func(), rb_define_class_under(), rb_define_const(), rb_define_method(), rb_define_module(), rb_intern, rb_require(), YAML_ANY_ENCODING, YAML_UTF16BE_ENCODING, YAML_UTF16LE_ENCODING, and YAML_UTF8_ENCODING.

Referenced by Init_psych().

static int io_reader | ( | void * | data,
|  | unsigned char * | buf,
|  | size_t | size,
|  | size_t * | read
| ) |  |
| static

Definition at line 27 of file psych_parser.c.

References id_read, INT2NUM, io, memcpy(), NIL_P(), rb_funcall(), RSTRING_LEN, str, and StringValuePtr.

Referenced by parse().

static VALUE make_exception | ( | yaml_parser_t * | parser,
|  | VALUE | path
| ) |  |
| static

Definition at line 62 of file psych_parser.c.

References yaml_mark_s::column, yaml_parser_s::context, yaml_parser_s::context_mark, ePsychSyntaxError, INT2NUM, yaml_mark_s::line, yaml_parser_s::problem, yaml_parser_s::problem_offset, Qnil, rb_funcall(), rb_intern, and rb_usascii_str_new2.

Referenced by parse().

static VALUE mark | ( | VALUE | self | ) |
| static

Definition at line 523 of file psych_parser.c.

References args, yaml_mark_s::column, cPsychParser, Data_Get_Struct, yaml_mark_s::index, INT2NUM, yaml_mark_s::line, yaml_parser_s::mark, parser, rb_class_new_instance(), rb_const_get_at(), and rb_intern.

Referenced by Init_psych_parser(), yaml_alias_event_initialize(), yaml_document_add_mapping(), yaml_document_add_scalar(), yaml_document_add_sequence(), yaml_document_end_event_initialize(), yaml_document_initialize(), yaml_document_start_event_initialize(), yaml_emitter_close(), yaml_emitter_dump(), yaml_emitter_dump_alias(), yaml_emitter_dump_mapping(), yaml_emitter_dump_scalar(), yaml_emitter_dump_sequence(), yaml_emitter_open(), yaml_mapping_end_event_initialize(), yaml_mapping_start_event_initialize(), yaml_parser_parse_block_mapping_key(), yaml_parser_parse_block_mapping_value(), yaml_parser_parse_block_sequence_entry(), yaml_parser_parse_flow_sequence_entry_mapping_key(), yaml_parser_parse_indentless_sequence_entry(), yaml_scalar_event_initialize(), yaml_sequence_end_event_initialize(), yaml_sequence_start_event_initialize(), yaml_stream_end_event_initialize(), and yaml_stream_start_event_initialize().

static VALUE parse | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 229 of file psych_parser.c.

References yaml_event_s::alias, alias, args, yaml_event_s::data, Data_Get_Struct, yaml_event_s::document_start, done, end, yaml_tag_directive_s::handle, id_path, id_read, INT2NUM, io_reader(), make_exception(), yaml_event_s::mapping_start, OBJ_TAINT, OBJ_TAINTED, parser, path, yaml_tag_directive_s::prefix, protected_alias(), protected_empty(), protected_end_document(), protected_end_mapping(), protected_end_sequence(), protected_end_stream(), protected_scalar(), protected_start_document(), protected_start_mapping(), protected_start_sequence(), protected_start_stream(), PSYCH_TRANSCODE, Qfalse, Qnil, Qtrue, rb_ary_new(), rb_ary_new3(), rb_ary_push(), rb_cIO, rb_default_internal_encoding(), rb_exc_raise(), rb_funcall(), rb_iv_get(), rb_jump_tag(), rb_obj_is_kind_of(), rb_protect(), rb_respond_to(), rb_scan_args(), rb_str_new(), rb_str_new2, rb_utf8_encindex(), RSTRING_LEN, RSTRING_PTR, RTEST, yaml_event_s::scalar, yaml_event_s::sequence_start, state, yaml_event_s::stream_start, StringValue, transcode_io(), transcode_string(), yaml_event_s::type, val, version(), YAML_ALIAS_EVENT, YAML_ANY_ENCODING, YAML_DOCUMENT_END_EVENT, YAML_DOCUMENT_START_EVENT, yaml_event_delete(), YAML_MAPPING_END_EVENT, YAML_MAPPING_START_EVENT, YAML_NO_EVENT, yaml_parser_delete(), yaml_parser_initialize(), yaml_parser_parse(), yaml_parser_set_encoding(), yaml_parser_set_input(), yaml_parser_set_input_string(), YAML_SCALAR_EVENT, YAML_SEQUENCE_END_EVENT, YAML_SEQUENCE_START_EVENT, YAML_STREAM_END_EVENT, and YAML_STREAM_START_EVENT.

Referenced by Init_psych_parser().

static VALUE protected_alias | ( | VALUE | pointer | ) |
| static

Definition at line 176 of file psych_parser.c.

References args, id_alias, and rb_funcall().

Referenced by parse().

static VALUE protected_empty | ( | VALUE | handler | ) |
| static

Definition at line 210 of file psych_parser.c.

References id_empty, and rb_funcall().

Referenced by parse().

static VALUE protected_end_document | ( | VALUE | pointer | ) |
| static

Definition at line 170 of file psych_parser.c.

References args, id_end_document, and rb_funcall().

Referenced by parse().

static VALUE protected_end_mapping | ( | VALUE | handler | ) |
| static

Definition at line 205 of file psych_parser.c.

References id_end_mapping, and rb_funcall().

Referenced by parse().

static VALUE protected_end_sequence | ( | VALUE | handler | ) |
| static

Definition at line 194 of file psych_parser.c.

References id_end_sequence, and rb_funcall().

Referenced by parse().

static VALUE protected_end_stream | ( | VALUE | handler | ) |
| static

Definition at line 215 of file psych_parser.c.

References id_end_stream, and rb_funcall().

Referenced by parse().

static VALUE protected_scalar | ( | VALUE | pointer | ) |
| static

Definition at line 182 of file psych_parser.c.

References args, id_scalar, and rb_funcall3().

Referenced by parse().

static VALUE protected_start_document | ( | VALUE | pointer | ) |
| static

Definition at line 164 of file psych_parser.c.

References args, id_start_document, and rb_funcall3().

Referenced by parse().

static VALUE protected_start_mapping | ( | VALUE | pointer | ) |
| static

Definition at line 199 of file psych_parser.c.

References args, id_start_mapping, and rb_funcall3().

Referenced by parse().

static VALUE protected_start_sequence | ( | VALUE | pointer | ) |
| static

Definition at line 188 of file psych_parser.c.

References args, id_start_sequence, and rb_funcall3().

Referenced by parse().

static VALUE protected_start_stream | ( | VALUE | pointer | ) |
| static

Definition at line 158 of file psych_parser.c.

References args, id_start_stream, and rb_funcall().

Referenced by parse().

static VALUE transcode_io | ( | VALUE | src,
|  | int * | parser_encoding
| ) |  |
| static

Definition at line 108 of file psych_parser.c.

References NIL_P(), rb_ascii8bit_encindex(), rb_enc_find_index(), rb_funcall(), rb_intern, rb_to_encoding_index(), rb_usascii_encindex(), rb_utf8_encindex(), src, YAML_ANY_ENCODING, YAML_UTF16BE_ENCODING, YAML_UTF16LE_ENCODING, and YAML_UTF8_ENCODING.

Referenced by parse().

static VALUE transcode_string | ( | VALUE | src,
|  | int * | parser_encoding
| ) |  |
| static

Definition at line 79 of file psych_parser.c.

References rb_enc_find_index(), rb_enc_get_index(), RB_GC_GUARD, rb_str_export_to_enc(), rb_utf8_encindex(), rb_utf8_encoding(), src, YAML_UTF16BE_ENCODING, YAML_UTF16LE_ENCODING, and YAML_UTF8_ENCODING.

Referenced by parse().

## Variable Documentation

VALUE cPsychParser

Definition at line 3 of file psych_parser.c.

Referenced by Init_psych_parser(), and mark().

VALUE ePsychSyntaxError

Definition at line 4 of file psych_parser.c.

Referenced by Init_psych_parser(), and make_exception().

ID id_alias
| static

Definition at line 13 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_alias().

ID id_empty
| static

Definition at line 8 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_empty().

ID id_end_document
| static

Definition at line 12 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_end_document().

ID id_end_mapping
| static

Definition at line 18 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_end_mapping().

ID id_end_sequence
| static

Definition at line 16 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_end_sequence().

ID id_end_stream
| static

Definition at line 10 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_end_stream().

ID id_path
| static

Definition at line 7 of file psych_parser.c.

Referenced by Init_psych_parser(), and parse().

ID id_read
| static

Definition at line 6 of file psych_parser.c.

Referenced by Init_psych_parser(), io_reader(), and parse().

ID id_scalar
| static

Definition at line 14 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_scalar().

ID id_start_document
| static

Definition at line 11 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_start_document().

ID id_start_mapping
| static

Definition at line 17 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_start_mapping().

ID id_start_sequence
| static

Definition at line 15 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_start_sequence().

ID id_start_stream
| static

Definition at line 9 of file psych_parser.c.

Referenced by Init_psych_parser(), and protected_start_stream().