[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ scoping of cross-reference?
From: |
Iain Woolf |
Subject: |
Re: C++ scoping of cross-reference? |
Date: |
Tue, 5 Apr 2011 13:10:11 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 |
On 04/04/2011 09:38 PM, Shigio YAMAGUCHI wrote:
>
>> This would provide class-qualifier definitions. When searching for a
>> definition, I would like to be able to optionally specify the class
>> qualifier. For example, consider:
>>
>> class A
>> {
>> public:
>> virtual void dump();
>> };
>>
>> class B1 : public A
>> {
>> public:
>> virtual void dump();
>> }
>>
>> class B2 : public B
>> {
>> public:
>> virtual void dump();
>> }
>>
>> class C : public A
>> {
>> public:
>> virtual void dump();
>> }
>>
>> If searching with "global -a dump" I would expect to see all of A::dump,
>> B1::dump, B2::dump, C::dump in the output. Alternatively, it should be
>> possible to search for "global -a B2::dump".
> What is the -a option? What occurs without it?
>
The -a option prints absolute pathnames for a file instead of relative
pathnames. It's unimportant for this example, I just always include it
when calling global.
> You mean the following behavior?
>
> [Class hierarchy]
>
> class A
> |- class B
> |- class C
>
> [Source files]
>
> [classA.cc]
> +--------------------------------
> |...
> |class A { void dump() {...}}
>
> [classB.cc]
> +--------------------------------
> |...
> |class B : A { void dump() {...}}
>
> [classC.cc]
> +--------------------------------
> |...
> |class C : B { void dump() {...}}
>
> [Execution image]
>
> $ global -x A::dump
> A::dump classA.cc 50 class A { void dump() {...} }
> B::dump classB.cc 100 class B : A { void dump() {...} }
> C::dump classC.cc 90 class C : B { void dump() {...} }
> $ _
>
> $ global -x B::dump
> B::dump classB.cc 100 class B : A { void dump() {...} }
> C::dump classC.cc 90 class C : B { void dump() {...} }
> $ _
>
> $ global -x C::dump
> C::dump classC.cc 90 class C : B { void dump() {...} }
> $ _
>
Yes, exactly. How would that work when the implementation doesn't
explicitly list the parent class though:
[Class hierarchy]
class A
|- class B
[Source files]
[classA.cc]
+--------------------------------
|...
|class A { void dump() {...}}
[classB.h]
+--------------------------------
|...
|class B : A { void dump() };
[classB.cc]
+--------------------------------
|...
|void B::dump() {...}
[Execution image] - should give
$ global -x A::dump
A::dump classA.cc 50 class A { void dump() {...} }
B::dump classB.h 20 class B : A { void dump() }
B::dump classB.cc 100 void B::dump() {...}
Would it still be possible to get that third line of output?
>> Hopefully this could be extended to include references to class specific
>> methods, e.g. "global -r B2::dump". However I realize that determining
>> these kinds of references would likely be a lot harder.
> Would you please describe it for example?
> Why do you think it is a lot harder?
Sure. Extending the above example, consider:
[Class hierarchy]
class A
|- class B
[Source files]
[classA.cc]
+--------------------------------
|...
|class A {
| virtual void dump() {...};
| void method2() {...};
|};
[classB.h]
+--------------------------------
|...
|class B : A { void dump() };
[classB.cc]
+--------------------------------
|...
|void B::dump() {...}
[other.cc]
+--------------------------------
|...
|int main(int, int)
|{
| B * b_p = new B;
| b_p->method2();
| b_p->dump();
| delete b_p;
|
| B local_b;
| local_b.method2();
| local_b.dump();
|
| A * a_p = new A;
| a_p->method2();
| delete a_p;
|
| return 0;
|}
[Execution image] - should give
$ global -x method2
A::method2 classA.cc 51 void method2() {...};
$_
$ global -xr method2
B::method2 other.cc 20 b_p->method2();
B::method2 other.cc 25 local_b.method2();
A::method2 other.cc 30 a_p->method2();
$_
$ global -xr B::method2
B::method2 other.cc 20 b_p->method2();
B::method2 other.cc 25 local_b.method2();
$_
$ global -xr A::method2
A::method2 other.cc 30 a_p->method2();
$_
I assumed this would be harder, because when a symbol is referenced
(e.g. the call to method2()), then you need to know the class that it is
actually referring to. However, I haven't looked at the internal
mechanism of building the gtags database, so maybe it isn't as hard as I
thought?
Cheers,
Iain
--
Iain Woolf W-CDMA Base Software, Alcatel-Lucent
Tel: 613-784-3465 / OnNET 2-825-3465
IM: iwoolf (im.ca.alcatel-lucent.com) / i_woolf (YahooIM)