Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / sendsite.c
blobafbbb61fd899c703cb93169591306704eea830bb
1 #include "shotgun/lib/shotgun.h"
2 #include "shotgun/lib/sendsite.h"
3 #include "shotgun/lib/selector.h"
5 void send_site_cleanup(STATE, OBJECT obj) {
9 void send_site_init(STATE) {
10 struct type_info info = {
11 .object_fields = SEND_SITE_OBJECT_FIELDS,
12 .cleanup = send_site_cleanup
15 BASIC_CLASS(send_site) = rbs_class_new(state, "SendSite", 0, BASIC_CLASS(object));
16 class_set_object_type(BASIC_CLASS(send_site), I2N(SendSiteType));
18 state_setup_type(state, SendSiteType, &info);
21 /*
22 send site created with the following information:
24 * message name symbol
25 * method lookup function reference
26 * reference to CompiledMethod containing send site
29 OBJECT send_site_create(STATE, OBJECT name) {
30 OBJECT ss_obj;
31 struct send_site *ss;
33 NEW_STRUCT(ss_obj, ss, BASIC_CLASS(send_site), struct send_site);
34 ss->name = name;
35 ss->sender = Qnil;
36 SET_STRUCT_FIELD(ss_obj, ss->selector, selector_lookup(state, name));
37 ss->data1 = ss->data2 = ss->data3 = Qnil;
38 ss->hits = ss->misses = 0;
40 cpu_initialize_sendsite(state, ss);
42 selector_associate(state, ss->selector, ss_obj);
44 return ss_obj;
47 /* cm is CompiledMethod that holds send site */
48 void send_site_set_sender(STATE, OBJECT self, OBJECT cm) {
49 struct send_site *ss;
51 ss = SENDSITE(self);
52 SET_STRUCT_FIELD(self, ss->sender, cm);