Re: [incr Tcl] state of this project?
From: Gustaf Neumann (neumann_at_wu-wien.ac.at)
Date: 10/24/03
- Next message: Roland Roberts: "Re: Cron and Expect"
- Previous message: Ken Jones: "Re: Communication with application under test."
- In reply to: David Gravereaux: "Re: [incr Tcl] state of this project?"
- Next in thread: David N. Welton: "Re: Xotcl - was: [incr Tcl] state of this project?"
- Reply: David N. Welton: "Re: Xotcl - was: [incr Tcl] state of this project?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 24 Oct 2003 11:46:30 -0700
David Gravereaux <davygrvy@pobox.com> wrote in message news:<iu5ipvcafktilnpfvnfll2gajf8fkd4kfp@4ax.com>...
> First I guess we need to make a blank class, then fill it with methods,
> yes?
yes; look at the following snipplet; it creates
a class named "MyClass" and adds an instance method named
"foo" to it. Here i used the definition of set (the method
is normally not exported). For real code, one should
check the return-codes and do ref-counting for the
Tcl_Obj.
XOTcl_Class *class, *myclass;
Tcl_Obj *name = Tcl_NewStringObj("MyClass", -1);
/* get the class structure from metaclass "Class" */
class = XOTclGetClass(in, "::xotcl::Class");
/* create MyClass */
XOTclCreateClass(in, name, class);
/* get the class structure from myclass */
myclass = XOTclGetClass(in, "MyClass");
/* add the instance method */
XOTclAddIMethod(in, myclass, "foo",
(Tcl_ObjCmdProc*)XOTclOSetMethod, 0, 0);
from the tcl shell, you can use after loading
MyClass create o1
o1 foo a 100
This sets an instance variable a of Object o1 to 100.
-gustaf
PS: certainly, you can create the class via
Tcl_Eval(in, "::xotcl::Class create MyClass")
to save most of the code.
- Next message: Roland Roberts: "Re: Cron and Expect"
- Previous message: Ken Jones: "Re: Communication with application under test."
- In reply to: David Gravereaux: "Re: [incr Tcl] state of this project?"
- Next in thread: David N. Welton: "Re: Xotcl - was: [incr Tcl] state of this project?"
- Reply: David N. Welton: "Re: Xotcl - was: [incr Tcl] state of this project?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|