"Fossies" - the Fresh Open Source Software Archive

Member "swig-4.1.1/Examples/test-suite/abstract_typedef2.i" (30 Nov 2022, 927 Bytes) of package /linux/misc/swig-4.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) ALAN Interactive Fiction Language source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 %module abstract_typedef2
    2 
    3  /*
    4    After the fix for abstract_typedef, this simpler
    5    example got broken.
    6  */
    7 
    8 %inline %{
    9 
   10   enum FieldDim {
   11     UnaryField,
   12     BinaryField
   13   };
   14   
   15   template <FieldDim Dim>
   16     struct Facet;
   17   
   18 
   19   template <FieldDim Dim>
   20     struct Base 
   21     {
   22       virtual ~Base() {}
   23       
   24       typedef unsigned int size_type;
   25       typedef Facet<Dim>* facet_ptr;
   26 
   27       // This works 
   28       // virtual Facet<Dim>* set(size_type) = 0;
   29       
   30       // This doesn't
   31       virtual facet_ptr set(size_type) = 0;
   32     };
   33   
   34 
   35   template <FieldDim Dim>
   36     struct Facet
   37     {
   38     };
   39   
   40 
   41   template <FieldDim Dim>
   42     struct A : Base<Dim>
   43     {
   44       typedef Base<Dim> base;
   45       typedef typename base::size_type size_type;
   46 
   47       A(int a = 0)
   48       {
   49       }
   50       
   51       Facet<Dim>* set(size_type) 
   52       {
   53     return 0;
   54       }      
   55     };
   56 %}
   57 
   58 
   59 %template(Base_UF) Base<UnaryField>;
   60 %template(A_UF) A<UnaryField>;