OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itcl/] [tests/] [mkindex.itcl] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Test file for:
2
#   auto_mkindex
3
#
4
# This file provides example cases for testing the Tcl autoloading
5
# facility.  Things are much more complicated with namespaces and classes.
6
# The "auto_mkindex" facility can no longer be built on top of a simple
7
# regular expression parser.  It must recognize constructs like this:
8
#
9
#   namespace eval foo {
10
#       class Internal { ... }
11
#       body Internal::func {x y} { ... }
12
#       namespace eval bar {
13
#           class Another { ... }
14
#       }
15
#   }
16
#
17
# Note that class definitions can be nested inside of namespaces.
18
#
19
# Copyright (c) 1993-1998  Lucent Technologies, Inc.
20
 
21
#
22
# Should be able to handle simple class definitions, even if
23
# they are prefaced with white space.
24
#
25
namespace import blt::*
26
 
27
class Simple1 {
28
    variable x 0
29
    public method bump {} {incr x}
30
}
31
  itcl::class Simple2 {
32
    variable x 0
33
    public variable by 1
34
    public method bump {}
35
  }
36
 
37
itcl_class OldStyle {
38
  public x 0
39
  method foo {args} {return $args}
40
}
41
 
42
itcl::ensemble ens {
43
    part one {x} {}
44
    part two {x y} {}
45
    part three {x y z} {}
46
}
47
 
48
#
49
# Should be able to handle "body" and "configbody" declarations.
50
#
51
body Simple2::bump {} {incr x $by}
52
configbody Simple2::by {if {$by <= 0} {error "bad increment}}
53
 
54
#
55
# Should be able to handle class declarations within namespaces,
56
# even if they have explicit namespace paths.
57
#
58
namespace eval buried {
59
    class inside {
60
        variable x 0
61
        public variable by 1
62
        public method bump {}
63
        method skip {x y z} {}
64
        proc find {args} {}
65
    }
66
    body inside::bump {} {incr x $by}
67
    configbody inside::by {if {$by <= 0} {error "bad increment}}
68
 
69
    class ::top {
70
        method skip {x y z} {}
71
        method ignore {} {}
72
        public proc find {args} {}
73
        protected proc notice {args} {}
74
    }
75
 
76
    ensemble ens {
77
        part one {x} {}
78
        part two {x y} {}
79
        part three {x y z} {}
80
    }
81
 
82
    namespace eval under {
83
        itcl::class neath { }
84
    }
85
    namespace eval deep {
86
        ::itcl::class within { }
87
    }
88
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.