[aspectc-user] Using puma to print out class member names

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Thu Dec 30 15:52:13 CET 2004


Hi Shyam,

you have to compile the examples/ccparser in ac-0.9-Sources-Woven with 
"make TARGET=linux-release", because the Puma library was woven and 
compiled in the linux-release configuration.

Olaf

Sunder, Shyam (MSTG - NY) wrote:
> Olaf,
> 
> I tried compiling the example under
> ac-0.9-Sources-Woven/Puma/examples/ccparser but it fails because of .ah
> includes in Syntax.h and Parser.h that are used in CCParser.h.
> 
> Shyam
> 
>  
> 
> -----Original Message-----
> From: Olaf Spinczyk [mailto:Olaf.Spinczyk at informatik.uni-erlangen.de] 
> Sent: Thursday, December 30, 2004 4:49 AM
> To: Sunder, Shyam (MSTG - NY)
> Cc: aspectc-user at aspectc.org
> Subject: Re: [aspectc-user] Using puma to print out class member names
> 
> Hi,
> 
> Sunder, Shyam (MSTG - NY) wrote:
> 
>>Hi,
>>
>>I am not sure if this is the right mailing list for asking questions
>>about the Puma parser. I'm going to try my luck...
> 
> 
> Well, there is no better mailing list for this question yet. We'll make 
> one if the number of Puma question will increase.
> 
> 
>>I am trying to print out the member names of a particular class. After
> 
> a
> 
>>fair amount of trial and error, I got to this stage:
>>
>>#include "Puma/ErrorStream.h"
>>#include "Puma/CProject.h"
>>#include "Puma/CClassDatabase.h"
>>#include "Puma/PathIterator.h"
>>#include "Puma/CFunctionInfo.h"
>>#include "Puma/CTypeInfo.h"
>>#include "Puma/CClassInfo.h"
>>#include "Puma/CAttributeInfo.h"
>>
>>#include <iostream>
>>
>>using namespace Puma;
>>
>>int main(int argc, char** argv)
>>{
>>    ErrorStream err;
>>    CProject project(err);
>>    project.scanFile("tests/A.h")->print(std::cout);    
>>
>>    CClassDatabase classdb(project);
>>
>>    classdb.Dump(std::cout);
>>
>>    DString d = classdb.ClassInfo(0)->AttributeInfo()->Name();
>>    std::cout << d.c_str() << std::endl;
>>
>>    return 0;
>>}
>>
>>However, The program crashes:
>>
>>#pragma once
>>
>>class A
>>{
>>public:
>>    int a;
>>
>>private:
>>    int b;
>>assertion "index >= 0 && index < count" failed: file
>>
> 
> "/home/matthias/Projekte/Cvsdir/Puma/gen/step1/inc/Puma/VoidPtrArray.h",
> 
>>line 186
>>};Aborted (core dumped)
>>
>>
>>Any ideas?
> 
> 
> Yes, there are two problems.
> 
> First of all, you didn't *parse* the input file. You only scanned it, 
> which means that Puma converted the characters in your input file into a
> 
> sequence of tokens. Look into Puma/examples/ccparser/ccparser.cc to find
> 
> out how to parse an input file and dump the results.
> 
> The second problem is that you call ClassInfo (0)->AttributeInfo (). 
> This is wrong, because AttributeInfo () checks if your class-db object 
> is an attribute and converts the object pointer into an CAttributeInfo* 
> pointer if it is an attribute. In this case the object is not an 
> attribute (it is the first class in the class-db) and AttributeInfo () 
> returns 0.
> 
> What you probably want here is the list of attributes defined in a 
> class. This can be obtained with the Attributes() and 
> Attribute(unsigned) functions, which CClassInfo inherits from
> CStructure.
> 
> I hope this helps,
> 
> Olaf
> --------------------------------------------------------
> 
> If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail.     http://www.ml.com/email_terms/
> --------------------------------------------------------




More information about the aspectc-user mailing list