Re: Semantic does not correctly show PRIVATE/PROTECTED methods to a class of whom those private/protected methods belong

"Dixon Ryan (ETAS/ESW6)" <[email protected]> Wed, 26 Nov 2014 17:33:44 +0000
Newsgroups gmane.emacs.semantic
Message-ID <[email protected]>
Hi Eric,

Yes I made a mistake after muddling things up with some tests I have been running.

This is solved. However, there is an issue friend classes I believe:

I do not seem to be getting access to all of the private/protected methods or variables of the class that declares another as a friend.

It is MySecondClass.cpp where the cursor should be put to see this problem.


Cheers.
====

Here are the project files that prove this issue:

===main.cpp=== (Don't even need this)
#include "MyClass.hpp"

int main ( void ) {
   MyClass mc;
   
   mc.

   return 0;
}
===END main.cpp===

===MyClass.hpp===
#include <string>
#include "MySecondClass.hpp"

class MyClass : public MySecondClass{
public:
   friend MySecondClass;

private:
   int data;
public:
   MyClass ( )
   : MySecondClass( ) 
   { }

   ~MyClass ( ) { }

   void myFunc( void ) const;
   void myOtherFunc( void ) const;
   int getData( void ) const;
protected:
   void onlySubclass( void ) const;
   void anotherFunction( std::string s );
   int data1;
public:
   std::string secondMyFunc( std::string s ) const;
   void oneMoreForGoodMeasure( void ) const;
   int data2;

private:
   void somePrivateMethod( void ) const;
   void someOtherPrivateMethod( void );
};
===END MyClass.hpp===

===MyClass.cpp===
#include "MyClass.hpp"

void MyClass::myFunc( void ) const { 
   ; 
}

void MyClass::myOtherFunc( void ) const { 
   ; 
}

int MyClass::getData( void ) const { 
   return 0; 
}

void MyClass::onlySubclass( void ) const {
   ;
}

void MyClass::anotherFunction( std::string s ) {
   return "";
}

std::string MyClass::secondMyFunc( std::string s ) const {
   return s; 
}

void MyClass::oneMoreForGoodMeasure( void ) const {
   ;
}

void MyClass::somePrivateMethod( void ) const {

   ;
}

void MyClass::someOtherPrivateMethod( void ) {
   ;
}
===END MyClass.cpp===

===MySecondClass.hpp===
#include "MyClass.hpp"

class MySecondClass { 
public:
   void methodOne( void ) const;
private:
   void methodTwo ( void ) const;
   int data1;
   void methodThree( MyClass mc );
};
===END MySecondClass.hpp===

===MySecondClass.cpp===
#include "MySecondClass.hpp"

void MySecondClass::methodOne( void ) const
{
   ;
}

void MySecondClass::methodTwo( void ) const
{
   ;
}

void MySecondClass::methodThree( MyClass mc )
{
   mc. //I seem to get inconsistent access. I should get access to all methods and variables that belong to MyClass as I have declared that MySecondClass (this) is a friend of MyClass in MyClass!
}
===END MySecondClass.hpp===

-----Original Message-----
From: Eric Ludlam [mailto:[email protected]] 
Sent: 26 November 2014 16:58
To: Dixon Ryan (ETAS/ESW6); [email protected]
Cc: [email protected]
Subject: Re: [cedet-semantic] Semantic does not correctly show PRIVATE/PROTECTED methods to a class of whom those private/protected methods belong

Hi,

Only showing those 5 methods is the correct behavior because you can't call the protected or private methods from Main.

If I go into MyClass.cpp, myfunc(void) and type in:

this.<complete>

then I get all the private and protected methods.

Eric

On 11/26/2014 06:44 AM, Dixon Ryan (ETAS/ESW6) wrote:
> I think the title explains the problem.
>
> Here are the source files which prove this bug (not showing 
> PRIVATE/PROTECTED when semantic should):
>
> ===MyClass.hpp===
>
> #include <string>
>
> class MyClass {
>
> private:
>
>     int data;
>
> public:
>
>     void myFunc( void ) const;
>
>     void myOtherFunc( void ) const;
>
>     int getData( void ) const;
>
> protected:
>
>     void onlySubclassAndPar( void ) const;
>
>     void anotherFunction( std::string s );
>
> public:
>
>     std::string secondMyFunc( std::string s ) const;
>
>     void oneMoreForGoodMeasure( void ) const;
>
> private:
>
>    void somePrivateMethod( void ) const;
>
>     void someOtherPrivateMethod( void );
>
> };
>
> ==END MyClass.hpp===
>
> ==MyClass.cpp===
>
> #include "MyClass.hpp"
>
> void MyClass::myFunc( void ) const {
>
>     ;
>
> }
>
> void MyClass::myOtherFunc( void ) const {
>
>     ;
>
> }
>
> int MyClass::getData( void ) const {
>
>     return 0;
>
> }
>
> void MyClass::onlySubclassAndPar( void ) const {
>
>     ;
>
> }
>
> void MyClass::anotherFunction( std::string s ) {
>
>     return "";
>
> }
>
> std::string MyClass::secondMyFunc( std::string s ) const {
>
>     return s;
>
> }
>
> void MyClass::oneMoreForGoodMeasure( void ) const {
>
>     ;
>
> }
>
> void MyClass::somePrivateMethod( void ) const {
>
>     ;
>
> }
>
> void MyClass::someOtherPrivateMethod( void ) {
>
>     ;
>
> }
>
> ===END MyClass.cpp===
>
> ===main.cpp===
>
> #include "MyClass.hpp"
>
> int main ( void ) {
>
>     MyClass mc;
>
>     mc. //only 5 PUBLIC methods
>
>     return 0;
>
> }
>
> ===END main.cpp===
>
>
>
> ----------------------------------------------------------------------
> -------- Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT 
> Server from Actuate! Instantly Supercharge Your Business Reports and 
> Dashboards with Interactivity, Sharing, Native Excel Exports, App 
> Integration & more Get technology previously reserved for 
> billion-dollar corporations, FREE 
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.
> clktrk
>
>
>
> _______________________________________________
> cedet-semantic mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cedet-semantic
>

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk