TCL_OBJECT by Stephan Herrmann (stephan@cs.tu-berlin.de) CONCEPTS: This is another approach on combining C++ and tcl: The idea was to write the whole funcionality of an application in C++, then decide which objects need to be represented by screen objects, add a tcl interface to these objects and write the whole user interface in tcl. This proceeding should enable the writing of maintainable (because of C++ (ok, I'd prefer EIFFEL; Eiffel encapsulation exists as well)) and adaptable (because of tcl) software. Furthermore I definitly wanted to use xf to build my screen objects! :-) (ok. I know read about "objectify" by Wayne Christopher, but his approach differs from mine in that he gives full control to tcl whereas I prefer to leave the control (including creating and destructing objects) on the C++ side. Additionally I will automatically have modular tcl-code as you will just see). I'm introducing the notion of "Tcl_Object" described by a base class for all (complex) objects that shall be represented on the screen. Each Tcl_Object will have its own interpreter that executes a given tcl script. There will normaly be one script per class that is derived from Tcl_Object. The filename for this script is given by a virtual function to be defined in every derived class. (In my case these files are generated by xf, so in fact I hardly write any tcl code myself). The interface is now given by - installing C++ member functions into tcl and - exchanging data via tcl variables (I do this explicitly, which seems to be the safest way). both activitys are (slightly) supported by Tcl_Object. The only little Hack is the embedding of C++ member functions into plain-C before exporting them to tcl. FILES: - The files Tcl_Object.[hC] realise this baseclass. - tcltest.C is a simply application of this principle. - tcltest.tcl is a xf-output file. I don't have to tell you, how little time it took to create tcltest.tcl by the means of xf. I hope you enjoy this light weigth solution STATUS: 13.Jan.1993 : placed on ftp. compiles with tcl7.3 - tk3.6