Andre Poenitz wrote:

> On Tue, Sep 16, 2003 at 12:20:58PM +0200, Alfredo Braunstein wrote:
>> > I think you could try to convert the math dispatch to your scheme
>> > without affecting the rest of LyX. This would give some reference
>> > implementation of the scheme without duplicated work...
>> 
>> I was thinking... how about implementing factory.C in a similar way also?
>> 
>> Every inset could register a constructor standalone function that returns
>> a base inset given some data.
>> 
>> Does it make sense?
> 
> Yes. [And works fine, I do this in my day time job all over the place].

I must admit that me also. ;-)
 
> The only tricky part is to get the 'seemingly unused' static dummy
> variables
> whose constructors are used for the registration on startup  from a
> library in a binary ;-}

I don't understand this. What I've done (I don't know if it is good practice
or not is nor if it would work on other systems):

class registery {
public:
        static registery & get();
        list<pair<identifier, callback> > cblist;
private:
        registery() {};
}

struct register {
        register(identifier id, callback cb) { registery::get().push_back(
make_pair(id ,cb))};
};


And I add a

register reg(id, &cb);

on every "InsetXXX.C" equivalent· What are the drawbacks of this?


> I do this with --whole-archive, but that's not optimal and I do not know
> how to do this for non-GNU ld. That's the reason why mathed's factory
> doesn't use it already.

No idea what's --whole-archive or why is it needed.

Regards, Alfredo


Reply via email to