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

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

DEFINITIONS

This source file includes following definitions.
  1. setFeet
  2. getFeet
  3. doNothing
  4. setAntlers
  5. getAntlers
  6. i_dont_have_symrefs
  7. doSomething
  8. setLatin
  9. getLatin
  10. doLatinStuff
  11. createMoose
  12. someFunction
  13. private_a
  14. public_a
  15. some_regular_function
  16. otherFunction
  17. testAccess
  18. testAccess
  19. testAccess

     1 // testsubclass.cpp --- unit test for analyzer and complex C++ inheritance
     2 
     3 // Copyright (C) 2007-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 //#include <iostream>
    23 #include "testsubclass.hh"
    24 
    25 void animal::moose::setFeet(int numfeet) //^1^
    26 {
    27   if (numfeet > 4) {
    28     std::cerr << "Why would a moose have more than 4 feet?" << std::endl;
    29     return;
    30   }
    31 
    32   fFeet = numfeet;
    33 }
    34 
    35 int animal::moose::getFeet() //^2^
    36 {
    37   return fFeet;
    38 }
    39 
    40 void animal::moose::doNothing() //^3^
    41 {
    42   animal::moose foo();
    43 
    44   fFeet = N// -15-
    45     ; // #15# ( "NAME1" "NAME2" "NAME3" )
    46 }
    47 
    48 
    49 void deer::moose::setAntlers(bool have_antlers) //^4^
    50 {
    51   fAntlers = have_antlers;
    52 }
    53 
    54 bool deer::moose::getAntlers() //^5^
    55 // %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) )
    56 {
    57   return fAntlers;
    58 }
    59 
    60 bool i_dont_have_symrefs()
    61 // %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs"))
    62 {
    63 }
    64 
    65 void deer::moose::doSomething() //^6^
    66 {
    67   // All these functions should be identified by semantic analyzer.
    68   getAntlers();
    69   setAntlers(true);
    70 
    71   getFeet();
    72   setFeet(true);
    73 
    74   doNothing();
    75 
    76   fSomeField = true;
    77 
    78   fIsValid = true;
    79 }
    80 
    81 void deer::alces::setLatin(bool l) {
    82   fLatin = l;
    83 }
    84 
    85 bool deer::alces::getLatin() {
    86   return fLatin;
    87 }
    88 
    89 void deer::alces::doLatinStuff(moose moosein) {
    90   // All these functions should be identified by semantic analyzer.
    91   getFeet();
    92   setFeet(true);
    93 
    94   getLatin();
    95   setLatin(true);
    96 
    97   doNothing();
    98 
    99   deer::moose foo();
   100 
   101 
   102 }
   103 
   104 moose deer::alces::createMoose()
   105 {
   106   moose MooseVariableName;
   107   bool tmp;
   108   int itmp;
   109   bool fool;
   110   int fast;
   111 
   112   MooseVariableName = createMoose();
   113 
   114   doLatinStuff(MooseVariableName);
   115 
   116   tmp = this.f// -1-
   117     // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
   118     ;
   119 
   120   itmp = this.f// -2-
   121     // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
   122     ;
   123 
   124   tmp = f// -3-
   125     // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
   126     ;
   127 
   128   itmp = f// -4-
   129     // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
   130     ;
   131 
   132   MooseVariableName = m// -5-
   133     // #5# ( "moose" )
   134 
   135   return MooseVariableName;
   136 }
   137 
   138 /** Test Scope Changes
   139  *
   140  * This function is rigged to make sure the scope changes to account
   141  * for different locations in local variable parsing.
   142  */
   143 int someFunction(int mPickle)
   144 {
   145   moose mMoose = deer::alces::createMoose();
   146 
   147   if (mPickle == 1) {
   148 
   149     int mOption1 = 2;
   150 
   151     m// -5-
   152       // #5# ( "mMoose" "mOption1" "mPickle" )
   153       ;
   154 
   155   } else {
   156 
   157     int mOption2 = 2;
   158 
   159     m// -6-
   160       // #6# ( "mMoose" "mOption2" "mPickle" )
   161       ;
   162   }
   163 
   164 }
   165 
   166 // Thanks Ming-Wei Chang for this next example.
   167 
   168 namespace pub_priv {
   169 
   170   class A{
   171   private:
   172     void private_a(){}
   173   public:
   174     void public_a();
   175   };
   176 
   177   void A::public_a() {
   178     A other_a;
   179 
   180     other_a.p// -7-
   181       // #7# ( "private_a" "public_a" )
   182       ;
   183   }
   184 
   185   int some_regular_function(){
   186     A a;
   187     a.p// -8-
   188       // #8# ( "public_a" )
   189       ;
   190     return 0;
   191   }
   192 
   193 }
   194 
   195 
   196 /** Test Scope w/in a function (non-method) with classes using
   197  * different levels of inheritance.
   198  */
   199 int otherFunction()
   200 {
   201   sneaky::antelope Antelope(1);
   202   sneaky::jackalope Jackalope(1);
   203   sneaky::bugalope Bugalope(1);
   204 
   205   Antelope.// -9-
   206     // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
   207     ;
   208 
   209   Jackalope.// -10-
   210     // #10# ( "fBunnyPublic" "testAccess")
   211     ;
   212 
   213   Jackalope// @1@ 6
   214     ;
   215   Jackalope;
   216   Jackalope;
   217   Jackalope;
   218 
   219   Bugalope.// -11-
   220     // #11# ( "fBugPublic" "testAccess")
   221     ;
   222   Bugalope// @2@ 3
   223     ;
   224 }
   225 
   226 /** Test methods within each class for types of access to the baseclass.
   227  */
   228 
   229 bool sneaky::antelope::testAccess() //^7^
   230 {
   231   this.// -12-
   232     // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
   233     ;
   234 }
   235 
   236 bool sneaky::jackalope::testAccess() //^8^
   237 {
   238   this.// -13-
   239     // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
   240     ;
   241 }
   242 
   243 bool sneaky::bugalope::testAccess() //^9^
   244 {
   245   this.// -14-
   246     // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )
   247     ;
   248 }

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