test_Itcl_CreateObject.tcl 797 B

1234567891011121314151617181920212223242526
  1. # this is a program for testing the stubs interface ItclCreateObject.
  2. # it uses itclTestRegisterC.c with the call C function functionality,
  3. # so it also tests that feature.
  4. # you need to define in Makefile CFLAGS: -DITCL_DEBUG_C_INTERFACE
  5. # for makeing that work.
  6. package require itcl
  7. ::itcl::class ::c1 {
  8. public method c0 {args} @cArgFunc
  9. public method m1 { args } { puts "Hello Tcl $args" }
  10. }
  11. set obj1 [::c1 #auto ]
  12. $obj1 m1 World
  13. # C method cargFunc implements a call to Itcl_CreateObject!
  14. #
  15. # args for method c0 of class ::c1
  16. # arg1 does not matter
  17. # arg2 is the class name
  18. # arg3 is the full class name (full path name)
  19. # arg4 is the object name of the created Itcl object
  20. set obj2 [$obj1 c0 ::itcl::parser::handleClass ::c1 ::c1 ::c1::c11]
  21. # test, if it is working!
  22. $obj2 m1 Folks