Show
Ignore:
Timestamp:
02/17/07 02:32:39 (2 years ago)
Author:
KirkMcDonald
Message:

* Class wrapping API replaced.
* Inheritance "shim" classes now automatically generated.
* Requires DMD 1.005 or newer. Breaks GDC support for the moment.
* Docs not yet updated to reflect changes.
* Copyright notices updated to 2007.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/inherit/inherit.d

    r91 r100  
    2121} 
    2222 
    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  
    4223void call_poly(Base b) { 
    4324    writefln("call_poly:"); 
     
    5738} 
    5839 
    59 Base return_poly_wrap() { 
    60     if (b3 is null) b3 = new DeriveWrap(3); 
    61     return b3; 
    62 } 
    63  
    6440extern(C) void PydMain() { 
    6541    def!(call_poly); 
    6642    def!(return_poly_base); 
    6743    def!(return_poly_derived); 
    68     def!(return_poly_wrap); 
    6944 
    7045    module_init(); 
    7146 
    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    ); 
    7753 
    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    ); 
    9459} 
    9560 
  • trunk/examples/inherit/test.py

    r91 r100  
    5050print "inherit.return_poly_derived returned the same object twice" 
    5151assert b2 is b2a 
    52 b3 = inherit.return_poly_wrap() 
    53 print "inherit.return_poly_wrap returned instance of DeriveWrap" 
    54 assert type(b3) == inherit.Derived 
    5552 
    5653print