Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 892 lines (799 sloc) 21.559 kb
9c1d230 committing experimental branch content
Laurent Sansonetti authored
1 /* -*-c-*- */
2 /*
3 * This file is included by vm_eval.c
4 */
5
6 static ID __send__, object_id;
7 static ID removed, singleton_removed, undefined, singleton_undefined;
8 static ID eqq, each, aref, aset, match, missing;
9 static ID added, singleton_added;
10
11 void
12 rb_add_method(VALUE klass, ID mid, NODE * node, int noex)
13 {
14 // TODO
15 return;
16 }
17
18 void
19 rb_define_alloc_func(VALUE klass, VALUE (*func)(VALUE))
20 {
21 // TODO
22 #if 0
23 Check_Type(klass, T_CLASS);
24 rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0),
25 NOEX_PUBLIC);
26 #endif
27 }
28
29 void
30 rb_undef_alloc_func(VALUE klass)
31 {
32 // TODO
33 #if 0
34 Check_Type(klass, T_CLASS);
35 rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
36 #endif
37 }
38
39 rb_alloc_func_t
40 rb_get_alloc_func(VALUE klass)
41 {
42 NODE *n;
43 Check_Type(klass, T_CLASS);
44 n = rb_method_node(CLASS_OF(klass), ID_ALLOCATOR);
45 if (!n) return 0;
46 if (nd_type(n) != NODE_METHOD) return 0;
47 n = n->nd_body;
48 if (nd_type(n) != NODE_CFUNC) return 0;
49 return (rb_alloc_func_t)n->nd_cfnc;
50 }
51
52 static NODE *
53 search_method(VALUE klass, ID id, VALUE *klassp)
54 {
55 NODE *node;
56 if (klass == 0) {
57 return NULL;
58 }
59 node = rb_method_node(klass, id);
60 if (node != NULL) {
61 if (klassp != NULL) { /* TODO honour klassp */
62 *klassp = klass;
63 }
64 }
65 return node;
66 }
67
68 /*
69 * search method body (NODE_METHOD)
70 * with : klass and id
71 * without : method cache
72 *
73 * if you need method node with method cache, use
74 * rb_method_node()
75 */
76 NODE *
77 rb_get_method_body(VALUE klass, ID id, ID *idp)
78 {
79 return search_method(klass, id, NULL);
80 }
81
82 NODE *
83 rb_method_node(VALUE klass, ID id)
84 {
85 NODE *node = rb_objc_method_node(klass, id, NULL, NULL);
86 if (node == NULL && id != ID_ALLOCATOR) {
87 const char *id_str = rb_id2name(id);
88 size_t slen = strlen(id_str);
89
90 if (strcmp(id_str, "retain") == 0
91 || strcmp(id_str, "release") == 0
92 || strcmp(id_str, "zone") == 0) {
93 char buf[100];
94 snprintf(buf, sizeof buf, "__rb_%s__", id_str);
95 return rb_method_node(klass, rb_intern(buf));
96 }
97 else {
98 if (id_str[slen - 1] == ':') {
99 return NULL;
100 }
101 else {
102 char buf[100];
103 snprintf(buf, sizeof buf, "%s:", id_str);
104 return rb_method_node(klass, rb_intern(buf));
105 }
106 }
107 }
108 return node;
109 }
110
111 static void
112 remove_method(VALUE klass, ID mid)
113 {
114 if (klass == rb_cObject) {
115 rb_secure(4);
116 }
117 if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
118 rb_raise(rb_eSecurityError, "Insecure: can't remove method");
119 }
120 if (OBJ_FROZEN(klass))
121 rb_error_frozen("class/module");
122 if (mid == object_id || mid == __send__ || mid == idInitialize) {
123 rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
124 }
125 SEL sel;
126 Method m;
127
128 sel = sel_registerName(rb_id2name(mid));
129 m = class_getInstanceMethod((Class)klass, sel);
130 if (m == NULL) {
131 char buf[100];
132 size_t len = strlen((char *)sel);
133 if (((char *)sel)[len - 1] != ':') {
134 snprintf(buf, sizeof buf, "%s:", (char *)sel);
135 sel = sel_registerName(buf);
136 m = class_getInstanceMethod((Class)klass, sel);
137 }
138 }
139 if (m == NULL) {
140 rb_name_error(mid, "method `%s' not defined in %s",
141 rb_id2name(mid), rb_class2name(klass));
142 }
143 if (rb_objc_method_node3(method_getImplementation(m)) == NULL) {
144 rb_warn("removing pure Objective-C method `%s' may cause serious problem", rb_id2name(mid));
145 }
146 method_setImplementation(m, NULL);
147
148
149 if (RCLASS_SINGLETON(klass)) {
150 rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1,
151 ID2SYM(mid));
152 }
153 else {
154 rb_funcall(klass, removed, 1, ID2SYM(mid));
155 }
156 }
157
158 void
159 rb_remove_method(VALUE klass, const char *name)
160 {
161 remove_method(klass, rb_intern(name));
162 }
163
164 /*
165 * call-seq:
166 * remove_method(symbol) => self
167 *
168 * Removes the method identified by _symbol_ from the current
169 * class. For an example, see <code>Module.undef_method</code>.
170 */
171
172 static VALUE
173 rb_mod_remove_method(VALUE mod, SEL sel, int argc, VALUE *argv)
174 {
175 int i;
176
177 for (i = 0; i < argc; i++) {
178 remove_method(mod, rb_to_id(argv[i]));
179 }
180 return mod;
181 }
182
183 #undef rb_disable_super
184 #undef rb_enable_super
185
186 void
187 rb_disable_super(VALUE klass, const char *name)
188 {
189 /* obsolete - no use */
190 }
191
192 void
193 rb_enable_super(VALUE klass, const char *name)
194 {
195 rb_warning("rb_enable_super() is obsolete");
196 }
197
198 void rb_print_undef(VALUE, ID, int);
199
200 static void
201 rb_export_method(VALUE klass, ID name, ID noex)
202 {
203 NODE *node;
204 SEL sel;
205
206 if (klass == rb_cObject) {
207 rb_secure(4);
208 }
209
210 if (!rb_vm_lookup_method2((Class)klass, name, &sel, NULL, &node)) {
211 if (TYPE(klass) != T_MODULE
212 || !rb_vm_lookup_method2((Class)rb_cObject, name, &sel, NULL, &node)) {
213 rb_print_undef(klass, name, 0);
214 }
215 }
216
217 #if 0 // TODO
218 if (node->nd_noex != noex) {
219 // TODO if the method exists on a super class, we should add a new method
220 // with the correct noex that calls super
221 assert(!rb_vm_lookup_method((Class)RCLASS_SUPER(klass), sel, NULL, NULL));
222
223 node->nd_noex = noex;
224 }
225 #endif
226 }
227
228 int
229 rb_method_boundp(VALUE klass, ID id, int ex)
230 {
231 NODE *method;
232
233 if ((method = rb_method_node(klass, id)) != 0) {
234 if (ex && (method->nd_noex & NOEX_PRIVATE)) {
235 return Qfalse;
236 }
237 return Qtrue;
238 }
239 return Qfalse;
240 }
241
242 void
243 rb_attr(VALUE klass, ID id, int read, int write, int ex)
244 {
245 const char *name;
246 int noex;
247
248 if (!ex) {
249 noex = NOEX_PUBLIC;
250 }
251 else {
252 // TODO honor current scope ex
253 noex = NOEX_PUBLIC;
254 }
255
256 if (!rb_is_local_id(id) && !rb_is_const_id(id)) {
257 rb_name_error(id, "invalid attribute name `%s'", rb_id2name(id));
258 }
259 name = rb_id2name(id);
260 if (!name) {
261 rb_raise(rb_eArgError, "argument needs to be symbol or string");
262 }
263 rb_vm_define_attr((Class)klass, name, read, write, noex);
264 if (write) {
265 rb_objc_define_kvo_setter(klass, id);
266 }
267 }
268
269 void
270 rb_undef(VALUE klass, ID id)
271 {
272 // TODO
273 #if 0
274 VALUE origin;
275 NODE *body;
276
277 #if 0 // TODO
278 if (rb_vm_cbase() == rb_cObject && klass == rb_cObject) {
279 rb_secure(4);
280 }
281 #endif
282 if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
283 rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'",
284 rb_id2name(id));
285 }
286 rb_frozen_class_p(klass);
287 if (id == object_id || id == __send__ || id == idInitialize) {
288 rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
289 }
290 /* TODO: warn if a very important method of NSObject is undefined
291 * by default, pure objc methods are not exposed by introspections API
292 */
293 body = search_method(klass, id, &origin);
294 if (!body || !body->nd_body) {
295 const char *s0 = " class";
296 VALUE c = klass;
297
298 if (RCLASS_SINGLETON(c)) {
299 VALUE obj = rb_iv_get(klass, "__attached__");
300
301 switch (TYPE(obj)) {
302 case T_MODULE:
303 case T_CLASS:
304 c = obj;
305 s0 = "";
306 }
307 }
308 else if (TYPE(c) == T_MODULE) {
309 s0 = " module";
310 }
311 rb_name_error(id, "undefined method `%s' for%s `%s'",
312 rb_id2name(id), s0, rb_class2name(c));
313 }
314
315 rb_add_method(klass, id, 0, NOEX_PUBLIC);
316
317 if (RCLASS_SINGLETON(klass)) {
318 rb_funcall(rb_iv_get(klass, "__attached__"),
319 singleton_undefined, 1, ID2SYM(id));
320 }
321 else {
322 rb_funcall(klass, undefined, 1, ID2SYM(id));
323 }
324 #endif
325 }
326
327 /*
328 * call-seq:
329 * undef_method(symbol) => self
330 *
331 * Prevents the current class from responding to calls to the named
332 * method. Contrast this with <code>remove_method</code>, which deletes
333 * the method from the particular class; Ruby will still search
334 * superclasses and mixed-in modules for a possible receiver.
335 *
336 * class Parent
337 * def hello
338 * puts "In parent"
339 * end
340 * end
341 * class Child < Parent
342 * def hello
343 * puts "In child"
344 * end
345 * end
346 *
347 *
348 * c = Child.new
349 * c.hello
350 *
351 *
352 * class Child
353 * remove_method :hello # remove from child, still in parent
354 * end
355 * c.hello
356 *
357 *
358 * class Child
359 * undef_method :hello # prevent any calls to 'hello'
360 * end
361 * c.hello
362 *
363 * <em>produces:</em>
364 *
365 * In child
366 * In parent
367 * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
368 */
369
370 static VALUE
371 rb_mod_undef_method(VALUE mod, SEL sel, int argc, VALUE *argv)
372 {
373 int i;
374 for (i = 0; i < argc; i++) {
375 rb_undef(mod, rb_to_id(argv[i]));
376 }
377 return mod;
378 }
379
380 /*
381 * call-seq:
382 * mod.method_defined?(symbol) => true or false
383 *
384 * Returns +true+ if the named method is defined by
385 * _mod_ (or its included modules and, if _mod_ is a class,
386 * its ancestors). Public and protected methods are matched.
387 *
388 * module A
389 * def method1() end
390 * end
391 * class B
392 * def method2() end
393 * end
394 * class C < B
395 * include A
396 * def method3() end
397 * end
398 *
399 * A.method_defined? :method1 #=> true
400 * C.method_defined? "method1" #=> true
401 * C.method_defined? "method2" #=> true
402 * C.method_defined? "method3" #=> true
403 * C.method_defined? "method4" #=> false
404 */
405
406 static VALUE
407 rb_mod_method_defined(VALUE mod, SEL sel, VALUE mid)
408 {
409 return rb_method_boundp(mod, rb_to_id(mid), 1);
410 }
411
412 #define VISI_CHECK(x,f) (((x)&NOEX_MASK) == (f))
413
414 /*
415 * call-seq:
416 * mod.public_method_defined?(symbol) => true or false
417 *
418 * Returns +true+ if the named public method is defined by
419 * _mod_ (or its included modules and, if _mod_ is a class,
420 * its ancestors).
421 *
422 * module A
423 * def method1() end
424 * end
425 * class B
426 * protected
427 * def method2() end
428 * end
429 * class C < B
430 * include A
431 * def method3() end
432 * end
433 *
434 * A.method_defined? :method1 #=> true
435 * C.public_method_defined? "method1" #=> true
436 * C.public_method_defined? "method2" #=> false
437 * C.method_defined? "method2" #=> true
438 */
439
440 static VALUE
441 rb_mod_public_method_defined(VALUE mod, SEL sel, VALUE mid)
442 {
443 ID id = rb_to_id(mid);
444 NODE *method;
445
446 method = rb_method_node(mod, id);
447 if (method) {
448 if (VISI_CHECK(method->nd_noex, NOEX_PUBLIC))
449 return Qtrue;
450 }
451 return Qfalse;
452 }
453
454 /*
455 * call-seq:
456 * mod.private_method_defined?(symbol) => true or false
457 *
458 * Returns +true+ if the named private method is defined by
459 * _ mod_ (or its included modules and, if _mod_ is a class,
460 * its ancestors).
461 *
462 * module A
463 * def method1() end
464 * end
465 * class B
466 * private
467 * def method2() end
468 * end
469 * class C < B
470 * include A
471 * def method3() end
472 * end
473 *
474 * A.method_defined? :method1 #=> true
475 * C.private_method_defined? "method1" #=> false
476 * C.private_method_defined? "method2" #=> true
477 * C.method_defined? "method2" #=> false
478 */
479
480 static VALUE
481 rb_mod_private_method_defined(VALUE mod, SEL sel, VALUE mid)
482 {
483 ID id = rb_to_id(mid);
484 NODE *method;
485
486 method = rb_method_node(mod, id);
487 if (method) {
488 if (VISI_CHECK(method->nd_noex, NOEX_PRIVATE))
489 return Qtrue;
490 }
491 return Qfalse;
492 }
493
494 /*
495 * call-seq:
496 * mod.protected_method_defined?(symbol) => true or false
497 *
498 * Returns +true+ if the named protected method is defined
499 * by _mod_ (or its included modules and, if _mod_ is a
500 * class, its ancestors).
501 *
502 * module A
503 * def method1() end
504 * end
505 * class B
506 * protected
507 * def method2() end
508 * end
509 * class C < B
510 * include A
511 * def method3() end
512 * end
513 *
514 * A.method_defined? :method1 #=> true
515 * C.protected_method_defined? "method1" #=> false
516 * C.protected_method_defined? "method2" #=> true
517 * C.method_defined? "method2" #=> true
518 */
519
520 static VALUE
521 rb_mod_protected_method_defined(VALUE mod, SEL sel, VALUE mid)
522 {
523 ID id = rb_to_id(mid);
524 NODE *method;
525
526 method = rb_method_node(mod, id);
527 if (method) {
528 if (VISI_CHECK(method->nd_noex, NOEX_PROTECTED))
529 return Qtrue;
530 }
531 return Qfalse;
532 }
533
534 void
535 rb_alias(VALUE klass, ID name, ID def)
536 {
537 rb_vm_alias(klass, name, def);
538 }
539
540 /*
541 * call-seq:
542 * alias_method(new_name, old_name) => self
543 *
544 * Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
545 * be used to retain access to methods that are overridden.
546 *
547 * module Mod
548 * alias_method :orig_exit, :exit
549 * def exit(code=0)
550 * puts "Exiting with code #{code}"
551 * orig_exit(code)
552 * end
553 * end
554 * include Mod
555 * exit(99)
556 *
557 * <em>produces:</em>
558 *
559 * Exiting with code 99
560 */
561
562 static VALUE
563 rb_mod_alias_method(VALUE mod, SEL sel, VALUE newname, VALUE oldname)
564 {
565 rb_alias(mod, rb_to_id(newname), rb_to_id(oldname));
566 return mod;
567 }
568
569 static void
570 secure_visibility(VALUE self)
571 {
572 if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
573 rb_raise(rb_eSecurityError,
574 "Insecure: can't change method visibility");
575 }
576 }
577
578 static void
579 set_method_visibility(VALUE self, int argc, VALUE *argv, ID ex)
580 {
581 int i;
582 secure_visibility(self);
583 for (i = 0; i < argc; i++) {
584 rb_export_method(self, rb_to_id(argv[i]), ex);
585 }
586 }
587
588 /*
589 * call-seq:
590 * public => self
591 * public(symbol, ...) => self
592 *
593 * With no arguments, sets the default visibility for subsequently
594 * defined methods to public. With arguments, sets the named methods to
595 * have public visibility.
596 */
597
598 static VALUE
599 rb_mod_public(VALUE module, SEL sel, int argc, VALUE *argv)
600 {
601 secure_visibility(module);
602 if (argc == 0) {
603 // TODO change scope!
604 }
605 else {
606 set_method_visibility(module, argc, argv, NOEX_PUBLIC);
607 }
608 return module;
609 }
610
611 /*
612 * call-seq:
613 * protected => self
614 * protected(symbol, ...) => self
615 *
616 * With no arguments, sets the default visibility for subsequently
617 * defined methods to protected. With arguments, sets the named methods
618 * to have protected visibility.
619 */
620
621 static VALUE
622 rb_mod_protected(VALUE module, SEL sel, int argc, VALUE *argv)
623 {
624 secure_visibility(module);
625 if (argc == 0) {
626 // TODO change scope!
627 }
628 else {
629 set_method_visibility(module, argc, argv, NOEX_PROTECTED);
630 }
631 return module;
632 }
633
634 /*
635 * call-seq:
636 * private => self
637 * private(symbol, ...) => self
638 *
639 * With no arguments, sets the default visibility for subsequently
640 * defined methods to private. With arguments, sets the named methods
641 * to have private visibility.
642 *
643 * module Mod
644 * def a() end
645 * def b() end
646 * private
647 * def c() end
648 * private :a
649 * end
650 * Mod.private_instance_methods #=> [:a, :c]
651 */
652
653 static VALUE
654 rb_mod_private(VALUE module, SEL sel, int argc, VALUE *argv)
655 {
656 secure_visibility(module);
657 if (argc == 0) {
658 // TODO change scope!
659 }
660 else {
661 set_method_visibility(module, argc, argv, NOEX_PRIVATE);
662 }
663 return module;
664 }
665
666 /*
667 * call-seq:
668 * mod.public_class_method(symbol, ...) => mod
669 *
670 * Makes a list of existing class methods public.
671 */
672
673 static VALUE
674 rb_mod_public_method(VALUE obj, SEL sel, int argc, VALUE *argv)
675 {
676 set_method_visibility(CLASS_OF(obj), argc, argv, NOEX_PUBLIC);
677 return obj;
678 }
679
680 /*
681 * call-seq:
682 * mod.private_class_method(symbol, ...) => mod
683 *
684 * Makes existing class methods private. Often used to hide the default
685 * constructor <code>new</code>.
686 *
687 * class SimpleSingleton # Not thread safe
688 * private_class_method :new
689 * def SimpleSingleton.create(*args, &block)
690 * @me = new(*args, &block) if ! @me
691 * @me
692 * end
693 * end
694 */
695
696 static VALUE
697 rb_mod_private_method(VALUE obj, SEL sel, int argc, VALUE *argv)
698 {
699 set_method_visibility(CLASS_OF(obj), argc, argv, NOEX_PRIVATE);
700 return obj;
701 }
702
703 /*
704 * call-seq:
705 * public
706 * public(symbol, ...)
707 *
708 * With no arguments, sets the default visibility for subsequently
709 * defined methods to public. With arguments, sets the named methods to
710 * have public visibility.
711 */
712
713 static VALUE
714 top_public(VALUE recv, SEL sel, int argc, VALUE *argv)
715 {
716 return rb_mod_public(rb_cObject, 0, argc, argv);
717 }
718
719 static VALUE
720 top_private(VALUE recv, SEL sel, int argc, VALUE *argv)
721 {
722 return rb_mod_private(rb_cObject, 0, argc, argv);
723 }
724
725 /*
726 * call-seq:
727 * module_function(symbol, ...) => self
728 *
729 * Creates module functions for the named methods. These functions may
730 * be called with the module as a receiver, and also become available
731 * as instance methods to classes that mix in the module. Module
732 * functions are copies of the original, and so may be changed
733 * independently. The instance-method versions are made private. If
734 * used with no arguments, subsequently defined methods become module
735 * functions.
736 *
737 * module Mod
738 * def one
739 * "This is one"
740 * end
741 * module_function :one
742 * end
743 * class Cls
744 * include Mod
745 * def callOne
746 * one
747 * end
748 * end
749 * Mod.one #=> "This is one"
750 * c = Cls.new
751 * c.callOne #=> "This is one"
752 * module Mod
753 * def one
754 * "This is the new one"
755 * end
756 * end
757 * Mod.one #=> "This is one"
758 * c.callOne #=> "This is the new one"
759 */
760
761 static VALUE
762 rb_mod_modfunc(VALUE module, SEL sel, int argc, VALUE *argv)
763 {
764 int i;
765
766 if (TYPE(module) != T_MODULE) {
767 rb_raise(rb_eTypeError, "module_function must be called for modules");
768 }
769
770 secure_visibility(module);
771 if (argc == 0) {
772 // TODO change scope!
773 return module;
774 }
775
776 set_method_visibility(module, argc, argv, NOEX_PRIVATE);
777
778 for (i = 0; i < argc; i++) {
779 ID id = rb_to_id(argv[i]);
780 IMP imp;
781 NODE *node;
782 SEL sel;
783
784 if (!rb_vm_lookup_method2((Class)module, id, &sel, &imp, &node)) {
785 // Methods are checked in set_method_visibility().
786 rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
787 }
788
789 rb_vm_define_method(*(Class *)module, sel, imp, node);
790 }
791
792 return module;
793 }
794
795 /*
796 * call-seq:
797 * obj.respond_to?(symbol, include_private=false) => true or false
798 *
799 * Returns +true+> if _obj_ responds to the given
800 * method. Private methods are included in the search only if the
801 * optional second parameter evaluates to +true+.
802 */
803
804 //static NODE *basic_respond_to = 0;
805
806 int
807 rb_obj_respond_to(VALUE obj, ID id, int priv)
808 {
809 const char *id_name = rb_id2name(id);
810 SEL sel = sel_registerName(id_name);
811 if (!rb_vm_respond_to(obj, sel, priv)) {
812 char buf[100];
813 snprintf(buf, sizeof buf, "%s:", id_name);
814 sel = sel_registerName(buf);
815 return rb_vm_respond_to(obj, sel, priv) == true;
816 }
817 return 1;
818 }
819
820 int
821 rb_respond_to(VALUE obj, ID id)
822 {
823 return rb_obj_respond_to(obj, id, Qfalse);
824 }
825
826 /*
827 * call-seq:
828 * obj.respond_to?(symbol, include_private=false) => true or false
829 *
830 * Returns +true+> if _obj_ responds to the given
831 * method. Private methods are included in the search only if the
832 * optional second parameter evaluates to +true+.
833 */
834
835 static VALUE
836 obj_respond_to(VALUE obj, SEL sel, int argc, VALUE *argv)
837 {
838 VALUE mid, priv;
839 ID id;
840
841 rb_scan_args(argc, argv, "11", &mid, &priv);
842 id = rb_to_id(mid);
843 return rb_obj_respond_to(obj, id, RTEST(priv)) ? Qtrue : Qfalse;
844 return Qfalse;
845 }
846
847 IMP basic_respond_to_imp = NULL;
848
849 void
850 Init_eval_method(void)
851 {
852 rb_objc_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
853 basic_respond_to_imp = class_getMethodImplementation((Class)rb_mKernel, selRespondTo);
854 //basic_respond_to = rb_method_node(rb_cObject, idRespond_to);
855 //rb_register_mark_object((VALUE)basic_respond_to);
856
857 rb_objc_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1);
858 rb_objc_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1);
859 rb_objc_define_private_method(rb_cModule, "alias_method", rb_mod_alias_method, 2);
860 rb_objc_define_private_method(rb_cModule, "public", rb_mod_public, -1);
861 rb_objc_define_private_method(rb_cModule, "protected", rb_mod_protected, -1);
862 rb_objc_define_private_method(rb_cModule, "private", rb_mod_private, -1);
863 rb_objc_define_private_method(rb_cModule, "module_function", rb_mod_modfunc, -1);
864
865 rb_objc_define_method(rb_cModule, "method_defined?", rb_mod_method_defined, 1);
866 rb_objc_define_method(rb_cModule, "public_method_defined?", rb_mod_public_method_defined, 1);
867 rb_objc_define_method(rb_cModule, "private_method_defined?", rb_mod_private_method_defined, 1);
868 rb_objc_define_method(rb_cModule, "protected_method_defined?", rb_mod_protected_method_defined, 1);
869 rb_objc_define_method(rb_cModule, "public_class_method", rb_mod_public_method, -1);
870 rb_objc_define_method(rb_cModule, "private_class_method", rb_mod_private_method, -1);
871
872 VALUE cTopLevel = *(VALUE *)rb_vm_top_self();
873 rb_objc_define_method(cTopLevel, "public", top_public, -1);
874 rb_objc_define_method(cTopLevel, "private", top_private, -1);
875
876 object_id = rb_intern("object_id");
877 __send__ = rb_intern("__send__");
878 eqq = rb_intern("===");
879 each = rb_intern("each");
880 aref = rb_intern("[]");
881 aset = rb_intern("[]=");
882 match = rb_intern("=~");
883 missing = rb_intern("method_missing");
884 added = rb_intern("method_added");
885 singleton_added = rb_intern("singleton_method_added");
886 removed = rb_intern("method_removed");
887 singleton_removed = rb_intern("singleton_method_removed");
888 undefined = rb_intern("method_undefined");
889 singleton_undefined = rb_intern("singleton_method_undefined");
890 }
891
Something went wrong with that request. Please try again.