root/test/lisp/cedet/semantic-utest-ia-resources/testtypedefs.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main
  2. someFunc
  3. otherFunc
  4. main
  5. epd_probe
  6. func
  7. myFunction
  8. dixon

     1 // testtypedefs.cpp --- Sample with some fake bits out of std::string
     2 
     3 // Copyright (C) 2008-2023 Free Software Foundation, Inc.
     4 
     5 // Author: Eric M. Ludlam <zappo@gnu.org>
     6 
     7 // This file is part of GNU Emacs.
     8 
     9 // GNU Emacs is free software: you can redistribute it and/or modify
    10 // it under the terms of the GNU General Public License as published by
    11 // the Free Software Foundation, either version 3 of the License, or
    12 // (at your option) any later version.
    13 
    14 // GNU Emacs is distributed in the hope that it will be useful,
    15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17 // GNU General Public License for more details.
    18 
    19 // You should have received a copy of the GNU General Public License
    20 // along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
    21 
    22 // Thanks Ming-Wei Chang for these examples.
    23 
    24 namespace std {
    25   template <T>class basic_string {
    26   public:
    27     void resize(int);
    28   };
    29 }
    30 
    31 typedef std::basic_string<char> mstring;
    32 
    33 using namespace std;
    34 typedef basic_string<char> bstring;
    35 
    36 int main(){
    37   mstring a;
    38   a.// -1-
    39     ;
    40   // #1# ( "resize" )
    41   bstring b;
    42   // It doesn't work here.
    43   b.// -2-
    44     ;
    45   // #2# ( "resize" )
    46   return 0;
    47 }
    48 
    49 // ------------------
    50 
    51 class Bar
    52 {
    53 public:
    54      void someFunc() {}
    55 };
    56 
    57 typedef Bar new_Bar;
    58 
    59 template <class mytype>
    60 class TBar
    61 {
    62 public:
    63      void otherFunc() {}
    64 };
    65 
    66 typedef TBar<char> new_TBar;
    67 
    68 int main()
    69 {
    70   new_Bar nb;
    71   new_TBar ntb;
    72 
    73   nb.// -3-
    74     ;
    75   // #3# ("someFunc")
    76   ntb.// -4-
    77     ;
    78   // #4# ("otherFunc")
    79 
    80   return 0;
    81 }
    82 
    83 // ------------------
    84 // Example from Yupeng.
    85 
    86 typedef struct epd_info {
    87      int a;
    88 } epd_info_t;
    89 
    90 static int epd_probe(struct platform_device *pdev)
    91 {
    92      struct epd_info *db;
    93      epd_info_t db1;
    94 
    95      db.// -5-
    96        ; // #5# ("a")
    97      db1.// -6-
    98        ;// #6# ("a")
    99 
   100      return 1;
   101 }
   102 
   103 // ------------------
   104 // Example from Michel LAFON-PUYO
   105 
   106 typedef enum
   107 {
   108    ENUM1,
   109    ENUM2
   110 } e_toto;
   111 
   112 typedef struct
   113 {
   114    int field_a;
   115    int field_b;
   116 } t_toto;
   117 
   118 // Note: Error condition from anonymous types in a typedef
   119 //       was that the first (ie - the enum) would be used in
   120 //       place of the struct.
   121 int func(void)
   122 {
   123    t_toto t;
   124    t. // -7-
   125      ; // #7# ( "field_a" "field_b" )
   126    return 0;
   127 }
   128 
   129 
   130 // ------------------
   131 // Example from Dixon Ryan
   132 
   133 
   134 namespace NS2 {
   135    class MyClass {
   136 
   137    public:
   138       void myFunction() { }
   139    };
   140 }
   141 
   142 typedef class NS2::MyClass* MyClassHandle;
   143 
   144 int dixon ( void ) {
   145   MyClassHandle mch = getMyClassHandle();
   146   NS2::MyClass* mcptr = getMyClassHandle();
   147 
   148   mcptr-> // -8-
   149     ; // #8# ( "myFunction" )
   150   mch-> // -    9- TODO bring over patch from SF
   151     ; // #9# ( "myFunction" )
   152   deleteMyClassHandle(mch);
   153 
   154   return 0;
   155 }

/* [<][>][^][v][top][bottom][index][help] */