[Metakit] Tcl -> C++ -> Metakit - how to bind to library?
Jean-Claude Wippler
jcw at equi4.com
Wed Nov 2 20:37:28 CET 2005
gdedwards at blueyonder.co.uk wrote:
> I have an application where I want to use Metakit as a persistent
> object
> store for some C++ code that happens to be coded as a Tcl
> extension. The
> Tcl code itself has no requirements to directly access the Metakit
> database through mk::whatever calls.
>
> Tcl interpreter <-> C++ extension <-> Metakit
>
> 1.) should I be binding to the C++ API (DLL or static LIB) or the Tcl
> Mk4tcl.dll?
>
> 2.) If the former, is there anything specific I should worry about
> w.r.t
> memory management or anything else of that ilk?
>
> 2.) if the latter, is the C++ API still available to my extension
> when the
> Mk4tcl.dll extension is loaded? Or do I need to Tcl_Eval "mk::blah"
> commands in my C++ code to access the database?
If all you want is MK inside your C++ code, then by all means link to
the C++ dll or lib. It's like using any other C/C++ lib inside a
compiled Tcl extension and simply does not expose MK to Tcl. IOW, as
far as Tcl is concerned MK is an implementation detail of your
extension.
If you do at some point wish to have access from Tcl, you can relink
to Mk4tcl, which includes the C++ API since it is purely a wrapper
around it.
Memory management should not be an issue as long as all alloc's (new)
and free's (delete) are done in the same context. Don't free an
object from Tcl if it has been created from C++, and vice-versa.
-jcw
More information about the Metakit
mailing list