@@ -282,14 +282,14 @@ unsafe fn cstr_to_string(ptr: *const c_char) -> Option<String> {
282282 CStr :: from_ptr ( ptr) . to_str ( ) . ok ( ) . map ( |s| s. to_string ( ) )
283283}
284284
285- unsafe fn value_to_string ( val : VALUE , to_s_id : ID ) -> Option < String > {
285+ unsafe fn value_to_string ( recorder : & Recorder , val : VALUE ) -> Option < String > {
286286 if RB_TYPE_P ( val, rb_sys:: ruby_value_type:: RUBY_T_STRING ) {
287287 let ptr = RSTRING_PTR ( val) ;
288288 let len = RSTRING_LEN ( val) as usize ;
289289 let slice = std:: slice:: from_raw_parts ( ptr as * const u8 , len) ;
290290 return Some ( String :: from_utf8_lossy ( slice) . to_string ( ) ) ;
291291 }
292- let str_val = rb_funcall ( val, to_s_id, 0 ) ;
292+ let str_val = rb_funcall ( val, recorder . to_s_id , 0 ) ;
293293 let ptr = RSTRING_PTR ( str_val) ;
294294 let len = RSTRING_LEN ( str_val) as usize ;
295295 let slice = std:: slice:: from_raw_parts ( ptr as * const u8 , len) ;
@@ -473,7 +473,7 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
473473 if !RB_TYPE_P ( members, rb_sys:: ruby_value_type:: RUBY_T_ARRAY )
474474 || !RB_TYPE_P ( values, rb_sys:: ruby_value_type:: RUBY_T_ARRAY )
475475 {
476- let text = value_to_string ( val , recorder . to_s_id ) . unwrap_or_default ( ) ;
476+ let text = value_to_string ( recorder , val ) . unwrap_or_default ( ) ;
477477 let type_id =
478478 TraceWriter :: ensure_type_id ( & mut * recorder. tracer , TypeKind :: Raw , & class_name) ;
479479 return ValueRecord :: Raw { r : text, type_id } ;
@@ -507,7 +507,7 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
507507 // generic object
508508 let ivars = rb_funcall ( val, recorder. instance_variables_id , 0 ) ;
509509 if !RB_TYPE_P ( ivars, rb_sys:: ruby_value_type:: RUBY_T_ARRAY ) {
510- let text = value_to_string ( val , recorder . to_s_id ) . unwrap_or_default ( ) ;
510+ let text = value_to_string ( recorder , val ) . unwrap_or_default ( ) ;
511511 let type_id =
512512 TraceWriter :: ensure_type_id ( & mut * recorder. tracer , TypeKind :: Raw , & class_name) ;
513513 return ValueRecord :: Raw { r : text, type_id } ;
@@ -528,7 +528,7 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
528528 if !names. is_empty ( ) {
529529 return struct_value ( recorder, & class_name, & names, & vals, depth) ;
530530 }
531- let text = value_to_string ( val , recorder . to_s_id ) . unwrap_or_default ( ) ;
531+ let text = value_to_string ( recorder , val ) . unwrap_or_default ( ) ;
532532 let type_id = TraceWriter :: ensure_type_id ( & mut * recorder. tracer , TypeKind :: Raw , & class_name) ;
533533 ValueRecord :: Raw { r : text, type_id }
534534}
@@ -747,7 +747,7 @@ unsafe extern "C" fn record_event_api(
747747 std:: str:: from_utf8 ( std:: slice:: from_raw_parts ( ptr as * const u8 , len) ) . unwrap_or ( "" )
748748 } ;
749749 let line_num = rb_num2long ( line) as i64 ;
750- let content_str = value_to_string ( content , recorder . to_s_id ) . unwrap_or_default ( ) ;
750+ let content_str = value_to_string ( recorder , content ) . unwrap_or_default ( ) ;
751751 record_event ( & mut * recorder. tracer , path_slice, line_num, content_str) ;
752752 Qnil . into ( )
753753}
@@ -860,7 +860,7 @@ unsafe extern "C" fn event_hook_raw(data: VALUE, arg: *mut rb_trace_arg_t) {
860860 TraceWriter :: register_return ( & mut * recorder. tracer , val_rec) ;
861861 } else if ( ev & RUBY_EVENT_RAISE ) != 0 {
862862 let exc = rb_tracearg_raised_exception ( arg) ;
863- if let Some ( msg) = value_to_string ( exc , recorder . to_s_id ) {
863+ if let Some ( msg) = value_to_string ( recorder , exc ) {
864864 TraceWriter :: register_special_event ( & mut * recorder. tracer , EventLogKind :: Error , & msg) ;
865865 }
866866 }
0 commit comments