[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: instantiating Application defined in C++ from tcl



Yes. Every split object must follow that naming rule, unfortunately. 

- Haobo

On Thu, 30 Sep 1999, T.Hval wrote:

> It is derived from Process, should it then be named as Process/*?
> 
> On Thu, 30 Sep 1999, Haobo Yu wrote:
> 
> > If it's derived from Application, it _must_ be named as Application/*.
> > 
> > - Haobo
> > 
> > On Thu, 30 Sep 1999, T.Hval wrote:
> > 
> > > > You don't need to modify ns/tcl/lib/ns-source.tcl to be able to
> > > > instantiate a c++ object from tcl. 
> > > > 
> > > > All you need is something like the following
> > > > 
> > > > static class MyAppClass : public TclClass {
> > > > public:
> > > >   SFQClass() : TclClass("Application/MyApp") {}
> > > >   TclObject* create(int, const char*const*) {
> > > >     return (new MyApp);
> > > >   }
> > > > } class_myapp;
> > > > 
> > > > and, assuminng the MyApp c++ class exists, you can create a new
> > > > Application/MyApp Tcl object using
> > > > 
> > > > set obj [new Application/MyApp]
> > > > 
> > > Thanks.
> > > I have been trying this without much luck, the "tcl name" (which above is
> > > Application/MyApp) is just a text string, righ? so as long as the string
> > > matches between the parameter to the TclClass statement, mactches with the
> > > Tcl set statement it should work?(In my case it doesn't). I still get the
> > > same error message:
> > > 
> > > invalid command name "App"
> > >     while executing
> > > "App create _o34 "
> > >     invoked from within
> > > "catch "$className create $o $args" msg"
> > >     (procedure "new" line 3)
> > >     invoked from within
> > > "new App"
> > >     (file "Apptest.tcl" line 27)
> > > 
> > > Tor Hval
> > > 
> > > 
> > 
> > 
> 
>