sender 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- metadata +19 -90
- data/.autotest +0 -11
- data/CHANGELOG.rdoc +0 -72
- data/Manifest.txt +0 -24
- data/Rakefile +0 -25
- data/VERSION.rdoc +0 -1
- data/ext/sender/RPSender_internal.c +0 -37
- data/ext/sender/RPSender_internal.h +0 -15
- data/ext/sender/RubySourceSupport.c +0 -47
- data/ext/sender/RubySourceSupport.h +0 -77
- data/ext/sender/rb_Global.c +0 -151
- data/ext/sender/rb_Global.h +0 -11
- data/ext/sender/rb_Global_internal.h +0 -8
- data/ext/sender/rb_Kernel.c +0 -683
- data/ext/sender/rb_Kernel.h +0 -31
- data/ext/sender/rb_Kernel_internal.h +0 -10
- data/ext/sender/sender.c +0 -16
- data/lib/sender/sender.bundle +0 -0
- data/mkmf.log +0 -69
- data/sender.gemspec +0 -51
- data/test/test_sender.rb +0 -22
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 1.5.
|
8
|
+
- 5
|
9
|
+
version: 1.5.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Asher
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-28 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,7 +27,8 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 0
|
30
|
-
|
30
|
+
- 1
|
31
|
+
version: "0.1"
|
31
32
|
type: :runtime
|
32
33
|
version_requirements: *id001
|
33
34
|
- !ruby/object:Gem::Dependency
|
@@ -40,102 +41,30 @@ dependencies:
|
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
segments:
|
42
43
|
- 0
|
43
|
-
|
44
|
+
- 1
|
45
|
+
version: "0.1"
|
44
46
|
type: :runtime
|
45
47
|
version_requirements: *id002
|
46
|
-
-
|
47
|
-
|
48
|
-
prerelease: false
|
49
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 2
|
56
|
-
- 0
|
57
|
-
- 4
|
58
|
-
version: 2.0.4
|
59
|
-
type: :development
|
60
|
-
version_requirements: *id003
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: rake-compiler
|
63
|
-
prerelease: false
|
64
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
segments:
|
70
|
-
- 0
|
71
|
-
version: "0"
|
72
|
-
type: :development
|
73
|
-
version_requirements: *id004
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: hoe
|
76
|
-
prerelease: false
|
77
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
segments:
|
83
|
-
- 2
|
84
|
-
- 6
|
85
|
-
- 1
|
86
|
-
version: 2.6.1
|
87
|
-
type: :development
|
88
|
-
version_requirements: *id005
|
89
|
-
description: |-
|
90
|
-
Adds :__sender__ and :__caller__ to the built-in :__callee__ and :__method__ methods in Ruby 1.9.1.
|
91
|
-
|
92
|
-
Also provides object-oriented :backtrace supporting n-levels backward, :each_backtrace_frame for iteration, :backtrace_includes?,
|
93
|
-
and :backtrace_includes_one_of? for context inspection, and :backtrace_frame_with and :backtrace_frames_with, which return
|
94
|
-
matching frame information for the frame(s) matching the given description.
|
95
|
-
email:
|
96
|
-
- asher@ridiculouspower.com
|
48
|
+
description: Also provides object-oriented :backtrace supporting n-levels backward, :each_backtrace_frame for iteration, :backtrace_includes?, and :backtrace_includes_one_of? for context inspection, and :backtrace_frame_with and :backtrace_frames_with, which return matching frame information for the frame(s) matching the given description.
|
49
|
+
email: asher@ridiculouspower.com
|
97
50
|
executables: []
|
98
51
|
|
99
52
|
extensions:
|
100
53
|
- ext/sender/extconf.rb
|
101
|
-
extra_rdoc_files:
|
102
|
-
|
103
|
-
- CHANGELOG.rdoc
|
104
|
-
- README.rdoc
|
105
|
-
- VERSION.rdoc
|
54
|
+
extra_rdoc_files: []
|
55
|
+
|
106
56
|
files:
|
107
|
-
- .
|
108
|
-
-
|
109
|
-
- Manifest.txt
|
57
|
+
- lib/sender.rb
|
58
|
+
- lib/VERSION.rdoc
|
110
59
|
- README.rdoc
|
111
|
-
- Rakefile
|
112
|
-
- VERSION.rdoc
|
113
|
-
- ext/sender/RPSender_internal.c
|
114
|
-
- ext/sender/RPSender_internal.h
|
115
|
-
- ext/sender/RubySourceSupport.c
|
116
|
-
- ext/sender/RubySourceSupport.h
|
117
60
|
- ext/sender/extconf.rb
|
118
|
-
- ext/sender/rb_Global.c
|
119
|
-
- ext/sender/rb_Global.h
|
120
|
-
- ext/sender/rb_Global_internal.h
|
121
|
-
- ext/sender/rb_Kernel.c
|
122
|
-
- ext/sender/rb_Kernel.h
|
123
|
-
- ext/sender/rb_Kernel_internal.h
|
124
|
-
- ext/sender/sender.c
|
125
|
-
- lib/VERSION.rdoc
|
126
|
-
- lib/sender.rb
|
127
|
-
- lib/sender/sender.bundle
|
128
|
-
- mkmf.log
|
129
|
-
- sender.gemspec
|
130
|
-
- test/test_sender.rb
|
131
61
|
has_rdoc: true
|
132
62
|
homepage: http://rubygems.org/gems/sender
|
133
63
|
licenses: []
|
134
64
|
|
135
65
|
post_install_message:
|
136
|
-
rdoc_options:
|
137
|
-
|
138
|
-
- README.rdoc
|
66
|
+
rdoc_options: []
|
67
|
+
|
139
68
|
require_paths:
|
140
69
|
- lib
|
141
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -156,10 +85,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
85
|
version: "0"
|
157
86
|
requirements: []
|
158
87
|
|
159
|
-
rubyforge_project:
|
88
|
+
rubyforge_project: sender
|
160
89
|
rubygems_version: 1.3.7
|
161
90
|
signing_key:
|
162
91
|
specification_version: 3
|
163
|
-
summary: Adds :__sender__ and :__caller__ to the built-in :__callee__ and :__method__ methods in Ruby 1.9.1
|
164
|
-
test_files:
|
165
|
-
|
92
|
+
summary: Adds :__sender__ and :__caller__ to the built-in :__callee__ and :__method__ methods in Ruby 1.9.1.
|
93
|
+
test_files: []
|
94
|
+
|
data/.autotest
DELETED
data/CHANGELOG.rdoc
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
=== 1.0.0 2010-06-22
|
2
|
-
|
3
|
-
Initial release
|
4
|
-
|
5
|
-
=== 1.0.1 2010-06-22
|
6
|
-
|
7
|
-
Minor detail changes
|
8
|
-
|
9
|
-
=== 1.1.0 2010-06-23
|
10
|
-
|
11
|
-
Added :Kernel.backtrace.
|
12
|
-
Added :Kernel.backtrace_includes?.
|
13
|
-
Fixed external requirement of Ruby source directory. Gem should now install transparently and painlessly.
|
14
|
-
|
15
|
-
=== 1.1.1-4 2010-06-23
|
16
|
-
|
17
|
-
Minor detail changes
|
18
|
-
|
19
|
-
=== 1.2 2010-06-24
|
20
|
-
|
21
|
-
Fixed __caller__.
|
22
|
-
Observed that no backtrace is available for :initialize. For now this can be circumvented by subclassing new (make sure you call super);
|
23
|
-
in the long term, I am investing what needs to be done for the special case.
|
24
|
-
|
25
|
-
=== 1.3 2010-06-27
|
26
|
-
|
27
|
-
Added init_sender_callbacks( sender, caller ) to take care of :initialize issue. Include Sender module in your class to activate and
|
28
|
-
:init_sender_callbacks( __sender__, __caller__ ) will be called on self from self.class.new before self.initialize.
|
29
|
-
|
30
|
-
=== 1.4 2010-06-29
|
31
|
-
|
32
|
-
Removed init_sender_callbacks that were added in 1.3.
|
33
|
-
New implementation of backtrace- now works for :initialize.
|
34
|
-
__sender__ and __caller__ now work for :initialize and return the object and method that called :new.
|
35
|
-
|
36
|
-
=== 1.4.1-2 2010-06-29
|
37
|
-
|
38
|
-
Fixed path problem for VERSION.rdoc.
|
39
|
-
|
40
|
-
=== 1.4.3 2010-06-29
|
41
|
-
|
42
|
-
Fixed problems with superclass method definitions so __sender__ and __caller__ return the caller to the first method in the class chain.
|
43
|
-
|
44
|
-
=== 1.5 2010-07-09
|
45
|
-
|
46
|
-
Added to Kernel:
|
47
|
-
* :each_backtrace_frame
|
48
|
-
* :backtrace_includes?
|
49
|
-
* :backtrace_includes_one_of?
|
50
|
-
* :backtrace_frame_with
|
51
|
-
* :backtrace_frames_with
|
52
|
-
|
53
|
-
Added Hash-specification support for context inspection. Now functions take element value (object instance, class, method symbol, filename string,
|
54
|
-
line number fixnum) or Hash containing frame detail specification.
|
55
|
-
|
56
|
-
Added Enumerator support. Non-block enumeration will iterate the backtrace that was the active context when :each_backtrace_frame was called.
|
57
|
-
|
58
|
-
=== 1.5.1 2010-07-09
|
59
|
-
|
60
|
-
Fixed return values for :backtrace_with_frame to return nil rather than false.
|
61
|
-
|
62
|
-
=== 1.5.2-3 2010-07-10
|
63
|
-
|
64
|
-
Added support for Ruby 1.9.2rc1 (iseq struct changed).
|
65
|
-
Added ruby_core_source support so that Ruby core files don't have to be included.
|
66
|
-
|
67
|
-
=== 1.5.4 2010-08-24
|
68
|
-
|
69
|
-
Updated for 1.9.2p0
|
70
|
-
Fixed dependencies (hopefully).
|
71
|
-
Changed from ruby_core_source gem to core-source gem
|
72
|
-
Changed from mkmf to mkmfmf gem
|
data/Manifest.txt
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
.autotest
|
2
|
-
CHANGELOG.rdoc
|
3
|
-
Manifest.txt
|
4
|
-
README.rdoc
|
5
|
-
Rakefile
|
6
|
-
VERSION.rdoc
|
7
|
-
ext/sender/RPSender_internal.c
|
8
|
-
ext/sender/RPSender_internal.h
|
9
|
-
ext/sender/RubySourceSupport.c
|
10
|
-
ext/sender/RubySourceSupport.h
|
11
|
-
ext/sender/extconf.rb
|
12
|
-
ext/sender/rb_Global.c
|
13
|
-
ext/sender/rb_Global.h
|
14
|
-
ext/sender/rb_Global_internal.h
|
15
|
-
ext/sender/rb_Kernel.c
|
16
|
-
ext/sender/rb_Kernel.h
|
17
|
-
ext/sender/rb_Kernel_internal.h
|
18
|
-
ext/sender/sender.c
|
19
|
-
lib/VERSION.rdoc
|
20
|
-
lib/sender.rb
|
21
|
-
lib/sender/sender.bundle
|
22
|
-
mkmf.log
|
23
|
-
sender.gemspec
|
24
|
-
test/test_sender.rb
|
data/Rakefile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'hoe'
|
2
|
-
require 'rake/extensiontask'
|
3
|
-
|
4
|
-
Hoe.spec 'sender' do
|
5
|
-
developer( 'Asher', 'asher@ridiculouspower.com' )
|
6
|
-
self.rubyforge_name = 'asher'
|
7
|
-
self.version = File.open( 'VERSION.rdoc' ).readline
|
8
|
-
self.readme_file = 'README.rdoc'
|
9
|
-
self.history_file = 'CHANGELOG.rdoc'
|
10
|
-
self.extra_rdoc_files = FileList['*.rdoc']
|
11
|
-
self.spec_extras = { :extensions => ["ext/sender/extconf.rb"] }
|
12
|
-
self.extra_dev_deps << ['rake-compiler', '>= 0']
|
13
|
-
self.extra_deps << ['core-source', '>= 0'] << ['mkmfmf', '>= 0']
|
14
|
-
Rake::ExtensionTask.new( 'sender', spec ) do |ext|
|
15
|
-
ext.lib_dir = File.join('lib', 'sender')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
Rake::Task[:test].prerequisites << :compile
|
20
|
-
|
21
|
-
task :cultivate do
|
22
|
-
system "touch Manifest.txt; rake check_manifest | grep -v \"(in \" | patch"
|
23
|
-
system "rake debug_gem | grep -v \"(in \" > sender.gemspec"
|
24
|
-
end
|
25
|
-
|
data/VERSION.rdoc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.5.4
|
@@ -1,37 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "RPSender_internal.h"
|
3
|
-
#include "RubySourceSupport.h"
|
4
|
-
|
5
|
-
/******************
|
6
|
-
* framePriorTo *
|
7
|
-
*****************/
|
8
|
-
|
9
|
-
rb_control_frame_t* RPRuby_internal_framePriorTo( rb_control_frame_t* c_control_frame ) {
|
10
|
-
|
11
|
-
rb_thread_t* c_thread = GET_THREAD();
|
12
|
-
rb_control_frame_t* c_prior_control_frame = NULL;
|
13
|
-
// get the current frame pointer
|
14
|
-
if ( c_control_frame == NULL ) {
|
15
|
-
c_control_frame = c_thread->cfp;
|
16
|
-
}
|
17
|
-
|
18
|
-
if ( ( c_prior_control_frame = rb_vm_get_ruby_level_next_cfp( c_thread, c_control_frame ) ) != 0) {
|
19
|
-
|
20
|
-
// not sure why we have to call this a second time after it was called at the end of rb_vm_get_ruby_level_next_cfp,
|
21
|
-
// but for some reason it seems to be necessary
|
22
|
-
c_prior_control_frame = RUBY_VM_PREVIOUS_CONTROL_FRAME( c_prior_control_frame );
|
23
|
-
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
c_prior_control_frame = NULL;
|
27
|
-
}
|
28
|
-
|
29
|
-
// if we have a nil object we've passed main, we're done
|
30
|
-
if ( c_prior_control_frame->self == Qnil ) {
|
31
|
-
return NULL;
|
32
|
-
}
|
33
|
-
|
34
|
-
return c_prior_control_frame;
|
35
|
-
|
36
|
-
}
|
37
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#ifndef RP_SENDER_INTERNAL
|
2
|
-
#define RP_SENDER_INTERNAL
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
#include "eval_intern.h"
|
6
|
-
|
7
|
-
typedef enum BOOL_e {
|
8
|
-
FALSE,
|
9
|
-
TRUE
|
10
|
-
} BOOL;
|
11
|
-
|
12
|
-
rb_control_frame_t* RPRuby_internal_framePriorTo( rb_control_frame_t* control_frame );
|
13
|
-
VALUE RPSender_internal_backtraceHashForControlFrame( const rb_control_frame_t* c_top_of_control_frame );
|
14
|
-
|
15
|
-
#endif
|
@@ -1,47 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "RubySourceSupport.h"
|
3
|
-
|
4
|
-
#include "rb_Kernel.h"
|
5
|
-
#include "RPSender_internal.h"
|
6
|
-
|
7
|
-
#include "iseq.h"
|
8
|
-
|
9
|
-
// Taken from eval.c in Ruby source
|
10
|
-
// No header, so easiest way to integrate was to copy the code and make my own header.
|
11
|
-
// Previously declared static; otherwise unchanged
|
12
|
-
|
13
|
-
int rb_vm_get_sourceline(const rb_control_frame_t *cfp)
|
14
|
-
{
|
15
|
-
int line_no = 0;
|
16
|
-
const rb_iseq_t *iseq = cfp->iseq;
|
17
|
-
|
18
|
-
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
|
19
|
-
rb_num_t i;
|
20
|
-
size_t pos = cfp->pc - cfp->iseq->iseq_encoded;
|
21
|
-
|
22
|
-
for (i = 0; i < iseq->insn_info_size; i++) {
|
23
|
-
if (iseq->insn_info_table[i].position == pos) {
|
24
|
-
if (i == 0) goto found;
|
25
|
-
line_no = iseq->insn_info_table[i - 1].line_no;
|
26
|
-
goto found;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
line_no = iseq->insn_info_table[i - 1].line_no;
|
30
|
-
}
|
31
|
-
found:
|
32
|
-
return line_no;
|
33
|
-
}
|
34
|
-
|
35
|
-
struct enumerator* enumerator_ptr(VALUE obj)
|
36
|
-
{
|
37
|
-
struct enumerator *ptr;
|
38
|
-
|
39
|
-
Data_Get_Struct(obj, struct enumerator, ptr);
|
40
|
-
|
41
|
-
// modified because a call to a local version of enumerator_mark won't verify
|
42
|
-
|
43
|
-
if (!ptr || ptr->obj == Qundef) {
|
44
|
-
rb_raise(rb_eArgError, "uninitialized enumerator");
|
45
|
-
}
|
46
|
-
return ptr;
|
47
|
-
}
|
@@ -1,77 +0,0 @@
|
|
1
|
-
#ifndef RP_SENDER_RUBY_SOURCE_SUPPORT
|
2
|
-
#define RP_SENDER_RUBY_SOURCE_SUPPORT
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
#include "eval_intern.h"
|
6
|
-
#include "version.h"
|
7
|
-
#if RUBY_PATCHLEVEL == -1
|
8
|
-
#include "vm_core.h"
|
9
|
-
#endif
|
10
|
-
#include "method.h"
|
11
|
-
|
12
|
-
#define MAX_POSBUF 128
|
13
|
-
|
14
|
-
enum context_type {
|
15
|
-
CONTINUATION_CONTEXT = 0,
|
16
|
-
FIBER_CONTEXT = 1,
|
17
|
-
ROOT_FIBER_CONTEXT = 2
|
18
|
-
};
|
19
|
-
|
20
|
-
typedef struct rb_context_struct {
|
21
|
-
enum context_type type;
|
22
|
-
VALUE self;
|
23
|
-
int argc;
|
24
|
-
VALUE value;
|
25
|
-
VALUE *vm_stack;
|
26
|
-
#ifdef CAPTURE_JUST_VALID_VM_STACK
|
27
|
-
int vm_stack_slen; /* length of stack (head of th->stack) */
|
28
|
-
int vm_stack_clen; /* length of control frames (tail of th->stack) */
|
29
|
-
#endif
|
30
|
-
VALUE *machine_stack;
|
31
|
-
VALUE *machine_stack_src;
|
32
|
-
#ifdef __ia64
|
33
|
-
VALUE *machine_register_stack;
|
34
|
-
VALUE *machine_register_stack_src;
|
35
|
-
int machine_register_stack_size;
|
36
|
-
#endif
|
37
|
-
rb_thread_t saved_thread;
|
38
|
-
rb_jmpbuf_t jmpbuf;
|
39
|
-
int machine_stack_size;
|
40
|
-
} rb_context_t;
|
41
|
-
|
42
|
-
enum fiber_status {
|
43
|
-
CREATED,
|
44
|
-
RUNNING,
|
45
|
-
TERMINATED
|
46
|
-
};
|
47
|
-
|
48
|
-
typedef struct rb_fiber_struct {
|
49
|
-
rb_context_t cont;
|
50
|
-
VALUE prev;
|
51
|
-
enum fiber_status status;
|
52
|
-
struct rb_fiber_struct *prev_fiber;
|
53
|
-
struct rb_fiber_struct *next_fiber;
|
54
|
-
} rb_fiber_t;
|
55
|
-
|
56
|
-
struct enumerator {
|
57
|
-
VALUE obj;
|
58
|
-
ID meth;
|
59
|
-
VALUE args;
|
60
|
-
VALUE fib;
|
61
|
-
VALUE dst;
|
62
|
-
VALUE no_next;
|
63
|
-
};
|
64
|
-
|
65
|
-
#define GetFiberPtr(obj, ptr) do {\
|
66
|
-
ptr = (rb_fiber_t*)DATA_PTR(obj);\
|
67
|
-
if (!ptr) rb_raise(rb_eFiberError, "uninitialized fiber");\
|
68
|
-
} while(0)
|
69
|
-
|
70
|
-
|
71
|
-
ID frame_func_id( rb_control_frame_t *cfp );
|
72
|
-
ID rb_frame_caller(void);
|
73
|
-
int rb_vm_get_sourceline(const rb_control_frame_t *cfp);
|
74
|
-
void control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp);
|
75
|
-
struct enumerator* enumerator_ptr(VALUE obj);
|
76
|
-
|
77
|
-
#endif
|
data/ext/sender/rb_Global.c
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "rb_Global.h"
|
3
|
-
#include "rb_Kernel.h"
|
4
|
-
|
5
|
-
// Internals from ruby that aren't included in the ruby lib
|
6
|
-
#include "RubySourceSupport.h"
|
7
|
-
|
8
|
-
#include "eval_intern.h"
|
9
|
-
|
10
|
-
/***********
|
11
|
-
* Global *
|
12
|
-
***********/
|
13
|
-
|
14
|
-
void Init_senderGlobal() {
|
15
|
-
|
16
|
-
rb_define_global_function( "__sender__", rb_RPRuby_Sender___sender__, 0 );
|
17
|
-
rb_define_global_function( "__caller__", rb_RPRuby_Sender___caller__, 0 );
|
18
|
-
|
19
|
-
}
|
20
|
-
|
21
|
-
/***************************************************************************************************************************************************************
|
22
|
-
****************************************************************************************************************************************************************
|
23
|
-
Ruby Global Methods
|
24
|
-
****************************************************************************************************************************************************************
|
25
|
-
***************************************************************************************************************************************************************/
|
26
|
-
|
27
|
-
/***************
|
28
|
-
* __sender__ *
|
29
|
-
***************/
|
30
|
-
|
31
|
-
/*
|
32
|
-
* call-seq:
|
33
|
-
* __sender__ -> object
|
34
|
-
*
|
35
|
-
* Return object sending message to receiver.
|
36
|
-
*/
|
37
|
-
VALUE rb_RPRuby_Sender___sender__() {
|
38
|
-
|
39
|
-
// we want 3 levels of backtrace:
|
40
|
-
// 1: current call to __method__ (__method__ in context)
|
41
|
-
// 2: the frame we want, unless it is :new (call to context: __sender__)
|
42
|
-
// 3: the frame we want in the case #2 is :new
|
43
|
-
VALUE rb_backtrace_limit = INT2FIX( 3 );
|
44
|
-
|
45
|
-
VALUE rb_backtrace_array = rb_RPRuby_Sender_Kernel_backtrace( 1,
|
46
|
-
& rb_backtrace_limit,
|
47
|
-
rb_mKernel );
|
48
|
-
|
49
|
-
int c_backtrace_index = 1;
|
50
|
-
|
51
|
-
VALUE rb_backtrace_frame_hash = rb_ary_entry( rb_backtrace_array, c_backtrace_index );
|
52
|
-
|
53
|
-
VALUE rb_caller = rb_hash_aref( rb_backtrace_frame_hash,
|
54
|
-
ID2SYM( rb_intern( "method" ) ) );
|
55
|
-
|
56
|
-
// if we get :initialize as our caller and our __method__ is :initialize, we need to go up the chain
|
57
|
-
// until our caller is no longer :initialize or :new
|
58
|
-
while ( rb_caller == ID2SYM( rb_intern( "initialize" ) ) ) {
|
59
|
-
c_backtrace_index++;
|
60
|
-
rb_backtrace_frame_hash = rb_ary_entry( rb_backtrace_array, c_backtrace_index );
|
61
|
-
rb_caller = rb_hash_aref( rb_backtrace_frame_hash,
|
62
|
-
ID2SYM( rb_intern( "method" ) ) );
|
63
|
-
|
64
|
-
// we have one parent past our current method; if that is also :initialize, get the whole backtrace
|
65
|
-
if ( c_backtrace_index == 2 ) {
|
66
|
-
rb_backtrace_array = rb_RPRuby_Sender_Kernel_backtrace( 0, NULL, rb_mKernel );
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
// if we get "new" as our caller we need to get the next level, as we are in :initialize
|
71
|
-
// and want to know what called :new
|
72
|
-
//
|
73
|
-
// since we might have had to go up the chain from :initialize through parents before getting here we
|
74
|
-
// want to use a separate if statement
|
75
|
-
if ( rb_caller == ID2SYM( rb_intern( "new" ) ) ) {
|
76
|
-
c_backtrace_index++;
|
77
|
-
rb_backtrace_frame_hash = rb_ary_entry( rb_backtrace_array, c_backtrace_index );
|
78
|
-
}
|
79
|
-
|
80
|
-
VALUE rb_sender = rb_hash_aref( rb_backtrace_frame_hash,
|
81
|
-
ID2SYM( rb_intern( "object" ) ) );
|
82
|
-
|
83
|
-
// assuming we have a previous frame, return its rb_self (our current receiver's sender)
|
84
|
-
return rb_sender;
|
85
|
-
}
|
86
|
-
|
87
|
-
/***************
|
88
|
-
* __caller__ *
|
89
|
-
***************/
|
90
|
-
|
91
|
-
/*
|
92
|
-
* call-seq:
|
93
|
-
* __caller__ -> object
|
94
|
-
*
|
95
|
-
* Return method sending message to receiver.
|
96
|
-
*/
|
97
|
-
VALUE rb_RPRuby_Sender___caller__() {
|
98
|
-
|
99
|
-
|
100
|
-
// we want 3 levels of backtrace:
|
101
|
-
// 1: current call to __method__ (__method__ in context)
|
102
|
-
// 2: the frame we want, unless it is :new (call to context: __sender__)
|
103
|
-
// 3: the frame we want in the case #2 is :new
|
104
|
-
VALUE rb_backtrace_limit = INT2FIX( 3 );
|
105
|
-
|
106
|
-
VALUE rb_backtrace_array = rb_RPRuby_Sender_Kernel_backtrace( 1,
|
107
|
-
& rb_backtrace_limit,
|
108
|
-
rb_mKernel );
|
109
|
-
|
110
|
-
int c_backtrace_index = 1;
|
111
|
-
|
112
|
-
VALUE rb_backtrace_frame_hash = rb_ary_entry( rb_backtrace_array, c_backtrace_index );
|
113
|
-
|
114
|
-
VALUE rb_caller = rb_hash_aref( rb_backtrace_frame_hash,
|
115
|
-
ID2SYM( rb_intern( "method" ) ) );
|
116
|
-
|
117
|
-
// we want to compare our caller as we go up the chain to our first caller to deal with super methods
|
118
|
-
// we have a symbol so no cloning is necessary (or appropriate)
|
119
|
-
VALUE rb_first_caller = rb_hash_aref( rb_ary_entry( rb_backtrace_array, 0 ),
|
120
|
-
ID2SYM( rb_intern( "method" ) ) );
|
121
|
-
|
122
|
-
// if we get :initialize as our caller and our __method__ is :initialize, we need to go up the chain
|
123
|
-
// until our caller is no longer :initialize or :new
|
124
|
-
while ( rb_caller == rb_first_caller ) {
|
125
|
-
c_backtrace_index++;
|
126
|
-
rb_backtrace_frame_hash = rb_ary_entry( rb_backtrace_array, c_backtrace_index );
|
127
|
-
rb_caller = rb_hash_aref( rb_backtrace_frame_hash,
|
128
|
-
ID2SYM( rb_intern( "method" ) ) );
|
129
|
-
|
130
|
-
// we have one parent past our current method; if that is also :initialize, get the whole backtrace
|
131
|
-
if ( c_backtrace_index == 2 ) {
|
132
|
-
rb_backtrace_array = rb_RPRuby_Sender_Kernel_backtrace( 0, NULL, rb_mKernel );
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
// if we get "new" as our caller we need to get the next level, as we are in :initialize
|
137
|
-
// and want to know what called :new
|
138
|
-
//
|
139
|
-
// since we might have had to go up the chain from :initialize through parents before getting here we
|
140
|
-
// want to use a separate if statement
|
141
|
-
if ( rb_caller == ID2SYM( rb_intern( "new" ) ) ) {
|
142
|
-
c_backtrace_index++;
|
143
|
-
rb_backtrace_frame_hash = rb_ary_entry( rb_backtrace_array, c_backtrace_index );
|
144
|
-
rb_caller = rb_hash_aref( rb_backtrace_frame_hash,
|
145
|
-
ID2SYM( rb_intern( "method" ) ) );
|
146
|
-
}
|
147
|
-
|
148
|
-
// assuming we have a previous frame, return its rb_self (our current receiver's sender)
|
149
|
-
return rb_caller;
|
150
|
-
}
|
151
|
-
|
data/ext/sender/rb_Global.h
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
|
2
|
-
#ifndef RP_SENDER_CALLER_GLOBAL_INTERNAL
|
3
|
-
#define RP_SENDER_CALLER_GLOBAL_INTERNAL
|
4
|
-
|
5
|
-
rb_control_frame_t* RPRuby_internal_framePriorTo();
|
6
|
-
rb_control_instruction_t* RPRuby_internal_instructionPriorTo( rb_control_instruction_t* c_control_instruction );
|
7
|
-
|
8
|
-
#endif
|