From: Francois T. <fra...@la...> - 2002-11-25 09:04:18
|
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 |