From: suresh <su...@em...> - 2002-11-25 17:15:41
|
Hi, I have solved the first and third problem mentioned in my previous email. Thanx for you guys help. For the second problem, which is finding the instantiation of all the objects of a class (classA), I just need to know the instantiation statements. I don't want any runtime information. Based on the objects (object names), I have to add MACROs in the header file of ClassA. The macro will take object name as an argument. Explaination: /* classA in file classA.h and classA.cpp */ Class classA { ..... ..... ...... } /* classB in file classB.h and classB.cpp */ class classB { ..... classA objA1; classA objA2 = new classA; ..... } Now I need to add MACRONAME(objA1) and MACRONAME(objA2) in the header file of classA. Any help is welcome. I am facing one more problem, I tried translateNew But translateNew's arguments don't have the object name. Is there anyway, I can get the name of object? Thanx in advance -Suresh Lalwani Note: I am using opencxx-2.5.12 version on windows XP for development purpose. Later on I will use this program on a Sun machine. -----Original Message----- From: own...@cs... [mailto:own...@cs...] On Behalf Of Francois Taiani Sent: Monday, November 25, 2002 1:57 AM To: OpenC++ Subject: Re: [opencxx] Looking for help Hi Suresh, I'm not a big expert on opencxx, but here are the few hints I can give you regarding your questions: On Fri, 2002-11-22 at 22:46, suresh wrote: > > 1. When I am trying to load the metaclass for c functions. It is > giving warning that: 'Mop is not able to load the "CFunctionClass" '. > CFunctionClass is a metaclass which I defined for translation of C > functions. Here is the code > Metaclasses are compiled into shared libraries. The error may come from occ not finding CFunctionClass.so in its library search path. Here's what the command reference says on the topic (man occ): " "First, MyClass.mc should be compiled into shared libraries MyClass.so and MyClass-init.so. The produced shared libraries must be under the directory specified by LD_LIBRARY_PATH." > > 2. I have several classes. I am using the same metaclass for all > classes' code translation. The problem is I need to see how many objects > of a class (say classA) are instantiated in the whole application. If you want to know the number of instantiation *statements* (i.e. the number of places in your code where you have "new classA"), I think occ can do that. If you need to know the number of instances of a given class that may be constructed on a given program run, I'm afraid no open compiler can do that. (I'm afraid that's what is called an undecidable property.) For the first question, I think you can use the Class::TranslateNew method. --- Ptree* TranslateNew(Environment* env, Ptree* header, Ptree* new_op, Ptree* placement, Ptree* type_name, Ptree* arglist) This translates a new expression. header is a user-defined keyword (type modifier), :: (if the expression is ::new), or nil. new_op is the new operator. type_name may include an array size surrounded by []. arglist is arguments to the constructor. It includes parentheses () . placement, type_name, and arglist have not been translated yet. -- > > > 3. As I have one metaclass, I want to statically overload this > metaclass so that I don't need to insert the metaclass declaration > before every class definition. I tried using > "ChangeDefaultMetaClass("mainMetaClass)" by calling it from the > Initialize() method and using -S option at the time of compilation but > this is not working. > > %occ -S mainMetaClass.mc > > this command is giving me problems at the time of linking. > What kind of linking problems? I have a small example that exactly do that and compiles fine. Here's what it looks like: -- class MyMetaClass : public Class { public: static bool Initialize(); [...] } // ---------------------------------------------------------- bool MyMetaClass::Initialize() { Class::ChangeDefaultMetaclass ("MyMetaClass"); Class::SetMetaclassForFunctions("MyMetaClass"); return true ; } // EndMethod MyMetaClass::Initialize -- Cheers Francois |