Sha256: 8596f40357356da40ff8a9620976f93154e49583fb799be55f858f1dbf1e9e06

Contents?: true

Size: 1.79 KB

Versions: 5

Compression:

Stored size: 1.79 KB

Contents

#include "rb_Global.h"

//	Internals from ruby that aren't included in the ruby lib
#include "RubySourceSupport.h"

#include "eval_intern.h"

/***********
*  Global  *
***********/

void Init_senderGlobal()	{
	
	rb_define_global_function( "__sender__",		rb_RPRuby_Sender___sender__,			0 );
	rb_define_global_function( "__caller__",		rb_RPRuby_Sender___caller__,			0 );

}

/***************************************************************************************************************************************************************
****************************************************************************************************************************************************************
													Ruby Global Methods
****************************************************************************************************************************************************************
***************************************************************************************************************************************************************/

/***************
*  __sender__  *
***************/

/*
 * call-seq:
 *   __sender__ -> object
 *
 * Return object sending message to receiver.
 */
VALUE rb_RPRuby_Sender___sender__()	{

	//	get the frame prior to current frame
	rb_control_frame_t*		c_sending_frame	=	RPRuby_internal_framePriorTo( NULL );
	
	//	make sure the current frame wasn't the first frame or return nil
	if ( c_sending_frame == NULL )	{
		return Qnil;
	}
	
	//	assuming we have a previous frame, return its rb_self (our current receiver's sender)
	return c_sending_frame->self;
}

/***************
*  __caller__  *
***************/

/*
 * call-seq:
 *   __caller__ -> object
 *
 * Return method sending message to receiver.
 */
VALUE rb_RPRuby_Sender___caller__()	{

	return ID2SYM( rb_frame_caller() );
}

Version data entries

5 entries across 5 versions & 1 rubygems

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