Define your C++ class that you want to expose to Tcl like this:
class TCLCPPCLASS(foo) { public: int method(int oc, Tcl_Obj *ov[]) { // // the body of your method goes here // return TCL_OK; } TCLCPPOBJCONSTRUCTOR(foo) { RegisterMethod("method", &foo::method); // // your object's constructor goes here // // int oc, Tcl_Obj *const ov[] are available // also the protected methods get_type() and get_name() and // get_interp() exist here // } }; |
TclCPPObjFactory<foo> objcreator(interp, "FOO"); |
set obj [::FOO::new] $obj method 1 2 3 |
set obj [::FOO::new 1 2 3] |
|