Skip to content

Commit

Permalink
Rust changes: Copy now requires Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhyunkang committed Apr 5, 2015
1 parent 62568d5 commit 2a414fd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/codegen/type_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main()

printf("#[allow(non_camel_case_types)]\n");
printf("#[repr(u%lu)]\n", ((size_t)(&dummy_event.data) - (size_t)(&dummy_event)) * 8);
printf("#[derive(Debug, PartialEq, Copy)]\n");
printf("#[derive(Debug, PartialEq, Clone, Copy)]\n");
printf("pub enum yaml_event_type_t {\n");
printf(" /** An empty event. */\n");
printf(" YAML_NO_EVENT = 0,\n\n");
Expand Down
2 changes: 1 addition & 1 deletion src/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum YamlStandardData {
YamlMapping(Vec<(YamlStandardData, YamlStandardData)>),
}

#[derive(Copy)]
#[derive(Clone, Copy)]
pub struct YamlStandardConstructor;

fn standard_error(message: String, mark: &YamlMark) -> YamlError {
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ffi;
use ffi::YamlErrorType;
use ffi::YamlErrorType::*;

#[derive(Debug, PartialEq, Copy)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct YamlMark {
pub index: usize,
pub line: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::ptr;

use codecs;

#[derive(Debug, PartialEq, Copy)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct YamlVersionDirective {
pub major: isize,
pub minor: isize,
Expand Down
62 changes: 12 additions & 50 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub type yaml_read_handler_t = extern fn(data: *mut YamlIoParser, buffer: *mut u
pub type yaml_write_handler_t = extern fn(data: *mut YamlEmitter, buffer: *const u8, size: size_t) -> c_int;

#[repr(C)]
#[derive(Debug, PartialEq, Copy)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum YamlErrorType {
/** No error is produced. */
YAML_NO_ERROR,
Expand All @@ -36,7 +36,7 @@ pub enum YamlErrorType {
YAML_EMITTER_ERROR
}

#[derive(Debug, PartialEq, Copy)]
#[derive(Debug, PartialEq, Clone, Copy)]
#[repr(C)]
pub enum YamlSequenceStyle {
/** Let the emitter choose the style. */
Expand All @@ -48,7 +48,7 @@ pub enum YamlSequenceStyle {
YamlFlowSequenceStyle
}

#[derive(Debug, PartialEq, Copy)]
#[derive(Debug, PartialEq, Clone, Copy)]
#[repr(C)]
pub enum YamlScalarStyle {
/** Let the emitter choose the style. */
Expand All @@ -68,7 +68,7 @@ pub enum YamlScalarStyle {
YamlFoldedScalarStyle
}

#[derive(Debug, PartialEq, Copy)]
#[derive(Debug, PartialEq, Clone, Copy)]
#[repr(C)]
pub enum YamlEncoding {
/** Let the parser choose the encoding. */
Expand All @@ -81,7 +81,7 @@ pub enum YamlEncoding {
YamlUtf16BeEncoding
}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_mark_t {
Expand All @@ -99,8 +99,6 @@ pub struct yaml_buffer_t {
pub last: *const yaml_char_t
}

impl Copy for yaml_buffer_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_queue_t {
Expand All @@ -110,8 +108,6 @@ pub struct yaml_queue_t {
pub tail: *const c_void
}

impl Copy for yaml_queue_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_stack_t {
Expand All @@ -120,9 +116,7 @@ pub struct yaml_stack_t {
pub top: *const c_void
}

impl Copy for yaml_stack_t {}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
pub enum yaml_node_type_t {
/** An empty node. */
Expand All @@ -146,8 +140,6 @@ pub struct yaml_node_t {
pub end_mark: yaml_mark_t,
}

impl Copy for yaml_node_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_scalar_node_t {
Expand All @@ -156,18 +148,14 @@ pub struct yaml_scalar_node_t {
pub style: YamlScalarStyle
}

impl Copy for yaml_scalar_node_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_sequence_node_t {
pub items: yaml_stack_t,
pub style: YamlSequenceStyle
}

impl Copy for yaml_sequence_node_t {}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_node_pair_t {
Expand All @@ -190,8 +178,6 @@ pub struct yaml_document_t {
pub end_mark: yaml_mark_t,
}

impl Copy for yaml_document_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_parser_t {
Expand Down Expand Up @@ -236,9 +222,7 @@ pub struct yaml_parser_t {
pub document: *const yaml_document_t,
}

impl Copy for yaml_parser_t {}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub enum yaml_break_t {
Expand Down Expand Up @@ -307,8 +291,6 @@ pub struct yaml_emitter_t {
pub document: *const yaml_document_t
}

impl Copy for yaml_emitter_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_emitter_anchor_data_t {
Expand All @@ -317,8 +299,6 @@ pub struct yaml_emitter_anchor_data_t {
pub alias: c_int
}

impl Copy for yaml_emitter_anchor_data_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_emitter_tag_data_t {
Expand All @@ -328,8 +308,6 @@ pub struct yaml_emitter_tag_data_t {
pub suffix_length: size_t
}

impl Copy for yaml_emitter_tag_data_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_emitter_scalar_data_t {
Expand All @@ -343,9 +321,7 @@ pub struct yaml_emitter_scalar_data_t {
pub style: YamlScalarStyle,
}

impl Copy for yaml_emitter_scalar_data_t {}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_event_t {
Expand All @@ -355,7 +331,7 @@ pub struct yaml_event_t {
pub end_mark: yaml_mark_t
}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_stream_start_event_t {
Expand All @@ -369,8 +345,6 @@ pub struct yaml_tag_directive_list_t {
pub end: *const yaml_tag_directive_t,
}

impl Copy for yaml_tag_directive_list_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_document_start_event_t {
Expand All @@ -379,9 +353,7 @@ pub struct yaml_document_start_event_t {
pub implicit: c_int
}

impl Copy for yaml_document_start_event_t {}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_document_end_event_t {
Expand All @@ -394,8 +366,6 @@ pub struct yaml_alias_event_t {
pub anchor: *const yaml_char_t
}

impl Copy for yaml_alias_event_t {}

#[allow(non_camel_case_types)]
pub struct yaml_sequence_start_event_t {
pub anchor: *const yaml_char_t,
Expand All @@ -404,8 +374,6 @@ pub struct yaml_sequence_start_event_t {
pub style: YamlSequenceStyle
}

impl Copy for yaml_sequence_start_event_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_mapping_start_event_t {
Expand All @@ -415,8 +383,6 @@ pub struct yaml_mapping_start_event_t {
pub style: YamlSequenceStyle
}

impl Copy for yaml_mapping_start_event_t {}

#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_scalar_event_t {
Expand All @@ -429,15 +395,13 @@ pub struct yaml_scalar_event_t {
pub style: YamlScalarStyle
}

impl Copy for yaml_scalar_event_t {}

impl yaml_event_t {
pub unsafe fn delete(&mut self) {
yaml_event_delete(self);
}
}

#[derive(Copy)]
#[derive(Clone, Copy)]
#[repr(C)]
#[allow(non_camel_case_types)]
pub struct yaml_version_directive_t {
Expand All @@ -452,8 +416,6 @@ pub struct yaml_tag_directive_t {
pub prefix: *const c_char
}

impl Copy for yaml_tag_directive_t {}

#[link(name = "yaml")]
extern {
pub fn yaml_get_version_string() -> *const c_char;
Expand Down

0 comments on commit 2a414fd

Please sign in to comment.