Sha256: c09bcb8e55790c7687c34df5bcac4aa3ae21925711f339743c33bdbb78a19144

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

#include "RPSender_internal.h"
#include "RubySourceSupport.h"

/*************************
 *  framePriorToCurrent  *
 ************************/

rb_control_frame_t* RPRuby_internal_framePriorTo( rb_control_frame_t* control_frame )	{
	
	rb_thread_t*			c_thread				= GET_THREAD();
	rb_control_frame_t*		prior_control_frame		= NULL;
	//	get the current frame pointer
	if ( control_frame == NULL )	{
		control_frame	= c_thread->cfp;
	}
	
    if ( ( prior_control_frame = rb_vm_get_ruby_level_next_cfp( c_thread, control_frame ) ) != 0) {
		
		prior_control_frame = RUBY_VM_PREVIOUS_CONTROL_FRAME( prior_control_frame );

    }
	else {
		prior_control_frame = NULL;
	}
	
	//	if we have a nil object we've passed main, we're done
	if ( prior_control_frame->self == Qnil )	{
		return NULL;
	}

	return prior_control_frame;
	
}

/**********************************
 *  backtraceHashForControlFrame  *
 *********************************/

VALUE RPSender_internal_backtraceHashForControlFrame( rb_control_frame_t* c_control_frame )	{

	//	create new hash for this frame
	VALUE	rb_frame_hash		=	rb_hash_new();
	
	//	get object and set in hash
	VALUE	rb_object_for_frame	=	c_control_frame->self;
	//	if we get nil we're done with our backtrace
	rb_hash_aset(	rb_frame_hash,
					ID2SYM( rb_intern( "object" ) ),
					rb_object_for_frame );
	
	//	get method and set in hash
	ID		c_frame_function_id	=	frame_func_id( c_control_frame );
	//	main has no method name
	if ( c_frame_function_id != 0)	{
		VALUE	rb_method_for_frame	=	ID2SYM( c_frame_function_id );
		rb_hash_aset(	rb_frame_hash,
						ID2SYM( rb_intern( "method" ) ),
						rb_method_for_frame );
		
	}
	
	return rb_frame_hash;
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sender-1.1.4 ext/sender/RPSender_internal.c
sender-1.1.3 ext/sender/RPSender_internal.c
sender-1.1.2 ext/sender/RPSender_internal.c
sender-1.1.1 ext/sender/RPSender_internal.c
sender-1.1.0 ext/sender/RPSender_internal.c