Objectify -- turn C++ classes into Tcl objects. Wayne Christopher, faustus@cs.berkeley.edu Version 2.0, Oct 28, 1993 Copyright (c) 1993 Wayne Christopher. Permission is granted to copy, modify and distribute, provided this notice is preserved. No warranty is provided or implied, etc, etc. This is my second cut at automating the process of turning C++ classes into Tcl object types. For a further description of this system, please read the paper in the file paper.ps. That, together with the simple examples described below, should be enough to get you started. This distribution contains the following files: - README This file - objectify A Tcl script to generate object interfaces - objectify.h To be included in the user's class .h file - test.h Sample class definition .h file - test.cc Implementation file for test.h classes - objectlib.cc A few library routines that implement predefined functions - objConfig.c Hacked version of Tk_ConfigureWidget, which is needed for non-widget objects - Makefile Creates test executable - test.tcl Exercise the test program - paper.tex, paper.bib Unformatted paper from the Tcl/Tk workshop on 6/10/93 and 6/11/93 that describes this system in more detail. - paper.ps Postscript version of this paper. I have compiled this code with gcc 2.3.3 with no problems (except for occasional unused functions) but it should work with any ANSI compiler. Please let me know of any problems with this code or any suggestions for its improvement. Sorry about the lack of documentation, but I don't have time right now to put together a real release. Some new features are: 1. Configure, delete, get, and help methods are automatically generated and need not be mentioned in the class definition. The AfterConfigure and BeforeDelete macros are mandatory now, however. The "get" method is just like [lindex [$object configure -whatever] 4]. 2. Slots and methods can be inherited, if both parent and child classes are TCL_OBJECTs. Brief description of the objectify macros ----------------------------------------- Classes that are to be exported to the Tcl level from C++ should be defined using a set of macros that are parsed by the objectify script. Here is an example: struct TCL_OBJECT("sample", Sample, object, "Documentation string") { Sample(Tcl_Interp* interp) { }; ~Sample() { } // The following three calls create data members of the class // that can be accessed using a Tk-style configure command. // The first one has arguments that give the resource names // and documentation strings. TCL_SLOT(RELIEF, int, relief, "-relief", "relief", "Relief", "flat", 0, NULL, "relief-value", "The relief to use for the object"); // This form leaves out the resource names. TCL_SLOT1(PIXELS, int, borderwidth, "-bw", "0", NULL, "pixels", "Width of the border"); // This form leaves out all but the type, name, default value, and // documentation string. The other arguments are infered from these. TCL_SLOT2(int, p, "17", ""); // This defines a member function that has an argc/argv style // interface, with maximum and minimum numbers of args. TCL_METHOD("method", MethodCmd, 3, 7, "doc1", "doc2"); // This defines a member function whose arguments are automatically // parsed. TCL_METHOD1("other_method", OtherMethodCmd(Tcl_Interp* interp, int a, char* b), "doc1", "doc2"); // These two member functions are required. int AfterConfigure(Tcl_Interp* interp); int BeforeDelete(Tcl_Interp* interp); } ;