File: test_Itcl_CreateObject.tcl

package info (click to toggle)
itcl4 4.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,512 kB
  • sloc: ansic: 25,739; tcl: 1,705; sh: 452; makefile: 68
file content (26 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# this is a program for testing the stubs interface ItclCreateObject.
# it uses itclTestRegisterC.c with the call C function functionality,
# so it also tests that feature.
# you need to define in Makefile CFLAGS: -DITCL_DEBUG_C_INTERFACE
# for makeing that work.
package require itcl

::itcl::class ::c1 {
   public method c0 {args} @cArgFunc
   public method m1 { args } { puts "Hello Tcl $args" }
}

set obj1 [::c1 #auto ]
$obj1 m1 World

# C method cargFunc implements a call to Itcl_CreateObject!
#
# args for method c0 of class ::c1
# arg1 does not matter
# arg2 is the class name
# arg3 is the full class name (full path name)
# arg4 is the object name of the created Itcl object
set obj2 [$obj1 c0 ::itcl::parser::handleClass ::c1 ::c1 ::c1::c11]
# test, if it is working!
$obj2 m1 Folks