|
List Info
Thread: How does C++ support create class declarations?
|
|
| How does C++ support create class
declarations? |

|
2008-02-17 16:18:17 |
Hi,
seems I'm still missing a piece here. Looking at C++
highlighting code I
see this:
if( dec->context()->scopeIdentifier().isEmpty() )
{
type = GlobalVariableType;
}...
and I'm wondering why that isn't empty. For Python
scopeIdentifier is
empty, although qualifiedIdentifier of the declaration
returns something
meaningful. I really must be missing something here.
Currently what I do
is:
openContext( astnode, DUContext::Class, identifierForName(
astnode->className ) );
addImportedContext();
openDefinition( astnode->className, astnode );
...
which gives me a context with scopeIdentifier
"Bar" (using the
includeClasses option) and a declaration with
qualifiedIdentifier
"Bar::".
So what am I doing wrong, that my declarations context
returns "" for
scopeIdentifier() while obviously that from C++ doesn't. Or
is it
correct in C++ to get a GlobalVariableType for a class Foo
{};?
Andreas
--
Your own qualities will help prevent your advancement in the
world.
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |

|
2008-02-17 17:06:29 |
On Sunday 17 February 2008 23:18:17 Andreas Pakulat wrote:
> Hi,
>
> seems I'm still missing a piece here. Looking at C++
highlighting code I
> see this:
>
> if( dec->context()->scopeIdentifier().isEmpty()
)
> {
> type = GlobalVariableType;
> }...
> and I'm wondering why that isn't empty. For Python
scopeIdentifier is
> empty, although qualifiedIdentifier of the declaration
returns something
> meaningful. I really must be missing something here.
Currently what I do
> is:
>
> openContext( astnode, DUContext::Class,
identifierForName(
> astnode->className ) );
> addImportedContext();
> openDefinition( astnode->className, astnode );
> ...
>
> which gives me a context with scopeIdentifier
"Bar" (using the
> includeClasses option) and a declaration with
qualifiedIdentifier
> "Bar::".
>
> So what am I doing wrong, that my declarations context
returns "" for
> scopeIdentifier() while obviously that from C++
doesn't. Or is it
> correct in C++ to get a GlobalVariableType for a class
Foo {};?
>
> Andreas
I think you are confusing internalContext() and context().
context() is the
context that surrounds a declaration, so for a global
declaration "class Foo
{};" the context is empty. The context you are creating
for the class-content
should have the same localScopeIdentifier as the class,
which in your case
is "Bar", and should be attached to the
Declaration
using "Declaration::setInternalContext". Then you
can get the declaration
from the context through "DUContext::owner()".
Hope this helped.
Greetings, David
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |

|
2008-02-18 16:11:36 |
On 18.02.08 22:30:20, David Nolden wrote:
> On Monday 18 February 2008 21:56:12 Andreas Pakulat
wrote:
> > Thats from a simple "class Foo {};"
apparently. What I don't quite
> > understand here is that there's no Declaration
dumped by DumpChain,
> > while apparently it got created:
> >
> > kdevelop(31278)/kdevelop (cpp support)
ContextBuilder::buildContexts: built
> > top-level context with 1 declarations and 0
included files
> >
> > Andreas
>
> This looks that strange because of simplified
environment matching. You
> shouldn't care about that thing for python.
Ok, I'll simply ignore that
> If you want to experiment, you should better do it in
test_duchain.cpp,
> because simplified matching isn't used there, or you
can turn it off in the
> initialization of CppLanguageSupport.
Thanks for the hint. That looks really promising. Yeah,
should help me
understand how C++ creates contexts and declarations.
Andreas
--
You are always busy.
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |
  Germany |
2008-02-18 13:57:52 |
On Monday 18 February 2008 19:47:16 Andreas Pakulat wrote:
> I've got the following DUChain:
> kdevelop(14055)/kdevelop (python support) Python: umpChain
::dump: "" New
> Context "" [ (0, 0) -> (23, 0) ]
top-context kdevelop(14055)/kdevelop
> (python support) Python: umpChain
::dump: " " New Context "Bar" [ (0, 0)
> -> (2, 1) ] kdevelop(14055)/kdevelop (python
support)
> Python: umpChain
::dump: " " Declaration: "<notype>
" [ "Bar::" ]
> 0x844ef20 (internal ctx 0x0 ) [ (0, 6) -> (0, 9) ]
, defined, 0 use(s)
>
> i.e. there's a Context with localScopeIdentifier
"Bar" and inside that
> the class declaration and following that would be the
body statements.
>
> Or should the Declaration be in the top context and
there should be a
> context just for the body with the localScopeIdentifier
"Bar"?
>
> Andreas
I think it should be like this:
Context "" [ (0, 0) -> (23, 0) ]
top-context
Context "Bar" id 0x1 [ (0, 0) -> (2, 1) ]
Declaration "Bar" (internal ctx 0x1)
So the context "Bar" and declaration
"Bar" are connected through
the "Context::owner()" and
"Declaration::internalContext()" relationship, and
they both have the top-context as parent context.
So the second is true. Yes it is very different that for
functions, there is
only one context for the class-body, with the correct
localScopeIdentifier.
That's needed, so members of classes can be addressed. For
functions, the
function-body probably just doesn't have a
localScopeIdentifier because it
doesn't matter, you don't need to address variables declared
in a function
from outside.
Greetings, David
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |

|
2008-02-18 12:47:16 |
On 18.02.08 00:06:29, David Nolden wrote:
> On Sunday 17 February 2008 23:18:17 Andreas Pakulat
wrote:
> > Hi,
> >
> > seems I'm still missing a piece here. Looking at
C++ highlighting code I
> > see this:
> >
> > if(
dec->context()->scopeIdentifier().isEmpty() )
> > {
> > type = GlobalVariableType;
> > }...
> > and I'm wondering why that isn't empty. For Python
scopeIdentifier is
> > empty, although qualifiedIdentifier of the
declaration returns something
> > meaningful. I really must be missing something
here. Currently what I do
> > is:
> >
> > openContext( astnode, DUContext::Class,
identifierForName(
> > astnode->className ) );
> > addImportedContext();
> > openDefinition( astnode->className, astnode );
> > ...
> >
> > which gives me a context with scopeIdentifier
"Bar" (using the
> > includeClasses option) and a declaration with
qualifiedIdentifier
> > "Bar::".
> >
> > So what am I doing wrong, that my declarations
context returns "" for
> > scopeIdentifier() while obviously that from C++
doesn't. Or is it
> > correct in C++ to get a GlobalVariableType for a
class Foo {};?
> >
> > Andreas
>
> I think you are confusing internalContext() and
context(). context() is the
> context that surrounds a declaration, so for a global
declaration "class Foo
> {};" the context is empty. The context you are
creating for the class-content
> should have the same localScopeIdentifier as the class,
which in your case
> is "Bar", and should be attached to the
Declaration
> using "Declaration::setInternalContext". Then
you can get the declaration
> from the context through
"DUContext::owner()".
Ok, now I'm totally confused I think Or rather
classes work quite
differently from functions, I guess...
Maybe some example is better, lets take this:
class Bar:
pass
I've got the following DUChain:
kdevelop(14055)/kdevelop (python support) Python: umpChain
::dump: "" New Context "" [ (0, 0)
-> (23, 0) ] top-context
kdevelop(14055)/kdevelop (python support) Python: umpChain
::dump: " " New Context "Bar" [ (0, 0)
-> (2, 1) ]
kdevelop(14055)/kdevelop (python support) Python: umpChain
::dump: " " Declaration: "<notype>
" [ "Bar::" ] 0x844ef20 (internal ctx 0x0
) [ (0, 6) -> (0, 9) ] , defined, 0 use(s)
i.e. there's a Context with localScopeIdentifier
"Bar" and inside that
the class declaration and following that would be the body
statements.
Or should the Declaration be in the top context and there
should be a
context just for the body with the localScopeIdentifier
"Bar"?
Andreas
--
Hope that the day after you die is a nice day.
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |

|
2008-02-18 14:39:23 |
On 18.02.08 21:26:44, Andreas Pakulat wrote:
> On 18.02.08 20:57:52, David Nolden wrote:
> > On Monday 18 February 2008 19:47:16 Andreas
Pakulat wrote:
> > > I've got the following DUChain:
> > > kdevelop(14055)/kdevelop (python support)
Python: umpChain
::dump: "" New
> > > Context "" [ (0, 0) -> (23,
0) ] top-context kdevelop(14055)/kdevelop
> > > (python support) Python: umpChain
::dump: " " New Context "Bar" [ (0, 0)
> > > -> (2, 1) ] kdevelop(14055)/kdevelop
(python support)
> > > Python: umpChain
::dump: " " Declaration: "<notype>
" [ "Bar::" ]
> > > 0x844ef20 (internal ctx 0x0 ) [ (0, 6) ->
(0, 9) ] , defined, 0 use(s)
> > >
> > > i.e. there's a Context with
localScopeIdentifier "Bar" and inside that
> > > the class declaration and following that
would be the body statements.
> > >
> > > Or should the Declaration be in the top
context and there should be a
> > > context just for the body with the
localScopeIdentifier "Bar"?
> > >
> > > Andreas
> >
> > I think it should be like this:
> >
> > Context "" [ (0, 0) -> (23, 0) ]
top-context
> > Context "Bar" id 0x1 [ (0, 0) ->
(2, 1) ]
> > Declaration "Bar" (internal ctx 0x1)
> >
> > So the context "Bar" and declaration
"Bar" are connected through
> > the "Context::owner()" and
"Declaration::internalContext()" relationship, and
> > they both have the top-context as parent context.
>
> Yeah, that makes more sense. However what I'm really
stumbling about is
> that in C++ apparently such code:
>
> class Foo {};
Ok, you can forget everything I just said and I declare
myself dumb. I
missed that its not an if - else if - else if - else block,
but rather
an if - if - else if - else thing
Andreas
--
Do what comes naturally. Seethe and fume and throw a
tantrum.
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |

|
2008-02-18 14:56:12 |
On 18.02.08 20:57:52, David Nolden wrote:
> On Monday 18 February 2008 19:47:16 Andreas Pakulat
wrote:
> > I've got the following DUChain:
> > kdevelop(14055)/kdevelop (python support)
Python: umpChain
::dump: "" New
> > Context "" [ (0, 0) -> (23, 0) ]
top-context kdevelop(14055)/kdevelop
> > (python support) Python: umpChain
::dump: " " New Context "Bar" [ (0, 0)
> > -> (2, 1) ] kdevelop(14055)/kdevelop (python
support)
> > Python: umpChain
::dump: " " Declaration: "<notype>
" [ "Bar::" ]
> > 0x844ef20 (internal ctx 0x0 ) [ (0, 6) -> (0,
9) ] , defined, 0 use(s)
> >
> > i.e. there's a Context with localScopeIdentifier
"Bar" and inside that
> > the class declaration and following that would be
the body statements.
> >
> > Or should the Declaration be in the top context
and there should be a
> > context just for the body with the
localScopeIdentifier "Bar"?
> >
> > Andreas
>
> I think it should be like this:
>
> Context "" [ (0, 0) -> (23, 0) ]
top-context
> Context "Bar" id 0x1 [ (0, 0) -> (2,
1) ]
> Declaration "Bar" (internal ctx 0x1)
I know I'm a PITA and everything, but would you mind
explaining this:
kdevelop(31278)/kdevelop (cpp support)
CPPInternalParseJob::run: ================== duchain
==================
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"" TranslationUnit [( 1 ) (0, 0) ]
""class Foo { } ;""
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| " SimpleDeclaration [( 1 ) (0, 0) ]
""class Foo { } ;""
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| | " ClassSpecifier [( 1 ) (0, 0) ]
""class Foo { }""
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| | | " Name [( 2 ) (0, 6) ]
""Foo""
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| | | | " UnqualifiedName [( 2 ) (0, 6) ]
""Foo""
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| | | | " / UnqualifiedName [( 3 ) (1, 0) ]
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| | | " / Name [( 3 ) (1, 0) ]
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| | " / ClassSpecifier [( 5 ) (2, 1) ]
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"| " / SimpleDeclaration [( 6 ) (3, 0) ]
kdevelop(31278)/kdevelop (cpp support) DumpChain::visit:
"" / TranslationUnit [( 6 ) (3, 0) ]
kdevelop(31278)/kdevelop (cpp support) DumpChain::dump:
"" New Context 0x83068c0 " ""
" [ "" ] [ (0, 0) -> (0, 0) ]
top-context
kdevelop(31278)/kdevelop (cpp support) DumpChain::dump:
" " ==import==> Context 0x864bcc8 "
"" " [ "" ] [ (0, 0) -> (3, 0)
] top-context
Thats from a simple "class Foo {};" apparently.
What I don't quite
understand here is that there's no Declaration dumped by
DumpChain,
while apparently it got created:
kdevelop(31278)/kdevelop (cpp support)
ContextBuilder::buildContexts: built top-level context with
1 declarations and 0 included files
Andreas
PS: Thanks for answering all these noob questions, I owe you
a beer or
two.
--
Beware of low-flying butterflies.
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
| Re: How does C++ support create class
declarations? |

|
2008-02-18 14:26:44 |
On 18.02.08 20:57:52, David Nolden wrote:
> On Monday 18 February 2008 19:47:16 Andreas Pakulat
wrote:
> > I've got the following DUChain:
> > kdevelop(14055)/kdevelop (python support)
Python: umpChain
::dump: "" New
> > Context "" [ (0, 0) -> (23, 0) ]
top-context kdevelop(14055)/kdevelop
> > (python support) Python: umpChain
::dump: " " New Context "Bar" [ (0, 0)
> > -> (2, 1) ] kdevelop(14055)/kdevelop (python
support)
> > Python: umpChain
::dump: " " Declaration: "<notype>
" [ "Bar::" ]
> > 0x844ef20 (internal ctx 0x0 ) [ (0, 6) -> (0,
9) ] , defined, 0 use(s)
> >
> > i.e. there's a Context with localScopeIdentifier
"Bar" and inside that
> > the class declaration and following that would be
the body statements.
> >
> > Or should the Declaration be in the top context
and there should be a
> > context just for the body with the
localScopeIdentifier "Bar"?
> >
> > Andreas
>
> I think it should be like this:
>
> Context "" [ (0, 0) -> (23, 0) ]
top-context
> Context "Bar" id 0x1 [ (0, 0) -> (2,
1) ]
> Declaration "Bar" (internal ctx 0x1)
>
> So the context "Bar" and declaration
"Bar" are connected through
> the "Context::owner()" and
"Declaration::internalContext()" relationship, and
> they both have the top-context as parent context.
Yeah, that makes more sense. However what I'm really
stumbling about is
that in C++ apparently such code:
class Foo {};
doesn't get "Foo" highlighted as GlobalVariable
but as a Class and I
don't understand how this happens.
I mean the highlighting code checks
declaration->context()->scopeIdentifier().isEmpty()
and if its empty it
uses GlobalVariable. And for my example obviously that
condition is
always true as the context of that class is the top-level
context.
So I think somehow I'm still missing a piece somewhere.
Note: I've
mostly copied the context and declaration builders functions
like
openContext/openDeclaration and such things...
Andreas
--
You will be run over by a bus.
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel
|
|
[1-8]
|
|