20 #define PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc) \ 22 rb_enc_associate_index((_str), (_yaml_enc)); \ 24 (_str) = rb_str_export_to_enc((_str), (_internal_enc)); \ 53 static size_t memsize(
const void *ptr)
65 #ifdef RUBY_TYPED_FREE_IMMEDIATELY 103 if (source_encoding == utf8) {
108 if (source_encoding == utf16le) {
113 if (source_encoding == utf16be) {
127 VALUE io_external_encoding;
128 int io_external_enc_index;
133 if (
NIL_P(io_external_encoding)) {
257 if (
rb_scan_args(argc, argv,
"11", &yaml, &path) == 1) {
314 VALUE version =
event.data.document_start.version_directive ?
323 event.data.document_start.tag_directives.start;
325 event.data.document_start.tag_directives.end;
326 for(; start != end; start++) {
346 args[2] = tag_directives;
347 args[3] =
event.data.document_start.implicit == 1 ?
Qtrue :
Qfalse;
356 args[1] =
event.data.document_end.implicit == 1 ?
Qtrue :
Qfalse;
380 VALUE plain_implicit, quoted_implicit, style;
402 event.data.scalar.plain_implicit == 0 ?
Qfalse :
Qtrue;
405 event.data.scalar.quoted_implicit == 0 ?
Qfalse :
Qtrue;
413 args[4] = plain_implicit;
414 args[5] = quoted_implicit;
424 VALUE implicit, style;
439 event.data.sequence_start.implicit == 0 ?
Qfalse :
Qtrue;
460 VALUE implicit, style;
474 event.data.mapping_start.implicit == 0 ?
Qfalse :
Qtrue;
static ID id_start_document
int rb_enc_get_index(VALUE obj)
yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event)
Parse the input stream and produce the next parsing event.
#define RUBY_TYPED_FREE_IMMEDIATELY
yaml_event_delete(yaml_event_t *event)
Free any memory allocated for an event object.
The UTF-16-BE encoding with BOM.
yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding)
Set the source encoding.
#define rb_usascii_str_new2
#define TypedData_Get_Struct(obj, type, data_type, sval)
yaml_parser_set_input_string(yaml_parser_t *parser, const unsigned char *input, size_t size)
Set a string input.
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
int rb_usascii_encindex(void)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
VALUE rb_iv_get(VALUE, const char *)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
static ID id_start_sequence
struct yaml_event_s::@58::@64 sequence_start
The sequence parameters (for YAML_SEQUENCE_START_EVENT).
Let the parser choose the encoding.
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
yaml_parser_delete(yaml_parser_t *parser)
Destroy a parser.
const char * context
The error context.
static const rb_data_type_t psych_parser_type
union yaml_event_s::@58 data
The event data.
yaml_char_t * prefix
The tag prefix.
static ID id_start_mapping
static VALUE parse(int argc, VALUE *argv, VALUE self)
rb_encoding * rb_utf8_encoding(void)
static VALUE protected_end_mapping(VALUE handler)
yaml_mark_t mark
The mark of the current position.
The UTF-16-LE encoding with BOM.
void rb_exc_raise(VALUE mesg)
static VALUE transcode_io(VALUE src, int *parser_encoding)
VALUE rb_require(const char *)
int rb_to_encoding_index(VALUE enc)
void Init_psych_parser(void)
static VALUE protected_end_stream(VALUE handler)
static VALUE protected_end_document(VALUE pointer)
static VALUE protected_end_sequence(VALUE handler)
RUBY_EXTERN VALUE rb_cObject
int rb_ascii8bit_encindex(void)
static void dealloc(void *ptr)
void rb_define_const(VALUE, const char *, VALUE)
#define PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc)
static VALUE protected_start_sequence(VALUE pointer)
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
VALUE rb_const_get(VALUE, ID)
yaml_parser_set_input(yaml_parser_t *parser, yaml_read_handler_t *handler, void *data)
Set a generic input handler.
yaml_char_t * handle
The tag handle.
static VALUE protected_start_mapping(VALUE pointer)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
unsigned char buf[MIME_BUF_SIZE]
int rb_utf8_encindex(void)
static VALUE protected_empty(VALUE handler)
static ID id_end_sequence
static int io_reader(void *data, unsigned char *buf, size_t size, size_t *read)
yaml_mark_t context_mark
The context position.
void rb_jump_tag(int tag)
The default UTF-8 encoding.
int rb_respond_to(VALUE, ID)
size_t problem_offset
The byte about which the problem occurred.
struct yaml_event_s::@58::@60 document_start
The document parameters (for YAML_DOCUMENT_START_EVENT).
struct yaml_event_s::@58::@59 stream_start
The stream parameters (for YAML_STREAM_START_EVENT).
static ID id_end_document
yaml_parser_initialize(yaml_parser_t *parser)
Initialize a parser.
size_t line
The position line.
static VALUE make_exception(yaml_parser_t *parser, VALUE path)
VALUE rb_str_export_to_enc(VALUE, rb_encoding *)
static VALUE mark(VALUE self)
#define TypedData_Make_Struct(klass, type, data_type, sval)
struct yaml_event_s::@58::@62 alias
The alias parameters (for YAML_ALIAS_EVENT).
struct yaml_event_s::@58::@63 scalar
The scalar parameters (for YAML_SCALAR_EVENT).
size_t index
The position index.
static VALUE allocate(VALUE klass)
VALUE rb_const_get_at(VALUE, ID)
#define StringValuePtr(v)
const char * problem
Error description.
static VALUE protected_start_document(VALUE pointer)
int rb_enc_find_index(const char *name)
static ID id_start_stream
VALUE rb_define_module(const char *name)
size_t column
The position column.
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
yaml_event_type_t type
The event type.
struct yaml_event_s::@58::@65 mapping_start
The mapping parameters (for YAML_MAPPING_START_EVENT).
static VALUE protected_start_stream(VALUE pointer)
static VALUE protected_alias(VALUE pointer)
static VALUE protected_scalar(VALUE pointer)
static VALUE transcode_string(VALUE src, int *parser_encoding)
VALUE rb_str_new(const char *, long)