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

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Thu Dec 30 16:41:49 CET 2004


Hi,

this is strange. It works for me. Here is what I did after downloading 
and unpacking a fresh ac-0.9-woven:

spinczyk at faui48:~/ac-0.9-Sources-Woven/Puma> make TARGET=linux-release

Compiling PUMA for TARGET=linux-release

Making tools.
Making library.
Generating.
Weaving.
Copying sources not to weave.
Compiling.
Compiling PreAnswer.cc.
Compiling PreAssertionEvaluator.cc.
...
Compiling PreParser.cc.
Compiling CMatchParser.cc.
Making the static library 
/home/inf4/spinczyk/ac-0.9-Sources-Woven/Puma/lib/libPuma.a.
Making the shared library 
/home/inf4/spinczyk/ac-0.9-Sources-Woven/Puma/lib/libPuma.so.
spinczyk at faui48:~/ac-0.9-Sources-Woven/Puma> cd examples/ccparser/
spinczyk at faui48:~/ac-0.9-Sources-Woven/Puma/examples/ccparser> make 
TARGET=linux-release
Generating dependencies for IncludeVisitor.cc.
Generating dependencies for ccparser.cc.
Compiling ccparser.cc.
Compiling IncludeVisitor.cc.
Linking ccparser.
spinczyk at faui48:~/ac-0.9-Sources-Woven/Puma/examples/ccparser> export 
LD_LIBRARY_PATH=~/ac-0.9-Sources-Woven/Puma/lib
spinczyk at faui48:~/ac-0.9-Sources-Woven/Puma/examples/ccparser> ./ccparser
PUMA C++ parser, library version 1.1
usage: ccparser [options] <filename>
options:
   -tr|--trace           trace parse process, write to stdout
   -tf|--trace-file      trace parse process, write to debug/trace.file
   -tt|--trace-tokens    trace parsing tokens too
   -ts|--trace-scopes    trace entered/leaved scopes
   -to|--trace-objs      trace inserted/destroyed semantic objects
   -tu|--trace-undo      trace deleted syntax tree nodes
   -tc|--trace-types     trace created types
   -ti|--trace-instances trace code of created instances
   -nd|--no-print-db     do not print the class database
   -nt|--no-print-tree   do not print the syntax tree
   -ns|--no-semantics    do not start the semantic process
   -E                    write preprocessor output to stdout
   -M                    print dependencies

Note that neither ac++ nor ag++ are needed for compiling the woven 
ac-0.9 sources and ccparser.

Olaf


Sunder, Shyam (MSTG - NY) wrote:
> Hi Olaf,
> 
> Tried that and I get this error:
> 
> Compiling cparser.cc.
> cparser.cc: In function `void evalOptions(int, char**)':
> cparser.cc:52: error: use of `TRACE_SCOPES' is ambiguous
> cparser.cc:17: error:   first declared as `int TRACE_SCOPES' here
> /home/matthias/Projekte/Cvsdir/Puma/gen/step1/inc/Puma/Semantic.h:41:
> error:
>    also declared as `int Puma::TRACE_SCOPES' here
> cparser.cc: In function `int main(int, char**)':
> cparser.cc:82: error: `trace' undeclared (first use this function)
> 
> Also, does TARGET=linux-release invoke ac++ or ag++ ?
> 
> -Shyam 
> 
> -----Original Message-----
> From: Olaf Spinczyk [mailto:Olaf.Spinczyk at informatik.uni-erlangen.de] 
> Sent: Thursday, December 30, 2004 9:52 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 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/
> 
>>--------------------------------------------------------
> 
> 
> 
> 
> 
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user




More information about the aspectc-user mailing list