This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Questions about __cxa_throw and type_info
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Brian Ellis <nullroute at yahoo dot com>
- Cc: llibstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 6 Apr 2007 11:41:49 -0700
- Subject: Re: Questions about __cxa_throw and type_info
- References: <636427.6369.qm@web32102.mail.mud.yahoo.com>
On Fri, Apr 06, 2007 at 10:29:27AM -0700, Brian Ellis wrote:
> I am in the proof of concepts stage of developing an extension language
> intended to interoperate natively with c++. The chief goal being the
> ability to derive new types at runtime, override virtuals, and have
> instances of these new types passed around to the engine of the extended
> application.
It's possible to do this entirely within the language; we did this 15
years ago in the Ptolemy project: http://ptolemy.eecs.berkeley.edu
(the C++ version is now called Ptolemy Classic as they went and re-did
the thing in Java after I left).
The basic approach is that objects know how to clone themselves. Then
you can add new classes that derive from an existing, preloaded class
that has a clone member function. The new code to be loaded in has
a constructor that has the side effect of registering a new object on
the known-classes list, then the application can create application graphs
consisting both of predefined classes and new classes loaded at runtime.
I don't understand why you are messing around with __cxa_throw and
type_id. Our implementation predated the introduction of RTTI into
the language so we needed to define conventions for object identification
(for example, return the class name as a string). But we managed to
do everything without messing with details like this, and still got the
thing to run on about six different C++ compilers.