Changeset 100 for trunk/examples/inherit
- Timestamp:
- 02/17/07 02:32:39 (2 years ago)
- Files:
-
- trunk/examples/inherit/inherit.d (modified) (2 diffs)
- trunk/examples/inherit/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/inherit/inherit.d
r91 r100 21 21 } 22 22 23 class BaseWrap : Base {24 mixin OverloadShim;25 this(int i) { super(i); }26 void foo() {27 get_overload(&super.foo, "foo");28 }29 void bar() {30 get_overload(&super.bar, "bar");31 }32 }33 34 class DeriveWrap : Derived {35 mixin OverloadShim;36 this(int i) { super(i); }37 void foo() {38 get_overload(&super.foo, "foo");39 }40 }41 42 23 void call_poly(Base b) { 43 24 writefln("call_poly:"); … … 57 38 } 58 39 59 Base return_poly_wrap() {60 if (b3 is null) b3 = new DeriveWrap(3);61 return b3;62 }63 64 40 extern(C) void PydMain() { 65 41 def!(call_poly); 66 42 def!(return_poly_base); 67 43 def!(return_poly_derived); 68 def!(return_poly_wrap);69 44 70 45 module_init(); 71 46 72 wrapped_class!(Base) b; 73 b.hide(); 74 b.def!(Base.foo); 75 b.def!(Base.bar); 76 finalize_class(b); 47 wrap_class!( 48 Base, 49 Init!(void function(int)), 50 Def!(Base.foo), 51 Def!(Base.bar) 52 ); 77 53 78 wrapped_class!(Derived) d; 79 d.hide(); 80 d.def!(Derived.foo); 81 finalize_class(d); 82 83 wrapped_class!(BaseWrap, "Base") bw; 84 bw.init!(void function(int)); 85 bw.def!(BaseWrap.foo); 86 bw.def!(BaseWrap.bar); 87 finalize_class(bw); 88 89 wrapped_class!(DeriveWrap, "Derived") dw; 90 dw.init!(void function(int)); 91 dw.parent!(BaseWrap); 92 dw.def!(DeriveWrap.foo); 93 finalize_class(dw); 54 wrap_class!( 55 Derived, 56 Init!(void function(int)), 57 Def!(Derived.foo) 58 ); 94 59 } 95 60 trunk/examples/inherit/test.py
r91 r100 50 50 print "inherit.return_poly_derived returned the same object twice" 51 51 assert b2 is b2a 52 b3 = inherit.return_poly_wrap()53 print "inherit.return_poly_wrap returned instance of DeriveWrap"54 assert type(b3) == inherit.Derived55 52 56 53 print
