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

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

DEFINITIONS

This source file includes following definitions.
  1. someFcn
  2. func
  3. testToggle1
  4. testToggle2
  5. testToggle3
  6. func2
  7. func3
  8. func4
  9. func5
  10. func6
  11. func6
  12. func7
  13. func8
  14. func9
  15. func10
  16. func11
  17. unfoundfunc
  18. acc_using
  19. acc_using2
  20. check_scope
  21. check_scope2

     1 // testusing.cpp --- semantic-ia-utest completion engine unit tests
     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 
    23 #include <adstdio.h>
    24 
    25 #include <testusing.hh>
    26 
    27 namespace moose {
    28 
    29   class MyClass;
    30   class Point;
    31 
    32   typedef MyClass snerk;
    33 }
    34 
    35 namespace moose {
    36 
    37   class Point;
    38   class MyClass;
    39 
    40 }
    41 
    42 namespace {
    43 
    44   int global_variable = 0;
    45 
    46 };
    47 
    48 using moose::MyClass;
    49 
    50 void someFcn() {
    51 
    52   MyClass f;
    53 
    54   f.//-1-
    55     ; //#1# ( "getVal" "setVal" )
    56 
    57 }
    58 
    59 // Code from Zhiqiu Kong
    60 
    61 namespace panda {
    62 
    63   using namespace bread_name;
    64 
    65   int func()
    66   {
    67     bread test;
    68     test.//-2-
    69       ;// #2# ( "geta" )
    70     return 0;
    71   }
    72 }
    73 
    74 namespace togglemoose {
    75 
    76   MyOtherClass::testToggle1() { //^1^
    77     // Impl for testToggle1
    78   }
    79 }
    80 
    81 togglemoose::MyOtherClass::testToggle2() { //^3^
    82   // Impl for testToggle2
    83 }
    84 
    85 using togglemoose;
    86 
    87 MyOtherClass::testToggle3() { //^3^
    88   // Impl for testToggle3
    89 }
    90 
    91 // Local using statements and aliased types
    92 // Code from David Engster
    93 
    94 void func2()
    95 {
    96   using namespace somestuff;
    97   OneClass f;
    98   f.//-3-
    99     ; //#3# ( "aFunc" "anInt" )
   100 }
   101 
   102 void func3()
   103 {
   104   using somestuff::OneClass;
   105   OneClass f;
   106   f.//-4-
   107     ; //#4# ( "aFunc" "anInt" )
   108 }
   109 
   110 // Dereferencing alias types created through 'using' statements
   111 
   112 // Alias with fully qualified name
   113 void func4()
   114 {
   115   otherstuff::OneClass f;
   116   f. //-5-
   117     ; //#5# ( "aFunc" "anInt" )
   118 }
   119 
   120 // Alias through namespace directive
   121 void func5()
   122 {
   123   using namespace otherstuff;
   124   OneClass f;
   125   f. //-6-
   126     ; //#6# ( "aFunc" "anInt" )
   127 }
   128 
   129 // Check name hiding
   130 void func6()
   131 {
   132   using namespace morestuff;
   133   OneClass f;           // Alias for somestuff::OneClass
   134   f.  //-7-
   135     ; //#7# ( "aFunc" "anInt" )
   136   aStruct g;    // This however is morestuff::aStruct !
   137   g. //-8-
   138     ; //#8# ( "anotherBar" "anotherFoo" )
   139 }
   140 
   141 // Alias of an alias
   142 // Currently doesn't work interactively for some reason.
   143 void func6()
   144 {
   145   using namespace evenmorestuff;
   146   OneClass f;
   147   f. //-7-
   148     ; //#7# ( "aFunc" "anInt" )
   149 }
   150 
   151 // Alias for struct in nested namespace, fully qualified
   152 void func7()
   153 {
   154   outer::StructNested f;
   155   f.//-8-
   156     ; //#8# ( "one" "two" )
   157 }
   158 
   159 // Alias for nested namespace
   160 void func8()
   161 {
   162   using namespace outerinner;
   163   StructNested f;
   164   AnotherStruct g;
   165   f.//-9-
   166     ; //#9# ( "one" "two" )
   167   g.//-10-
   168     ; //#10# ( "four" "three" )
   169 }
   170 
   171 // Check conventional namespace aliases
   172 // - fully qualified -
   173 void func9()
   174 {
   175   alias_for_somestuff::OneClass c;
   176   c.//-11-
   177     ; //#11# ( "aFunc" "anInt" )
   178   alias_for_outerinner::AnotherStruct s;
   179   s. //-12-
   180     ; //#12# ( "four" "three" )
   181 }
   182 
   183 // - unqualified -
   184 void func10()
   185 {
   186   using namespace alias_for_somestuff;
   187   OneClass c2;
   188   c2.//-13-
   189     ; //#13# ( "aFunc" "anInt" )
   190   using namespace alias_for_outerinner;
   191   AnotherStruct s2;
   192   s2.//-14-
   193     ; //#14# ( "four" "three" )
   194 }
   195 
   196 // Completion on namespace aliases
   197 void func11()
   198 {
   199    alias_for_somestuff:://-15-
   200       ; //#15# ( "OneClass" "aStruct")
   201    alias_for_outerinner:://-16-
   202       ; //#16# ( "AnotherStruct" "StructNested" )
   203 }
   204 
   205 // make sure unfound using statements don't crash stuff.
   206 using something::cantbe::Found;
   207 
   208 void unfoundfunc()
   209 {
   210   NotFound notfound; // Variable can't be found.
   211 
   212   notfound.//-17-
   213     ; //#17# ( )  Nothing here since this is an undefined class
   214 
   215 }
   216 
   217 // Using statements can depend on previous ones...
   218 
   219 void acc_using()
   220 {
   221   using namespace outer;
   222   // This is effectively like 'using namespace outer::inner'
   223   using namespace inner;
   224 
   225   StructNested sn;
   226   sn.//-18-
   227     ; //#18# ( "one" "two" )
   228 }
   229 
   230 // Check the same outside of function scope
   231 
   232 using namespace outer;
   233 using namespace inner;
   234 
   235 void acc_using2()
   236 {
   237   StructNested sn;
   238   sn.//-19-
   239     ; //#19# ( "one" "two" )
   240 }
   241 
   242 // Check if scope gets correctly generated, i.e., without us providing any
   243 // hints in the form of an existing type
   244 
   245 void check_scope()
   246 {
   247   using namespace first;
   248   AAA//-20-
   249     ; //#20# ( "AAA1" "AAA2" )
   250 }
   251 
   252 void check_scope2()
   253 {
   254   using namespace third;
   255   AAA//-21-
   256     ; //#21# ( "AAA1" "AAA2" "AAA3" )
   257 }
   258 
   259 // Make sure this also works not only in functions
   260 
   261 namespace check_scope3 {
   262   using namespace first;
   263   AAA//-22-
   264   ; //#22# ( "AAA1" "AAA2" )
   265 }

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